Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextType.java167
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java79
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/DocumentTemplateContext.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ITemplateEditor.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/SimpleTemplateVariable.java55
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Template.java160
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateBuffer.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateContext.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.properties106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplatePosition.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateSet.java295
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateTranslator.java215
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateVariable.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java102
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java197
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFunctionContextType.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CGlobalContextType.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CStructureContextType.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContext.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContextType.java180
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppFunctionContextType.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppGlobalContextType.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppStructureContextType.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/GlobalVariables.java80
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ICompilationUnit.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml125
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/ISourceRange.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/Messages.properties17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MoveTextEdit.java146
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MultiTextEdit.java136
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/NopTextEdit.java61
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SimpleTextEdit.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SwapTextEdit.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBuffer.java451
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferEditor.java218
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferFactory.java192
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEdit.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNode.java496
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNodeComparator.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextManipulationMessages.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRange.java196
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRegion.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextUtil.java147
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/UndoMemento.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java288
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java182
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsole.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java238
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java118
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java79
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java480
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java80
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java80
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java231
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java228
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties332
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java73
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ErrorTickAdornmentProvider.java136
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IAdornmentProvider.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java61
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java102
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/StandardCElementLabelProvider.java91
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java71
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties274
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleAction.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java313
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ClearConsoleAction.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/AddIncludeOperation.java151
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/StubUtility.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CParseTreeBuilder.java310
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java173
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java334
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CElementFilters.java132
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CLibFilter.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CPatternFilter.java123
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java1373
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewDropAdapter.java446
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewSorter.java191
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FiltersContentProvider.java104
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ShowLibrariesAction.java69
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java277
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java114
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java126
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java250
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java187
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java163
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java102
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java73
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/DelegatingDragAdapter.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/FileTransferDragAdapter.java186
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/LocalSelectionTransferDragAdapter.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/ResourceTransferDragAdapter.java147
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/TransferDragSourceListener.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java190
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java333
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java425
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java941
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java203
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties136
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorTextHoverDispatcher.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java263
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java76
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTextEditorActionConstants.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultCEditorTextHover.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java486
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchAction.java160
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchActionInWorkingSet.java157
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoErrorAction.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPositionManager.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java251
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java212
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java179
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SharedTextColors.java79
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java134
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java107
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java192
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPartitionScanner.java133
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java164
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java226
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java1227
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java100
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorEditor.java118
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java540
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java477
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java447
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java591
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java305
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java162
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java219
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CElementLabels.java362
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties172
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java154
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java671
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java161
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java138
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java93
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java100
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java109
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java219
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java159
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAnnotationHover.java162
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java225
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java230
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentAutoIndentStrategy.java105
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java213
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java83
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java243
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java220
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java393
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java240
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java206
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CppCodeScanner.java144
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java485
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java255
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java110
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java185
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineBreakingReader.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java117
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java134
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java673
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java468
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java844
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java229
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java495
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionListener.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionManager.java449
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.properties9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionUI.java547
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateContentProvider.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java92
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateLabelProvider.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateProposal.java225
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java330
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java137
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java104
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java87
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemItemMapper.java195
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java149
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java137
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java122
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java118
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java390
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java375
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java171
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java69
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/IStatusChangeListener.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties595
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java68
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java216
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java225
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java213
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java392
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java894
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java192
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java256
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java95
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java137
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridData.java171
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridLayout.java682
277 files changed, 0 insertions, 45015 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextType.java
deleted file mode 100644
index 92d9145e30b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextType.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.textmanipulation.MultiTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.NopTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.SimpleTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBufferEditor;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextEdit;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import java.util.Vector;
-import org.eclipse.core.runtime.CoreException;
-
-
-/**
- * A context type is a context factory.
- */
-public abstract class ContextType implements ITemplateEditor {
-
- /** name of the context type */
- private final String fName;
-
- /** variables used by this content type */
- private final Map fVariables= new HashMap();
-
- /**
- * Creates a context type with a name.
- *
- * @param name the name of the context. It has to be unique wrt to other context names.
- */
- public ContextType(String name) {
- fName= name;
- }
-
- /**
- * Returns the name of the context type.
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Adds a template variable to the context type.
- */
- public void addVariable(TemplateVariable variable) {
- fVariables.put(variable.getName(), variable);
- }
-
- /**
- * Removes a template variable from the context type.
- */
- public void removeVariable(TemplateVariable variable) {
- fVariables.remove(variable.getName());
- }
-
- /**
- * Removes all template variables from the context type.
- */
- public void removeAllVariables() {
- fVariables.clear();
- }
-
- /**
- * Returns an iterator for the variables known to the context type.
- */
- public Iterator variableIterator() {
- return fVariables.values().iterator();
- }
-
- /**
- * Creates a template context.
- */
- public abstract TemplateContext createContext();
-
- /*
- * @see ITemplateEditor#edit(TemplateBuffer)
- */
- public void edit(TemplateBuffer templateBuffer, TemplateContext context) throws CoreException {
- TextBuffer textBuffer= TextBuffer.create(templateBuffer.getString());
- TemplatePosition[] variables= templateBuffer.getVariables();
-
- MultiTextEdit positions= variablesToPositions(variables);
- MultiTextEdit multiEdit= new MultiTextEdit();
-
- // iterate over all variables and try to resolve them
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- if (variable.isResolved())
- continue;
-
- String name= variable.getName();
- int[] offsets= variable.getOffsets();
- int length= variable.getLength();
-
- TemplateVariable evaluator= (TemplateVariable) fVariables.get(name);
- String value= (evaluator == null)
- ? null
- : evaluator.evaluate(context);
-
- if (value == null)
- continue;
-
- variable.setLength(value.length());
- variable.setResolved(evaluator.isResolved(context));
-
- for (int k= 0; k != offsets.length; k++)
- multiEdit.add(SimpleTextEdit.createReplace(offsets[k], length, value));
- }
-
- TextBufferEditor editor= new TextBufferEditor(textBuffer);
- editor.add(positions);
- editor.add(multiEdit);
- editor.performEdits(null);
-
- positionsToVariables(positions, variables);
-
- templateBuffer.setContent(textBuffer.getContent(), variables);
- }
-
- private static MultiTextEdit variablesToPositions(TemplatePosition[] variables) {
- MultiTextEdit positions= new MultiTextEdit();
- for (int i= 0; i != variables.length; i++) {
- int[] offsets= variables[i].getOffsets();
- for (int j= 0; j != offsets.length; j++)
- positions.add(new NopTextEdit(offsets[j], 0));
- }
-
- return positions;
- }
-
- private static void positionsToVariables(MultiTextEdit positions, TemplatePosition[] variables) {
- Iterator iterator= positions.iterator();
-
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- int[] offsets= new int[variable.getOffsets().length];
- for (int j= 0; j != offsets.length; j++)
- offsets[j]= ((TextEdit) iterator.next()).getTextRange().getOffset();
-
- variable.setOffsets(offsets);
- }
- }
-
- /**
- * Returns the templates associated with this context type.
- */
- public Template[] getTemplates() {
- Template[] templates= Templates.getInstance().getTemplates();
-
- Vector vector= new Vector();
- for (int i= 0; i != templates.length; i++)
- if (templates[i].getContextTypeName().equals(fName))
- vector.add(templates[i]);
-
- return (Template[]) vector.toArray(new Template[vector.size()]);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
deleted file mode 100644
index 7bcbf8526e0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.corext.template.c.CFunctionContextType;
-import org.eclipse.cdt.internal.corext.template.c.CGlobalContextType;
-import org.eclipse.cdt.internal.corext.template.c.CStructureContextType;
-import org.eclipse.cdt.internal.corext.template.c.CppFunctionContextType;
-import org.eclipse.cdt.internal.corext.template.c.CppGlobalContextType;
-import org.eclipse.cdt.internal.corext.template.c.CppStructureContextType;
-
-
-/**
- * A singleton to keep track of all known context types.
- */
-public class ContextTypeRegistry {
-
- /** the singleton */
- private static ContextTypeRegistry fInstance;
-
- /** all known context types */
- private final Map fContextTypes= new HashMap();
-
- /**
- * Returns the single instance of this class.
- */
- public static ContextTypeRegistry getInstance() {
- if (fInstance == null)
- fInstance= new ContextTypeRegistry();
-
- return fInstance;
- }
-
- /**
- * Adds a context type to the registry.
- */
- public void add(ContextType contextType) {
- fContextTypes.put(contextType.getName(), contextType);
- }
-
- /**
- * Removes a context type from the registry.
- */
- public void remove(ContextType contextType) {
- fContextTypes.remove(contextType.getName());
- }
-
- /**
- * Returns the context type if the name is valid, <code>null</code> otherwise.
- */
- public ContextType getContextType(String name) {
- return (ContextType) fContextTypes.get(name);
- }
-
- /**
- * Returns an iterator over the registered context type names.
- */
- public Iterator iterator() {
- return fContextTypes.keySet().iterator();
- }
-
- // XXX bootstrap with C and C++ types
- private ContextTypeRegistry() {
- add(new CGlobalContextType());
- add(new CStructureContextType());
- add(new CFunctionContextType());
- add(new CppGlobalContextType());
- add(new CppStructureContextType());
- add(new CppFunctionContextType());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/DocumentTemplateContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/DocumentTemplateContext.java
deleted file mode 100644
index c7a5fcb59bb..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/DocumentTemplateContext.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.util.Assert;
-
-
-
-/**
- * A typical text based document template context.
- */
-public abstract class DocumentTemplateContext extends TemplateContext {
-
- /** The text of the document. */
- private final String fString;
- /** The completion position. */
- private final int fCompletionPosition;
-
- /**
- * Creates a document template context.
- */
- protected DocumentTemplateContext(ContextType type, String string, int completionPosition) {
- super(type);
-
- Assert.isNotNull(string);
- Assert.isTrue(completionPosition >= 0 && completionPosition <= string.length());
-
- fString= string;
- fCompletionPosition= completionPosition;
- }
-
- /**
- * Returns the string of the context.
- */
- public String getString() {
- return fString;
- }
-
- /**
- * Returns the completion position within the string of the context.
- */
- public int getCompletionPosition() {
- return fCompletionPosition;
- }
-
- /**
- * Returns the keyword which triggered template insertion.
- */
- public String getKey() {
- return fString.substring(getStart(), getEnd());
- }
-
- /**
- * Returns the beginning offset of the keyword.
- */
- public int getStart() {
- return fCompletionPosition;
- }
-
- /**
- * Returns the end offset of the keyword.
- */
- public int getEnd() {
- return fCompletionPosition;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ITemplateEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ITemplateEditor.java
deleted file mode 100644
index 34c64f98145..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ITemplateEditor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A template editor implements an action to edit a template buffer in its context.
- */
-public interface ITemplateEditor {
-
- /**
- * Modifies a template buffer.
- *
- * @param buffer the template buffer
- * @param context the template context
- * @throws CoreException if the buffer cannot be successfully modified
- */
- void edit(TemplateBuffer buffer, TemplateContext context) throws CoreException;
-
- public class TemplateContextKind {
- public static final String C_GLOBAL_CONTEXT_TYPE = "C Global";
- public static final String C_FUNCTION_CONTEXT_TYPE = "C Function";
- public static final String C_STRUCTURE_CONTEXT_TYPE = "C Structure";
- public static final String CPP_GLOBAL_CONTEXT_TYPE = "C++ Global";
- public static final String CPP_FUNCTION_CONTEXT_TYPE = "C++ Function";
- public static final String CPP_STRUCTURE_CONTEXT_TYPE = "C++ Structure";
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/SimpleTemplateVariable.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/SimpleTemplateVariable.java
deleted file mode 100644
index 2e0ec456df2..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/SimpleTemplateVariable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A simple template variable, which always evaluates to a defined string.
- */
-public class SimpleTemplateVariable extends TemplateVariable {
-
- /** The string to which this variable evaluates. */
- private String fEvaluationString;
- /** A flag indicating if this variable can be resolved. */
- private boolean fResolved;
-
- /*
- * @see TemplateVariable#TemplateVariable(String, String)
- */
- protected SimpleTemplateVariable(String name, String description) {
- super(name, description);
- }
-
- /**
- * Sets the string to which this variable evaluates.
- *
- * @param evaluationString the evaluation string, may be <code>null</code>.
- */
- public final void setEvaluationString(String evaluationString) {
- fEvaluationString= evaluationString;
- }
-
- /*
- * @see TemplateVariable#evaluate(TemplateContext)
- */
- public String evaluate(TemplateContext context) {
- return fEvaluationString;
- }
-
- /**
- * Sets the resolved flag.
- */
- public final void setResolved(boolean resolved) {
- fResolved= resolved;
- }
-
- /*
- * @see TemplateVariable#isResolved(TemplateContext)
- */
- public boolean isResolved(TemplateContext context) {
- return fResolved;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Template.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Template.java
deleted file mode 100644
index f44fcd0c456..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Template.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A template consiting of a name and a pattern.
- */
-public class Template {
-
- /** The name of this template */
- private String fName;
- /** A description of this template */
- private String fDescription;
- /** The name of the context type of this template */
- private String fContextTypeName;
- /** The template pattern. */
- private String fPattern;
- /** A flag indicating if the template is active or not. */
- private boolean fEnabled= true;
-
- /**
- * Creates an empty template.
- */
- public Template() {
- this("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * Creates a copy of a template.
- */
- public Template(Template template) {
- this(template.getName(), template.getDescription(), template.getContextTypeName(), template.getPattern());
- }
-
- /**
- * Creates a template.
- *
- * @param name the name of the template.
- * @param description the description of the template.
- * @param contextTypeName the name of the context type in which the template can be applied.
- * @param pattern the template pattern.
- */
- public Template(String name, String description, String contextTypeName, String pattern) {
- fName= name;
- fDescription= description;
- fContextTypeName= contextTypeName;
- fPattern= pattern;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
- if (!(object instanceof Template))
- return false;
-
- Template template= (Template) object;
-
- if (template == this)
- return true;
-
- return
- template.fName.equals(fName) &&
- template.fPattern.equals(fPattern) &&
- template.fContextTypeName.equals(fContextTypeName);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return fName.hashCode() ^ fPattern.hashCode() ^ fContextTypeName.hashCode();
- }
-
- /**
- * Sets the description of the template.
- */
- public void setDescription(String description) {
- fDescription= description;
- }
-
- /**
- * Returns the description of the template.
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- * Sets the name of the context type in which the template can be applied.
- */
- public void setContext(String contextTypeName) {
- fContextTypeName= contextTypeName;
- }
-
- /**
- * Returns the name of the context type in which the template can be applied.
- */
- public String getContextTypeName() {
- return fContextTypeName;
- }
-
- /**
- * Sets the name of the template.
- */
- public void setName(String name) {
- fName= name;
- }
-
- /**
- * Returns the name of the template.
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Sets the pattern of the template.
- */
- public void setPattern(String pattern) {
- fPattern= pattern;
- }
-
- /**
- * Returns the template pattern.
- */
- public String getPattern() {
- return fPattern;
- }
-
- /**
- * Sets the enable state of the template.
- */
- public void setEnabled(boolean enable) {
- fEnabled= enable;
- }
-
- /**
- * Returns <code>true</code> if template is enabled, <code>false</code> otherwise.
- */
- public boolean isEnabled() {
- return fEnabled;
- }
-
- /**
- * Returns <code>true</code> if template matches the prefix and context,
- * <code>false</code> otherwise.
- */
- public boolean matches(String prefix, String contextTypeName) {
- return
- fEnabled &&
- fContextTypeName.equals(contextTypeName) &&
- (prefix.length() != 0) &&
- fName.toLowerCase().startsWith(prefix.toLowerCase());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateBuffer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateBuffer.java
deleted file mode 100644
index 1012037c6bc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateBuffer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * A template buffer is a container for a string and variables.
- */
-public final class TemplateBuffer {
-
- /** The string of the template buffer */
- private String fString;
- /** The variable positions of the template buffer */
- private TemplatePosition[] fVariables;
-
- /**
- * Creates a template buffer.
- *
- * @param string the string
- * @param variables the variable positions
- * @throws CoreException for illegal variable positions
- */
- public TemplateBuffer(String string, TemplatePosition[] variables) throws CoreException {
- setContent(string, variables);
- }
-
- /**
- * Sets the content of the template buffer.
- *
- * @param string the string
- * @param variables the variable positions
- * @throws CoreException for illegal variable positions
- */
- public final void setContent(String string, TemplatePosition[] variables) throws CoreException {
- Assert.isNotNull(string);
- Assert.isNotNull(variables);
-
- // XXX assert non-overlapping variable properties
-
- fString= string;
- fVariables= variables;
- }
-
- /**
- * Returns the string of the template buffer.
- */
- public final String getString() {
- return fString;
- }
-
- /**
- * Returns the variable positions of the template buffer.
- */
- public final TemplatePosition[] getVariables() {
- return fVariables;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateContext.java
deleted file mode 100644
index 56272046f2b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateContext.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A template context. A template context is associated with a context type.
- */
-public abstract class TemplateContext {
-
- /** context type of this context */
- private final ContextType fContextType;
-
- /**
- * Creates a template context of a particular context type.
- */
- protected TemplateContext(ContextType contextType) {
- fContextType= contextType;
- }
-
- /**
- * Returns the context type of this context.
- */
- public ContextType getContextType() {
- return fContextType;
- }
-
- /**
- * Evaluates the template and returns a template buffer.
- */
- public abstract TemplateBuffer evaluate(Template template) throws CoreException;
-
- /**
- * Tests if the specified template can be evaluated in this context.
- */
- public abstract boolean canEvaluate(Template template);
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.java
deleted file mode 100644
index a484961b86f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TemplateMessages {
-
- private static final String RESOURCE_BUNDLE= TemplateMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TemplateMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * 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
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.properties
deleted file mode 100644
index 73743c48aea..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateMessages.properties
+++ /dev/null
@@ -1,106 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-# preference page
-TemplatePreferencePage.error.import=Failed to import templates.
-TemplatePreferencePage.error.export=Failed to export templates.
-TemplatePreferencePage.error.read.title=Reading Templates
-TemplatePreferencePage.error.write.title=Reading Templates
-TemplatePreferencePage.message=&Create, edit or remove templates:
-TemplatePreferencePage.title=Templates
-
-TemplatePreferencePage.new=&New...
-TemplatePreferencePage.edit=&Edit...
-TemplatePreferencePage.import=&Import...
-TemplatePreferencePage.export=E&xport...
-TemplatePreferencePage.export.all=Ex&port All...
-TemplatePreferencePage.remove=&Remove
-TemplatePreferencePage.enable.all=Ena&ble All
-TemplatePreferencePage.disable.all=Di&sable All
-TemplatePreferencePage.editor=Template
-
-TemplatePreferencePage.column.name=Name
-TemplatePreferencePage.column.context=Context
-TemplatePreferencePage.column.description=Description
-
-TemplatePreferencePage.use.code.formatter=Use Code &Formatter
-
-TemplatePreferencePage.import.title=Importing Templates
-TemplatePreferencePage.import.extension=*.xml
-
-TemplatePreferencePage.export.title=Exporting {0} Templates
-TemplatePreferencePage.export.filename=templates.xml
-TemplatePreferencePage.export.extension=*.xml
-
-TemplatePreferencePage.export.exists.title=Exporting Templates
-TemplatePreferencePage.export.message={0} already exists.\nDo you want to replace it?
-
-TemplatePreferencePage.question.create.new.title=Edit Template
-TemplatePreferencePage.question.create.new.message=The name of the template was changed.\nDo you want to create a new template?
-
-# edit template dialog
-EditTemplateDialog.error.noname=Template name must not be empty.
-EditTemplateDialog.error.adjacent.variables=Template pattern has adjacent variables.
-EditTemplateDialog.title.new=New Template
-EditTemplateDialog.title.edit=Edit Template
-
-EditTemplateDialog.name=&Name:
-EditTemplateDialog.description=&Description:
-EditTemplateDialog.context=&Context:
-EditTemplateDialog.pattern=&Pattern:
-EditTemplateDialog.insert.variable=Insert &Variable...
-
-EditTemplateDialog.undo=&Undo@Ctrl+Z
-EditTemplateDialog.cut=Cu&t@Ctrl+X
-EditTemplateDialog.copy=&Copy@Ctrl+C
-EditTemplateDialog.paste=&Paste@Ctrl+V
-EditTemplateDialog.select.all=Select &All@Ctrl+A
-EditTemplateDialog.content.assist=Insert &Variable...@Ctrl+Space
-
-# template variable dialog
-TemplateVariableDialog.title=Select a template variable.
-TemplateVariableDialog.column.name=Name
-TemplateVariableDialog.column.description=Description
-TemplateVariableDialog.insert=&Insert
-
-TemplateVariableProposal.error.title=Error applying template variable proposal
-TemplateVariableProcessor.error.title=Error creating template variable proposals
-
-# template set
-TemplateSet.error.read=Error occured while reading templates.
-TemplateSet.error.write=Error occured while writing templates.
-
-# templates
-Templates.error.title=Error accessing templates.
-Templates.error.read=Error occured while reading templates.
-Templates.error.write=Error occured while writing templates.
-
-# template engine
-TemplateEngine.error.title=Could not create template proposals.
-
-# template proposal
-TemplateProposal.delimiter=\ -
-
-# template evaluator
-TemplateEvaluator.error.title=Template Evaluation Error
-
-# template collector
-TemplateCollector.variable.description.file=Filename of compilation unit
-TemplateCollector.variable.description.line=Current line number
-TemplateCollector.variable.description.date=Current date
-TemplateCollector.variable.description.time=Current time
-TemplateCollector.variable.description.user=User name
-TemplateCollector.variable.description.array=A proposal for an array
-TemplateCollector.variable.description.array.type=A proposal for the element type of an array
-TemplateCollector.variable.description.array.element=A proposal for the element name of an array
-TemplateCollector.variable.description.index=A proposal for an index (int)
-TemplateCollector.variable.description.collector=A proposal for a collector (java.util.Collector)
-TemplateCollector.variable.description.iterator=A proposal for an iterator (java.util.Iterator)
-TemplateCollector.variable.description.return.type=Return type (evaluates to void)
-TemplateCollector.variable.description.arguments=Method arguments (evaluates to empty string)
-
-# template translator
-TemplateTranslator.error.incomplete.variable=Template has incomplete variables.
-TemplateTranslator.error.invalid.identifier=Template has invalid variable identifiers.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplatePosition.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplatePosition.java
deleted file mode 100644
index e760c48f518..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplatePosition.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- *
- */
-public class TemplatePosition {
-
- /** The name of the template position */
- private final String fName;
- /** The default value of the template position */
- private final String fDefaultValue;
-
- /** The length of the template positions. */
- private int fLength;
- /** The offsets of the template positions. */
- private int[] fOffsets;
- /** A flag indicating if the template position has been resolved. */
- private boolean fResolved;
-
- /**
- * Creates a template position.
- *
- * @param name the name of the template position.
- * @param defaultValue the default value of the position.
- * @param offsets the array of offsets of the position.
- * @param the length of the position.
- */
- public TemplatePosition(String name, String defaultValue, int[] offsets, int length) {
- fName= name;
- fDefaultValue= defaultValue;
- fOffsets= offsets;
- fLength= length;
- fResolved= false;
- }
-
- /**
- * Returns the name of the position.
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Returns the default value of the position.
- */
- public String getDefaultValue() {
- return fDefaultValue;
- }
-
- /**
- * Sets the length of the position.
- */
- public void setLength(int length) {
- fLength= length;
- }
-
- /**
- * Returns the length of the position.
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Sets the offsets of the position.
- */
- public void setOffsets(int[] offsets) {
- fOffsets= offsets;
- }
-
- /**
- * Returns the offsets of the position.
- */
- public int[] getOffsets() {
- return fOffsets;
- }
-
- /**
- * Sets the resolved flag of the position.
- */
- public void setResolved(boolean resolved) {
- fResolved= resolved;
- }
-
- /**
- * Returns <code>true</code> if the position is resolved, <code>false</code> otherwise.
- */
- public boolean isResolved() {
- return fResolved;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateSet.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateSet.java
deleted file mode 100644
index 94fbff31f63..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateSet.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.internal.ui.CUIException;
-import org.eclipse.cdt.internal.ui.CUIStatus;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * <code>TemplateSet</code> manages a collection of templates and makes them
- * persistent.
- */
-public class TemplateSet {
-
- private static class TemplateComparator implements Comparator {
- public int compare(Object arg0, Object arg1) {
- if (arg0 == arg1)
- return 0;
-
- if (arg0 == null)
- return -1;
-
- Template template0= (Template) arg0;
- Template template1= (Template) arg1;
-
- return template0.getName().compareTo(template1.getName());
- }
- }
-
- private static final String TEMPLATE_TAG= "template"; //$NON-NLS-1$
- private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
- private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$
- private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
-
- private List fTemplates= new ArrayList();
- private Comparator fTemplateComparator= new TemplateComparator();
- private Template[] fSortedTemplates= new Template[0];
-
- /**
- * Convenience method for reading templates from a file.
- *
- * @see addFromStream(InputStream)
- */
- public void addFromFile(File file) throws CoreException {
- InputStream stream= null;
-
- try {
- stream= new FileInputStream(file);
- addFromStream(stream);
-
- } catch (IOException e) {
- throwReadException(e);
-
- } finally {
- try {
- if (stream != null)
- stream.close();
- } catch (IOException e) {}
- }
- }
-
- /**
- * Reads templates from a XML stream and adds them to the template set.
- */
- public void addFromStream(InputStream stream) throws CoreException {
- try {
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder parser= factory.newDocumentBuilder();
- Document document= parser.parse(new InputSource(stream));
- NodeList elements= document.getElementsByTagName(TEMPLATE_TAG);
-
- int count= elements.getLength();
- for (int i= 0; i != count; i++) {
- Node node= elements.item(i);
- NamedNodeMap attributes= node.getAttributes();
-
- if (attributes == null)
- continue;
-
- String name= getAttributeValue(attributes, NAME_ATTRIBUTE);
- String description= getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE);
- String context= getAttributeValue(attributes, CONTEXT_ATTRIBUTE);
- Node enabledNode= attributes.getNamedItem(ENABLED_ATTRIBUTE);
-
- if (name == null || description == null || context == null)
- throw new SAXException("Missing required attribute");
-
- boolean enabled= (enabledNode == null) || (enabledNode.getNodeValue().equals("true")); //$NON-NLS-1$
-
- StringBuffer buffer= new StringBuffer();
- NodeList children= node.getChildNodes();
- for (int j= 0; j != children.getLength(); j++) {
- String value= children.item(j).getNodeValue();
- if (value != null)
- buffer.append(value);
- }
- String pattern= buffer.toString().trim();
-
- Template template= new Template(name, description, context, pattern);
- template.setEnabled(enabled);
- add(template);
- }
-
- sort();
-
- } catch (ParserConfigurationException e) {
- throwReadException(e);
- } catch (IOException e) {
- throwReadException(e);
- } catch (SAXException e) {
- throwReadException(e);
- }
- }
-
- private String getAttributeValue(NamedNodeMap attributes, String name) {
- Node node= attributes.getNamedItem(name);
-
- return node == null
- ? null
- : node.getNodeValue();
- }
-
- /**
- * Convenience method for saving to a file.
- *
- * @see saveToStream(OutputStream)
- */
- public void saveToFile(File file) throws CoreException {
- OutputStream stream= null;
-
- try {
- stream= new FileOutputStream(file);
- saveToStream(stream);
-
- } catch (IOException e) {
- throwWriteException(e);
-
- } finally {
- try {
- if (stream != null)
- stream.close();
- } catch (IOException e) {}
- }
- }
-
- /**
- * Saves the template set as XML.
- */
- public void saveToStream(OutputStream stream) throws CoreException {
- try {
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- DocumentBuilder builder= factory.newDocumentBuilder();
- Document document= builder.newDocument();
-
- Node root= document.createElement("templates"); // $NON-NLS-1$ //$NON-NLS-1$
- document.appendChild(root);
-
- for (int i= 0; i != fTemplates.size(); i++) {
- Template template= (Template) fTemplates.get(i);
-
- Node node= document.createElement("template"); // $NON-NLS-1$ //$NON-NLS-1$
- root.appendChild(node);
-
- NamedNodeMap attributes= node.getAttributes();
-
- Attr name= document.createAttribute(NAME_ATTRIBUTE);
- name.setValue(template.getName());
- attributes.setNamedItem(name);
-
- Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
- description.setValue(template.getDescription());
- attributes.setNamedItem(description);
-
- Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
- context.setValue(template.getContextTypeName());
- attributes.setNamedItem(context);
-
- Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE);
- enabled.setValue(template.isEnabled() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- attributes.setNamedItem(enabled);
-
- Text pattern= document.createTextNode(template.getPattern());
- node.appendChild(pattern);
- }
-
- OutputFormat format = new OutputFormat();
- format.setPreserveSpace(true);
- Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$
- serializer.asDOMSerializer().serialize(document);
-
- } catch (ParserConfigurationException e) {
- throwWriteException(e);
- } catch (IOException e) {
- throwWriteException(e);
- }
- }
-
- private static void throwReadException(Throwable t) throws CoreException {
- IStatus status= new CUIStatus(CStatusConstants.TEMPLATE_IO_EXCEPTION,
- TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
- throw new CUIException(status);
- }
-
- private static void throwWriteException(Throwable t) throws CoreException {
- IStatus status= new CUIStatus(CStatusConstants.TEMPLATE_IO_EXCEPTION,
- TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
- throw new CUIException(status);
- }
-
- /**
- * Adds a template to the set.
- */
- public void add(Template template) {
- if (exists(template))
- return; // ignore duplicate
-
- fTemplates.add(template);
- sort();
- }
-
- private boolean exists(Template template) {
- for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
- Template anotherTemplate = (Template) iterator.next();
-
- if (template.equals(anotherTemplate))
- return true;
- }
-
- return false;
- }
-
- /**
- * Removes a template to the set.
- */
- public void remove(Template template) {
- fTemplates.remove(template);
- sort();
- }
-
- /**
- * Empties the set.
- */
- public void clear() {
- fTemplates.clear();
- sort();
- }
-
- /**
- * Returns all templates.
- */
- public Template[] getTemplates() {
- return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
- }
-
- private void sort() {
- fSortedTemplates= (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
- Arrays.sort(fSortedTemplates, fTemplateComparator);
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateTranslator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateTranslator.java
deleted file mode 100644
index 1159f94ecdc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateTranslator.java
+++ /dev/null
@@ -1,215 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * The template translator translates a string into a template buffer.
- * The EBNF grammer of a valid string is as follows:
- *
- * <p>
- * template := (text | escape)*.<br />
- * text := character - dollar.<br />
- * escape := dollar ('{' identifier '}' | dollar).<br />
- * dollar := '$'.<br />
- * </p>
- */
-public class TemplateTranslator {
-
- // states
- private static final int TEXT= 0;
- private static final int ESCAPE= 1;
- private static final int IDENTIFIER= 2;
-
- // tokens
- private static final char ESCAPE_CHARACTER= '$';
- private static final char IDENTIFIER_BEGIN= '{';
- private static final char IDENTIFIER_END= '}';
-
- /** a buffer for the translation result string */
- private final StringBuffer fBuffer= new StringBuffer();
- /** position offsets of variables */
- private final Vector fOffsets= new Vector();
- /** position lengths of variables */
- private final Vector fLengths= new Vector();
-
- /** the current parsing state */
- private int fState;
- /** the last translation error */
- private String fErrorMessage;
-
- /**
- * Returns an error message if an error occured for the last translation, <code>null</code>
- * otherwise.
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * Translates a template string to <code>TemplateBuffer</code>. <code>null</code>
- * is returned if there was an error. <code>getErrorMessage()</code> retrieves the
- * associated error message.
- *
- * @param string the string to translate.
- * @return returns the template buffer corresponding to the string, <code>null</code>
- * if there was an error.
- * @see getErrorMessage()
- */
- public TemplateBuffer translate(String string) throws CoreException {
-
- fBuffer.setLength(0);
- fOffsets.clear();
- fLengths.clear();
- fState= TEXT;
- fErrorMessage= null;
-
- if (!parse(string))
- return null;
-
- switch (fState) {
- case TEXT:
- break;
-
- // illegal, but be tolerant
- case ESCAPE:
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- return null;
-
- // illegal, but be tolerant
- case IDENTIFIER:
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- return null;
- }
-
- int[] offsets= new int[fOffsets.size()];
- int[] lengths= new int[fLengths.size()];
-
- for (int i= 0; i < fOffsets.size(); i++) {
- offsets[i]= ((Integer) fOffsets.get(i)).intValue();
- lengths[i]= ((Integer) fLengths.get(i)).intValue();
- }
-
- String translatedString= fBuffer.toString();
- TemplatePosition[] variables= findVariables(translatedString, offsets, lengths);
-
- return new TemplateBuffer(translatedString, variables);
- }
-
- private static TemplatePosition[] findVariables(String string, int[] offsets, int[] lengths) {
-
- Map map= new HashMap();
-
- for (int i= 0; i != offsets.length; i++) {
- int offset= offsets[i];
- int length= lengths[i];
-
- String content= string.substring(offset, offset + length);
- Vector vector= (Vector) map.get(content);
- if (vector == null) {
- vector= new Vector();
- map.put(content, vector);
- }
- vector.add(new Integer(offset));
- }
-
- TemplatePosition[] variables= new TemplatePosition[map.size()];
- int k= 0;
-
- Set keys= map.keySet();
- for (Iterator i= keys.iterator(); i.hasNext(); ) {
- String name= (String) i.next();
- Vector vector= (Vector) map.get(name);
-
- int[] offsets_= new int[vector.size()];
- for (int j= 0; j != offsets_.length; j++)
- offsets_[j]= ((Integer) vector.get(j)).intValue();
-
- variables[k]= new TemplatePosition(name, name, offsets_, name.length());
- k++;
- }
-
- return variables;
- }
-
- /** internal parser */
- private boolean parse(String string) {
-
- for (int i= 0; i != string.length(); i++) {
- char ch= string.charAt(i);
-
- switch (fState) {
- case TEXT:
- switch (ch) {
- case ESCAPE_CHARACTER:
- fState= ESCAPE;
- break;
-
- default:
- fBuffer.append(ch);
- break;
- }
- break;
-
- case ESCAPE:
- switch (ch) {
- case ESCAPE_CHARACTER:
- fBuffer.append(ch);
- fState= TEXT;
- break;
-
- case IDENTIFIER_BEGIN:
- fOffsets.add(new Integer(fBuffer.length()));
- fState= IDENTIFIER;
- break;
-
- default:
- // illegal single escape character, but be tolerant
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
- fBuffer.append(ESCAPE_CHARACTER);
- fBuffer.append(ch);
- fState= TEXT;
- return false;
- }
- break;
-
- case IDENTIFIER:
- switch (ch) {
- case IDENTIFIER_END:
- int offset = ((Integer) fOffsets.get(fOffsets.size() - 1)).intValue();
- fLengths.add(new Integer(fBuffer.length() - offset));
- fState= TEXT;
- break;
-
- default:
- if (!Character.isUnicodeIdentifierStart((char) ch) &&
- !Character.isUnicodeIdentifierPart((char) ch))
- {
- // illegal identifier character
- fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.invalid.identifier"); //$NON-NLS-1$
- return false;
- }
-
- fBuffer.append(ch);
- break;
- }
- break;
- }
- }
-
- return true;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateVariable.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateVariable.java
deleted file mode 100644
index dd1f650d0e4..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/TemplateVariable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A template variable.
- */
-public abstract class TemplateVariable {
-
- /** name of the variable */
- private final String fName;
-
- /** description of the variable */
- private final String fDescription;
-
- /**
- * Creates an instance of <code>TemplateVariable</code>.
- *
- * @param name the name of the variable
- * @param description the description for the variable
- */
- protected TemplateVariable(String name, String description) {
- fName= name;
- fDescription= description;
- }
-
- /**
- * Returns the name of the variable.
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Returns the description for the variable.
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- * Tests if this variable can be evaluated.
- */
-// public abstract boolean canEvaluate(TemplateContext context);
-
- /**
- * Evaluates this variable
- *
- * @return the evaluated string, or <code>null</code> if not evaluatable.
- */
- public abstract String evaluate(TemplateContext context);
-
- /**
- * Returns whether this variable is resolved.
- * By default, the variable is not resolved.
- * Clients can overwrite this method to force resolution of the variable.
- */
- public boolean isResolved(TemplateContext context) {
- return false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java
deleted file mode 100644
index 64056a442aa..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.eclipse.cdt.internal.corext.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.dialogs.ErrorDialog;
-
-/**
- * <code>Templates</code> gives access to the available templates.
- */
-public class Templates extends TemplateSet {
-
- private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$
- private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
-
- /** Singleton. */
- private static Templates fgTemplates;
-
- /**
- * Returns an instance of templates.
- */
- public static Templates getInstance() {
- if (fgTemplates == null)
- fgTemplates= create();
-
- return fgTemplates;
- }
-
- private static Templates create() {
- Templates templates= new Templates();
-
- try {
- File templateFile= getTemplateFile();
- if (templateFile.exists()) {
- templates.addFromFile(templateFile);
- } else {
- templates.addFromStream(getDefaultsAsStream());
- templates.saveToFile(templateFile);
- }
-
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- ErrorDialog.openError(null,
- TemplateMessages.getString("Templates.error.title"), //$NON-NLS-1$
- e.getMessage(), e.getStatus());
-
- templates.clear();
- }
-
- return templates;
- }
-
- /**
- * Resets the template set.
- */
- public void reset() throws CoreException {
- clear();
- addFromFile(getTemplateFile());
- }
-
- /**
- * Resets the template set with the default templates.
- */
- public void restoreDefaults() throws CoreException {
- clear();
- addFromStream(getDefaultsAsStream());
- }
-
- /**
- * Saves the template set.
- */
- public void save() throws CoreException {
- saveToFile(getTemplateFile());
- }
-
- private static InputStream getDefaultsAsStream() {
- return Templates.class.getResourceAsStream(DEFAULT_FILE);
- }
-
- private static File getTemplateFile() {
- IPath path= CUIPlugin.getDefault().getStateLocation();
- path= path.append(TEMPLATE_FILE);
-
- return path.toFile();
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
deleted file mode 100644
index 8a2b0c2f65c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.corext.template.TemplateBuffer;
-import org.eclipse.cdt.internal.corext.template.TemplateTranslator;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextUtil;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-
-
-
-/**
- * A context for c/c++
- */
-public class CContext extends CompilationUnitContext {
-
- /**
- * Creates a javadoc template context.
- *
- * @param type the context type.
- * @param string the document string.
- * @param completionPosition the completion position within the document.
- * @param unit the compilation unit (may be <code>null</code>).
- */
- public CContext(ContextType type, String string, int completionPosition,
- ICompilationUnit compilationUnit)
- {
- super(type, string, completionPosition, compilationUnit);
- }
-
- /*
- * @see DocumentTemplateContext#getStart()
- */
- public int getStart() {
- String string= getString();
- int start= getCompletionPosition();
-
- while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
- start--;
-
- if ((start != 0) && Character.isUnicodeIdentifierStart(string.charAt(start - 1)))
- start--;
-
- return start;
- }
-
- /**
- * Returns the indentation level at the position of code completion.
- */
- public int getIndentationLevel() {
- String string= getString();
- int start= getStart();
-
- try {
- TextBuffer textBuffer= TextBuffer.create(string);
- String lineContent= textBuffer.getLineContentOfOffset(start);
-
- return TextUtil.getIndent(lineContent, CUIPlugin.getDefault().getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
-
- } catch (CoreException e) {
- return 0;
- }
- }
-
- /*
- * @see TemplateContext#canEvaluate(Template templates)
- */
- public boolean canEvaluate(Template template) {
- return template.matches(getKey(), getContextType().getName());
- }
-
- /*
- * @see TemplateContext#evaluate(Template)
- */
- public TemplateBuffer evaluate(Template template) throws CoreException {
- if (!canEvaluate(template))
- return null;
-
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(template.getPattern());
-
- getContextType().edit(buffer, this);
-
- ITemplateEditor formatter= new CFormatter();
- formatter.edit(buffer, this);
-
- return buffer;
- }
-
-}
-
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
deleted file mode 100644
index dd0629bd4af..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateBuffer;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-import org.eclipse.cdt.internal.corext.template.TemplatePosition;
-import org.eclipse.cdt.internal.corext.textmanipulation.MultiTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.NopTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.SimpleTextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBufferEditor;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextEdit;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextRegion;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextUtil;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-
-
-/**
- * A template editor using the Java formatter to format a template buffer.
- */
-public class CFormatter implements ITemplateEditor {
-
- private static final String CURSOR= "cursor"; //$NON-NLS-1$
- private static final String MARKER= "/*${cursor}*/"; //$NON-NLS-1$
-
- /*
- * @see ITemplateEditor#edit(TemplateBuffer, TemplateContext)
- */
- public void edit(TemplateBuffer buffer, TemplateContext context) throws CoreException {
- int indentationLevel= ((CContext) context).getIndentationLevel();
-
- //if (TemplatePreferencePage.useCodeFormatter())
- // format(buffer, indentationLevel);
- //else
- indentate(buffer, indentationLevel);
-
- trimBegin(buffer);
- }
-
- private static int getCaretOffset(TemplatePosition[] variables) {
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- if (variable.getName().equals(CURSOR))
- return variable.getOffsets()[0];
- }
-
- return -1;
- }
-
-
- private static void indentate(TemplateBuffer templateBuffer, int indentationLevel) throws CoreException {
-
- String string= templateBuffer.getString();
- TemplatePosition[] variables= templateBuffer.getVariables();
- String indentation= TextUtil.createIndentString(indentationLevel);
-
- MultiTextEdit positions= variablesToPositions(variables);
- MultiTextEdit multiEdit= new MultiTextEdit();
-
- TextBuffer textBuffer= TextBuffer.create(string);
- int lineCount= textBuffer.getNumberOfLines();
- for (int i= 0; i < lineCount; i++) {
- TextRegion region= textBuffer.getLineInformation(i);
- multiEdit.add(SimpleTextEdit.createInsert(region.getOffset(), indentation));
- }
-
- string= edit(string, positions, multiEdit);
- positionsToVariables(positions, variables);
-
- templateBuffer.setContent(string, variables);
- }
-
- private static void trimBegin(TemplateBuffer templateBuffer) throws CoreException {
- String string= templateBuffer.getString();
- TemplatePosition[] variables= templateBuffer.getVariables();
-
- MultiTextEdit positions= variablesToPositions(variables);
-
- int i= 0;
- while ((i != string.length()) && Character.isWhitespace(string.charAt(i)))
- i++;
-
- string= edit(string, positions, SimpleTextEdit.createDelete(0, i));
- positionsToVariables(positions, variables);
-
- templateBuffer.setContent(string, variables);
- }
-
- private static String edit(String string, MultiTextEdit positions, MultiTextEdit multiEdit) throws CoreException {
- TextBuffer textBuffer= TextBuffer.create(string);
- TextBufferEditor editor= new TextBufferEditor(textBuffer);
- editor.add(positions);
- editor.add(multiEdit);
- editor.performEdits(null);
-
- return textBuffer.getContent();
- }
-
- private static String edit(String string, MultiTextEdit positions, TextEdit singleEdit) throws CoreException {
- TextBuffer textBuffer= TextBuffer.create(string);
- TextBufferEditor editor= new TextBufferEditor(textBuffer);
- editor.add(positions);
- editor.add(singleEdit);
- editor.performEdits(null);
-
- return textBuffer.getContent();
- }
-
- private static int[] variablesToOffsets(TemplatePosition[] variables) {
- Vector vector= new Vector();
- for (int i= 0; i != variables.length; i++) {
- int[] offsets= variables[i].getOffsets();
- for (int j= 0; j != offsets.length; j++)
- vector.add(new Integer(offsets[j]));
- }
-
- int[] offsets= new int[vector.size()];
- for (int i= 0; i != offsets.length; i++)
- offsets[i]= ((Integer) vector.get(i)).intValue();
-
- Arrays.sort(offsets);
-
- return offsets;
- }
-
- private static void offsetsToVariables(int[] allOffsets, TemplatePosition[] variables) {
- int[] currentIndices= new int[variables.length];
- for (int i= 0; i != currentIndices.length; i++)
- currentIndices[i]= 0;
-
- int[][] offsets= new int[variables.length][];
- for (int i= 0; i != variables.length; i++)
- offsets[i]= variables[i].getOffsets();
-
- for (int i= 0; i != allOffsets.length; i++) {
-
- int min= Integer.MAX_VALUE;
- int minVariableIndex= -1;
- for (int j= 0; j != variables.length; j++) {
- int currentIndex= currentIndices[j];
-
- // determine minimum
- if (currentIndex == offsets[j].length)
- continue;
-
- int offset= offsets[j][currentIndex];
-
- if (offset < min) {
- min= offset;
- minVariableIndex= j;
- }
- }
-
- offsets[minVariableIndex][currentIndices[minVariableIndex]]= allOffsets[i];
- currentIndices[minVariableIndex]++;
- }
-
- for (int i= 0; i != variables.length; i++)
- variables[i].setOffsets(offsets[i]);
- }
-
- private static MultiTextEdit variablesToPositions(TemplatePosition[] variables) {
- MultiTextEdit positions= new MultiTextEdit();
- for (int i= 0; i != variables.length; i++) {
- int[] offsets= variables[i].getOffsets();
- for (int j= 0; j != offsets.length; j++)
- positions.add(new NopTextEdit(offsets[j], 0));
- }
-
- return positions;
- }
-
- private static void positionsToVariables(MultiTextEdit positions, TemplatePosition[] variables) {
- Iterator iterator= positions.iterator();
-
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- int[] offsets= new int[variable.getOffsets().length];
- for (int j= 0; j != offsets.length; j++)
- offsets[j]= ((TextEdit) iterator.next()).getTextRange().getOffset();
-
- variable.setOffsets(offsets);
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFunctionContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFunctionContextType.java
deleted file mode 100644
index 0fa6d755ff6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFunctionContextType.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Created on 19/12/2003
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.cdt.internal.corext.template.c;
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class CFunctionContextType extends CompilationUnitContextType {
-
- /**
- * @param name
- */
- public CFunctionContextType() {
- super(ITemplateEditor.TemplateContextKind.C_FUNCTION_CONTEXT_TYPE);
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- // @@@ Need to add some specific C ones
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.corext.template.ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CGlobalContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CGlobalContextType.java
deleted file mode 100644
index c6b4f785480..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CGlobalContextType.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-
-/**
- * A context type for javadoc.
- */
-public class CGlobalContextType extends CompilationUnitContextType {
-
- /**
- * Creates a C context type.
- */
- public CGlobalContextType() {
- super(ITemplateEditor.TemplateContextKind.C_GLOBAL_CONTEXT_TYPE);
-
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- // @@@ Need to add some specific C ones
- }
-
- /*
- * @see ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CStructureContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CStructureContextType.java
deleted file mode 100644
index 539e9eb2581..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CStructureContextType.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Created on 19/12/2003
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.cdt.internal.corext.template.c;
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class CStructureContextType extends CompilationUnitContextType {
-
- /**
- * @param name
- */
- public CStructureContextType() {
- super(ITemplateEditor.TemplateContextKind.C_STRUCTURE_CONTEXT_TYPE);
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- // @@@ Need to add some specific C ones
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.corext.template.ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContext.java
deleted file mode 100644
index 37a056eb658..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.DocumentTemplateContext;
-
-
-/**
- * A compilation unit context.
- */
-public abstract class CompilationUnitContext extends DocumentTemplateContext {
-
- /** The compilation unit, may be <code>null</code>. */
- private final ICompilationUnit fCompilationUnit;
-
- /**
- * Creates a compilation unit context.
- *
- * @param type the context type.
- * @param string the document string.
- * @param completionPosition the completion position within the document.
- * @param compilationUnit the compilation unit (may be <code>null</code>).
- */
- protected CompilationUnitContext(ContextType type, String string, int completionPosition,
- ICompilationUnit compilationUnit)
- {
- super(type, string, completionPosition);
- fCompilationUnit= compilationUnit;
- }
-
- /**
- * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
- */
- public final ICompilationUnit getCompilationUnit() {
- return fCompilationUnit;
- }
-
- /**
- * Returns the enclosing element of a particular element type, <code>null</code>
- * if no enclosing element of that type exists.
- */
- public ICElement findEnclosingElement(int elementType) {
- if (fCompilationUnit == null)
- return null;
-
- /* try {
- ICElement element= fCompilationUnit.getElementAt(getStart());
- while (element != null && element.getElementType() != elementType)
- element= element.getParent();
-
- return element;
-
- } catch (JavaModelException e) {
- return null;
- } */
- return null;
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContextType.java
deleted file mode 100644
index 6b458e7f9a1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CompilationUnitContextType.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-import org.eclipse.cdt.internal.corext.template.TemplateVariable;
-
-
-/**
- * Compilation unit context type.
- */
-public abstract class CompilationUnitContextType extends ContextType {
-
- /** the document string */
- protected String fString;
-
- /** the completion position within the document string */
- protected int fPosition;
-
- /** the associated compilation unit, may be <code>null</code> */
- protected ICompilationUnit fCompilationUnit;
-
- protected static class ReturnType extends TemplateVariable {
- public ReturnType() {
- super("return_type", TemplateMessages.getString("JavaContextType.variable.description.return.type"));
- }
- public String evaluate(TemplateContext context) {
- /* IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
- if (element == null)
- return null;
-
- try {
- return Signature.toString(((IMethod) element).getReturnType());
- } catch (JavaModelException e) {
- return null;
- } */
- return null;
- }
- public boolean isResolved(TemplateContext context) {
- return evaluate(context) != null;
- }
- }
-
- protected static class File extends TemplateVariable {
- public File() {
- super("file", TemplateMessages.getString("JavaContextType.variable.description.file"));
- }
- public String evaluate(TemplateContext context) {
- //ICompilationUnit unit= ((CompilationUnitContext) context).getCompilationUnit();
-
- //return (unit == null) ? null : unit.getElementName();
- return null;
- }
- public boolean isResolved(TemplateContext context) {
- return evaluate(context) != null;
- }
- }
-
- protected static class EnclosingJavaElement extends TemplateVariable {
- protected final int fElementType;
-
- public EnclosingJavaElement(String name, String description, int elementType) {
- super(name, description);
- fElementType= elementType;
- }
- public String evaluate(TemplateContext context) {
- /*IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(fElementType);
- return (element == null) ? null : element.getElementName(); */
- return null;
- }
- public boolean isResolved(TemplateContext context) {
- return evaluate(context) != null;
- }
- }
-
- protected static class Method extends EnclosingJavaElement {
- public Method() {
- //super("enclosing_method", TemplateMessages.getString("JavaContextType.variable.description.enclosing.method"), IJavaElement.METHOD);
- super("enclosing_method", TemplateMessages.getString("JavaContextType.variable.description.enclosing.method"), 0);
- }
- }
-
- protected static class Type extends EnclosingJavaElement {
- public Type() {
- super("enclosing_type", TemplateMessages.getString("JavaContextType.variable.description.enclosing.type"), 0);
- }
- }
-/*
- protected static class SuperClass extends EnclosingJavaElement {
- public Type() {
- super("super_class", TemplateMessages.getString("JavaContextType.variable.description.type"), IJavaElement.TYPE);
- }
- }
-*/
- protected static class Package extends EnclosingJavaElement {
- public Package() {
- super("enclosing_package", TemplateMessages.getString("JavaContextType.variable.description.enclosing.package"), 0);
- }
- }
-
- protected static class Project extends EnclosingJavaElement {
- public Project() {
- super("enclosing_project", TemplateMessages.getString("JavaContextType.variable.description.enclosing.project"), 0);
- }
- }
-/*
- protected static class Project2 extends TemplateVariable {
- public Project2() {
- super("project", TemplateMessages.getString("JavaContextType.variable.description.project"));
- }
- public String evaluate(TemplateContext context) {
- ICompilationUnit unit= ((JavaContext) context).getUnit();
- return (unit == null) ? null : unit.getJavaProject().getElementName();
- }
- }
-*/
- protected static class Arguments extends TemplateVariable {
- public Arguments() {
- super("enclosing_method_arguments", TemplateMessages.getString("JavaContextType.variable.description.enclosing.method.arguments"));
- }
- public String evaluate(TemplateContext context) {
- /*IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
- if (element == null)
- return null;
-
- IMethod method= (IMethod) element;
-
- try {
- String[] arguments= method.getParameterNames();
- StringBuffer buffer= new StringBuffer();
-
- for (int i= 0; i < arguments.length; i++) {
- if (i > 0)
- buffer.append(", ");
- buffer.append(arguments[i]);
- }
-
- return buffer.toString();
-
- } catch (JavaModelException e) {
- return null;
- } */
- return null;
- }
- }
-
-/*
- protected static class Line extends TemplateVariable {
- public Line() {
- super("line", TemplateMessages.getString("CompilationUnitContextType.variable.description.line"));
- }
- public String evaluate(TemplateContext context) {
- return ((JavaTemplateContext) context).guessLineNumber();
- }
- }
-*/
-
- /*
- * @see ContextType#ContextType(String)
- */
- public CompilationUnitContextType(String name) {
- super(name);
- }
-
- /**
- * Sets context parameters. Needs to be called before createContext().
- */
- public void setContextParameters(String string, int position, ICompilationUnit compilationUnit) {
- fString= string;
- fPosition= position;
- fCompilationUnit= compilationUnit;
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppFunctionContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppFunctionContextType.java
deleted file mode 100644
index 2a717dc0c5f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppFunctionContextType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Created on 19/12/2003
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.cdt.internal.corext.template.c;
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class CppFunctionContextType extends CompilationUnitContextType {
-
- public CppFunctionContextType() {
- super(ITemplateEditor.TemplateContextKind.CPP_FUNCTION_CONTEXT_TYPE);
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.corext.template.ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppGlobalContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppGlobalContextType.java
deleted file mode 100644
index 72a75051600..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppGlobalContextType.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-/**
- * A context type for javadoc.
- */
-public class CppGlobalContextType extends CompilationUnitContextType {
-
- /**
- * Creates a C context type.
- */
- public CppGlobalContextType() {
- super(ITemplateEditor.TemplateContextKind.CPP_GLOBAL_CONTEXT_TYPE);
-
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- }
-
- /*
- * @see ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppStructureContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppStructureContextType.java
deleted file mode 100644
index 61e3c5d18b7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CppStructureContextType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Created on 19/12/2003
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.cdt.internal.corext.template.c;
-
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class CppStructureContextType extends CompilationUnitContextType {
-
- public CppStructureContextType() {
- super(ITemplateEditor.TemplateContextKind.CPP_STRUCTURE_CONTEXT_TYPE);
- // global
- addVariable(new GlobalVariables.Cursor());
- addVariable(new GlobalVariables.Dollar());
- addVariable(new GlobalVariables.Date());
- addVariable(new GlobalVariables.Time());
- addVariable(new GlobalVariables.User());
-
- // compilation unit
- addVariable(new File());
- /* addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package()); */
- addVariable(new Project());
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.corext.template.ContextType#createContext()
- */
- public TemplateContext createContext() {
- return new CContext(this, fString, fPosition, fCompilationUnit);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/GlobalVariables.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/GlobalVariables.java
deleted file mode 100644
index 4c276d16ff9..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/GlobalVariables.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.SimpleTemplateVariable;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-import java.text.DateFormat;
-
-
-/**
- * Global variables which are available in any context.
- */
-public class GlobalVariables {
-
- /**
- * The cursor variable determines the cursor placement after template edition.
- */
- static class Cursor extends SimpleTemplateVariable {
- public Cursor() {
- super("cursor", TemplateMessages.getString("GlobalVariables.variable.description.cursor"));
- setEvaluationString("");
- setResolved(true);
- }
- }
-
- /**
- * The dollar variable inserts an escaped dollar symbol.
- */
- static class Dollar extends SimpleTemplateVariable {
- public Dollar() {
- super("dollar", TemplateMessages.getString("GlobalVariables.variable.description.dollar"));
- setEvaluationString("$");
- setResolved(true);
- }
- }
-
- /**
- * The date variable evaluates to the current date.
- */
- static class Date extends SimpleTemplateVariable {
- public Date() {
- super("date", TemplateMessages.getString("GlobalVariables.variable.description.date"));
- setResolved(true);
- }
- public String evaluate(TemplateContext context) {
- return DateFormat.getDateInstance().format(new java.util.Date());
- }
- }
-
- /**
- * The time variable evaluates to the current time.
- */
- static class Time extends SimpleTemplateVariable {
- public Time() {
- super("time", TemplateMessages.getString("GlobalVariables.variable.description.time"));
- setResolved(true);
- }
- public String evaluate(TemplateContext context) {
- return DateFormat.getTimeInstance().format(new java.util.Date());
- }
- }
-
- /**
- * The user variable evaluates to the current user.
- */
- static class User extends SimpleTemplateVariable {
- public User() {
- super("user", TemplateMessages.getString("GlobalVariables.variable.description.user"));
- setResolved(true);
- }
- public String evaluate(TemplateContext context) {
- return System.getProperty("user.name");
- }
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ICompilationUnit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ICompilationUnit.java
deleted file mode 100644
index 872ed89bb8c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ICompilationUnit.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-public interface ICompilationUnit {
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
deleted file mode 100644
index 49fdc795f12..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.cdt.internal.corext.template.c;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TemplateMessages {
-
- private static final String RESOURCE_BUNDLE= TemplateMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TemplateMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * 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
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties
deleted file mode 100644
index 6a95267b954..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-GlobalVariables.variable.description.dollar=The dollar symbol
-GlobalVariables.variable.description.cursor=The cursor position after editing template variables
-
-GlobalVariables.variable.description.line=Current line number
-GlobalVariables.variable.description.date=Current date
-GlobalVariables.variable.description.time=Current time
-GlobalVariables.variable.description.user=User name
-
-JavaDocContextType.variable.description.file=Filename of compilation unit
-
-JavaContextType.variable.description.file=Filename of compilation unit
-JavaContextType.variable.description.array=A proposal for an array
-JavaContextType.variable.description.array.type=A proposal for the element type of an array
-JavaContextType.variable.description.array.element=A proposal for the element name of an array
-JavaContextType.variable.description.index=A proposal for an index (int)
-JavaContextType.variable.description.collector=A proposal for a collector (java.util.Collector)
-JavaContextType.variable.description.iterator=A proposal for an iterator (java.util.Iterator)
-JavaContextType.variable.description.arguments=Method arguments (evaluates to empty string)
-JavaContextType.variable.description.enclosing.method=Enclosing method name
-JavaContextType.variable.description.enclosing.type=Enclosing type name
-JavaContextType.variable.description.enclosing.package=Enclosing package name
-JavaContextType.variable.description.enclosing.project=Enclosing project name
-JavaContextType.variable.description.enclosing.method.arguments=Argument names of enclosing method
-JavaContextType.variable.description.return.type=Enclosing method return type
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml
deleted file mode 100644
index 5be99d3854b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-(c) Copyright IBM Corp. 2000, 2001.
-All Rights Reserved.
--->
-
-<templates>
-
-<!-- C++ -->
-
-<template description="for loop" name="for" context="C Function">
-for (${var} = 0; ${var} &lt; ${max}; ${var}++) {
- ${cursor}
-}
-</template>
-
-<template description="for loop with temporary variable" name="for" context="C Function">
-for (int ${var} = 0; ${var} &lt; ${max}; ${var}++) {
- ${cursor}
-}
-</template>
-
-<template description="do while statement" name="do" context="C Function">
-do {
- ${cursor}
-} while (${condition});
-</template>
-
-<template description="switch case statement" name="switch" context="C Function">
-switch (${key}) {
- case ${value}:
- ${cursor}
- break;
- default:
- break;
-}
-</template>
-
-<template description="if statement" name="if" context="C Function">
-if (${condition}) {
- ${cursor}
-}
-</template>
-
-<template description="if else statement" name="ifelse" context="C Function">
-if (${condition}) {
- ${cursor}
-} else {
-
-}
-</template>
-
-<template description="else if block" name="elseif" context="C Function">
-else if (${condition}) {
- ${cursor}
-}
-</template>
-
-<template description="else block" name="else" context="C Function">
-else {
- ${cursor}
-}
-</template>
-
-<template description="try catch block" name="try" context="C++ Function">
-try {
- ${cursor}
-} catch (${Exception} e) {
-}
-</template>
-
-<template description="catch block" name="catch" context="C++ Function">
-catch (${Exception} e) {
- ${cursor}
-}
-</template>
-
-<template description="main method" name="main" context="C Global">
-int
-main(int argc, char **argv) {
- ${cursor}
-}
-</template>
-
-<template description="class declaration" name="class" context="C++ Global">
-class ${name} {
- ${cursor}
-private:
-};
-</template>
-
-<template description="using a namespace" name="using" context="C++ Global">
-using namespace ${namespace};
-</template>
-
- <template description="namespace declaration" name="namespace" context="C++ Global"
- >namespace ${namespace} {
- ${cursor}
-}</template>
-
- <template description="create new object" name="new" context="C++ Function"
->${type} ${name} = new ${type}(${arguments});
-</template>
-
-
-<template name="comment" description="default multiline comment" context="C Global" enabled="true">/*
- * author ${user}
- *
- * To change this generated comment edit the template variable &quot;comment&quot;:
- * Window&gt;Preferences&gt;C&gt;Templates.
- */</template>
-
- <template description="print to standard out" name="stdout" context="C Function"
- >printf(${cursor});</template>
-
- <template description="print to standard error" name="stderr" context="C Function"
- >fprintf(stderr, ${cursor});</template>
-
- <!-- javadoc -->
-
- <template description="author name" name="author" context="C Global"
- >author ${user}</template>
-
-</templates>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/ISourceRange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/ISourceRange.java
deleted file mode 100644
index 73d08927f27..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/ISourceRange.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A source range defines an element's source coordinates relative to
- * its source buffer.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface ISourceRange {
-
-/**
- * Returns the number of characters of the source code for this element,
- * relative to the source buffer in which this element is contained.
- */
-int getLength();
-/**
- * Returns the 0-based index of the first character of the source code for this element,
- * relative to the source buffer in which this element is contained.
- */
-int getOffset();
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/Messages.properties
deleted file mode 100644
index 729774b29aa..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/Messages.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-################################################################################
-# Copyright (c) 2002 International Business Machines Corp. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v0.5
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v05.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-################################################################################
-
-TextRange.offset=Offset:
-TextRange.length=\ Length:
-
-TextBuffer.wrongRange=Replace failed due to wrong range [{0},{1}]
-
-TextBufferFactory.bufferNotManaged=Buffer not managed
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MoveTextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MoveTextEdit.java
deleted file mode 100644
index ef6ca13c97d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MoveTextEdit.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-
-/**
- * A text edit that moves text inside a text buffer.
- */
-public final class MoveTextEdit extends TextEdit {
-
- /* package */ static class TargetMark extends NopTextEdit {
- private MoveTextEdit fMoveTextEdit;
- public TargetMark(TextRange range, MoveTextEdit edit) {
- super(range);
- fMoveTextEdit= edit;
- }
- /* package */ MoveTextEdit getMoveTextEdit() {
- return fMoveTextEdit;
- }
- public TextEdit perform(TextBuffer buffer) throws CoreException {
- fMoveTextEdit.internalPerform(buffer);
- return super.perform(buffer);
- }
- public TextEdit copy() {
- Assert.isTrue(false, "This should never happen"); //$NON-NLS-1$
- return super.copy();
- }
- }
-
- private TextRange fTarget;
- private TextRange fSource;
- private int fPerformCounter;
-
- /**
- * Creates a new <code>MoveTextEdit</code>. The text edit doesn't support
- * overlapping moves. So for a <code>MoveTextEdit</code> <code>destination &lt;= offset &&
- * offset + length - 1 &lt;= destination</code> must be <code>true</code>.
- *
- * @param offset the offset of the text to be moved
- * @param length the text length to be moved
- * @param destination the destination offset
- */
- public MoveTextEdit(int offset, int length, int destination) {
- Assert.isTrue(destination <= offset || offset + length <= destination);
- fSource= new TextRange(offset, length);
- fTarget= new TextRange(destination);
- }
-
- /**
- * Creates a new <code>MoveTextEdit</code> with the given source and target range.
- *
- * @param source the source
- * @param target the target
- */
- private MoveTextEdit(TextRange source,TextRange target) {
- fSource= source;
- fTarget= target;
- }
-
- /**
- * Returns the move text edit's source range. This method returns the same range
- * as <code>TextEdit#getTextRange()</code>
- *
- * @return the edit's source range
- */
- public TextRange getSourceRange() {
- return fSource;
- }
-
- /**
- * Returns the move text edit's target range.
- *
- * @return the edit's target range
- */
- public TextRange getTargetRange() {
- return fTarget;
- }
-
- /* non Java-doc
- * @see TextEdit#getTextRange()
- */
- public TextRange getTextRange() {
- return fSource;
- }
-
- /* non Java-doc
- * @see TextEdit#connect(TextBufferEditor)
- */
- public void connect(TextBufferEditor editor) throws CoreException {
- editor.add(new TargetMark(fTarget, this));
- }
-
- /* non Java-doc
- * @see TextEdit#perform(TextBuffer)
- */
- public TextEdit perform(TextBuffer buffer) throws CoreException {
- internalPerform(buffer);
- return new MoveTextEdit(fTarget, fSource);
- }
-
- /* non Java-doc
- * @see TextEdit#copy()
- */
- public TextEdit copy() {
- TextRange source= getSourceRange();
- TextRange target= getTargetRange();
- return new MoveTextEdit(source.fOffset, source.fLength, target.fOffset);
- }
-
- //---- Helper method ---------------------------------------------------------------------------------
-
- protected void internalPerform(TextBuffer buffer) throws CoreException {
- Assert.isTrue(fPerformCounter < 2);
- if (++fPerformCounter == 2) {
- TextRange source= getSourceRange();
- TextRange target= getTargetRange();
- String current= buffer.getContent(source.fOffset, source.fLength);
- buffer.replace(source, ""); //$NON-NLS-1$
- buffer.replace(target, current);
- }
- }
-
- /* package */ boolean isUpMove() {
- return fSource.fOffset < fTarget.fOffset;
- }
-
- /* package */ boolean isDownMove() {
- return fSource.fOffset > fTarget.fOffset;
- }
-
- /* package */ TextRange getChildRange() {
- int offset= fSource.fOffset;
- int length= fSource.fLength;
- int destination= fTarget.fOffset;
- if (destination <= offset)
- return new TextRange(destination, offset + length - destination);
- else
- return new TextRange(offset, destination - offset);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MultiTextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MultiTextEdit.java
deleted file mode 100644
index dd056ff4c8f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/MultiTextEdit.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.internal.utils.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-public class MultiTextEdit {
-
- private List fChildren;
-
- /**
- * Creates a new composite text edit.
- */
- public MultiTextEdit() {
- fChildren= new ArrayList(3);
- }
-
- protected MultiTextEdit(List children) throws CoreException {
- fChildren= new ArrayList(children.size());
- for (Iterator iter= children.iterator(); iter.hasNext();) {
- fChildren.add(((TextEdit)iter.next()).copy());
- }
- }
-
- protected List getChildren() {
- return fChildren;
- }
-
- /**
- * Adds all <code>TextEdits</code> managed by the given multt text edit.
- *
- * @param edit the multi text edit to be added.
- */
- public void add(MultiTextEdit edit) {
- Assert.isNotNull(edit);
- fChildren.add(edit);
- }
-
- /**
- * Adds a text edit.
- *
- * @param edit the text edit to be added
- */
- public void add(TextEdit edit) {
- Assert.isNotNull(edit);
- fChildren.add(edit);
- }
-
- /**
- * Returns the children managed by this text edit collection.
- *
- * @return the children of this composite text edit
- */
- public Iterator iterator() {
- return fChildren.iterator();
- }
-
- /**
- * Connects this text edit to the given <code>TextBufferEditor</code>.
- * Note that this method <b>should only be called</b> by a <code>
- * TextBufferEditor</code>.
- *<p>
- * This default implementation does nothing. Subclasses may override
- * if needed.
- *
- * @param editor the text buffer editor this text edit has been added to
- */
- public void connect(TextBufferEditor editor) throws CoreException {
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof TextEdit)
- editor.add((TextEdit)element);
- else
- editor.add((MultiTextEdit)element);
- }
- }
-
- /**
- * Creates and returns a copy of this text edit collection. The copy method should
- * be implemented in a way so that the copy can be added to a different <code>
- * TextBuffer</code> without causing any harm to the object from which the copy
- * has been created.
- *
- * @return a copy of this object.
- */
- public MultiTextEdit copy() throws CoreException {
- return new MultiTextEdit(fChildren);
- }
-
- /**
- * Returns the <code>TextRange</code> that this text edit is going to
- * manipulate. If this method is called before the <code>MultiTextEdit</code>
- * has been added to a <code>TextBufferEditor</code> it may return <code>
- * null</code> to indicate this situation.
- *
- * @return the <code>TextRange</code>s this <code>TextEdit is going
- * to manipulate
- */
- public TextRange getTextRange() {
- int size= fChildren.size();
- if (size == 0)
- return new TextRange(0,0);
- TextRange range= ((TextEdit)fChildren.get(0)).getTextRange();
- int start= range.getOffset();
- int end= range.getInclusiveEnd();
- for (int i= 1; i < size; i++) {
- range= ((TextEdit)fChildren.get(i)).getTextRange();
- start= Math.min(start, range.getOffset());
- end= Math.max(end, range.getInclusiveEnd());
- }
- return new TextRange(start, end - start + 1);
- }
-
- /**
- * Returns the element modified by this text edit. The method
- * may return <code>null</code> if the modification isn't related to a
- * element or if the content of the modified text buffer doesn't
- * follow any syntax.
- * <p>
- * This default implementation returns <code>null</code>
- *
- * @return the element modified by this text edit
- */
- public Object getModifiedElement() {
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/NopTextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/NopTextEdit.java
deleted file mode 100644
index 2b8fc3350aa..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/NopTextEdit.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A text edit that does nothing. A <code>NopTextEdit</code> can be used to track
- * positions when executing <code>TextEdits</code> associated with a <code>
- * TextBufferEditor</code>.
- */
-public class NopTextEdit extends TextEdit {
-
- private TextRange fTextRange;
-
- /**
- * Creates a new <code>NopTextEdit</code> for the given
- * offset and length.
- *
- * @param offset the starting offset this text edit is "working on"
- * @param length the length this text edit is "working on"
- */
- public NopTextEdit(int offset, int length) {
- this(new TextRange(offset, length));
- }
-
- /**
- * Creates a new <code>NopTextEdit</code> for the given
- * range.
- *
- * @param range the <code>TextRange</code> this text edit is "working on"
- */
- public NopTextEdit(TextRange range) {
- fTextRange= range;
- }
-
- /* non Java-doc
- * @see TextEdit#getTextRange
- */
- public TextRange getTextRange() {
- return fTextRange;
- }
-
- /* non Java-doc
- * @see TextEdit#perform
- */
- public TextEdit perform(TextBuffer buffer) throws CoreException {
- return new NopTextEdit(fTextRange);
- }
-
- /* non Java-doc
- * @see TextEdit#perform
- */
- public TextEdit copy() {
- return new NopTextEdit(fTextRange.copy());
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SimpleTextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SimpleTextEdit.java
deleted file mode 100644
index 21ffb7a6b53..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SimpleTextEdit.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-
-
-public abstract class SimpleTextEdit extends TextEdit {
-
- private TextRange fRange;
- private String fText;
-
- public static SimpleTextEdit createReplace(int offset, int length, String text) {
- return new SimpleTextEditImpl(offset, length, text);
- }
-
- public static SimpleTextEdit createInsert(int offset, String text) {
- return new SimpleTextEditImpl(offset, 0, text);
- }
-
- public static SimpleTextEdit createDelete(int offset, int length) {
- return new SimpleTextEditImpl(offset, length, ""); //$NON-NLS-1$
- }
-
- private final static class SimpleTextEditImpl extends SimpleTextEdit {
- protected SimpleTextEditImpl(TextRange range, String text) {
- super(range, text);
- }
- protected SimpleTextEditImpl(int offset, int length, String text) {
- super(offset, length, text);
- }
- public TextEdit copy() {
- return new SimpleTextEditImpl(getTextRange().copy(), getText());
- }
- }
-
- protected SimpleTextEdit() {
- this(TextRange.UNDEFINED, ""); //$NON-NLS-1$
- }
-
- protected SimpleTextEdit(int offset, int length, String text) {
- this(new TextRange(offset, length), text);
- }
- protected SimpleTextEdit(TextRange range, String text) {
- Assert.isNotNull(range);
- Assert.isNotNull(text);
- fRange= range;
- fText= text;
- }
-
- /**
- * Returns the text edit's text
- *
- * @return the text edit's text
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Sets the text edit's text
- * <p>
- * This method should only be called from within the <code>
- * connect</code> method.
- *
- * @param text the text edit's text
- */
- protected final void setText(String text) {
- fText= text;
- Assert.isNotNull(fText);
- }
-
- /**
- * Sets the text edit's range.
- * <p>
- * This method should only be called from within the <code>
- * connect</code> method.
- *
- * @param range the text edit's range.
- */
- protected void setTextRange(TextRange range) {
- fRange= range;
- Assert.isNotNull(fRange);
- }
-
- /* non Java-doc
- * @see TextEdit#getTextRange
- */
- public TextRange getTextRange() {
- return fRange;
- }
-
- /* non Java-doc
- * @see TextEdit#doPerform
- */
- public final TextEdit perform(TextBuffer buffer) throws CoreException {
- String current= buffer.getContent(fRange.fOffset, fRange.fLength);
- buffer.replace(fRange, fText);
- return new SimpleTextEditImpl(fRange, current);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SwapTextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SwapTextEdit.java
deleted file mode 100644
index 53693786816..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/SwapTextEdit.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A <code>SwapTextEdit</code> exchanges to text ranges.
- */
-public class SwapTextEdit extends MultiTextEdit {
- /**
- * Create a new <code>SwapTextEdit</code>
- *
- * @param offset1 the offset of the first text range
- * @param length1 the length of the first text range
- * @param offset2 the offset of the second text range
- * @param length2 the length of the second text range
- */
- public SwapTextEdit(int offset1, int length1, int offset2, int length2) {
- add(new MoveTextEdit(offset1, length1, offset2));
- add(new MoveTextEdit(offset2, length2, offset1));
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBuffer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBuffer.java
deleted file mode 100644
index ac4e0a60f64..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBuffer.java
+++ /dev/null
@@ -1,451 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-
-/**
- * An implementation of a <code>TextBuffer</code> that is based on <code>ITextSelection</code>
- * and <code>IDocument</code>.
- */
-public class TextBuffer {
-
- private static class DocumentRegion extends TextRegion {
- IRegion fRegion;
- public DocumentRegion(IRegion region) {
- fRegion= region;
- }
- public int getOffset() {
- return fRegion.getOffset();
- }
- public int getLength() {
- return fRegion.getLength();
- }
- }
-
- private IDocument fDocument;
-
- private static final TextBufferFactory fgFactory= new TextBufferFactory();
-
- TextBuffer(IDocument document) {
- fDocument= document;
- Assert.isNotNull(fDocument);
- }
-
- /**
- * Returns the number of characters in this text buffer.
- *
- * @return the number of characters in this text buffer
- */
- public int getLength() {
- return fDocument.getLength();
- }
-
- /**
- * Returns the number of lines in this text buffer.
- *
- * @return the number of lines in this text buffer
- */
- public int getNumberOfLines() {
- return fDocument.getNumberOfLines();
- }
-
- /**
- * Returns the character at the given offset in this text buffer.
- *
- * @param offset a text buffer offset
- * @return the character at the offset
- * @exception IndexOutOfBoundsException if the <code>offset</code>
- * argument is negative or not less than the length of this text buffer.
- */
- public char getChar(int offset) {
- try {
- return fDocument.getChar(offset);
- } catch (BadLocationException e) {
- throw new ArrayIndexOutOfBoundsException(e.getMessage());
- }
- }
-
- /**
- * Returns the whole content of the text buffer.
- *
- * @return the whole content of the text buffer
- */
- public String getContent() {
- return fDocument.get();
- }
-
- /**
- * Returns length characters starting from the specified position.
- *
- * @return the characters specified by the given text region. Returns <code>
- * null</code> if text range is illegal
- */
- public String getContent(int start, int length) {
- try {
- return fDocument.get(start, length);
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns the preferred line delimiter to be used for this text buffer.
- *
- * @return the preferred line delimiter
- */
- public String getLineDelimiter() {
- String lineDelimiter= getLineDelimiter(0);
- if (lineDelimiter == null)
- lineDelimiter= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- return lineDelimiter;
- }
-
- /**
- * Returns the line delimiter used for the given line number. Returns <code>
- * null</code> if the line number is out of range.
- *
- * @return the line delimiter used by the given line number or <code>null</code>
- */
- public String getLineDelimiter(int line) {
- try {
- return fDocument.getLineDelimiter(line);
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns the line for the given line number. If there isn't any line for
- * the given line number, <code>null</code> is returned.
- *
- * @return the line for the given line number or <code>null</code>
- */
- public String getLineContent(int line) {
- try {
- IRegion region= fDocument.getLineInformation(line);
- return fDocument.get(region.getOffset(), region.getLength());
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns the line indent for the given line. If there isn't any line for the
- * given line number, <code>-1</code> is returned.
- *
- * @return the line indent for the given line number of <code>-1</code>
- */
- public int getLineIndent(int lineNumber, int tabWidth) {
- return getIndent(getLineContent(lineNumber), tabWidth);
- }
-
- /**
- * Returns a region of the specified line. The region contains the offset and the
- * length of the line excluding the line's delimiter. Returns <code>null</code>
- * if the line doesn't exist.
- *
- * @param line the line of interest
- * @return a line description or <code>null</code> if the given line doesn't
- * exist
- */
- public TextRegion getLineInformation(int line) {
- try {
- return new DocumentRegion(fDocument.getLineInformation(line));
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns a line region of the specified offset. The region contains the offset and
- * the length of the line excluding the line's delimiter. Returns <code>null</code>
- * if the line doesn't exist.
- *
- * @param offset an offset into a line
- * @return a line description or <code>null</code> if the given line doesn't
- * exist
- */
- public TextRegion getLineInformationOfOffset(int offset) {
- try {
- return new DocumentRegion(fDocument.getLineInformationOfOffset(offset));
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns the line number that contains the given position. If there isn't any
- * line that contains the position, <code>null</code> is returned. The returned
- * string is a copy and doesn't contain the line delimiter.
- *
- * @return the line that contains the given offset or <code>null</code> if line
- * doesn't exist
- */
- public int getLineOfOffset(int offset) {
- try {
- return fDocument.getLineOfOffset(offset);
- } catch (BadLocationException e) {
- return -1;
- }
- }
-
- /**
- * Returns the line that contains the given position. If there isn't any
- * line that contains the position, <code>null</code> is returned. The returned
- * string is a copy and doesn't contain the line delimiter.
- *
- * @return the line that contains the given offset or <code>null</code> if line
- * doesn't exist
- */
- public String getLineContentOfOffset(int offset) {
- try {
- IRegion region= fDocument.getLineInformationOfOffset(offset);
- return fDocument.get(region.getOffset(), region.getLength());
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Converts the text determined by the region [offset, length] into an array of lines.
- * The lines are copies of the original lines and don't contain any line delimiter
- * characters.
- *
- * @return the text converted into an array of strings. Returns <code>null</code> if the
- * region lies outside the source.
- */
- public String[] convertIntoLines(int offset, int length) {
- try {
- String text= fDocument.get(offset, length);
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(text);
- int size= tracker.getNumberOfLines();
- String result[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- result[i]= getContent(offset + region.getOffset(), region.getLength());
- }
- return result;
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Subsitutes the given text for the specified text position
- *
- * @param offset the starting offset of the text to be replaced
- * @param length the length of the text to be replaced
- * @param text the substitution text
- * @exception CoreException if the text position [offset, length] is invalid.
- */
- public void replace(int offset, int length, String text) throws CoreException {
- try {
- fDocument.replace(offset, length, text);
- } catch (BadLocationException e) {
- IStatus s= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, CStatusConstants.INTERNAL_ERROR,
- TextManipulationMessages.getFormattedString(
- "TextBuffer.wrongRange", //$NON-NLS-1$
- new Object[] {new Integer(offset), new Integer(length) } ), e);
- throw new CoreException(s);
- }
- }
-
- public void replace(TextRange range, String text) throws CoreException {
- replace(range.fOffset, range.fLength, text);
- }
-
- //---- Special methods used by the <code>TextBufferEditor</code>
-
- /**
- * Releases this text buffer.
- */
- /* package */ void release() {
- }
-
- /* package */ void registerUpdater(IDocumentListener listener) {
- fDocument.addDocumentListener(listener);
- }
-
- /* package */ void unregisterUpdater(IDocumentListener listener) {
- fDocument.removeDocumentListener(listener);
- }
-
- //---- Utility methods
-
- /**
- * Returns the indent for the given line.
- * If line is <code>null</code>, <code>-1</code> is returned.
- *
- * @param line the line for which the indent is determined
- * @return the line indent for the given line number or <code>-1</code>
- */
- public static int getIndent(String line, int tabWidth) {
- if (line == null)
- return -1;
- int indent= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
- switch (line.charAt(i)) {
- case '\t':
- indent++;
- blanks= 0;
- continue;
- case ' ':
- blanks++;
- if (blanks == tabWidth) {
- indent++;
- blanks= 0;
- }
- continue;
- default:
- break;
- }
- break;
- }
- return indent;
- }
-
- /**
- * Returns a copy of the line with the given number of identations
- * removed from the beginning.
- * If the count is zero, the line is returned.
- */
- public static String removeIndent(String line, int indentsToRemove, int tabWidth) {
- if (line != null) {
- int indent= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
-
- if (indent >= indentsToRemove) {
- line= line.substring(i);
- break;
- }
-
- switch (line.charAt(i)) {
- case '\t':
- indent++;
- blanks= 0;
- continue;
- case ' ':
- blanks++;
- if (blanks == tabWidth) {
- indent++;
- blanks= 0;
- }
- continue;
- default:
- break;
- }
- }
- }
- return line;
- }
-
- //---- Factory methods ----------------------------------------------------------------
-
- /**
- * Acquires a text buffer for the given file. If a text buffer for the given
- * file already exists, then that one is returned.
- *
- * @param file the file for which a text buffer is requested
- * @return a managed text buffer for the given file
- * @exception CoreException if it was not possible to acquire the
- * text buffer
- */
- public static TextBuffer acquire(IFile file) throws CoreException {
- return fgFactory.acquire(file);
- }
-
- /**
- * Releases the given text buffer.
- *
- * @param buffer the text buffer to be released
- */
- public static void release(TextBuffer buffer) {
- fgFactory.release(buffer);
- }
-
- /**
- * Commits the changes made to the given text buffer to the underlying
- * storage system.
- *
- * @param buffer the text buffer containing the changes to be committed.
- * @param force if <code>true</code> the text buffer is committed in any case.
- * If <code>false</code> the text buffer is <b>ONLY</b> committed if the client
- * is the last one that holds a reference to the text buffer. Clients of this
- * method must make sure that they don't call this method from within an <code>
- * IWorkspaceRunnable</code>.
- * @param pm the progress monitor used to report progress if committing is
- * necessary
- */
- public static void commitChanges(TextBuffer buffer, boolean force, IProgressMonitor pm) throws CoreException {
- fgFactory.commitChanges(buffer, force, pm);
- }
-
- /**
- * Creates a new <code>TextBuffer</code> for the given file. The returned
- * buffer will not be managed. Any subsequent call to <code>create</code>
- * with the same file will return a different text buffer.
- * <p>
- * If the file is currently open in a text editor, the editors content is copied into
- * the returned <code>TextBuffer</code>. Otherwise the content is read from
- * disk.
- *
- * @param file the file for which a text buffer is to be created
- * @return a new unmanaged text buffer
- * @exception CoreException if it was not possible to create the text buffer
- */
- public static TextBuffer create(IFile file) throws CoreException {
- return fgFactory.create(file);
- }
-
- /**
- * Creates a new <code>TextBuffer</code> for the string. The returned
- * buffer will not be managed. Any subsequent call to <code>create</code>
- * with the same string will return a different text buffer.
- *
- * @param content the text buffer's content
- * @return a new unmanaged text buffer
- * @exception CoreException if it was not possible to create the text buffer
- */
- public static TextBuffer create(String content) throws CoreException {
- return fgFactory.create(content);
- }
-
- // Unclear which methods are needed if we get the new save model. If optimal no
- // save is needed at all.
-
- public static void save(TextBuffer buffer, IProgressMonitor pm) throws CoreException {
- fgFactory.save(buffer, pm);
- }
-
- public static void aboutToChange(TextBuffer buffer) throws CoreException {
- fgFactory.aboutToChange(buffer);
- }
-
- public static void changed(TextBuffer buffer) throws CoreException {
- fgFactory.changed(buffer);
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferEditor.java
deleted file mode 100644
index 2ee24f66208..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferEditor.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-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.Status;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.internal.corext.textmanipulation.TextEditNode.RootNode;
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.ui.CUIPlugin;
-/**
- * A <code>TextBufferEditor</code> manages a set of <code>TextEdit</code>s and applies
- * them as a whole to a <code>TextBuffer</code>. Added <code>TextEdit</code>s must
- * not overlap. The only exception from this rule are insertion point. There can be more than
- * one insert point at the same text position. Clients should use the method <code>
- * canPerformEdits</code> to validate if all added text edits follow these rules.
- * <p>
- * Clients can attach more than one <code>TextBufferEditor</code> to a single <code>
- * TextBuffer</code>. If so <code>canPerformEdits</code> validates all text edits from
- * all text buffer editors working on the same text buffer.
- */
-public class TextBufferEditor {
-
- private TextBuffer fBuffer;
- private List fEdits;
- private RootNode fRootNode;
- private int fNumberOfNodes;
- private int fConnectCount;
- private int fMode;
-
- /* package */ static final int UNDEFINED= 0;
- /* package */ static final int REDO= 1;
- /* package */ static final int UNDO= 2;
-
- /**
- * Creates a new <code>TextBufferEditor</code> for the given
- * <code>TextBuffer</code>.
- *
- * @param the text buffer this editor is working on.
- */
- public TextBufferEditor(TextBuffer buffer) {
- fBuffer= buffer;
- Assert.isNotNull(fBuffer);
- fEdits= new ArrayList();
- }
-
- /**
- * Returns the text buffer this editor is working on.
- *
- * @return the text buffer this editor is working on
- */
- public TextBuffer getTextBuffer() {
- return fBuffer;
- }
-
- /**
- * Adds a <code>TextEdit</code> to this text editor. Adding a <code>TextEdit</code>
- * to a <code>TextBufferEditor</code> transfers ownership of the edit to the editor. So
- * after a edit has been added to a editor the creator of that edit <b>must</b> not continue
- * modifing it.
- *
- * @param edit the text edit to be added
- * @exception CoreException if the text edit can not be added
- * to this text buffer editor
- */
- public void add(TextEdit edit) throws CoreException {
- Assert.isTrue(fMode == UNDEFINED || fMode == REDO);
- internalAdd(edit);
- fMode= REDO;
- }
-
- /**
- * Adds a <code>MultiTextEdit</code> to this text editor. Adding a <code>MultiTextEdit</code>
- * to a <code>TextBufferEditor</code> transfers ownership of the edit to the editor. So
- * after a edit has been added to a editor the creator of that edit <b>must</b> not continue
- * modifing it.
- *
- * @param edit the multi text edit to be added
- * @exception CoreException if the multi text edit can not be added
- * to this text buffer editor
- */
- public void add(MultiTextEdit edit) throws CoreException {
- Assert.isTrue(fMode == UNDEFINED || fMode == REDO);
- edit.connect(this);
- fMode= REDO;
- }
-
- /**
- * Adds a <code>UndoMemento</code> to this text editor. Adding a <code>UndoMemento</code>
- * to a <code>TextBufferEditor</code> transfers ownership of the memento to the editor. So
- * after a memento has been added to a editor the creator of that memento <b>must</b> not continue
- * modifing it.
- *
- * @param undo the undo memento to be added
- * @exception CoreException if the undo memento can not be added
- * to this text buffer editor
- */
- public void add(UndoMemento undo) throws CoreException {
- Assert.isTrue(fMode == UNDEFINED);
- List list= undo.fEdits;
- // Add them reverse since we are adding undos.
- for (int i= list.size() - 1; i >= 0; i--) {
- internalAdd((TextEdit)list.get(i));
- }
- fMode= undo.fMode;
- }
-
- /**
- * Checks if the <code>TextEdit</code> added to this text editor can be executed.
- *
- * @return <code>true</code> if the edits can be executed. Return <code>false
- * </code>otherwise. One major reason why text edits cannot be executed
- * is a wrong offset or length value of a <code>TextEdit</code>.
- */
- public boolean canPerformEdits() {
- if (fRootNode != null)
- return true;
- fRootNode= buildTree();
- if (fRootNode == null)
- return false;
- if (fRootNode.validate(fBuffer.getLength()))
- return true;
-
- fRootNode= null;
- return false;
- }
-
- /**
- * Clears the text buffer editor.
- */
- public void clear() {
- fRootNode= null;
- fMode= UNDEFINED;
- fEdits.clear();
- }
-
- /**
- * Executes the text edits added to this text buffer editor and clears all added
- * text edits.
- *
- * @param pm a progress monitor to report progress
- * @return an object representing the undo of the executed <code>TextEdit</code>s
- * @exception CoreException if the edits cannot be executed
- */
- public UndoMemento performEdits(IProgressMonitor pm) throws CoreException {
- if (pm == null)
- pm= new NullProgressMonitor();
-
- int size= fEdits.size();
- if (size == 0)
- return new UndoMemento(fMode == UNDO ? REDO : UNDO);
-
- if (fRootNode == null) {
- fRootNode= buildTree();
- if (fRootNode == null || !fRootNode.validate(fBuffer.getLength())) {
- IStatus s= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, CStatusConstants.INTERNAL_ERROR,
- "RootNode empty", null);
- throw new CoreException(s);
- }
- }
- try {
- pm.beginTask("", fNumberOfNodes + 10); //$NON-NLS-1$
- UndoMemento undo= null;
- if (fMode == REDO) {
- undo= fRootNode.performDo(fBuffer, pm);
- fRootNode.performedDo();
- } else {
- undo= fRootNode.performUndo(fBuffer, pm);
- fRootNode.performedUndo();
- }
- pm.worked(10);
- return undo;
- } finally {
- pm.done();
- clear();
- }
- }
-
- //---- Helper methods ------------------------------------------------------------
-
- private RootNode buildTree() {
- TextEditNode[] nodes= new TextEditNode[fEdits.size()];
- for (int i= fEdits.size() - 1; i >= 0; i--) {
- nodes[i]= TextEditNode.create((TextEdit)fEdits.get(i));
- }
- fNumberOfNodes= nodes.length;
- Arrays.sort(nodes, new TextEditNodeComparator());
- RootNode root= new RootNode(fBuffer.getLength());
- for (int i= 0; i < nodes.length; i++) {
- root.add(nodes[i]);
- }
- return root;
- }
-
- private void internalAdd(TextEdit edit) throws CoreException {
- edit.index= fEdits.size();
- edit.isSynthetic= fConnectCount > 0;
- try {
- fConnectCount++;
- edit.connect(this);
- } finally {
- fConnectCount--;
- }
- fEdits.add(edit);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferFactory.java
deleted file mode 100644
index 1236362e47d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextBufferFactory.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-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.Status;
-
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-
-
-/* package */ class TextBufferFactory {
-
- protected IDocumentProvider fDocumentProvider;
- private Map fFileValueMap;
- private Map fBufferValueMap;
-
- private static class Value {
- TextBuffer buffer;
- FileEditorInput input;
- IDocument document;
- IAnnotationModel annotationModel;
- int references;
- public Value(TextBuffer b, FileEditorInput i, IDocument d, IAnnotationModel m) {
- buffer= b;
- input= i;
- document= d;
- annotationModel= m;
- }
- }
-
- public TextBufferFactory() {
- // XXX http://dev.eclipse.org/bugs/show_bug.cgi?id=5170
- // Need way to map a file to a document without knowing any kind of document provider.
- this(CUIPlugin.getDefault().getDocumentProvider());
- }
-
- public TextBufferFactory(IDocumentProvider provider) {
- fDocumentProvider= provider;
- Assert.isNotNull(fDocumentProvider);
- fFileValueMap= new HashMap(5);
- fBufferValueMap= new HashMap(5);
- }
-
- public TextBuffer acquire(IFile file) throws CoreException {
- FileEditorInput input= new FileEditorInput(file);
-
- Value value= (Value)fFileValueMap.get(input);
- if (value != null) {
- value.references++;
- return value.buffer;
- }
-
- fDocumentProvider.connect(input);
- IDocument document= fDocumentProvider.getDocument(input);
- IAnnotationModel annotationModel= fDocumentProvider.getAnnotationModel(input);
- annotationModel.connect(document);
- value= new Value(new TextBuffer(document), input, document, annotationModel);
- fFileValueMap.put(input, value);
- fBufferValueMap.put(value.buffer, value);
- value.references++;
- return value.buffer;
- }
-
- public void release(TextBuffer buffer) {
- final Value value= (Value)fBufferValueMap.get(buffer);
- if (value == null)
- return;
-
- value.references--;
- if (value.references == 0) {
- buffer.release();
- value.annotationModel.disconnect(value.document);
- fDocumentProvider.disconnect(value.input);
- fFileValueMap.remove(value.input);
- fBufferValueMap.remove(buffer);
- }
- }
-
- public void commitChanges(TextBuffer buffer, boolean force, IProgressMonitor pm) throws CoreException {
- final Value value= (Value)fBufferValueMap.get(buffer);
- if (value == null)
- return;
-
- boolean save= force || fDocumentProvider.mustSaveDocument(value.input);
- if (save) {
- IWorkspaceRunnable action= new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- fDocumentProvider.aboutToChange(value.input);
- fDocumentProvider.saveDocument(pm, value.input, value.document, true);
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(action, pm);
- } finally {
- fDocumentProvider.changed(value.input);
- }
- }
- }
-
- public TextBuffer create(IFile file) throws CoreException {
- FileEditorInput input= new FileEditorInput(file);
- IDocument document= fDocumentProvider.getDocument(input);
- if (document != null) {
- return new TextBuffer(new Document(document.get()));
- } else {
- return createFromFile(file);
- }
- }
-
- private TextBuffer createFromFile(IFile file) throws CoreException {
- IDocument document;
- InputStreamReader in= null;
- try {
- document= new Document();
- in= new InputStreamReader(new BufferedInputStream(file.getContents()));
- StringBuffer buffer= new StringBuffer();
- char[] readBuffer= new char[2048];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
- document.set(buffer.toString());
- return new TextBuffer(document);
- } catch (IOException x) {
- IStatus s= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, CStatusConstants.INTERNAL_ERROR, x.getMessage(), x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- public TextBuffer create(String content) throws CoreException {
- return new TextBuffer(new Document(content));
- }
-
- public void save(TextBuffer buffer, IProgressMonitor pm) throws CoreException {
- Value value= (Value)fBufferValueMap.get(buffer);
- if (value == null)
- throwNotManaged();
- fDocumentProvider.saveDocument(pm, value.input, value.document, true);
- }
-
- public void aboutToChange(TextBuffer buffer) throws CoreException {
- Value value= (Value)fBufferValueMap.get(buffer);
- if (value == null)
- throwNotManaged();
- fDocumentProvider.aboutToChange(value.input);
- }
-
- public void changed(TextBuffer buffer) throws CoreException {
- Value value= (Value)fBufferValueMap.get(buffer);
- if (value == null)
- throwNotManaged();
- fDocumentProvider.changed(value.input);
- }
-
- private void throwNotManaged() throws CoreException {
- IStatus s= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
- CStatusConstants.INTERNAL_ERROR, "TextBufferFactory.bufferNotManaged", null); //$NON-NLS-1$
- throw new CoreException(s);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEdit.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEdit.java
deleted file mode 100644
index 18123d16e3b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEdit.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A text edit describes an elementary text manipulation operation. Text edits
- * are executed by adding them to a <code>TextBufferEditor</code> and then
- * calling <code>perform</code> on the <code>TextBufferEditor</code>.
- * <p>
- * After a <code>TextEdit</code> has been added to a <code>TextBufferEditor</code>
- * the method <code>connect</code> is sent to the text edit. A <code>TextEdit</code>
- * is allowed to do some adjustments of the text range it is going to manipulate while inside
- * the hook <code>connect</code>.
- *
- * @see TextBufferEditor
- */
-public abstract class TextEdit {
-
- // index that determines the insertion order into a text buffer
- /* package */ int index;
- /* package */ boolean isSynthetic;
-
- /**
- * Connects this text edit to the given <code>TextBufferEditor</code>. A text edit
- * must not keep a reference to the passed text buffer editor. It is guaranteed that
- * the buffer passed to <code>perform<code> is equal to the buffer managed by
- * the given text buffer editor. But they don't have to be identical.
- * <p>
- * Note that this method <b>should only be called</b> by a <code>
- * TextBufferEditor</code>.
- *<p>
- * This default implementation does nothing. Subclasses may override
- * if needed.
- *
- * @param editor the text buffer editor this text edit has been added to
- */
- public void connect(TextBufferEditor editor) throws CoreException {
- // does nothing
- }
-
- /**
- * Returns the <code>TextRange</code> that this text edit is going to
- * manipulate. If this method is called before the <code>TextEdit</code>
- * has been added to a <code>TextBufferEditor</code> it may return <code>
- * null</code> or <code>TextRange.UNDEFINED</code> to indicate this situation.
- *
- * @return the <code>TextRange</code>s this <code>TextEdit is going
- * to manipulate
- */
- public abstract TextRange getTextRange();
-
- /**
- * Performs the text edit. Note that this method <b>should only be called</b>
- * by a <code>TextBufferEditor</code>.
- *
- * @param buffer the actual buffer to manipulate
- * @return a text edit that can undo this text edit
- */
- public abstract TextEdit perform(TextBuffer buffer) throws CoreException;
-
- /**
- * This method gets called after all <code>TextEdit</code>s added to a text buffer
- * editor are executed. Implementors of this method can do some clean-up or can
- * release allocated resources that are now longer needed.
- * <p>
- * This default implementation does nothing.
- */
- public void performed() {
- // do nothing
- }
-
- /**
- * Creates and returns a copy of this object. The copy method should
- * be implemented in a way so that the copy can be added to a different
- * <code>TextBufferEditor</code> without causing any harm to the object
- * from which the copy has been created.
- *
- * @return a copy of this object.
- */
- public abstract TextEdit copy() throws CoreException;
-
- /**
- * Returns the element modified by this text edit. The method
- * may return <code>null</code> if the modification isn't related to a
- * element or if the content of the modified text buffer doesn't
- * follow any syntax.
- * <p>
- * This default implementation returns <code>null</code>
- *
- * @return the element modified by this text edit
- */
- public Object getModifiedElement() {
- return null;
- }
-
- /** @deprecated reimplement getModifiedElement */
- public final Object getModifiedLanguageElement() {
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNode.java
deleted file mode 100644
index 0bc1790b132..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNode.java
+++ /dev/null
@@ -1,496 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * A helper class to arrange <code>TextEdit</code>s into a tree to optimize their
- * execution.
- */
-/* package */ abstract class TextEditNode {
-
- /* package */ TextEditNode fParent;
- /* package */ List fChildren;
- /* package */ TextEdit fEdit;
-
- /* package */ static class DefaultNode extends TextEditNode {
- public DefaultNode(TextEdit edit) {
- super(edit);
- }
- }
-
- /* package */ static class RootNode extends TextEditNode {
- private int fUndoIndex;
- public RootNode(int length) {
- super(new NopTextEdit(new TextRange(0, length)));
- fEdit.isSynthetic= true;
- }
- public boolean covers(TextEditNode node) {
- return true;
- }
- public UndoMemento performDo(TextBuffer buffer, IProgressMonitor pm) throws CoreException {
- DoRangeUpdater updater= new DoRangeUpdater();
- UndoMemento undo= new UndoMemento(TextBufferEditor.UNDO);
- try {
- buffer.registerUpdater(updater);
- performDo(buffer, updater, undo, pm);
- } finally {
- buffer.unregisterUpdater(updater);
- updater.setActiveNode(null);
- }
- return undo;
- }
- public UndoMemento performUndo(TextBuffer buffer, IProgressMonitor pm) throws CoreException {
- UndoRangeUpdater updater= new UndoRangeUpdater(this);
- UndoMemento undo= new UndoMemento(TextBufferEditor.REDO);
- try {
- buffer.registerUpdater(updater);
- performUndo(buffer, updater, undo, pm);
- } finally {
- buffer.unregisterUpdater(updater);
- updater.setActiveNode(null);
- }
- return undo;
- }
-
- protected void setUndoIndex(int index) {
- fUndoIndex= index;
- }
-
- protected int getUndoIndex() {
- return fUndoIndex;
- }
- }
-
- /* package */ abstract static class AbstractMoveNode extends TextEditNode {
- private int state;
-
- private int fTargetIndex;
- private int fSourceIndex;
-
- private List fAffectedChildren;
-
- public AbstractMoveNode(TextEdit edit) {
- super(edit);
- reset();
- }
- protected abstract TextRange getSourceRange();
- protected abstract TextRange getTargetRange();
- protected abstract boolean isUpMove();
- protected boolean isDownMove() {
- return !isUpMove();
- }
- public boolean isMove() {
- return true;
- }
- protected void checkRange(DocumentEvent event) {
- TextRange range= getChildRange();
- int eventOffset= event.getOffset();
- int eventLength= event.getLength();
- int eventEnd = eventOffset + eventLength - 1;
- // "Edit changes text that lies outside its defined range"
- Assert.isTrue(range.fOffset <= eventOffset && eventEnd <= range.getInclusiveEnd());
- }
- protected boolean activeNodeChanged(int delta) {
- TextRange targetRange= getTargetRange();
- TextRange sourceRange= getSourceRange();
- switch (state) {
- case 0: // the move delete
- init();
- Assert.isTrue(Math.abs(delta) == sourceRange.fLength);
- if (isUpMove()) {
- updateOffset(fAffectedChildren, delta);
- targetRange.fOffset+= delta;
- }
- sourceRange.fLength= 0;
- state= 1;
- break;
- case 1:
- TextEditNode target= (TextEditNode)fParent.fChildren.get(fTargetIndex);
- TextEditNode source= (TextEditNode)fParent.fChildren.get(fSourceIndex);
- updateOffset(source.fChildren, targetRange.fOffset - sourceRange.fOffset);
- target.fChildren= source.fChildren;
- if (target.fChildren != null) {
- for (Iterator iter= target.fChildren.iterator(); iter.hasNext();) {
- ((TextEditNode)iter.next()).fParent= target;
- }
- }
- source.fChildren= null;
- if (isDownMove()) {
- updateOffset(fAffectedChildren, delta);
- sourceRange.fOffset+= delta;
- }
- targetRange.fLength= delta;
- reset();
- break;
- }
- return true;
- }
- private static void updateOffset(List nodes, int delta) {
- if (nodes == null)
- return;
- for (int i= nodes.size() - 1; i >= 0; i--) {
- TextEditNode node= (TextEditNode)nodes.get(i);
- TextRange range= node.getTextRange();
- range.fOffset+= delta;
- updateOffset(node.fChildren, delta);
- }
- }
- private void init() {
- TextRange source= getSourceRange();
- TextRange target= getTargetRange();
- List children= fParent.fChildren;
- for (int i= children.size() - 1; i >= 0; i--) {
- TextEditNode child= (TextEditNode)children.get(i);
- TextRange range= child.fEdit.getTextRange();
- if (range == source)
- fSourceIndex= i;
- else if (range == target)
- fTargetIndex= i;
- }
- int start= Math.min(fTargetIndex, fSourceIndex);
- int end= Math.max(fTargetIndex, fSourceIndex);
- fAffectedChildren= new ArrayList(3);
- for (int i= start + 1; i < end; i++) {
- fAffectedChildren.add(children.get(i));
- }
- }
- private void reset() {
- state= 0;
- fSourceIndex= -1;
- fTargetIndex= -1;
- }
- }
-
- /* package */ static class MoveNode extends AbstractMoveNode {
- public MoveNode(TextEdit edit) {
- super(edit);
- }
- protected TextRange getChildRange() {
- return ((MoveTextEdit)fEdit).getChildRange();
- }
- protected TextRange getSourceRange() {
- return ((MoveTextEdit)fEdit).getSourceRange();
- }
- protected TextRange getTargetRange() {
- return ((MoveTextEdit)fEdit).getTargetRange();
- }
- protected boolean isUpMove() {
- return ((MoveTextEdit)fEdit).isUpMove();
- }
- public boolean isMovePartner(TextEditNode other) {
- if (!(other instanceof TargetMarkNode))
- return false;
- return fEdit == ((MoveTextEdit.TargetMark)other.fEdit).getMoveTextEdit();
- }
- public boolean covers(TextEditNode node) {
- if (node instanceof TargetMarkNode) {
- MoveTextEdit.TargetMark edit= (MoveTextEdit.TargetMark)node.fEdit;
- if (edit.getMoveTextEdit() == fEdit)
- return false;
- }
- return getParentRange().covers(node.getChildRange());
- }
- }
-
- /* package */ static class TargetMarkNode extends AbstractMoveNode {
- public TargetMarkNode(TextEdit edit) {
- super(edit);
- }
- protected TextRange getChildRange() {
- return ((MoveTextEdit.TargetMark)fEdit).getMoveTextEdit().getChildRange();
- }
- protected TextRange getSourceRange() {
- return ((MoveTextEdit.TargetMark)fEdit).getMoveTextEdit().getSourceRange();
- }
- protected TextRange getTargetRange() {
- return ((MoveTextEdit.TargetMark)fEdit).getMoveTextEdit().getTargetRange();
- }
- protected boolean isUpMove() {
- return ((MoveTextEdit.TargetMark)fEdit).getMoveTextEdit().isUpMove();
- }
- public boolean isMovePartner(TextEditNode other) {
- return ((MoveTextEdit.TargetMark)fEdit).getMoveTextEdit() == other.fEdit;
- }
- }
-
- //---- Range updating ---------------------------------------------------------------------------
-
- private static abstract class RangeUpdater implements IDocumentListener {
- protected TextEditNode fActiveNode;
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
- public void setActiveNode(TextEditNode node) {
- fActiveNode= node;
- }
- public void updateParents(int delta) {
- TextEditNode node= fActiveNode.fParent;
- while (node != null) {
- node.childNodeChanged(delta);
- node= node.fParent;
- }
- }
- public static int getDelta(DocumentEvent event) {
- return (event.getText() == null ? 0 : event.getText().length()) - event.getLength();
- }
- }
- private static class DoRangeUpdater extends RangeUpdater {
- private List fProcessedNodes= new ArrayList(10);
- public void setActiveNode(TextEditNode node) {
- if (fActiveNode != null)
- fProcessedNodes.add(fActiveNode);
- super.setActiveNode(node);
- }
- public void documentChanged(DocumentEvent event) {
- fActiveNode.checkRange(event);
- int delta= getDelta(event);
- if (!fActiveNode.activeNodeChanged(delta)) {
- for (Iterator iter= fProcessedNodes.iterator(); iter.hasNext();) {
- ((TextEditNode)iter.next()).previousNodeChanged(delta);
- }
- }
- updateParents(delta);
- }
- }
- private static class UndoRangeUpdater extends RangeUpdater {
- private RootNode fRootNode;
- public UndoRangeUpdater(RootNode root) {
- fRootNode= root;
- }
- public void setActiveNode(TextEditNode node) {
- super.setActiveNode(node);
- }
- public void documentChanged(DocumentEvent event) {
- fActiveNode.checkRange(event);
- int delta= getDelta(event);
- if (!fActiveNode.activeNodeChanged(delta)) {
- int start= fRootNode.getUndoIndex() + 1;
- List children= fRootNode.fChildren;
- int size= children != null ? children.size() : 0;
- for (int i= start; i < size; i++) {
- updateUndo((TextEditNode)children.get(i), delta);
- }
- }
- updateParents(delta);
- }
- private void updateUndo(TextEditNode node, int delta) {
- node.previousNodeChanged(delta);
- List children= node.fChildren;
- int size= children != null ? children.size() : 0;
- for (int i= 0; i < size; i++) {
- updateUndo((TextEditNode)children.get(i), delta);
- }
- }
- }
-
- //---- Creating instances ---------------------------------------------------------------------------
-
- static TextEditNode create(TextEdit edit) {
- if (edit instanceof MoveTextEdit)
- return new MoveNode(edit);
- if (edit instanceof MoveTextEdit.TargetMark)
- return new TargetMarkNode(edit);
- return new DefaultNode(edit);
- }
-
- static RootNode createRoot(int length) {
- return new RootNode(length);
- }
-
- protected TextEditNode(TextEdit edit) {
- fEdit= edit;
- }
-
- //---- Adding children ---------------------------------------------------------------------------
-
- protected void add(TextEditNode node) {
- if (fChildren == null) {
- fChildren= new ArrayList(1);
- node.fParent= this;
- fChildren.add(node);
- return;
- }
- // Optimize using binary search
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- TextEditNode child= (TextEditNode)iter.next();
- if (child.covers(node)) {
- child.add(node);
- return;
- }
- }
- for (int i= 0; i < fChildren.size(); ) {
- TextEditNode child= (TextEditNode)fChildren.get(i);
- if (node.covers(child)) {
- fChildren.remove(i);
- node.add(child);
- } else {
- i++;
- }
- }
- node.fParent= this;
- fChildren.add(node);
- }
-
- public boolean covers(TextEditNode node) {
- return false;
- }
-
- //---- Accessing --------------------------------------------------------------------------------------
-
- protected RootNode getRoot() {
- TextEditNode candidate= this;
- while(candidate.fParent != null)
- candidate= candidate.fParent;
- return (RootNode)candidate;
- }
-
- //---- Query interface --------------------------------------------------------------------------------
-
- protected boolean isSynthetic() {
- return fEdit.isSynthetic;
- }
-
- public boolean isMove() {
- return false;
- }
-
- //---- Accessing Ranges ------------------------------------------------------------------------------
-
- protected void checkRange(DocumentEvent event) {
- TextRange range= getTextRange();
- int eventOffset= event.getOffset();
- int eventLength= event.getLength();
- int eventEnd = eventOffset + eventLength - 1;
- // "Edit changes text that lies outside its defined range"
- Assert.isTrue(range.fOffset <= eventOffset && eventEnd <= range.getInclusiveEnd());
- }
-
- protected TextRange getTextRange() {
- return fEdit.getTextRange();
- }
-
- protected TextRange getChildRange() {
- return getTextRange();
- }
-
- protected TextRange getParentRange() {
- return getTextRange();
- }
-
- public boolean validate(int bufferLength) {
- if (fChildren == null)
- return true;
- // Only Moves and Nops can be parents
- if (!(fEdit instanceof MoveTextEdit || fEdit instanceof NopTextEdit))
- return false;
- TextRange lastRange= null;
- for (Iterator iter= fChildren.iterator(); iter.hasNext(); ) {
- TextEditNode node= (TextEditNode)iter.next();
- if (!node.validate(bufferLength))
- return false;
- TextRange range= node.fEdit.getTextRange();
- if (!range.isValid() || range.fOffset + range.fLength > bufferLength)
- return false;
- if (lastRange != null && !(range.isInsertionPointAt(lastRange.fOffset) || range.liesBehind(lastRange)))
- return false;
- lastRange= range;
- }
- return true;
- }
-
- //---- Updating ----------------------------------------------------------------------------------------
-
- protected boolean activeNodeChanged(int delta) {
- TextRange range= getTextRange();
- range.fLength+= delta;
- // we didn't adjust any processed nodes.
- return false;
- }
-
- protected void previousNodeChanged(int delta) {
- TextRange range= getTextRange();
- range.fOffset+= delta;
- }
-
- protected void childNodeChanged(int delta) {
- getTextRange().fLength+= delta;
- }
-
- //---- Do it ---------------------------------------------------------------------------------------------
-
- protected void performDo(TextBuffer buffer, RangeUpdater updater, UndoMemento undo, IProgressMonitor pm) throws CoreException {
- int size= fChildren != null ? fChildren.size() : 0;
- for (int i= size - 1; i >= 0; i--) {
- TextEditNode child= (TextEditNode)fChildren.get(i);
- child.performDo(buffer, updater, undo, pm);
- }
- updater.setActiveNode(this);
- if (isSynthetic())
- fEdit.perform(buffer);
- else
- undo.add(fEdit.perform(buffer));
- pm.worked(1);
- }
-
- public void performedDo() {
- int size= fChildren != null ? fChildren.size() : 0;
- for (int i= size - 1; i >= 0; i--) {
- TextEditNode child= (TextEditNode)fChildren.get(i);
- child.performedDo();
- }
- fEdit.performed();
- }
-
- //---- Undo it -------------------------------------------------------------------------------------------
-
- protected void performUndo(TextBuffer buffer, RangeUpdater updater, UndoMemento undo, IProgressMonitor pm) throws CoreException {
- int size= fChildren != null ? fChildren.size() : 0;
- for (int i= 0; i < size; i++) {
- setUndoIndex(i);
- TextEditNode child= (TextEditNode)fChildren.get(i);
- child.performUndo(buffer, updater, undo, pm);
- }
- updater.setActiveNode(this);
- if (isSynthetic())
- fEdit.perform(buffer);
- else
- undo.add(fEdit.perform(buffer));
- pm.worked(1);
- }
-
- protected void setUndoIndex(int index) {
- }
-
- public void performedUndo() {
- int size= fChildren != null ? fChildren.size() : 0;
- for (int i= 0; i < size; i++) {
- TextEditNode child= (TextEditNode)fChildren.get(i);
- child.performedUndo();
- }
- fEdit.performed();
- }
-
-// protected void createUndoList(List list) {
-// int size= fChildren != null ? fChildren.size() : 0;
-// for (int i= 0; i < size; i++) {
-// TextEditNode child= (TextEditNode)fChildren.get(i);
-// child.createUndoList(list);
-// }
-// list.add(this);
-// }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNodeComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNodeComparator.java
deleted file mode 100644
index 33e527f5787..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextEditNodeComparator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Comparator;
-
-/**
- * A special comparator to comapre <code>TextRange</code>s.
- */
-class TextEditNodeComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- TextEditNode node1= (TextEditNode)o1;
- TextEditNode node2= (TextEditNode)o2;
- TextRange pos1= node1.getTextRange();
- TextRange pos2= node2.getTextRange();
-
- int offset1= pos1.fOffset;
- int offset2= pos2.fOffset;
- if (offset1 < offset2)
- return -1;
- if (offset1 > offset2)
- return 1;
-
- // same offset
- int length1= pos1.fLength;
- int length2= pos2.fLength;
-
- // insertion points come before anything else at the same position.
- if (length1 == 0 && length2 != 0)
- return -1;
- if (length1 != 0 && length2 == 0)
- return 1;
-
- // Longer edits come before shorter edits
- if (length1 < length2)
- return 1;
- if (length1 > length2)
- return -1;
-
- if (node1.fEdit.index < node2.fEdit.index)
- return -1;
- return 1;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextManipulationMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextManipulationMessages.java
deleted file mode 100644
index d39190172bd..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextManipulationMessages.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TextManipulationMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.corext.textmanipulation.Messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private TextManipulationMessages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRange.java
deleted file mode 100644
index 6bff924fc3a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRange.java
+++ /dev/null
@@ -1,196 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.util.Assert;
-
-
-
-public final class TextRange {
-
- /* package */ int fOffset;
- /* package */ int fLength;
-
- public static final TextRange UNDEFINED= new TextRange((TextRange)null);
-
- /**
- * Creates a insert position with the given offset.
- *
- * @param offset the position offset, must be >= 0
- */
- public TextRange(int offset) {
- this(offset, 0);
- }
-
- /**
- * Creates a new range with the given offset and length.
- *
- * @param offset the position offset, must be >= 0
- * @param length the position length, must be >= 0
- */
- public TextRange(int offset, int length) {
- fOffset= offset;
- Assert.isTrue(fOffset >= 0);
- fLength= length;
- Assert.isTrue(fLength >= 0);
- }
-
- /**
- * Constructor for the undefined text range.
- */
- private TextRange(TextRange dummy) {
- fOffset= -1;
- fLength= -1;
- }
-
- public static TextRange createFromStartAndLength(int start, int length) {
- return new TextRange(start, length);
- }
-
- public static TextRange createFromStartAndInclusiveEnd(int start, int end) {
- return new TextRange(start, end - start + 1);
- }
-
- public static TextRange createFromStartAndExclusiveEnd(int start, int end) {
- return new TextRange(start, end - start);
- }
-
- /**
- * Creates a new range from the given source range.
- *
- * @range the source range denoting offset and length
- */
- public TextRange(ISourceRange range) {
- this(range.getOffset(), range.getLength());
- }
-
- /**
- * Returns the offset of this range.
- *
- * @return the length of this range
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Returns the length of this range.
- *
- * @return the length of this range
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Returns the inclusive end position of this range. That means that the end position
- * denotes the last character of this range.
- *
- * @return the inclusive end position
- */
- public int getInclusiveEnd() {
- return fOffset + fLength - 1;
- }
-
- /**
- * Returns the exclusive end position of this range. That means that the end position
- * denotes the first character after this range.
- *
- * @return the exclusive end position
- */
- public int getExclusiveEnd() {
- return fOffset + fLength;
- }
-
- /**
- * Creates a copy of this <code>TextRange</code>.
- *
- * @return a copy of this <code>TextRange</code>
- */
- public TextRange copy() {
- if (isUndefined())
- return this;
- return new TextRange(fOffset, fLength);
- }
-
- /**
- * Returns <code>true</code> if this text range is the <code>UNDEFINED</code>
- * text range. Otherwise <code>false</code> is returned.
- */
- public boolean isUndefined() {
- return UNDEFINED == this;
- }
-
- /**
- * Checks if this <code>TextRange</code> is valid. For valid text range the following
- * expression evaluates to <code>true</code>:
- * <pre>
- * getOffset() >= 0 && getLength() >= 0
- * </pre>
- *
- * @return <code>true</code> if this text range is a valid range. Otherwise <code>
- * false</code>
- */
- public boolean isValid() {
- return fOffset >= 0 && fLength >= 0;
- }
-
- /* package */ boolean isInsertionPoint() {
- return fLength == 0;
- }
-
- /* package */ boolean equals(TextRange range) {
- return fOffset == range.fOffset && fLength == range.fLength;
- }
-
- /* package */ boolean isEqualInsertionPoint(TextRange range) {
- return fLength == 0 && range.fLength == 0 && fOffset == range.fOffset;
- }
-
- /* package */ boolean liesBehind(TextRange range) {
- return fOffset >= range.fOffset + range.fLength;
- }
-
- /* package */ boolean isInsertionPointAt(int o) {
- return fOffset == o && fLength == 0;
- }
-
- /* package */ boolean covers(TextRange other) {
- if (fLength == 0) { // an insertion point can't cover anything
- return false;
- } else if (other.fLength == 0) {
- int otherOffset= other.fOffset;
- return fOffset < otherOffset && otherOffset < fOffset + fLength;
- } else {
- int otherOffset= other.fOffset;
- return fOffset <= otherOffset && otherOffset + other.fLength <= fOffset + fLength;
- }
- }
- /* non Java-doc
- * @see Object#toString()
- */
- public String toString() {
- StringBuffer buffer= new StringBuffer();
- buffer.append(TextManipulationMessages.getString("TextRange.offset")); //$NON-NLS-1$
- buffer.append(fOffset);
- buffer.append(TextManipulationMessages.getString("TextRange.length")); //$NON-NLS-1$
- buffer.append(fLength);
- return buffer.toString();
- }
-
- public boolean equals(Object obj) {
- if (! (obj instanceof TextRange))
- return false;
- TextRange other= (TextRange)obj;
- return fOffset == other.getOffset() && fLength == other.getLength();
- }
-
- public int hashCode() {
- return fOffset ^ fLength;
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRegion.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRegion.java
deleted file mode 100644
index b6e06dd88eb..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextRegion.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * A text region describes a certain range in an <code>ITextBuffer</code>. A region is defined by
- * its offset into the text buffer and its length.
- * <p>
- * A region is considered a value object. Its offset or length do not change over time. </p>
- * <p>
- * <bf>NOTE:<bf> This class/interface is part of an interim API that is still under development
- * and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any
- * code that uses this API will almost certainly be broken (repeatedly) as the API evolves.</p>
- */
-
-// This class avoids contamination of clients with wrong imports.
-
-public abstract class TextRegion {
-
- /**
- * Returns the offset of the region.
- *
- * @return the offset of the region
- */
- public abstract int getOffset();
- /**
- * Returns the length of the region.
- *
- * @return the length of the region
- */
- public abstract int getLength();
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextUtil.java
deleted file mode 100644
index 0cefd11a18f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/TextUtil.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.util.Assert;
-
-
-public class TextUtil {
-
- /**
- * Returns the length of the string desribed by <code>start</code> and
- * <code>end</code>.
- *
- * @param start the start position. The position is inclusive
- * @param end the end position. The position is inclusive
- * @return the length of the string desribed by <code>start</code> and
- * <code>end</code>
- */
- public static int getLength(int start, int end) {
- return end - start + 1;
- }
-
- /**
- * Returns the indent of the given line.
- * @param line the text line
- * @param tabWidth the width of the '\t' character.
- */
- public static int getIndent(String line, int tabWidth) {
- int result= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- switch (c) {
- case '\t':
- result++;
- blanks= 0;
- break;
- case ' ':
- blanks++;
- if (blanks == tabWidth) {
- result++;
- blanks= 0;
- }
- break;
- default:
- return result;
- }
- }
- return result;
- }
-
- /**
- * Removes the given number of idents from the line and returns a new
- * copy of the line. Asserts that the given line has the requested
- * number of indents.
- */
- public static String removeIndent(int numberOfIndents, String line, int tabWidth) {
- if (numberOfIndents <= 0)
- return new String(line);
-
- int start= 0;
- int indents= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- switch (c) {
- case '\t':
- indents++;
- blanks= 0;
- break;
- case ' ':
- blanks++;
- if (blanks == tabWidth) {
- indents++;
- blanks= 0;
- }
- break;
- default:
- Assert.isTrue(false, "Line does not have requested number of indents"); //$NON-NLS-1$
- }
- if (indents == numberOfIndents) {
- start= i + 1;
- break;
- }
- }
- if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
-
- /**
- * Removes any leading indents from the given string.
- */
- public static String removeLeadingIndents(String line, int tabWidth) {
- int indents= getIndent(line, tabWidth);
- return removeIndent(indents, line, tabWidth);
- }
-
- /**
- * Creates a string that consists of the given number of tab characters.
- */
- public static String createIndentString(int indent) {
- StringBuffer result= new StringBuffer();
- for (int i= 0; i < indent; i++) {
- result.append('\t');
- }
- return result.toString();
- }
-
- /**
- * Removes any leading white spaces from the given string.
- * The method returns a new string.
- */
- public static String removeLeadingWhiteSpaces(String line) {
- int size= line.length();
- int start= 0;
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (c != '\t' && c != ' ') {
- start= i;
- break;
- }
- }
- return line.substring(start);
- }
-
- /**
- * Returns <code>true</code> if the given string consists only of
- * white spaces (e.g. space and '\t'). If the string is empty,
- * <code>true</code> is returned.
- */
- public static boolean containsOnlyWhiteSpaces(String line) {
- int size= line.length();
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (c != '\t' && c != ' ')
- return false;
- }
- return true;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/UndoMemento.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/UndoMemento.java
deleted file mode 100644
index 3af1ebf7473..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/UndoMemento.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.cdt.internal.corext.textmanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class encapsulates the reverse change of a number of <code>TextEdit</code>s
- * executed on a <code>TextBufferEditor</code>
- */
-public final class UndoMemento {
-
- /* package */ int fMode;
- /* package */ List fEdits;
-
- /* package */ UndoMemento(int mode) {
- fMode= mode;
- fEdits= new ArrayList(10);
- }
-
- /* package */ void add(TextEdit edit) {
- fEdits.add(edit);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
deleted file mode 100644
index 546de621487..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ILibraryReference;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * A base content provider for C elements. It provides access to the
- * C element hierarchy without listening to changes in the C model.
- * Use this class when you want to present the C elements
- * in a modal dialog or wizard.
- * <p>
- * The following C element hierarchy is surfaced by this content provider:
- * <p>
- * <pre>
-C model (<code>ICModel</code>)
- C project (<code>ICProject</code>)
- C Container(folders) (<code>ICContainer</code>)
- Translation unit (<code>ITranslationUnit</code>)
- Binary file (<code>IBinary</code>)
- Archive file (<code>IArchive</code>)
- Non C Resource file (<code>Object</code>)
-
- * </pre>
- */
-public class BaseCElementContentProvider implements ITreeContentProvider {
-
- protected static final Object[] NO_CHILDREN= new Object[0];
-
- protected boolean fProvideMembers= false;
- protected boolean fProvideWorkingCopy= false;
-
- public BaseCElementContentProvider() {
- }
-
- public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
- fProvideMembers= provideMembers;
- //fProvideWorkingCopy= provideWorkingCopy;
- }
-
- /**
- * Returns whether the members are provided when asking
- * for a TU's or ClassFile's children.
- */
- public boolean getProvideMembers() {
- return fProvideMembers;
- }
-
- /**
- * Returns whether the members are provided when asking
- * for a TU's or ClassFile's children.
- */
- public void setProvideMembers(boolean b) {
- fProvideMembers= b;
- }
-
- /**
- * Sets whether the members are provided from
- * a working copy of a compilation unit
- */
- public void setProvideWorkingCopy(boolean b) {
- //fProvideWorkingCopy= b;
- }
-
- /**
- * Returns whether the members are provided
- * from a working copy a compilation unit.
- */
- public boolean getProvideWorkingCopy() {
- return fProvideWorkingCopy;
- }
-
- /* (non-Cdoc)
- * Method declared on IStructuredContentProvider.
- */
- public Object[] getElements(Object parent) {
- return getChildren(parent);
- }
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- }
-
- /* (non-Cdoc)
- * Method declared on ITreeContentProvider.
- */
- public Object[] getChildren(Object element) {
- if (element instanceof ICElement) {
- ICElement celement = (ICElement)element;
- if (celement instanceof ICModel) {
- return getCProjects((ICModel)celement);
- } else if (celement instanceof ICProject ) {
- return getCProjectResources((ICProject)celement);
- } else if (celement instanceof ICContainer) {
- return getCResources((ICContainer)celement);
- } else if (celement.getElementType() == ICElement.C_UNIT) {
- if (fProvideMembers) {
- return ((IParent)element).getChildren();
- }
- } else if (celement instanceof IParent) {
- return (Object[])((IParent)celement).getChildren();
- }
- }
- return getResources(element);
- }
-
- /* (non-Cdoc)
- *
- * @see ITreeContentProvider
- */
- public boolean hasChildren(Object element) {
- if (fProvideMembers) {
- // assume TUs and binary files are never empty
- if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
- return true;
- }
- } else {
- // don't allow to drill down into a compilation unit or class file
- if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive) {
- return false;
- }
- }
-
- if (element instanceof ICProject) {
- ICProject cp= (ICProject)element;
- if (!cp.getProject().isOpen()) {
- return false;
- } else {
- return true;
- }
- }
-
- if (element instanceof ICContainer) {
- return true;
- }
-
- if (element instanceof IParent) {
- // when we have C children return true, else we fetch all the children
- return ((IParent)element).hasChildren();
- }
- Object[] children= getChildren(element);
- return (children != null) && children.length > 0;
- }
-
- /* (non-Cdoc)
- * Method declared on ITreeContentProvider.
- */
- public Object getParent(Object element) {
- if (!exists(element)) {
- return null;
- }
- return internalGetParent(element);
- }
-
- public Object internalGetParent(Object element) {
- if (element instanceof ICElement) {
- return ((ICElement)element).getParent();
- }
- if (element instanceof IResource) {
- IResource parent= ((IResource)element).getParent();
- ICElement cParent= CoreModel.getDefault().create(parent);
- if (cParent != null && cParent.exists()) {
- return cParent;
- }
- return parent;
- }
- return null;
- }
-
- protected Object[] getCProjects(ICModel cModel) {
- return cModel.getCProjects();
- }
-
- protected Object[] getCProjectResources(ICProject cproject) {
- Object[] objects = getCResources((ICContainer)cproject);
- IArchiveContainer archives = cproject.getArchiveContainer();
- if (archives.hasChildren()) {
- objects = concatenate(objects, new Object[] {archives});
- }
- IBinaryContainer bins = cproject.getBinaryContainer();
- if (bins.hasChildren()) {
- objects = concatenate(objects, new Object[] {bins});
- }
- try {
- ILibraryReference[] refs = cproject.getLibraryReferences();
- objects = concatenate(objects, refs);
- } catch (CModelException e) {
- }
- return objects;
- }
-
- protected Object[] getCResources(ICContainer container) {
- Object[] objects = null;
- Object[] children = container.getChildren();
- try {
- objects = container.getNonCResources();
- } catch (CModelException e) {
- }
- if (objects == null) {
- return children;
- }
- return concatenate(children, objects);
- }
-
- private Object[] getResources(Object resource) {
- try {
- if (resource instanceof IContainer) {
- Object[] members= ((IContainer)resource).members();
- List nonCResources= new ArrayList();
- for (int i= 0; i < members.length; i++) {
- Object o= members[i];
- nonCResources.add(o);
- }
- return nonCResources.toArray();
- }
- } catch(CoreException e) {
- }
- return NO_CHILDREN;
- }
-/*
- protected boolean isBuildPathChange(ICElementDelta delta) {
- int flags= delta.getFlags();
- return (delta.getKind() == ICElementDelta.CHANGED &&
- ((flags & ICElementDelta.F_ADDED_TO_CLASSPATH) != 0) ||
- ((flags & ICElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) ||
- ((flags & ICElementDelta.F_CLASSPATH_REORDER) != 0));
- }
-*/
-
-
- protected boolean exists(Object element) {
- if (element == null) {
- return false;
- }
- if (element instanceof IResource) {
- return ((IResource)element).exists();
- }
- if (element instanceof ICElement) {
- return ((ICElement)element).exists();
- }
- return true;
- }
-
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- */
- protected static Object[] concatenate(Object[] a1, Object[] a2) {
- int a1Len = a1.length;
- int a2Len = a2.length;
- Object[] res = new Object[a1Len + a2Len];
- System.arraycopy(a1, 0, res, 0, a1Len);
- System.arraycopy(a2, 0, res, a1Len, a2Len);
- return res;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
deleted file mode 100644
index 770b9ad34ff..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-public class BinaryPropertySource implements IPropertySource {
-
- private final static String ELF_CPU= "CElementProperties.elf_cpu";
- private final static String ELF_TEXT= "CElementProperties.elf_text";
- private final static String ELF_DATA= "CElementProperties.elf_data";
- private final static String ELF_BSS= "CElementProperties.elf_bss";
- private final static String ELF_TYPE= "CElementProperties.elf_type";
- private final static String ELF_HAS_DEBUG= "CElementProperties.elf_has_debug";
- private final static String ELF_SONAME= "CElementProperties.elf_soname";
- private final static String ELF_NEEDED= "CElementProperties.elf_needed";
-
- private IBinary binary;
-
- // Property Descriptors
- static private IPropertyDescriptor[] fgPropertyDescriptors;
-
- /**
- * Get a PropertyDescriptor that defines the binary properties of an Elf
- * @return the PropertyDescriptor
- */
- private static IPropertyDescriptor[] getInitialPropertyDescriptor() {
- // cpu name
- String cpuName= CUIPlugin.getResourceString(ELF_CPU);
- PropertyDescriptor cpuDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_CPU, cpuName);
- cpuDescriptor.setAlwaysIncompatible(true);
-
- // elf text
- String textName = CUIPlugin.getResourceString(ELF_TEXT);
- PropertyDescriptor textDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TEXT, textName);
- textDescriptor.setAlwaysIncompatible(true);
-
- // elf data
- String dataName = CUIPlugin.getResourceString(ELF_DATA);
- PropertyDescriptor dataDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_DATA, dataName);
- dataDescriptor.setAlwaysIncompatible(true);
-
- // elf bss
- String bssName = CUIPlugin.getResourceString(ELF_BSS);
- PropertyDescriptor bssDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_BSS, bssName);
- bssDescriptor.setAlwaysIncompatible(true);
-
- // elf type
- String typeName = CUIPlugin.getResourceString(ELF_TYPE);
- PropertyDescriptor typeDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TYPE, typeName);
- bssDescriptor.setAlwaysIncompatible(true);
-
- // elf needed
- String neededName = CUIPlugin.getResourceString(ELF_NEEDED);
- PropertyDescriptor neededDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_NEEDED, neededName);
- bssDescriptor.setAlwaysIncompatible(true);
-
- // elf soname
- String sonameName = CUIPlugin.getResourceString(ELF_SONAME);
- PropertyDescriptor sonameDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_SONAME, sonameName);
- bssDescriptor.setAlwaysIncompatible(true);
-
- // elf debug
- String debugName = CUIPlugin.getResourceString(ELF_HAS_DEBUG);
- PropertyDescriptor debugDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_HAS_DEBUG, debugName);
- bssDescriptor.setAlwaysIncompatible(true);
-
- return new IPropertyDescriptor[] { cpuDescriptor, textDescriptor, dataDescriptor,
- bssDescriptor, typeDescriptor, sonameDescriptor, debugDescriptor, neededDescriptor };
- }
-
- public BinaryPropertySource(IBinary bin) {
- binary= bin;
- }
-
- /**
- * @see IPropertySource#getPropertyDescriptors
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- if (fgPropertyDescriptors == null)
- initializeBinaryDescriptors();
- return fgPropertyDescriptors;
- }
-
- /**
- * @see IPropertySource#getPropertyValue
- */
- public Object getPropertyValue(Object name) {
-// if (element != null) {
-// Object returnValue = super.getPropertyValue(name);
-//
-// if(returnValue != null)
-// return returnValue;
-// }
- if (name.equals(IBasicPropertyConstants.P_TEXT)) {
- return binary.getElementName();
- } else if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
- return binary.getCPU();
- } else if (name.equals(ICElementPropertyConstants.P_ELF_TEXT)) {
- return Long.toString(binary.getText());
- } else if (name.equals(ICElementPropertyConstants.P_ELF_DATA)) {
- return Long.toString(binary.getData());
- } else if (name.equals(ICElementPropertyConstants.P_ELF_BSS)) {
- return Long.toString(binary.getBSS());
- } else if (name.equals(ICElementPropertyConstants.P_ELF_SONAME)) {
- return binary.getSoname();
- } else if (name.equals(ICElementPropertyConstants.P_ELF_HAS_DEBUG)) {
- if (binary.hasDebug()) {
- return "true";//$NON-NLS-1$
- } else {
- return "false";//$NON-NLS-1$
- }
- } else if (name.equals(ICElementPropertyConstants.P_ELF_NEEDED)) {
- String[] needed = binary.getNeededSharedLibs();
- String need = "";
- for (int i = 0; i < needed.length; i++) {
- need += " " + needed[i];
- }
- return need.trim();
- } else if (name.equals(ICElementPropertyConstants.P_ELF_TYPE)) {
- if (binary.isObject()) {
- return "object";
- } else if (binary.isExecutable()) {
- return "executable";
- } else if (binary.isSharedLib()) {
- return "shared library";
- } else if (binary.isCore()) {
- return "core file";
- }
- }
- return null;
- }
-
- /**
- * Return the Property Descriptors for the file type.
- */
- private void initializeBinaryDescriptors() {
-// IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
-// int superLength = superDescriptors.length;
-// IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
-// int binLength = binDescriptors.length;
-// fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
-// System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
-// System.arraycopy(binDescriptors, 0, fgPropertyDescriptors, superLength, binLength);
- fgPropertyDescriptors = getInitialPropertyDescriptor();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value) {
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsole.java
deleted file mode 100644
index c6e24b5865e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsole.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * (c) Copyright QNX Software System Ltd. 2002.
- * All Rights Reserved.
- */
-package org.eclipse.cdt.internal.ui;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.ui.*;
-import org.eclipse.core.resources.IProject;
-
-public class BuildConsole implements IConsole {
- IProject project;
- IBuildConsoleManager fConsoleManager;
-
- /**
- * Constructor for BuildConsole.
- */
- public BuildConsole() {
- fConsoleManager = CUIPlugin.getDefault().getConsoleManager();
- }
-
- public void start(IProject project ) {
- this.project = project;
- fConsoleManager.getConsole(project).start(project);
- }
-
- /**
- * @see org.eclipse.cdt.core.resources.IConsole#clear()
- */
- public void clear() {
- fConsoleManager.getConsole(project).clear();
- }
-
- /**
- * @see org.eclipse.cdt.core.resources.IConsole#getOutputStream()
- */
- public ConsoleOutputStream getOutputStream() {
- return fConsoleManager.getConsole(project).getOutputStream();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java
deleted file mode 100644
index 9dfa0ebafb0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * (c) Copyright QNX Software System Ltd. 2002.
- * All Rights Reserved.
- */
-package org.eclipse.cdt.internal.ui;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleListener;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-
-public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener, IPropertyChangeListener {
- private HashMap fConsoleDocumentMap;
- ListenerList listeners = new ListenerList(1);
-
- private class BuildConsoleDocument extends Document {
-
- private int fMaxLines;
-
- public BuildConsoleDocument(int nLines) {
- super();
- fMaxLines = nLines;
- }
-
- public void setDocumentSize(int nLines) {
- fMaxLines = nLines;
- nLines = getNumberOfLines();
- if (nLines > fMaxLines) {
- try {
- int start = getLineOffset(nLines - fMaxLines);
- String part = get(start, getLength() - start);
- set(part);
- } catch (BadLocationException e) {
- }
- }
- }
-
- public BuildConsoleDocument(String initialContent) {
- super(initialContent);
- }
-
- public void replace(int offset, int length, String text) throws BadLocationException {
- super.replace(offset, length, text);
- int nLines = getNumberOfLines();
- if (nLines > fMaxLines) {
- int start = getLineOffset(nLines - fMaxLines);
- String part = get(start, getLength() - start);
- set(part);
- }
- }
- }
-
- private class BuildConsole extends ConsoleOutputStream implements IConsole {
- protected BuildConsoleDocument fDocument;
-
- public BuildConsole() {
- fDocument = new BuildConsoleDocument(BuildConsolePreferencePage.buildConsoleLines());
- }
-
- public void setConsoleSize(int nLines) {
- fDocument.setDocumentSize(nLines);
- }
-
- public void start(IProject project) {
- if (BuildConsolePreferencePage.isClearBuildConsole()) {
- clear();
- }
- Object[] list = listeners.getListeners();
- if (list.length > 0) {
- for (int i = 0; i < list.length; i++) {
- IBuildConsoleListener listener = (IBuildConsoleListener) list[i];
- ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, ConsoleEvent.CONSOLE_START);
- listener.consoleChange(event);
- }
- }
- }
-
- public void clear() {
- super.clear();
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- fDocument.set("");
- }
- });
- }
-
- public ConsoleOutputStream getOutputStream() {
- return this;
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- public void flush() throws IOException {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- bringConsoleOnTop();
- try {
- int len = fDocument.getLength();
- fDocument.replace(len, 0, readBuffer());
- } catch (BadLocationException x) {
- }
- }
- });
- }
-
- void bringConsoleOnTop() {
- IWorkbenchWindow window = CUIPlugin.getDefault().getActiveWorkbenchWindow();
- if (window == null)
- return;
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- try {
- // show the build console
- IViewPart cBuild = page.findView(CUIPlugin.CONSOLE_ID);
- if (cBuild == null) {
- if (BuildConsolePreferencePage.isAutoOpenConsole()) {
- IWorkbenchPart activePart = page.getActivePart();
- cBuild = page.showView(CUIPlugin.CONSOLE_ID);
- //restore focus
- page.activate(activePart);
- }
- }
- if (cBuild != null && BuildConsolePreferencePage.isConsoleOnTop()) {
- page.bringToTop(cBuild);
- }
- } catch (PartInitException pie) {
- }
- }
- }
-
- public void close() throws IOException {
- flush();
- }
-
- }
-
- public BuildConsoleManager() {
- fConsoleDocumentMap = new HashMap();
- }
-
- /**
- * Traverses the delta looking for added/removed/changed launch
- * configuration files.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (fConsoleDocumentMap == null) {
- return;
- }
- IResource resource = event.getResource();
- if (resource != null && resource.getType() == IResource.PROJECT) {
- if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
- fConsoleDocumentMap.remove(resource);
- Object[] list = listeners.getListeners();
- if (list.length > 0) {
- for (int i = 0; i < list.length; i++) {
- IBuildConsoleListener listener = (IBuildConsoleListener) list[i];
- ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject) resource, ConsoleEvent.CONSOLE_CLOSE);
- listener.consoleChange(consoleEvent);
- }
- }
- }
- }
- }
-
- public void shutdown() {
- CUIPlugin.getWorkspace().removeResourceChangeListener(this);
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
-
- public void startup() {
- CUIPlugin.getWorkspace().addResourceChangeListener(this);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- private BuildConsole getBuildConsole(IProject project) {
- BuildConsole console = (BuildConsole) fConsoleDocumentMap.get(project);
- if (console == null) {
- console = new BuildConsole();
- fConsoleDocumentMap.put(project, console);
- }
- return console;
- }
-
- public IConsole getConsole(IProject project) {
- return getBuildConsole(project);
- }
-
- public IDocument getConsoleDocument(IProject project) {
- return getBuildConsole(project).getDocument();
- }
-
- public void addConsoleListener(IBuildConsoleListener listener) {
- listeners.add(listener);
- }
-
- public void removeConsoleListener(IBuildConsoleListener listener) {
- listeners.remove(listener);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty() == BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) {
- Collection consoles = fConsoleDocumentMap.values();
- Iterator iter = consoles.iterator();
- while (iter.hasNext()) {
- BuildConsole console = (BuildConsole) iter.next();
- console.setConsoleSize(BuildConsolePreferencePage.buildConsoleLines());
- }
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java
deleted file mode 100644
index 2c1eaaee17a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.ICCompletionContributor;
-import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Manages external plugins that contribute completion and function
- * info through the CCompletionContributor extension point
- */
-
-public class CCompletionContributorManager {
-
- static private List fCompletionContributors;
- static boolean fContributorsLoaded = false;
- public static final String CONTRIBUTION_EXTENSION = "CCompletionContributor";
- static private CCompletionContributorManager fInstance;
-
- private CCompletionContributorManager() {
- // Initialize and scan the extension points
- }
-
- public static CCompletionContributorManager getDefault() {
- if (fInstance == null) {
- fInstance = new CCompletionContributorManager();
- }
- return fInstance;
- }
-
- public IFunctionSummary getFunctionInfo(String name) {
- if (!fContributorsLoaded)
- loadExtensions();
-
- for (int i = 0; i < fCompletionContributors.size(); i++) {
- ICCompletionContributor c = (ICCompletionContributor) fCompletionContributors.get(i);
- IFunctionSummary f = c.getFunctionInfo(name);
-
- if (f != null)
- return f;
- }
- return null;
- }
-
- public IFunctionSummary[] getMatchingFunctions(String frag) {
- if (!fContributorsLoaded)
- loadExtensions();
- IFunctionSummary[] fs = null;
-
- for (int i = 0; i < fCompletionContributors.size(); i++) {
- ICCompletionContributor c = (ICCompletionContributor) fCompletionContributors.get(i);
- IFunctionSummary[] f = c.getMatchingFunctions(frag);
- if (f != null) {
- if (fs != null) {
- int length = f.length + fs.length;
- IFunctionSummary[] ft = new IFunctionSummary[length];
- int j;
- for (j = 0; j < fs.length; j++)
- ft[j] = fs[j];
- for (j = 0; j < f.length; j++)
- ft[j + fs.length] = f[j];
- fs = ft;
- } else {
- fs = f;
- }
- }
-
- //if(f != null)
- //return f;
- }
-
- return fs;
- }
-
- private void loadExtensions() {
- fContributorsLoaded = true;
- fCompletionContributors = new ArrayList(2);
-
- // populate list
- IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "CCompletionContributor"); //$NON-NLS-1$
- if (extensionPoint != null) {
- IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals("provider")) {
- try {
- final ICCompletionContributor c;
- // Instantiate the classe
- c = (ICCompletionContributor) elements[i].createExecutableExtension("class");
- ISafeRunnable runnable = new ISafeRunnable() {
- public void run() throws Exception {
- // Initialize
- c.initialize();
- // Add to contributor list
- fCompletionContributors.add(c);
- }
- public void handleException(Throwable exception) {
- }
- };
- Platform.run(runnable);
- } catch (CoreException e) {
- }
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
deleted file mode 100644
index 40f72b6257e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-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.runtime.IAdapterFactory;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.views.properties.FilePropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.ResourcePropertySource;
-
-/**
- * Implements basic UI support for C elements.
- */
-public class CElementAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- IPropertySource.class,
- IResource.class,
- IWorkbenchAdapter.class,
- IProject.class,
- IWorkspaceRoot.class
- };
-
- private static CWorkbenchAdapter fgCWorkbenchAdapter= new CWorkbenchAdapter();
-
- /**
- * @see CElementAdapterFactory#getAdapterList
- */
- public Class[] getAdapterList() {
- return PROPERTIES;
- }
-
- /**
- * @see CElementAdapterFactory#getAdapter
- */
- public Object getAdapter(Object element, Class key) {
- ICElement celem = (ICElement) element;
- IResource res = null;
-
- if (IPropertySource.class.equals(key)) {
- if (celem instanceof IBinary) {
- return new BinaryPropertySource((IBinary)celem);
- } else if (celem.getElementType() == ICElement.C_UNIT) {
- IResource file = celem.getResource();
- if (file != null && file instanceof IFile) {
- return new FilePropertySource((IFile)file);
- }
- } else {
- res = celem.getResource();
- if (res != null) {
- return new ResourcePropertySource(res);
- }
- }
- return new CElementPropertySource(celem);
- } else if (IWorkspaceRoot.class.equals(key)) {
- res = celem.getUnderlyingResource();
- if (res != null)
- return res.getWorkspace().getRoot();
- } else if (IProject.class.equals(key)) {
- res = celem.getResource();
- if (res != null)
- return res.getProject();
- } else if (IResource.class.equals(key)) {
- return celem.getResource();
- } else if (IWorkbenchAdapter.class.equals(key)) {
- return fgCWorkbenchAdapter;
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
deleted file mode 100644
index 3baa5eae23e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
+++ /dev/null
@@ -1,480 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryModule;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IDeclaration;
-import org.eclipse.cdt.core.model.IField;
-import org.eclipse.cdt.core.model.ILibraryReference;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.model.ITemplate;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
-import org.eclipse.cdt.ui.CElementImageDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-
-/**
- * Default strategy of the C plugin for the construction of C element icons.
- */
-public class CElementImageProvider {
-
- /**
- * Flags for the CImageLabelProvider:
- * Generate images with overlays.
- */
- public final static int OVERLAY_ICONS= 0x1;
-
- /**
- * Generate small sized images.
- */
- public final static int SMALL_ICONS= 0x2;
-
- /**
- * Use the 'light' style for rendering types.
- */
- public final static int LIGHT_TYPE_ICONS= 0x4;
-
- /**
- * Show error overrlay.
- */
- public final static int OVERLAY_ERROR= 0x8;
-
- /**
- * Show warning overrlay
- */
- public final static int OVERLAY_WARNING= 0x10;
-
- /**
- * Show override overrlay.
- */
- public final static int OVERLAY_OVERRIDE= 0x20;
-
- /**
- * Show implements overrlay.
- */
- public final static int OVERLAY_IMPLEMENTS= 0x40;
-
- private static final Point SMALL_SIZE= new Point(16, 16);
- private static final Point BIG_SIZE= new Point(22, 16);
-
- private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED;
- private static ImageDescriptor DESC_OBJ_PROJECT;
- private static ImageDescriptor DESC_OBJ_FOLDER;
- {
- ISharedImages images= CUIPlugin.getDefault().getWorkbench().getSharedImages();
- DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT_CLOSED);
- DESC_OBJ_PROJECT= images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT);
- DESC_OBJ_FOLDER= images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
- }
-
- private ImageDescriptorRegistry fRegistry;
-
- public CElementImageProvider() {
- fRegistry= CUIPlugin.getImageDescriptorRegistry();
- }
-
- /**
- * Returns the icon for a given element. The icon depends on the element type
- * and element properties. If configured, overlay icons are constructed for
- * <code>ISourceReference</code>s.
- * @param flags Flags as defined by the JavaImageLabelProvider
- */
- public Image getImageLabel(Object element, int flags) {
- ImageDescriptor descriptor= null;
- if (element instanceof ICElement) {
- descriptor= getCImageDescriptor((ICElement) element, flags);
- }
- if (descriptor == null && element instanceof IAdaptable) {
- descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
- }
- if (descriptor != null) {
- return fRegistry.get(descriptor);
- }
- return null;
- }
-
- /**
- *
- * @param type
- * @return
- */
- public static ImageDescriptor getImageDescriptor(int type) {
- switch (type) {
- case ICElement.C_VCONTAINER:
- return CPluginImages.DESC_OBJS_CONTAINER;
-
- case ICElement.C_BINARY:
- return CPluginImages.DESC_OBJS_BINARY;
-
- case ICElement.C_ARCHIVE:
- return CPluginImages.DESC_OBJS_ARCHIVE;
-
- case ICElement.C_UNIT:
- return CPluginImages.DESC_OBJS_TUNIT;
-
- case ICElement.C_CCONTAINER:
- return DESC_OBJ_FOLDER;
-
- case ICElement.C_PROJECT:
- return DESC_OBJ_PROJECT;
-
- case ICElement.C_STRUCT:
- case ICElement.C_TEMPLATE_STRUCT:
- return CPluginImages.DESC_OBJS_STRUCT;
-
- case ICElement.C_CLASS:
- case ICElement.C_TEMPLATE_CLASS:
- return CPluginImages.DESC_OBJS_CLASS;
-
- case ICElement.C_UNION:
- case ICElement.C_TEMPLATE_UNION:
- return CPluginImages.DESC_OBJS_UNION;
-
- case ICElement.C_TYPEDEF:
- return CPluginImages.DESC_OBJS_TYPEDEF;
-
- case ICElement.C_ENUMERATION:
- return CPluginImages.DESC_OBJS_ENUMERATION;
-
- case ICElement.C_ENUMERATOR:
- return CPluginImages.DESC_OBJS_ENUMERATOR;
-
- case ICElement.C_FIELD:
- return CPluginImages.DESC_OBJS_PUBLIC_FIELD;
-
- case ICElement.C_VARIABLE:
- case ICElement.C_TEMPLATE_VARIABLE:
- return CPluginImages.DESC_OBJS_VARIABLE;
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD:
- return CPluginImages.DESC_OBJS_PUBLIC_METHOD;
-
- case ICElement.C_FUNCTION:
- return CPluginImages.DESC_OBJS_FUNCTION;
-
- case ICElement.C_VARIABLE_DECLARATION:
- return CPluginImages.DESC_OBJS_VAR_DECLARARION;
-
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION:
- return CPluginImages.DESC_OBJS_DECLARARION;
-
- case ICElement.C_INCLUDE:
- return CPluginImages.DESC_OBJS_INCLUDE;
-
- case ICElement.C_MACRO:
- return CPluginImages.DESC_OBJS_MACRO;
-
- case ICElement.C_NAMESPACE:
- return CPluginImages.DESC_OBJS_CONTAINER;
- }
- return null;
- }
-
- private boolean showOverlayIcons(int flags) {
- return (flags & OVERLAY_ICONS) != 0;
- }
-
-// private boolean useLightIcons(int flags) {
-// return (flags & LIGHT_TYPE_ICONS) != 0;
-// }
-
- private boolean useSmallSize(int flags) {
- return (flags & SMALL_ICONS) != 0;
- }
-
- /**
- * Returns an image descriptor for a C element. The descriptor includes overlays, if specified.
- */
- public ImageDescriptor getCImageDescriptor(ICElement element, int flags) {
- int adornmentFlags= computeCAdornmentFlags(element, flags);
- Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
- ImageDescriptor desc = getBaseImageDescriptor(element, flags);
- if(desc != null) {
- return new CElementImageDescriptor(desc, adornmentFlags, size);
- }
- return null;
- }
-
- /**
- * Returns an image descriptor for a IAdaptable. The descriptor includes overlays, if specified (only error ticks apply).
- * Returns <code>null</code> if no image could be found.
- */
- public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
- IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
- if (wbAdapter == null) {
- return null;
- }
- ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
- if (descriptor == null) {
- return null;
- }
- int adornmentFlags= computeBasicAdornmentFlags(adaptable, flags);
- Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
- return new CElementImageDescriptor(descriptor, adornmentFlags, size);
- }
-
- // ---- Computation of base image key -------------------------------------------------
-
- /**
- * Returns an image descriptor for a C element. This is the base image, no overlays.
- */
- public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
- int type = celement.getElementType();
- switch (type) {
- case ICElement.C_VCONTAINER:
- if (celement instanceof IBinaryModule) {
- return CPluginImages.DESC_OBJS_BINARY;
- } else if (celement instanceof ILibraryReference) {
- return CPluginImages.DESC_OBJS_LIBRARY;
- }
- return CPluginImages.DESC_OBJS_CONTAINER;
-
- case ICElement.C_BINARY: {
- IBinary bin = (IBinary)celement;
- if (bin.isExecutable()) {
- if (bin.hasDebug())
- return CPluginImages.DESC_OBJS_CEXEC_DEBUG;
- return CPluginImages.DESC_OBJS_CEXEC;
- } else if (bin.isSharedLib()) {
- return CPluginImages.DESC_OBJS_SHLIB;
- } else if (bin.isCore()) {
- return CPluginImages.DESC_OBJS_CORE;
- }
- return CPluginImages.DESC_OBJS_BINARY;
- }
-
- case ICElement.C_ARCHIVE:
- return CPluginImages.DESC_OBJS_ARCHIVE;
-
- case ICElement.C_UNIT:
- String ext = celement.getPath().getFileExtension();
- if (ext != null) {
- String[] exts = CoreModel.getDefault().getHeaderExtensions();
- for (int i = 0; i < exts.length; i++) {
- if (exts[i].equalsIgnoreCase(ext)) {
- return CPluginImages.DESC_OBJS_TUNIT_HEADER;
- }
- }
- }
- return CPluginImages.DESC_OBJS_TUNIT;
-
- case ICElement.C_CCONTAINER:
- return DESC_OBJ_FOLDER;
-
- case ICElement.C_PROJECT:
- ICProject cp= (ICProject)celement;
- if (cp.getProject().isOpen()) {
- IProject project= cp.getProject();
- IWorkbenchAdapter adapter= (IWorkbenchAdapter)project.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- ImageDescriptor result= adapter.getImageDescriptor(project);
- if (result != null)
- return result;
- }
- return DESC_OBJ_PROJECT;
- }
- return DESC_OBJ_PROJECT_CLOSED;
-
- case ICElement.C_STRUCT:
- case ICElement.C_TEMPLATE_STRUCT:
- return getStructImageDescriptor();
-
- case ICElement.C_CLASS:
- case ICElement.C_TEMPLATE_CLASS:
- return getClassImageDescriptor();
-
- case ICElement.C_UNION:
- case ICElement.C_TEMPLATE_UNION:
- return getUnionImageDescriptor();
-
- case ICElement.C_TYPEDEF:
- return getTypedefImageDescriptor();
-
- case ICElement.C_ENUMERATION:
- return getEnumerationImageDescriptor();
-
- case ICElement.C_ENUMERATOR:
- return getEnumeratorImageDescriptor();
-
- case ICElement.C_FIELD:
- {
- IField field = (IField)celement;
- ASTAccessVisibility visibility = field.getVisibility();
- return getFieldImageDescriptor(visibility);
- }
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD:
- {
- IMethodDeclaration md= (IMethodDeclaration)celement;
- ASTAccessVisibility visibility =md.getVisibility();
- return getMethodImageDescriptor(visibility);
- }
-
- case ICElement.C_VARIABLE:
- case ICElement.C_TEMPLATE_VARIABLE:
- return getVariableImageDescriptor();
-
- case ICElement.C_FUNCTION:
- return getFunctionImageDescriptor();
-
- case ICElement.C_VARIABLE_DECLARATION:
- return getVariableDeclarationImageDescriptor();
-
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION:
- return getFunctionDeclarationImageDescriptor();
-
- case ICElement.C_INCLUDE:
- return getIncludeImageDescriptor();
-
- case ICElement.C_MACRO:
- return getMacroImageDescriptor();
-
- case ICElement.C_NAMESPACE:
- return getNamespaceImageDescriptor();
-
- }
- return null;
- }
-
-
- // ---- Methods to compute the adornments flags ---------------------------------
-
- private int computeCAdornmentFlags(ICElement element, int renderFlags) {
-
- int flags= computeBasicAdornmentFlags(element, renderFlags);
-
- if (showOverlayIcons(renderFlags) && element instanceof IDeclaration) {
- IDeclaration decl = (IDeclaration) element;
- if(decl.isStatic()){
- flags |= CElementImageDescriptor.STATIC;
- }
- if(decl.isConst()){
- flags |= CElementImageDescriptor.CONSTANT;
- }
- if(decl.isVolatile()){
- flags |= CElementImageDescriptor.VOLATILE;
- }
- if(element instanceof ITemplate){
- flags |= CElementImageDescriptor.TEMPLATE;
- }
- }
- return flags;
- }
-
- private int computeBasicAdornmentFlags(Object element, int renderFlags) {
- int flags= 0;
- if ((renderFlags & OVERLAY_ERROR) !=0) {
- flags |= CElementImageDescriptor.ERROR;
- }
- if ((renderFlags & OVERLAY_WARNING) !=0) {
- flags |= CElementImageDescriptor.WARNING;
- }
- if ((renderFlags & OVERLAY_OVERRIDE) !=0) {
- flags |= CElementImageDescriptor.OVERRIDES;
- }
- if ((renderFlags & OVERLAY_IMPLEMENTS) !=0) {
- flags |= CElementImageDescriptor.IMPLEMENTS;
- }
- return flags;
- }
-
- public void dispose() {
- }
-
- public static ImageDescriptor getStructImageDescriptor(){
- return CPluginImages.DESC_OBJS_STRUCT;
- }
-
- public static ImageDescriptor getClassImageDescriptor(){
- return CPluginImages.DESC_OBJS_CLASS;
- }
-
- public static ImageDescriptor getUnionImageDescriptor(){
- return CPluginImages.DESC_OBJS_UNION;
- }
-
- public static ImageDescriptor getTypedefImageDescriptor(){
- return CPluginImages.DESC_OBJS_TYPEDEF;
- }
-
- public static ImageDescriptor getEnumerationImageDescriptor(){
- return CPluginImages.DESC_OBJS_ENUMERATION;
- }
-
- public static ImageDescriptor getEnumeratorImageDescriptor(){
- return CPluginImages.DESC_OBJS_ENUMERATOR;
- }
-
- public static ImageDescriptor getFieldImageDescriptor(ASTAccessVisibility visibility) {
- if (visibility == ASTAccessVisibility.PUBLIC)
- return CPluginImages.DESC_OBJS_PUBLIC_FIELD;
- if( visibility == ASTAccessVisibility.PROTECTED)
- return CPluginImages.DESC_OBJS_PROTECTED_FIELD;
-
- return CPluginImages.DESC_OBJS_PRIVATE_FIELD;
- }
-
- public static ImageDescriptor getMethodImageDescriptor(ASTAccessVisibility visibility) {
- if( visibility == ASTAccessVisibility.PUBLIC)
- return CPluginImages.DESC_OBJS_PUBLIC_METHOD;
- if( visibility == ASTAccessVisibility.PROTECTED)
- return CPluginImages.DESC_OBJS_PROTECTED_METHOD;
-
- return CPluginImages.DESC_OBJS_PRIVATE_METHOD;
-
- }
-
- public static ImageDescriptor getVariableImageDescriptor(){
- return CPluginImages.DESC_OBJS_VARIABLE;
- }
-
- public static ImageDescriptor getLocalVariableImageDescriptor(){
- return CPluginImages.DESC_OBJS_LOCAL_VARIABLE;
- }
-
- public static ImageDescriptor getFunctionImageDescriptor(){
- return CPluginImages.DESC_OBJS_FUNCTION;
- }
-
- public static ImageDescriptor getVariableDeclarationImageDescriptor(){
- return CPluginImages.DESC_OBJS_VAR_DECLARARION;
- }
-
- public static ImageDescriptor getFunctionDeclarationImageDescriptor(){
- return CPluginImages.DESC_OBJS_DECLARARION;
- }
-
- public static ImageDescriptor getIncludeImageDescriptor(){
- return CPluginImages.DESC_OBJS_INCLUDE;
- }
-
- public static ImageDescriptor getMacroImageDescriptor(){
- return CPluginImages.DESC_OBJS_MACRO;
- }
-
- public static ImageDescriptor getNamespaceImageDescriptor(){
- return CPluginImages.DESC_OBJS_CONTAINER;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java
deleted file mode 100644
index d49038f6e7a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.*;
-
-public class CElementProperties implements IPropertySource {
-
- private final static String LABEL= "CElementProperties.name";
-
- private ICElement fCElement;
-
- // Property Descriptors
- static private IPropertyDescriptor[] fgPropertyDescriptors;
-
- static {
- // resource name
- String displayName= CUIPlugin.getResourceString(LABEL);
- PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
- descriptor.setAlwaysIncompatible(true);
-
- fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor };
- }
-
- public CElementProperties(ICElement elem) {
- fCElement= elem;
- }
-
- /**
- * @see IPropertySource#getPropertyDescriptors
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return fgPropertyDescriptors;
- }
-
- /**
- * @see IPropertySource#getPropertyValue
- */
- public Object getPropertyValue(Object name) {
- if (name.equals(IBasicPropertyConstants.P_TEXT)) {
- return fCElement.getElementName();
- }
- return null;
- }
-
- /**
- * @see IPropertySource#setPropertyValue
- */
- public void setPropertyValue(Object name, Object value) {
- }
-
- /**
- * @see IPropertySource#getEditableValue
- */
- public Object getEditableValue() {
- return null;
- }
-
- /**
- * @see IPropertySource#isPropertySet
- */
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- /**
- * @see IPropertySource#resetPropertyValue
- */
- public void resetPropertyValue(Object property) {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
deleted file mode 100644
index d8481647422..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.*;
-
-public class CElementPropertySource implements IPropertySource {
-
- private final static String LABEL= "CElementProperties.name";
-
- private ICElement fCElement;
-
- // Property Descriptors
- static private IPropertyDescriptor[] fgPropertyDescriptors;
-
- static {
- // resource name
- String displayName= CUIPlugin.getResourceString(LABEL);
- PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
- descriptor.setAlwaysIncompatible(true);
-
- fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor };
- }
-
- public CElementPropertySource(ICElement elem) {
- fCElement= elem;
- }
-
- /**
- * @see IPropertySource#getPropertyDescriptors
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return fgPropertyDescriptors;
- }
-
- /**
- * @see IPropertySource#getPropertyValue
- */
- public Object getPropertyValue(Object name) {
- if (name.equals(IBasicPropertyConstants.P_TEXT)) {
- return fCElement.getElementName();
- }
- return null;
- }
-
- /**
- * @see IPropertySource#setPropertyValue
- */
- public void setPropertyValue(Object name, Object value) {
- }
-
- /**
- * @see IPropertySource#getEditableValue
- */
- public Object getEditableValue() {
- return null;
- }
-
- /**
- * @see IPropertySource#isPropertySet
- */
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- /**
- * @see IPropertySource#resetPropertyValue
- */
- public void resetPropertyValue(Object property) {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
deleted file mode 100644
index 45f0f6a1d07..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBuffer;
-import org.eclipse.cdt.core.model.IBufferChangedListener;
-import org.eclipse.cdt.core.model.IOpenable;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.WorkingCopy;
-import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
-import org.eclipse.cdt.internal.ui.editor.DocumentAdapter;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-
-public class CFileElementWorkingCopy extends WorkingCopy {
-
- IDocumentProvider fProvider;
- IEditorInput input;
- IBuffer buffer;
-
- /**
- * Internal IBuffer implementation very simple, must cases will use DocumentAdapter.
- *
- */
- class Buffer implements IBuffer {
-
- CFileElementWorkingCopy owner;
-
- public Buffer(CFileElementWorkingCopy o) {
- owner = o;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#addBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener)
- */
- public void addBufferChangedListener(IBufferChangedListener listener) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
- */
- public void append(char[] text) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
- */
- public void append(String text) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#close()
- */
- public void close() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
- */
- public char getChar(int position) {
- IDocument doc = fProvider.getDocument(input);
- if (doc != null) {
- try {
- return doc.getChar(position);
- } catch (BadLocationException e) {
- }
- }
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
- */
- public char[] getCharacters() {
- return getContents().toCharArray();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getContents()
- */
- public String getContents() {
- IDocument doc = fProvider.getDocument(input);
- if (doc != null) {
- return doc.get();
- }
- return new String();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getLength()
- */
- public int getLength() {
- IDocument doc = fProvider.getDocument(input);
- if (doc != null) {
- return doc.getLength();
- }
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
- */
- public IOpenable getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
- */
- public String getText(int offset, int length) {
- IDocument doc = fProvider.getDocument(input);
- if (doc != null) {
- try {
- return doc.get(offset, length);
- } catch (BadLocationException e) {
- }
- }
- return new String();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
- */
- public IResource getUnderlyingResource() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
- */
- public boolean hasUnsavedChanges() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
- */
- public boolean isClosed() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
- */
- public boolean isReadOnly() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#removeBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener)
- */
- public void removeBufferChangedListener(IBufferChangedListener listener) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
- */
- public void replace(int position, int length, char[] text) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
- */
- public void replace(int position, int length, String text) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void save(IProgressMonitor progress, boolean force) throws CModelException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
- */
- public void setContents(char[] contents) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
- */
- public void setContents(String contents) {
- }
-
- }
-
- /**
- * Creates a working copy of this element
- */
- public CFileElementWorkingCopy(IStorageEditorInput StoreInput, IDocumentProvider provider) throws CoreException {
- super(null, new Path(StoreInput.getName()), null);
- input = StoreInput;
- fProvider = provider;
- IStorage storage = StoreInput.getStorage();
- super.setLocation(storage.getFullPath());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IOpenable#getBuffer()
- */
- public IBuffer getBuffer() throws CModelException {
- if (buffer == null) {
- if (fProvider instanceof CDocumentProvider) {
- buffer = new DocumentAdapter(this, fProvider.getDocument(input), new DefaultLineTracker(), (CDocumentProvider)fProvider, input);
- } else {
- buffer = new Buffer(this);
- }
- }
- return buffer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.model.IWorkingCopy#getOriginalElement()
- */
- public ITranslationUnit getOriginalElement() {
- return this;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
deleted file mode 100644
index af1b061d565..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.ui.*;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-public class CPerspectiveFactory implements IPerspectiveFactory {
-
- /**
- * Constructs a new Default layout engine.
- */
- public CPerspectiveFactory() {
- super();
- }
-
- /**
- * @see IPerspectiveFactory#createInitialLayout
- */
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea);
- folder1.addView(IPageLayout.ID_RES_NAV);
- folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- folder1.addView(CUIPlugin.CVIEW_ID);
-
- IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea);
- folder2.addView(IPageLayout.ID_TASK_LIST);
- folder2.addView(CUIPlugin.CONSOLE_ID);
- folder2.addView(IPageLayout.ID_PROP_SHEET);
-
- IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea);
- folder3.addView(IPageLayout.ID_OUTLINE);
-
- layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
- layout.addActionSet(CUIPlugin.FOLDER_ACTION_SET_ID);
-
- // views - build console
- layout.addShowViewShortcut(CUIPlugin.CONSOLE_ID);
-
- // views - searching
- layout.addShowViewShortcut(SearchUI.SEARCH_RESULT_VIEW_ID);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
-
- // link - things we should do
- layout.addShowInPart(CUIPlugin.CVIEW_ID);
- layout.addShowInPart(IPageLayout.ID_RES_NAV);
-
- // new actions - C project creation wizard
- layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID);
- layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
- layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
deleted file mode 100644
index d3e69156033..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.cdt.ui.*;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Bundle of all images used by the C plugin.
- */
-public class CPluginImages {
-
- // The plugin registry
- private static ImageRegistry imageRegistry = new ImageRegistry();
-
- // Subdirectory (under the package containing this class) where 16 color images are
- private static URL fgIconBaseURL;
- static {
- try {
- fgIconBaseURL= new URL(CUIPlugin.getDefault().getDescriptor().getInstallURL(), "icons/" );
- } catch (MalformedURLException e) {
- CUIPlugin.getDefault().log(e);
- }
- }
- private static final String NAME_PREFIX= CUIPlugin.PLUGIN_ID + '.';
- private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
- private static final String T= "full/";
-
- public static final String T_OBJ= T + "obj16/";
- public static final String T_WIZBAN= T + "wizban/";
- public static final String T_LCL= "lcl16/";
- public static final String T_TOOL= "tool16/";
- public static final String T_VIEW= "view16/";
- public static final String T_OVR= T + "ovr16/";
-
- public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif";
- public static final String IMG_OBJS_VARIABLE= NAME_PREFIX + "variable_obj.gif";
- public static final String IMG_OBJS_LOCAL_VARIABLE= NAME_PREFIX + "variable_local_obj.gif";
- public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif";
- public static final String IMG_OBJS_STRUCT= NAME_PREFIX + "struct_obj.gif";
- public static final String IMG_OBJS_UNION= NAME_PREFIX + "union_obj.gif";
- public static final String IMG_OBJS_TYPEDEF= NAME_PREFIX + "typedef_obj.gif";
- public static final String IMG_OBJS_ENUMERATION= NAME_PREFIX + "enum_obj.gif";
- public static final String IMG_OBJS_ENUMERATOR= NAME_PREFIX + "enumerator_obj.gif";
- public static final String IMG_OBJS_FUNCTION= NAME_PREFIX + "function_obj.gif";
- public static final String IMG_OBJS_PUBLIC_METHOD= NAME_PREFIX + "method_public_obj.gif";
- public static final String IMG_OBJS_PROTECTED_METHOD= NAME_PREFIX + "method_protected_obj.gif";
- public static final String IMG_OBJS_PRIVATE_METHOD= NAME_PREFIX + "method_private_obj.gif";
- public static final String IMG_OBJS_PUBLIC_FIELD= NAME_PREFIX + "field_public_obj.gif";
- public static final String IMG_OBJS_PROTECTED_FIELD= NAME_PREFIX + "field_protected_obj.gif";
- public static final String IMG_OBJS_PRIVATE_FIELD= NAME_PREFIX + "field_private_obj.gif";
- public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif";
- public static final String IMG_OBJS_VAR_DECLARATION= NAME_PREFIX + "var_declaration_obj.gif";
- public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif";
- public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif";
- public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif";
- public static final String IMG_OBJS_TUNIT_HEADER= NAME_PREFIX + "h_file_obj.gif";
- public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif";
- public static final String IMG_OBJS_BINARY= NAME_PREFIX + "bin_obj.gif";
- public static final String IMG_OBJS_SHLIB= NAME_PREFIX + "shlib_obj.gif";
- public static final String IMG_OBJS_CEXEC= NAME_PREFIX + "exec_obj.gif";
- public static final String IMG_OBJS_CEXEC_DEBUG= NAME_PREFIX + "exec_dbg_obj.gif";
- public static final String IMG_OBJS_CORE= NAME_PREFIX + "core_obj.gif";
- public static final String IMG_OBJS_CONTAINER= NAME_PREFIX + "container_obj.gif";
- public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "lib_obj.gif";
-
- // Breakpoint images
- public static final String IMG_OBJS_BREAKPOINT = NAME_PREFIX + "breakpoint.gif";
- public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "breakpoint_disabled.gif";
- public static final String IMG_OBJS_BREAKPOINT_ACTIVE = NAME_PREFIX + "breakpoint_active.gif";
-
- public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
- public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
- public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
- public static final ImageDescriptor DESC_OBJS_STRUCT= createManaged(T_OBJ, IMG_OBJS_STRUCT);
- public static final ImageDescriptor DESC_OBJS_UNION= createManaged(T_OBJ, IMG_OBJS_UNION);
- public static final ImageDescriptor DESC_OBJS_TYPEDEF= createManaged(T_OBJ, IMG_OBJS_TYPEDEF);
- public static final ImageDescriptor DESC_OBJS_ENUMERATION= createManaged(T_OBJ, IMG_OBJS_ENUMERATION);
- public static final ImageDescriptor DESC_OBJS_ENUMERATOR= createManaged(T_OBJ, IMG_OBJS_ENUMERATOR);
- public static final ImageDescriptor DESC_OBJS_FUNCTION= createManaged(T_OBJ, IMG_OBJS_FUNCTION);
- public static final ImageDescriptor DESC_OBJS_PUBLIC_METHOD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_METHOD);
- public static final ImageDescriptor DESC_OBJS_PROTECTED_METHOD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_METHOD);
- public static final ImageDescriptor DESC_OBJS_PRIVATE_METHOD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_METHOD);
- public static final ImageDescriptor DESC_OBJS_PUBLIC_FIELD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_FIELD);
- public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
- public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
- public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
- public static final ImageDescriptor DESC_OBJS_VAR_DECLARARION= createManaged(T_OBJ, IMG_OBJS_VAR_DECLARATION);
- public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
- public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
- public static final ImageDescriptor DESC_OBJS_TUNIT= createManaged(T_OBJ, IMG_OBJS_TUNIT);
- public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER= createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
- public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
- public static final ImageDescriptor DESC_OBJS_BINARY= createManaged(T_OBJ, IMG_OBJS_BINARY);
- public static final ImageDescriptor DESC_OBJS_SHLIB= createManaged(T_OBJ, IMG_OBJS_SHLIB);
- public static final ImageDescriptor DESC_OBJS_CEXEC= createManaged(T_OBJ, IMG_OBJS_CEXEC);
- public static final ImageDescriptor DESC_OBJS_CEXEC_DEBUG= createManaged(T_OBJ, IMG_OBJS_CEXEC_DEBUG);
- public static final ImageDescriptor DESC_OBJS_CORE= createManaged(T_OBJ, IMG_OBJS_CORE);
- public static final ImageDescriptor DESC_OBJS_CONTAINER= createManaged(T_OBJ, IMG_OBJS_CONTAINER);
- public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
-
- // Breakpoint image descriptors
- public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
- public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
- public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ACTIVE = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_ACTIVE );
-
- public static final String IMG_MENU_SHIFT_RIGHT= NAME_PREFIX + "shift_r_edit.gif";
- public static final String IMG_MENU_SHIFT_LEFT= NAME_PREFIX + "shift_l_edit.gif";
- public static final String IMG_MENU_OPEN_INCLUDE= NAME_PREFIX + "open_incl.gif";
- public static final String IMG_MENU_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif";
- public static final String IMG_MENU_CODE_ASSIST= NAME_PREFIX + "metharg_obj.gif";
- public static final String IMG_MENU_COLLAPSE_ALL= NAME_PREFIX + "collapseall.gif";
- public static final String IMG_CLEAR_CONSOLE= NAME_PREFIX + "clear_co.gif";
- public static final String IMG_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif";
- public static final String IMG_TOOL_GOTO_PREV_ERROR= NAME_PREFIX + "prev_error_nav.gif";
- public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif";
- public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif";
-
- public static final String IMG_ACTION_SHOW_FIELDS= NAME_PREFIX + "fields_co.gif";
- public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif";
- public static final String IMG_ACTION_SHOW_STATIC= NAME_PREFIX + "static_co.gif";
-
- public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
-
- public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif");
- public static final ImageDescriptor DESC_OVR_CONSTANT= create(T_OVR, "c_ovr.gif");
- public static final ImageDescriptor DESC_OVR_VOLATILE= create(T_OVR, "volatile_co.gif");
- public static final ImageDescriptor DESC_OVR_TEMPLATE= create(T_OVR, "template_co.gif");
-
- public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif");
- public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif");
-
- public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ= create(T_WIZBAN, "newcprj_wiz.gif");
- public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif");
- public static final ImageDescriptor DESC_WIZABAN_C_APP= create(T_WIZBAN, "c_app_wiz.gif");
- public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "prj_obj.gif";
- public static final ImageDescriptor DESC_PROJECT= createManaged(T_WIZBAN, IMG_OBJS_PROJECT);
-
- public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_TOOL, "newclass_wiz.gif"); //$NON-NLS-1$
-
- // For the build image
- public static final String IMG_OBJS_BUILD= NAME_PREFIX + "build_menu.gif";
- public static final ImageDescriptor DESC_BUILD_MENU = createManaged(T_OBJ, IMG_OBJS_BUILD);
-
- //for search
- public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX + "search_ref_obj.gif";
- public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX + "search_decl_obj.gif";
- public static final String IMG_OBJS_CSEARCH = NAME_PREFIX + "csearch_obj.gif";
-
- public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
- public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
- public static final ImageDescriptor DESC_OBJS_CSEARCH = createManaged(T_OBJ, IMG_OBJS_CSEARCH);
-
- public static void initialize() {
- //createManaged(registry, T_OBJ, IMG_OBJS_TUNIT);
- //createManaged(registry, T_OBJ, IMG_OBJS_FIELD);
- //createManaged(registry, T_OBJ, IMG_OBJS_CLASS);
- //createManaged(registry, T_OBJ, IMG_OBJS_STRUCT);
- //createManaged(registry, T_OBJ, IMG_OBJS_UNION);
- //createManaged(registry, T_OBJ, IMG_OBJS_FUNCTION);
- //createManaged(registry, T_OBJ, IMG_OBJS_INCLUDE);
- //createManaged(registry, T_OBJ, IMG_OBJS_DEFINE);
-
- //createManaged(registry, T_OBJ, IMG_OBJS_ARCHIVE);
- //createManaged(registry, T_OBJ, IMG_OBJS_SHLIB);
- //createManaged(registry, T_OBJ, IMG_OBJS_BINARY);
- //createManaged(registry, T_OBJ, IMG_OBJS_CEXEC);
- //createManaged(registry, T_OBJ, IMG_OBJS_CEXEC_DEBUG);
- //createManaged(registry, T_OBJ, IMG_OBJS_CONTAINER);
-
- //createManaged(registry, T_OBJ, IMG_OBJS_TEMPLATE);
- }
-
- private static ImageDescriptor createManaged(String prefix, String name) {
- return createManaged(imageRegistry, prefix, name);
- }
-
- private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
- ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
- registry.put(name, result);
- return result;
- }
-
- public static Image get(String key) {
- return imageRegistry.get(key);
- }
-
- private static ImageDescriptor create(String prefix, String name) {
- return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
- }
-
- private static URL makeIconFileURL(String prefix, String name) {
- StringBuffer buffer= new StringBuffer(prefix);
- buffer.append(name);
- try {
- return new URL(fgIconBaseURL, buffer.toString());
- } catch (MalformedURLException e) {
- CUIPlugin.getDefault().log(e);
- return null;
- }
- }
-
- /**
- * Sets all available image descriptors for the given action.
- */
- public static void setImageDescriptors(IAction action, String type, String relPath) {
- relPath= relPath.substring(NAME_PREFIX_LENGTH);
- action.setDisabledImageDescriptor(create(T + "d" + type, relPath));
- action.setHoverImageDescriptor(create(T + "c" + type, relPath));
- action.setImageDescriptor(create(T + "e" + type, relPath));
- }
-
- /**
- * Helper method to access the image registry from the JavaPlugin class.
- */
- static ImageRegistry getImageRegistry() {
- return imageRegistry;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
deleted file mode 100644
index 02e22e4484a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
+++ /dev/null
@@ -1,332 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-# ------- CView -----------------
-CView.make_edit_action =Project properties
-
-# ------- Preference Page -------
-
-#CBasePreferencePage.description=The build command is an executable program which will be used by the builder\nto build your C project. If the build command is not on the current system\nenvironment path, you have to enter an absolute path name.\nThe command given here will be filled in new C projects by default.\nTo change the builder for a specific project, use the project's property page.
-CBasePreferencePage.description=The build command is an executable program which will be used by the builder\nto build your C/C++ project. If the build command is not on the current system\nenvironment path, you have to enter an absolute path name.\nThe command given here will be filled in new C/C++ projects by default.
-CBasePreferencePage.buildLocation.label=Default build command:
-CBasePreferencePage.clearConsole.label=Always clear C-Build view before building
-CBasePreferencePage.autoOpenConsole.label=Open C-Build view when building
-CBasePreferencePage.consoleOnTop.label=Bring C-Build view to top when building (if present)
-CBasePreferencePage.buildConsole.errorMessage=Value must be an integer between 10 and 2147483647
-CBasePreferencePage.linkToEditor.label=Link view selection to active editor
-CBasePreferencePage.CUChildren.label=Show file members in Project View
-CBasePreferencePage.OutlineView.structuralParseMode.label=Use Structural-Parse mode to build the CModel
-
-CBasePreferencePage.editorFont.label=C Editor font:
-CBasePreferencePage.consoleFont.label=C-Build view font:
-
-CBasePreferencePage.bracketHighlightBox.label=Highlight matching brackets with box
-CBasePreferencePage.bracketHighlightClr.label=Highlight matching brackets with color
-CBasePreferencePage.bracketColour.label=Bracket highlighting color
-
-OpenProjectWizardAction.title=New Project
-OpenNewFileWizardAction.title=New File
-OpenNewFolderWizardAction.title=New Folder
-OpenClassWizardAction.title=New Class
-
-# ------- Project/Prefernces/Wizards COnfiguration blocks -------
-
-ErrorParserBlock.label=Error Parsers
-ErrorParserBlock.desc=Set the error parser for this project
-
-BinaryParserBlock.label=Binary Parser
-BinaryParserBlock.desc=Set required binary parser for this project
-
-IndexerBlock.label=Indexer
-IndexerBlock.desc=Project Indexer option
-
-ReferenceBlock.label= Projects
-ReferenceBlock.desc= Referenced C/C++ Projects
-
-# ------- NewProjectCreationPluginPage-------
-
-CProjectWizardPage.nameLabel=Name:
-CProjectWizardPage.useDefaultLabel=Use Default Location
-CProjectWizardPage.locationLabel=Location:
-CProjectWizardPage.browseLabel=Browse...
-CProjectWizardPage.projectNameEmpty=Project name must be specified.
-CProjectWizardPage.defaultLocationError=Location path can not overlap with default location.
-CProjectWizardPage.projectExistsMessage=Project already exists.
-CProjectWizardPage.directoryLabel=Select the project contents directory.
-CProjectWizardPage.locationError=Invalid path location.
-
-# ------- ProjectConfigurationBlock-------
-
-ProjectConfigurationBlock.buildCmdText.label=The build command is an executable program which will be used by the builder to build your C project. If the build command is not on the current system environment path, you have to enter an absolute path name. If the build command is make then it will use the makefile which is located in the project folder
-ProjectConfigurationBlock.buildArgsText.label=Build can be either incremental or full. You can specify different build arguments\nfor the two kinds.
-ProjectConfigurationBlock.buildArgText.label=Additional build arguments
-
-ProjectConfigurationBlock.buildLocation.label=Build command:
-ProjectConfigurationBlock.buildLocation.button=Browse...
-ProjectConfigurationBlock.fullBuildArguments.label=Full Build Arguments:
-ProjectConfigurationBlock.incrBuildArguments.label=Incremental Build Arguments:
-ProjectConfigurationBlock.error.InvalidBuildCommand=Invalid build command
-
-# --- The new wizards ----
-# FIXME: Remove the properties above when satisfy with wizards.
-
-SettingsBlock.label=Build Settings
-SettingsBlock.keepOnGoing=Keep Going On Error
-SettingsBlock.stopOnError=Stop On Error
-SettingsBlock.makeOption.label=Build Command
-SettingsBlock.makeOption.use_default=Use Default
-SettingsBlock.makeOption.build_cmd=Build Command:
-
-#Strings for the platform selection tab
-PlatformBlock.label.platform=Platform:
-PlatformBlock.tip.platform=Select the platform you wish to deploy on
-PlatformBlock.label.configs=Configurations:
-
-# String constants for the build configuration tab
-ConfigurationBlock.label=Build Information
-ConfigurationBlock.type=Project Type
-ConfigurationBlock.type.app=Application
-ConfigurationBlock.type.shared=Shared Library/DLL
-ConfigurationBlock.type.static=Static Library
-ConfigurationBlock.build.label=Build Settings
-ConfigurationBlock.build.continue=Continue On Error
-ConfigurationBlock.build.stop=Stop On Error
-
-# String constants for the build include path and preprocessor symbols
-BuildPathInfoBlock.label=Paths and Symbols
-BuildPathInfoBlock.paths=Include paths:
-BuildPathInfoBlock.symbols=Defined symbols:
-BuildPathInfoBlock.browse.path=New Include Path
-BuildPathInfoBlock.browse.path.label=Path:
-BuildPathInfoBlock.browse.symbol=New Defined Symbol
-BuildPathInfoBlock.browse.symbol.label=Symbol:
-
-StdMakeProjectWizard.op_error=Standard Make Error
-StdMakeProjectWizard.title=Standard Make Project
-StdMakeProjectWizard.description=Create a new Standard Make project.
-StdMakeProjectWizardSettings.title=Standard Make Settings
-StdMakeProjectWizardSettings.description=Define the Standard Make build settings.
-
-StdCWizard.title=Standard Make C Project
-StdCWizard.description=Create a new Standard Make C project.
-StdCWizardSettings.title=Standard Make C Settings
-StdCWizardSettings.description=Define the Standard Make C build settings.
-
-StdCCWizard.title=Standard Make C++ Project
-StdCCWizard.description=Create a new Standard Make C++ Project.
-StdCCWizardSettings.title=Standard Make C++ Settings
-StdCCWizardSettings.description=Define the Standard Make C++ build settings.
-
-MngMakeProjectWizard.op_error=Managed Make Error
-MngMakeProjectWizard.title=Managed Make Project
-MngMakeProjectWizard.description=Create a new Managed Make project.
-MngMakeProjectWizardSettings.title=Managed Make Settings
-MngMakeProjectWizardSettings.description=Define the Managed Make build settings.
-
-MngCWizard.title=Managed Make C Project
-MngCWizard.description=Create a new Managed Make C project.
-MngCWizardSettings.title=Managed Make C Settings
-MngCWizardSettings.description=Define the Managed Make C build settings.
-
-MngCCWizard.title=Managed Make C++ Project
-MngCCWizard.description=Create a new Managed Make C++ Project.
-MngCCWizardSettings.title=Managed Make C++ Settings
-MngCCWizardSettings.description=Define the Managed Make C++ build settings.
-
-NewClassWizard.title=New C++ Class
-NewClassWizard.description=Create a new C++ Class.
-NewClassWizard.page.title=C++ Class
-
-CProjectWizard.op_error.title=Error Creating Project
-CProjectWizard.op_error.message=Project cannot be created
-CProjectWizard.op_description=C Project Wizard
-CProjectWizard.windowTitle=New Project
-CProjectWizard.description=C Project Wizard
-CProjectWizard.title=C Project Wizard
-CProjectWizardPage=C Wizard Page
-
-# Defaults from ConvertProjectWizardPage
-ConversionWizard.windowTitle=Convert C/C++ Projects
-ConversionWizard.description=Select project(s) for conversion
-ConversionWizard.title=Add a C++ Nature to project(s)
-ConversionWizard.projectlist=Candidates for conversion
-
-# Convert to C/C++
-StdMakeConversionWizard.windowTitle=Convert Projects to C or C++
-StdMakeConversionWizard.description=Select project(s) for conversion
-StdMakeConversionWizard.title=Add a C or C++ Nature to selected project(s)
-
-TabFolderPage=Tab Folder Page
-TabFolderPage.title=Project
-TabFolderPage.desc=Project Settings
-
-# ------- CProjectPropertyPage-------
-
-CProjectPropertyPage.nocproject=Not a C builder
-CProjectPropertyPage.closedproject=C information is not available for a closed project
-
-# ------- Building -------
-
-CBuilder.build_error=Could not execute builder "{0}" configured in the project property page.
-
-# ------- Properties-------
-
-CElementProperties.name=name
-CElementProperties.elf_cpu=cpu
-CElementProperties.elf_text=text
-CElementProperties.elf_data=data
-CElementProperties.elf_bss=bss
-CElementProperties.elf_type=type
-CElementProperties.elf_soname=soname
-CElementProperties.elf_has_debug=debug
-CElementProperties.elf_needed=needed
-
-# ------- Compare -------
-
-CMergeViewer.title=C Compare Viewer
-CStructureCreator.name=C Compare
-
-# ------- Editor ------------
-
-Editor.Undo.label=Undo@Ctrl+Z
-Editor.Undo.tooltip=Undo
-Editor.Undo.image=
-Editor.Undo.description=Undo
-
-Editor.Redo.label=Redo@Ctrl+Y
-Editor.Redo.tooltip=Redo
-Editor.Redo.image=
-Editor.Redo.description=Redo
-
-Editor.Cut.label=Cut@Ctrl+X
-Editor.Cut.tooltip=Cut
-Editor.Cut.image=
-Editor.Cut.description=Cut
-
-Editor.Copy.label=&Copy@Ctrl+C
-Editor.Copy.tooltip=Copy
-Editor.Copy.image=
-Editor.Copy.description=Copy
-
-Editor.Paste.label=Paste@Ctrl+V
-Editor.Paste.tooltip=Paste
-Editor.Paste.image=
-Editor.Paste.description=Paste
-
-Editor.Delete.label=Delete@Delete
-Editor.Delete.tooltip=Delete
-Editor.Delete.image=
-Editor.Delete.description=Delete
-
-Editor.SelectAll.label=Select &All@Ctrl+A
-Editor.SelectAll.tooltip=Select All
-Editor.SelectAll.image=
-Editor.SelectAll.description=Select All
-
-Editor.ShiftRight.label=Sh&ift Right@Ctrl+I
-Editor.ShiftRight.tooltip=Shift Right
-Editor.ShiftRight.image=
-Editor.ShiftRight.description=Shift the selected text to the right
-
-Editor.ShiftLeft.label=S&hift Left@Ctrl+Shift+I
-Editor.ShiftLeft.tooltip=Shift Left
-Editor.ShiftLeft.image=
-Editor.ShiftLeft.description=Shift the selected text to the left
-
-Editor.FindReplace.label=Find/Replace...@Ctrl+F
-Editor.FindReplace.tooltip=Find/Replace
-Editor.FindReplace.image=
-Editor.FindReplace.description=Find/Replace
-
-Editor.AddBookmark.label=Boo&kmark...
-Editor.AddBookmark.tooltip=Bookmark
-Editor.AddBookmark.image=
-Editor.AddBookmark.description=Add Bookmark
-Editor.AddBookmark.dialog.title=Add Bookmark
-Editor.AddBookmark.dialog.message=Enter Bookmark name
-
-Editor.AddTask.label=&Task...
-Editor.AddTask.tooltip=Task
-Editor.AddTask.image=
-Editor.AddTask.description=Add Task
-
-Editor.Save.label=Save@Ctrl+S
-Editor.Save.tooltip=Save
-Editor.Save.image=
-Editor.Save.description=Save
-
-Editor.Revert.label=Re&vert
-Editor.Revert.tooltip=Revert
-Editor.Revert.image=
-Editor.Revert.description=Revert
-
-Editor.GotoLine.label=&Go to Line...@Ctrl+L
-Editor.GotoLine.tooltip=Go to a Line
-Editor.GotoLine.image=
-Editor.GotoLine.description=Go to a line
-Editor.GotoLine.dialog.title=Go to Line
-Editor.GotoLine.dialog.message=Enter line number:
-Editor.GotoLine.dialog.invalid_input=Invalid line number
-Editor.GotoLine.dialog.invalid_range=Line number out of range
-
-Editor.NextError.label= Go To Next Error
-Editor.PreviousError.label=Go To Previous Error
-Editor.NextError.tooltip= Jump to next error marker
-Editor.PreviousError.tooltip=Jump to previous error marker
-
-
-Editor.error.no_provider=Text editor does not have a document provider
-Editor.error.save.title=Save Problems
-Editor.error.save.message=Internal error:
-Editor.error.revert.title=Problems While Reverting to Saved State
-Editor.error.revert.message=Internal error:
-Editor.error.no_input=Unable to read text editor input
-Editor.error.invalid_input=Invalid text editor input
-
-CEditorPreferencePage.description= C Editor Preferences
-
-# ------- OpenIncludeDeclarationAction------------
-
-OpenIncludeAction.label=&Open
-OpenIncludeAction.tooltip=Open the Selected Include in the Editor
-OpenIncludeAction.description=Open the selected include in the editor
-OpenIncludeAction.dialog.title=Open Include
-OpenIncludeAction.dialog.message=Select the file to open
-
-# ------- FileSearchAction ---------------
-FileSearchAction.label=Workspace
-FileSearchAction.tooltip=Performs a text based file search for element in workspace
-FileSearchAction.description=Performs a text based file search for element in workspace
-
-# ------- FileSearchActionInWorkingSet ---------------
-FileSearchActionInWorkingSet.label=Working Set...
-FileSearchActionInWorkingSet.tooltip=Performs a text based file search for element in the selected working set
-FileSearchActionInWorkingSet.description=Performs a text based file search for element in the selected working set
-
-
-# ------- SearchDialogAction ---------------
-SearchDialogAction.label=C/C++ Search...
-SearchDialogAction.tooltip=Opens C/C++ Search Dialog
-SearchDialogAction.description=Opens C/C++ Search Dialog
-
-
-# ------- LexicalSortingAction------------
-
-LexicalSortingAction.label=Sort
-LexicalSortingAction.description=Sorts the elements in the outliner
-LexicalSortingAction.tooltip=Sort
-LexicalSortingAction.tooltip.on=Do Not Sort
-LexicalSortingAction.tooltip.off=Sort
-
-# ------- ClearOutputAction------------
-ClearOutputAction.label=Clea&r Console
-ClearOutputAction.tooltip=Clear Console
-
-# ------- New menu items to overwrite superclass ----------
-CreateFileAction.text = &File
-CreateFolderAction.text = F&older
-
-# ------- Drag and Drop Message Text -----------
-CViewDragNDrop.txt = already exists. Would you like to overwrite it?
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
deleted file mode 100644
index f333bb96704..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Defines status codes relevant to the C UI plug-in. When a
- * Core exception is thrown, it contain a status object describing
- * the cause of the exception. The status objects originating from the
- * C UI plug-in use the codes defined in this interface.
- */
-public class CStatusConstants {
-
- // Prevent instantiation
- private CStatusConstants() {
- }
-
- /** Status code describing an internal error */
- public static final int INTERNAL_ERROR= 1;
-
- /**
- * Status constant indicating that an exception occured on
- * storing or loading templates.
- */
- public static final int TEMPLATE_IO_EXCEPTION = 2;
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
deleted file mode 100644
index 0c2462b1a26..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * An exception to wrap a status. This is necessary to use the core's IRunnableWithProgress
- * support
- */
-
-public class CUIException extends CoreException {
-
- public CUIException(IStatus status) {
- super(status);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
deleted file mode 100644
index e2342b05d81..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class CUIMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.CUIMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private CUIMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static String getFormattedString(String key, String arg) {
- return getFormattedString(key, new String[] { arg });
- }
-
- public static String getFormattedString(String key, String[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
deleted file mode 100644
index 998d356f7ef..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2002,2003 Rational Software Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v0.5
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v05.html
-#
-# Contributors:
-# Rational Software - Initial API and implementation
-###############################################################################
-
-Drag.move.problem.title=Drag and Drop Problem
-Drag.move.problem.message={0} is read only. Do you still wish to delete it?
-ExceptionDialog.seeErrorLogMessage=See error log for more details.
-
-################
-# Content Assist
-################
-CEditor.contentassist.noCompletions=No completions available.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
deleted file mode 100644
index 925ba70b115..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.ui.*;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Convenience class for error exceptions thrown inside JavaUI plugin.
- */
-public class CUIStatus extends Status {
-
- public CUIStatus(int code, String message, Throwable throwable) {
- super(IStatus.ERROR, CUIPlugin.getPluginId(), code, message, throwable);
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
deleted file mode 100644
index 54f588df243..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-
-/**
- * An imlementation of the IWorkbenchAdapter for CElements.
- */
-public class CWorkbenchAdapter implements IWorkbenchAdapter {
-
- private static final Object[] fgEmptyArray = new Object[0];
- private CElementImageProvider fImageProvider;
- private CElementLabelProvider fLabelProvider;
-
- public CWorkbenchAdapter() {
- fImageProvider = new CElementImageProvider();
- fLabelProvider = new CElementLabelProvider();
- }
-
- /**
- * @see IWorkbenchAdapter#getChildren
- */
- public Object[] getChildren(Object o) {
- if (o instanceof IParent) {
- Object[] members = ((IParent) o).getChildren();
- if (members != null) {
- return members;
- }
- }
- return fgEmptyArray;
- }
-
- /**
- * @see IWorkbenchAdapter#getImageDescriptor
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- if (element instanceof ICElement) {
- return fImageProvider.getCImageDescriptor(
- (ICElement) element,
- CElementImageProvider.OVERLAY_ICONS | CElementImageProvider.SMALL_ICONS);
- }
- return null;
- }
-
- /**
- * @see IWorkbenchAdapter#getLabel
- */
- public String getLabel(Object o) {
- if (o instanceof ICElement) {
- return fLabelProvider.getText((ICElement) o);
- }
- return null;
- }
-
- /**
- * @see IWorkbenchAdapter#getParent
- */
- public Object getParent(Object o) {
- if (o instanceof ICElement) {
- return ((ICElement) o).getParent();
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java
deleted file mode 100644
index 14ab2d7b580..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * (c) Copyright QNX Software System Ltd. 2002.
- * All Rights Reserved.
- */package org.eclipse.cdt.internal.ui;
-
-import java.util.EventObject;
-
-import org.eclipse.cdt.ui.IBuildConsoleEvent;
-import org.eclipse.core.resources.IProject;
-
-public class ConsoleEvent extends EventObject implements IBuildConsoleEvent {
- private IProject fProject;
- private int fType;
-
- public ConsoleEvent(Object source, IProject project, int type) {
- super(source);
- fProject = project;
- fType = type;
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- public int getType() {
- return fType;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
deleted file mode 100644
index 14f4535d216..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
- import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
- /**
- * Input stream which reads from a document
- */
-public class DocumentInputStream extends InputStream {
-
- private IDocument fDocument;
- private int fCurrPos;
-
- public DocumentInputStream(IDocument document) {
- fDocument= document;
- fCurrPos= 0;
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * @see InputStream#read
- */
- public int read() throws IOException {
- try {
- if (fCurrPos < fDocument.getLength()) {
- return fDocument.getChar(fCurrPos++);
- }
- } catch (BadLocationException e) {
- }
- return -1;
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ErrorTickAdornmentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ErrorTickAdornmentProvider.java
deleted file mode 100644
index 82245afa976..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ErrorTickAdornmentProvider.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-
-public class ErrorTickAdornmentProvider implements IAdornmentProvider {
-
- private static final int ERRORTICK_WARNING= CElementImageProvider.OVERLAY_WARNING;
- private static final int ERRORTICK_ERROR= CElementImageProvider.OVERLAY_ERROR;
-
- /*
- * @see IAdornmentProvider#computeAdornmentFlags(Object, int)
- */
- public int computeAdornmentFlags(Object obj) {
- try {
- if (obj instanceof ICElement) {
- ICElement element= (ICElement) obj;
- if (!element.exists()) {
- // @@@ Not relevant right now...
- //return 0;
- }
-
- int type= element.getElementType();
- switch (type) {
- case ICElement.C_PROJECT:
- case ICElement.C_CCONTAINER:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
- case ICElement.C_UNIT:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
- case ICElement.C_FUNCTION:
- case ICElement.C_CLASS:
- case ICElement.C_UNION:
- case ICElement.C_STRUCT:
- case ICElement.C_VARIABLE:
- case ICElement.C_METHOD:
- ITranslationUnit tu= (ITranslationUnit) ((ISourceReference)element).getTranslationUnit();
- if (tu != null && tu.exists()) {
- // I assume that only source elements in compilation unit can have markers
- ISourceRange range= ((ISourceReference)element).getSourceRange();
- return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE, range);
- }
- default:
- }
- } else if (obj instanceof IResource) {
- return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null);
- }
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- }
- return 0;
- }
-
- /*
- * @see IAdornmentProvider#dispose()
- */
- public void dispose() {
- }
-
- private int getErrorTicksFromMarkers(IResource res, int depth, ISourceRange range) throws CoreException {
- // Trying to call findMarkers() on non existing resources will throw an exception
- // findMarkers() --> CoreException - if this method fails.
- // Reasons include:
- // This resource does not exist.
- // This resource is a project that is not open.
- if (res == null || !res.exists()) { // for elements in archives
- return 0;
- }
- int info= 0;
-
- IMarker[] markers= res.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, depth);
- if (markers != null) {
- for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
- IMarker curr= markers[i];
- if (range == null || isMarkerInRange(curr, range)) {
- int priority= curr.getAttribute(IMarker.SEVERITY, -1);
- if (priority == IMarker.SEVERITY_WARNING) {
- info= ERRORTICK_WARNING;
- } else if (priority == IMarker.SEVERITY_ERROR) {
- info= ERRORTICK_ERROR;
- }
- }
- }
- }
- return info;
- }
-
- private boolean isMarkerInRange(IMarker marker, ISourceRange range) throws CoreException {
- if (marker.isSubtypeOf(IMarker.TEXT)) {
- int pos= marker.getAttribute(IMarker.CHAR_START, -1);
- int offset= range.getStartPos();
- if(pos == -1) {
- int line= MarkerUtilities.getLineNumber(marker);
- if (line >= 0) {
- return (line >= range.getStartLine() && line <= range.getEndLine());
- }
-
- }
- return (offset <= pos && offset + range.getLength() > pos);
- }
- return false;
- }
-
-
- private IMarker isAnnotationInRange(IAnnotationModel model, Annotation annot, ISourceRange range) throws CoreException {
- if (annot instanceof MarkerAnnotation) {
- IMarker marker= ((MarkerAnnotation)annot).getMarker();
- if (marker.exists() && marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
- Position pos= model.getPosition(annot);
- if (pos.overlapsWith(range.getStartPos(), range.getLength())) {
- return marker;
- }
- }
- }
-
- return null;
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IAdornmentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IAdornmentProvider.java
deleted file mode 100644
index 782e77836f6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IAdornmentProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * @since 1.0
- */
-public interface IAdornmentProvider {
-
- /**
- * Computes the adornment flags for the given element.
- * Flags defined in <code>JavaElementImageProvider</code>.
- */
- int computeAdornmentFlags(Object element);
-
-
- /**
- * Called when the parent label provider is disposed
- */
- void dispose();
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
deleted file mode 100644
index 093bd15e59a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/**
- * This interface documents the property constants used by the ICElement
- * property source.
- */
-
-public interface ICElementPropertyConstants {
- /**
- * The <code>ICElement</code> property key for elf cpu.
- */
- public static final String P_ELF_CPU = "elf_cpu";
-
- /**
- * The <code>ICElement</code> property key for elf text.
- */
- public static final String P_ELF_TEXT = "text";
-
- /**
- * The <code>ICElement</code> property key for elf data.
- */
- public static final String P_ELF_DATA = "data";
-
- /**
- * The <code>ICElement</code> property key for elf bss.
- */
- public static final String P_ELF_BSS = "bss";
-
- /**
- * The <code>ICElement</code> property key for elf bss.
- */
- public static final String P_ELF_HAS_DEBUG = "debug";
-
- /**
- * The <code>ICElement</code> property key for elf soname.
- */
- public static final String P_ELF_SONAME = "soname";
-
- /**
- * The <code>ICElement</code> property key for elf type.
- */
- public static final String P_ELF_TYPE = "type";
-
- /**
- * The <code>ICElement</code> property key for elf type.
- */
- public static final String P_ELF_NEEDED = "needed";
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
deleted file mode 100644
index 1a8cb51ce10..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Help context ids for the c ui.
- * <p>
- * This interface contains constants only; it is not intended to be implemented
- * or extended.
- * </p>
- *
- */
-public interface ICHelpContextIds {
- public static final String PREFIX= CUIPlugin.PLUGIN_ID + ".";
-
- // Wizard pages
- public static final String NEW_CPROJECT_WIZARD_PAGE= PREFIX + "new_cproject_wizard_page_context";
- public static final String NEW_LAUNCH_WIZARD_PAGE= PREFIX + "new_launch_wizard_page_context";
- public static final String NEW_CLASS_WIZARD_PAGE= PREFIX + "new_class_wizard_page_context";
- public static final String OPEN_CLASS_WIZARD_ACTION= PREFIX + "open_class_wizard_action";
-
- // Actions
- public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action";
- public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action";
- public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action";
-
- // Preference/property pages
- public static final String C_PREF_PAGE= PREFIX + "new_c_pref_page_context";
- public static final String C_EDITOR_PREF_PAGE= PREFIX + "new_c_editor_pref_page_context";
- public static final String C_EDITOR_ANNOTATIONS_PREF_PAGE= PREFIX + "new_c_editor_annotations_pref_page_context";
- public static final String C_EDITOR_COLORS_PREF_PAGE= PREFIX + "new_c_editor_colors_pref_page_context";
- public static final String C_EDITOR_CONTENT_ASSIST_PREF_PAGE= PREFIX + "new_c_editor_content_assist_pref_page_context";
- public static final String TEMPLATE_PREFERENCE_PAGE= PREFIX + "new_c_templates_pref_page_context";
- public static final String LAUNCH_PROPERTY_PAGE= PREFIX + "new_launch_property_page_context";
- public static final String PROJECT_PROPERTY_PAGE= PREFIX + "new_project_property_page_context";
-
- public static final String PROJ_CONF_BLOCK= PREFIX + "new_proj_conf_block_context";
-
- public static final String TODO_TASK_INPUT_DIALOG= PREFIX + "todo_task_input_dialog_context"; //$NON-NLS-1$
- public static final String TODO_TASK_PROPERTY_PAGE= PREFIX + "tasktags_property_page_context"; //$NON-NLS-1$
- public static final String TODO_TASK_PREFERENCE_PAGE= PREFIX + "tasktags_preference_page_context"; //$NON-NLS-1$
-
- public static final String BINARY_PARSER_PAGE= PREFIX + "cdt_binary_parser_page"; //$NON-NLS-1$
- public static final String ERROR_PARSERS_PAGE= PREFIX + "cdt_error_parsers_page"; //$NON-NLS-1$
-
- // Console view
- public static final String CLEAR_CONSOLE_ACTION= PREFIX + "clear_console_action_context";
- public static final String CLEAR_CONSOLE_VIEW= PREFIX + "clear_console_view_context";
-
- public static final String TOGGLE_PRESENTATION_ACTION= PREFIX + "toggle_presentation_action_context"; //$NON-NLS-1$
- public static final String TOGGLE_TEXTHOVER_ACTION= PREFIX + "toggle_texthover_action_context"; //$NON-NLS-1$
-
- public static final String COLLAPSE_ALL_ACTION= PREFIX + "collapse_all_action"; //$NON-NLS-1$
-
- public static final String C_SEARCH_PAGE= PREFIX + "c_search_page"; //$NON-NLS-1$
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
deleted file mode 100644
index 1651004a28b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.ui.IWorkbenchActionConstants;
-
-/**
- * Constants for menu groups used in context menus for C views and editors.
- * <p>
- * This interface declares constants only; it is not intended to be implemented.
- * </p>
- */
-public interface IContextMenuConstants {
-
-
- /**
- * Pop-up menu: name of group for goto actions (value <code>"group.open"</code>).
- * <p>
- * Examples for open actions are:
- * <ul>
- * <li>Go Into</li>
- * <li>Go To</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_GOTO= "group.goto"; //$NON-NLS-1$
- /**
- * Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
- * <p>
- * Examples for open actions are:
- * <ul>
- * <li>Open To</li>
- * <li>Open With</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_OPEN= "group.open"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
- * <p>
- * Examples for show actions are:
- * <ul>
- * <li>Show in Navigator</li>
- * <li>Show in Type Hierarchy</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_SHOW= "group.show"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
- * <p>
- * Examples for new actions are:
- * <ul>
- * <li>Create new class</li>
- * <li>Create new interface</li>
- * </ul>
- * </p>
- */
- public static final String GROUP_NEW= "group.new"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
- */
- public static final String GROUP_BUILD= "group.build"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
- */
- public static final String GROUP_REORGANIZE= IWorkbenchActionConstants.GROUP_REORGANIZE;
-
- /**
- * Pop-up menu: name of group for code generation or refactoring actions (
- * value <code>"group.generate"</code>).
- */
- public static final String GROUP_GENERATE= "group.generate"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
- */
- public static final String GROUP_SEARCH= "group.search"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>).
- */
- public static final String GROUP_ADDITIONS= "additions"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
- */
- public static final String GROUP_VIEWER_SETUP= "group.viewerSetup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
- */
- public static final String GROUP_PROPERTIES= "group.properties"; //$NON-NLS-1$
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
deleted file mode 100644
index d69bd81578e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IAdapterFactory;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.CoreModel;
-
-public class ResourceAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- ICElement.class
- };
-
- //private static CElementFactory celementFactory= new CElementFactory();
- private static CoreModel celementFactory= CoreModel.getDefault();
-
- /**
- * @see IAdapterFactory#getAdapterList
- */
- public Class[] getAdapterList() {
- return PROPERTIES;
- }
-
- /**
- * @see IAdapterFactory#getAdapter
- */
- public Object getAdapter(Object element, Class key) {
- if (ICElement.class.equals(key)) {
- //try {
- if (element instanceof IFile) {
- return celementFactory.create((IFile)element);
- } else if (element instanceof IFolder) {
- return celementFactory.create((IFolder)element);
- } else if (element instanceof IProject) {
- return celementFactory.create((IProject)element);
- } else if (element instanceof IWorkspaceRoot) {
- return celementFactory.create((IWorkspaceRoot)element);
- } else if (element instanceof IResource) {
- return celementFactory.create((IResource)element);
- }
- //} catch (CoreException e) {
- // CUIPlugin.getDefault().getLog().log(e.getStatus());
- //}
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/StandardCElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/StandardCElementLabelProvider.java
deleted file mode 100644
index c756f0a8915..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/StandardCElementLabelProvider.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.ui.*;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * CElementLabelProvider that respects settings from the Appearance preference page.
- * Triggers a viewer update when a preference changes.
- */
-public class StandardCElementLabelProvider extends CElementLabelProvider implements IPropertyChangeListener {
-
- public final static int DEFAULT_TEXTFLAGS= 0; //CElementLabels.ROOT_VARIABLE | JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_APP_RETURNTYPE;
- public final static int DEFAULT_IMAGEFLAGS= CElementImageProvider.OVERLAY_ICONS;
-
- private int fTextFlagMask;
- private int fImageFlagMask;
-
- /**
- * Constructor for StandardCElementLabelProvider.
- * @see CElementLabelProvider#CElementLabelProvider
- */
- public StandardCElementLabelProvider(int textFlags, int imageFlags, IAdornmentProvider[] adormentProviders) {
- super(textFlags, imageFlags, adormentProviders);
- initMasks();
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /**
- * Creates a StandardCElementLabelProvider with DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS
- * and the ErrorTickAdornmentProvider.
- */
- public StandardCElementLabelProvider() {
- this(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS, new IAdornmentProvider[] { new ErrorTickAdornmentProvider() });
- }
-
- private void initMasks() {
- fTextFlagMask= -1;
- /* if (!AppearancePreferencePage.showMethodReturnType()) {
- fTextFlagMask ^= JavaElementLabels.M_APP_RETURNTYPE;
- }
- if (!AppearancePreferencePage.isCompressingPkgNameInPackagesView()) {
- fTextFlagMask ^= JavaElementLabels.P_COMPRESSED;
- } */
-
- fImageFlagMask= -1;
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- //String property= event.getProperty();
- /* if (property.equals(AppearancePreferencePage.PREF_METHOD_RETURNTYPE)
- || property.equals(AppearancePreferencePage.PREF_OVERRIDE_INDICATOR)
- || property.equals(AppearancePreferencePage.PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW)) {
- initMasks();
- LabelProviderChangedEvent lpEvent= new LabelProviderChangedEvent(this, null); // refresh all
- fireLabelProviderChanged(lpEvent);
- } */
- }
-
- /*
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- super.dispose();
- }
-
- /*
- * @see JavaUILabelProvider#getImageFlags()
- */
- public int getImageFlags() {
- return super.getImageFlags() & fImageFlagMask;
- }
-
- /*
- * @see JavaUILabelProvider#getTextFlags()
- */
- public int getTextFlags() {
- return super.getTextFlags() & fTextFlagMask;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
deleted file mode 100644
index c4d4c179a09..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Class that gives access to the action messages resource bundle.
- */
-public class ActionMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.ActionMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private ActionMessages() {
- // no instance
- }
-
- /**
- * Returns the resource string associated with the given key in the resource bundle. If there isn't
- * any value under the given key, the key is returned.
- *
- * @param key the resource key
- * @return the string
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * <code>MessageFormat</code> is used to format the message. If there isn't any value
- * under the given key, the key is returned.
- *
- * @param key the resource key
- * @param arg the message argument
- * @return the string
- */
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- /**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * <code>MessageFormat</code> is used to format the message. If there isn't any value
- * under the given key, the key is returned.
- *
- * @param key the resource key
- * @param args the message arguments
- * @return the string
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
deleted file mode 100644
index e3f3b5b4559..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
+++ /dev/null
@@ -1,274 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-OpenWithMenu.label=Open Wit&h
-RefactorMenu.label=Refac&tor
-SourceMenu.label=&Source
-NavigateMenu.label=&Navigate
-
-BuildAction.label=&Build Project
-RebuildAction.label=Rebuild Pro&ject
-
-SelectionConverter.codeResolveOrInput_failed=Couldn't convert text selection into a Java element
-SelectionConverter.codeResolve_failed=Couldn't convert text selection into a Java element
-
-OpenAction.label=&Open
-OpenAction.tooltip=Open an editor on the selected element
-OpenAction.description=Open an editor on the selected element
-OpenAction.declaration.label=&Open Declaration
-OpenAction.select_element=&Select or enter the element to open:
-
-OpenAction.error.title=Open
-OpenAction.error.message=Cannot open default editor.
-OpenAction.error.messageArgs=Cannot open default editor on {0}. {1}
-OpenAction.error.messageProblems=Problems Opening Editor
-OpenAction.error.messageBadSelection=Current text selection doesn't resolve to a Java element
-
-OpenSuperImplementationAction.label=Open S&uper Implementation
-OpenSuperImplementationAction.tooltip=Open the Implementation in the Super Type
-OpenSuperImplementationAction.description=Open the Implementation in the Super Type
-OpenSuperImplementationAction.error.title=Open Super Implementation
-OpenSuperImplementationAction.error.message=Opening failed. Check log for details.
-OpenSuperImplementationAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a method.
-OpenSuperImplementationAction.no_super_implementation=Super implementation for method ''{0}'' does not exist.
-
-OpenTypeHierarchyAction.label=Open Type Hie&rarchy
-OpenTypeHierarchyAction.tooltip=Open a type hierarchy on the selected element
-OpenTypeHierarchyAction.description=Open a type hierarchy on the selected element
-OpenTypeHierarchyAction.dialog.title=Open Type Hierarchy
-OpenTypeHierarchyAction.messages.title=Can\'t create type hierarchy
-OpenTypeHierarchyAction.messages.no_java_element=No Java element selected.
-OpenTypeHierarchyAction.messages.no_java_resources=Selected package fragment doesn\'t contain any Java resource.
-OpenTypeHierarchyAction.messages.no_types=Selected compilation unit doesn\'t contain a type.
-OpenTypeHierarchyAction.messages.no_valid_java_element=No valid Java element selected.
-
-ShowInPackageViewAction.label=Show in Pac&kage Explorer
-ShowInPackageViewAction.description=Show the selected element in Package Explorer
-ShowInPackageViewAction.tooltip=Show in Package Explorer
-ShowInPackageViewAction.select_name=&Select or enter the element to reveal:
-ShowInPackageViewAction.dialog.title=Show In Package Explorer
-ShowInPackageViewAction.error.message=Internal error. Please see log for details.
-ShowInPackageViewAction.not_found=Cannot reveal the selected element in Package Explorer. The element may be filtered out.
-
-ShowInNavigatorView.label=Show in &Navigator View
-ShowInNavigatorView.dialog.title=Show in Navigator View
-ShowInNavigatorView.dialog.message=Select the element to be opened in the navigator view:
-ShowInNavigatorView.error.activation_failed=Unable to activate Resource Navigator
-ShowInNavigatorView.error.conversion_failed=Unable to convert Java element into a resource
-
-OverrideMethodsAction.label=O&verride/Implement Methods...
-OverrideMethodsAction.description=Override or Implement Methods from super types.
-OverrideMethodsAction.tooltip=Override/Implement Methods
-
-OverrideMethodsAction.error.title=Override/Implement Methods
-OverrideMethodsAction.error.nothing_found=No methods to override found for this type.
-OverrideMethodsAction.error.type_removed_in_editor=Input type has been removed in editor.
-OverrideMethodsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type.
-
-AddGetterSetterAction.label=Gene&rate Getter and Setter...
-AddGetterSetterAction.description=Generate Getter and Setter methods for type's fields
-AddGetterSetterAction.tooltip=Generate Getter and Setter methods for the Type's Fields
-
-AddGetterSetterAction.error.title=Generate Getter and Setter
-AddGetterSetterAction.error.actionfailed=Generating Getter and Setter Failed.
-AddGetterSetterAction.error.fieldNotExisting=The field ''{0}'' has been removed in the editor.
-AddGetterSetterAction.not_applicable=Operation not applicable to current text selection. A field has to be selected or a type that declares fields.
-AddGetterSetterAction.read_only=The compilation unit in which the field ''{0}'' is declared is read only.
-
-AddGetterSetterAction.QueryDialog.title=Generate Getter and Setter
-AddGetterSetterAction.SkipSetterForFinalDialog.message=Field ''{0}'' is final.\nOK to skip creation of the setter method?
-AddGetterSetterAction.SkipExistingDialog.message=Method ''{0}'' already exists.\nSkip creation?
-AddGetterSetterAction.SkipExistingDialog.skip.label=&Skip
-AddGetterSetterAction.SkipExistingDialog.replace.label=&Replace
-AddGetterSetterAction.SkipExistingDialog.skipAll.label=Skip &All
-
-AddGetterSetterAction.dialog.title=&Select getters and setters to create:
-AddGetterSetterAction.one_selected=1 method selected.
-AddGetterSetterAction.methods_selected={0} methods selected.
-AddGettSetterAction.typeContainsNoFields.message=The type contains no fields or all fields have getters/setters already.
-
-
-AddUnimplementedConstructorsAction.label=Add &Constructors from Superclass
-AddUnimplementedConstructorsAction.description=Evaluate and add constructors from superclass
-AddUnimplementedConstructorsAction.tooltip=Add Constructors from Superclass
-
-AddUnimplementedConstructorsAction.error.title=Add Constructors from Superclass
-AddUnimplementedConstructorsAction.error.nothing_found=No unimplemented constructors found.
-AddUnimplementedConstructorsAction.error.type_removed_in_editor=Input type has been removed in editor.
-AddUnimplementedConstructorsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type.
-
-AddJavaDocStubAction.label=Add &Javadoc Comment
-AddJavaDocStubAction.description=Add a Javadoc comment stub to the member element
-AddJavaDocStubAction.tooltip=Add a Javadoc comment stub to the member element
-
-AddJavaDocStubsAction.error.dialogTitle=Add Javadoc Comment
-AddJavaDocStubsAction.error.noWorkingCopy=Could not find working copy.
-AddJavaDocStubsAction.error.memberNotExisting=Member has been removed in editor.
-AddJavaDocStubsAction.error.actionFailed=Error while adding Javadoc comment
-AddJavaDocStubsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type or method.
-
-ExternalizeStringsAction.label= &Externalize Strings...
-ExternalizeStringsAction.dialog.title= Externalize Strings
-ExternalizeStringsAction.dialog.message=Couldn't open Externalize String Wizard
-
-FindStringsToExternalizeAction.label= &Find Strings to Externalize...
-FindStringsToExternalizeAction.dialog.title= Find Strings to Externalize
-FindStringsToExternalizeAction.error.message=Unexpected Exception. See log.
-FindStringsToExternalizeAction.foundStrings= {0} in {1}
-FindStringsToExternalizeAction.noStrings= No strings to externalize were found.
-FindStringsToExternalizeAction.not_externalized= {0} &not externalized string(s) found.
-FindStringsToExternalizeAction.button.label= &Externalize...
-FindStringsToExternalizeAction.find_strings=Finding not externalized strings...
-
-OpenExternalJavadocAction.label=Open E&xternal Javadoc
-OpenExternalJavadocAction.description=Opens the Javadoc of the selected element in an external browser
-OpenExternalJavadocAction.tooltip=Opens the Javadoc of the selected element in an external browser
-OpenExternalJavadocAction.help_not_available=Help support not available
-OpenExternalJavadocAction.select_element=&Select or enter the element to open:
-OpenExternalJavadocAction.libraries.no_location=The documentation location for ''{0}'' has not been configured. For elements from libraries specify the Javadoc location URL on the property page of the parent JAR (''{1}'')
-OpenExternalJavadocAction.source.no_location=The documentation location for ''{0}'' has not been configured. For elements from source specify the Javadoc location URL on the property page of the parent project (''{1}'')
-OpenExternalJavadocAction.no_entry=The documentation does not contain an entry for ''{0}''.\n(File ''{1}'' does not exist.)
-OpenExternalJavadocAction.opening_failed=Opening Javadoc failed. See log for details
-OpenExternalJavadocAction.dialog.title=Open External Javadoc
-OpenExternalJavadocAction.code_resolve_failed=Couldn't convert text selection into a Java element
-
-SelfEncapsulateFieldAction.label=Encap&sulate Field...
-SelfEncapsulateFieldAction.dialog.title=Encapsulate Field
-SelfEncapsulateFieldAction.dialog.unavailable=Operation unavailable on the current selection. Select a field.
-SelfEncapsulateFieldAction.dialog.cannot_perform=Cannot perform refactoring. See log for more details.
-SelfEncapsulateFieldAction.dialog.field_doesnot_exit=Editor buffer does not contain field {0}.
-
-OrganizeImportsAction.label=Or&ganize Imports
-OrganizeImportsAction.tooltip=Evaluate All Required Imports and Replace the Current Imports
-OrganizeImportsAction.description=Evaluate all required imports and replace the current imports
-
-OrganizeImportsAction.multi.op.description=Organizing imports...
-OrganizeImportsAction.multi.error.parse={0}: Compilation unit has parse errors. No changes applied.
-OrganizeImportsAction.multi.error.readonly={0}: Compilation unit is read-only. No changes applied.
-OrganizeImportsAction.multi.error.unresolvable={0}: Compilation unit contains ambiguous references. User interaction required.
-OrganizeImportsAction.multi.error.unexpected={0}: Unexpected error. See log for details.
-OrganizeImportsAction.multi.error.notoncp={0}: Compilation unit not on build path. No changes applied.
-
-OrganizeImportsAction.selectiondialog.title=Organize Imports
-OrganizeImportsAction.selectiondialog.message=&Choose type to import:
-
-OrganizeImportsAction.error.title=Organize Imports
-OrganizeImportsAction.error.message=Unexpected error in organize imports. See log for details.
-
-OrganizeImportsAction.single.error.parse=Compilation unit has parse errors: ''{0}''. No changes applied.
-
-OrganizeImportsAction.summary_added={0} import(s) added.
-OrganizeImportsAction.summary_removed={0} import(s) removed.
-
-OrganizeImportsAction.multi.status.title=Organize Imports
-OrganizeImportsAction.multi.status.description=Problems while organizing imports on some compilation units. See 'Details' for more information.
-
-SortMembersAction.label=Sort &Members
-SortMembersAction.tooltip=Sorts all Members using the Member Order Preference
-SortMembersAction.description=Sorts all members using the member order preference
-
-SortMembersAction.error.title=Sort Members
-SortMembersAction.not_applicable=Operation not applicable to current text editor.
-SortMembersAction.containsmarkers=Markers like bookmarks, breakpoints or user defined tasks in a reordered member will be lost. Ok to continue?
-
-OpenBrowserUtil.help_not_available=Help support not available
-
-MemberFilterActionGroup.hide_fields.label=Hide Fiel&ds
-MemberFilterActionGroup.hide_fields.tooltip=Hide Fields
-MemberFilterActionGroup.hide_fields.description=Toggles the visibility of fields
-
-MemberFilterActionGroup.hide_static.label=Hide &Static Members
-MemberFilterActionGroup.hide_static.tooltip=Hide Static Members
-MemberFilterActionGroup.hide_static.description=Toggles the visibility of static members
-
-MemberFilterActionGroup.hide_nonpublic.label=Hide Non-&Public Members
-MemberFilterActionGroup.hide_nonpublic.tooltip=Hide Non-Public Members
-MemberFilterActionGroup.hide_nonpublic.description=Toggles the visibility of non-public members
-
-NewWizardsActionGroup.new=Ne&w
-
-OpenProjectAction.dialog.title=Open Project
-OpenProjectAction.dialog.message=Select project(s) to be opened
-OpenProjectAction.error.message=Problems while opening projects
-OpenProjectAction.no_java_nature.one=The following project doesn't have a Java nature and is therefore not present in the Package Explorer:
-OpenProjectAction.no_java_nature.multiple=The following projects don't have a Java nature and are therefore not present in the Package Explorer:
-
-
-OpenJavaPerspectiveAction.dialog.title=Open Java Perspective
-OpenJavaPerspectiveAction.error.open_failed=Couldn\'t open Java perspective
-
-OpenJavaBrowsingPerspectiveAction.dialog.title=Open Java Browsing Perspective
-OpenJavaBrowsingPerspectiveAction.error.open_failed=Couldn\'t open Java browsing perspective
-
-OpenTypeInHierarchyAction.label=Open Type in Hierarchy...
-OpenTypeInHierarchyAction.description=Open a type in a type hierarchy
-
-OpenTypeInHierarchyAction.tooltip=Open a type in a type hierarchy
-OpenTypeInHierarchyAction.dialogMessage=&Choose a type (? = any character, * = any string):
-OpenTypeInHierarchyAction.dialogTitle=Open Type in Hierarchy
-
-RefreshAction.label= Re&fresh
-RefreshAction.toolTip= Refresh
-RefreshAction.progressMessage= Refreshing...
-RefreshAction.error.title= Refresh Problems
-RefreshAction.error.message= Problems occurred refreshing the selected resources.
-RefreshAction.locationDeleted.title= Project location has been deleted
-RefreshAction.locationDeleted.message= The location for project {0} ({1}) has been deleted.\n Delete {0} from the workspace?
-
-ModifyParameterAction.problem.title=Refactoring
-ModifyParameterAction.problem.message=Operation not possible.
-
-PullUpAction.problem.title=Refactoring
-PullUpAction.problem.message=Operation not possible.
-
-OverrideMethodQuery.groupMethodsByTypes=Group methods by &types
-OverrideMethodQuery.dialog.title=Override/Implement Methods
-OverrideMethodQuery.dialog.description=&Select methods to override or implement:
-OverrideMethodQuery.selectioninfo.one={0} method selected.
-OverrideMethodQuery.selectioninfo.more={0} methods selected.
-
-ActionUtil.notOnBuildPath.title=Operation Cannot be Performed
-ActionUtil.notOnBuildPath.message=The resource is not on the build path of a Java project.
-ActionUtil.not_possible=Operation Not Possible
-ActionUtil.no_linked=This operation is unavailable on linked packages and package fragment roots.
-
-SelectAllAction.label= Select A&ll
-SelectAllAction.tooltip= Select All
-
-AddToClasspathAction.label=Add to &Build Path
-AddToClasspathAction.toolTip=Add JAR to the Java build path
-AddToClasspathAction.progressMessage=Adding to build path...
-AddToClasspathAction.error.title=Add to Build Path
-AddToClasspathAction.error.message=Problems occurred while adding to the build path.
-
-RemoveFromClasspathAction.Remove=Remove from &Build Path
-RemoveFromClasspathAction.tooltip=Remove package fragment root from the Java build path
-RemoveFromClasspathAction.Removing=Removing from build path...
-RemoveFromClasspathAction.exception_dialog_title=Remove From Build Path
-RemoveFromClasspathAction.Problems_occurred=Problems occurred while removing from the build path.
-
-AddDelegateMethodsAction.error.title=Generate Delegate Methods
-AddDelegateMethodsAction.error.actionfailed=Generating delegate methods failed.
-
-AddDelegateMethodsAction.label=Generate Delegate &Methods...
-AddDelegateMethodsAction.description=Adds delegate methods for a type's fields
-AddDelegateMethodsAction.tooltip=Adds Delegates Methods for a Type's Fields
-
-AddDelegateMethodsAction.not_applicable=Operation not applicable to current text selection. Please select a field or a type that declares some fields.
-
-AddDelegateMethodsAction.duplicate_methods=Duplicate method(s) selected
-
-AddDelegateMethodsAction.title=Delegate Methods Generation
-AddDelegateMethodsAction.message=Select &methods to create delegates for:
-
-AddDelegateMethodsAction.monitor.message=Creating {0} methods...
-AddDelegateMethodsAction.selectioninfo.one={0} method selected.
-AddDelegateMethodsAction.selectioninfo.more={0} methods selected.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
deleted file mode 100644
index 2b9b4e7b3d9..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.cdt.core.model.CoreModel;
-
-/**
- * An <code>IRunnableWithProgress</code> that adapts and <code>IWorkspaceRunnable</code>
- * so that is can be executed inside <code>IRunnableContext</code>. <code>OperationCanceledException</code>
- * thrown by the apapted runnabled are cought and rethrown as a <code>InterruptedException</code>.
- */
-
-public class WorkbenchRunnableAdapter implements IRunnableWithProgress {
-
- private IWorkspaceRunnable fWorkspaceRunnable;
-
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
- fWorkspaceRunnable= runnable;
- }
-
- /*
- * @see IRunnableWithProgress#run(IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- CoreModel.run(fWorkspaceRunnable, monitor);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleAction.java
deleted file mode 100644
index fa792acda60..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleAction.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.util.ResourceBundle;
-
-
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.TextViewer;
-
-
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-
-public class BuildConsoleAction extends TextEditorAction {
-
-
- private int fOperationCode= -1;
- private ITextOperationTarget fOperationTarget;
-
-
- public BuildConsoleAction(ResourceBundle bundle, String prefix, TextViewer viewer, int operationCode) {
- super(bundle, prefix, null);
- fOperationCode= operationCode;
- fOperationTarget= viewer.getTextOperationTarget();
- update();
- }
- /**
- * @see Action
- */
- public void run() {
- if (fOperationCode != -1 && fOperationTarget != null) {
- fOperationTarget.doOperation(fOperationCode);
- }
- }
- /**
- * @see TextEditorAction
- */
- public void update() {
-
- boolean wasEnabled= isEnabled();
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
-
- if (wasEnabled != isEnabled) {
- setEnabled(isEnabled);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
deleted file mode 100644
index 8966f84f2f6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
+++ /dev/null
@@ -1,313 +0,0 @@
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleEvent;
-import org.eclipse.cdt.ui.IBuildConsoleListener;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-/**
-
-/**
- * Console view for the desktop. Registered using XML.
- */
-public class BuildConsoleView extends ViewPart implements ISelectionListener, IBuildConsoleListener {
- private IProject selProject;
- private Font fFont;
- private IPropertyChangeListener fPropertyChangeListener;
- protected TextViewer fTextViewer;
- IBuildConsoleManager fConsoleManager;
- ClearConsoleAction fClearOutputAction;
- TextEditorAction fCopyAction;
- TextEditorAction fSelectAllAction;
- String origTitle;
-
- public BuildConsoleView() {
- super();
- fFont = null;
- fPropertyChangeListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (fTextViewer != null && event.getProperty().equals(BuildConsolePreferencePage.PREF_CONSOLE_FONT)) {
- initializeWidgetFont(fTextViewer.getTextWidget());
- }
- }
- };
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- store.addPropertyChangeListener(fPropertyChangeListener);
- fConsoleManager = CUIPlugin.getDefault().getConsoleManager();
- }
-
- private void initializeActions() {
- ResourceBundle bundle = CUIPlugin.getResourceBundle();
-
- IActionBars actionBars = getViewSite().getActionBars();
- fClearOutputAction = new ClearConsoleAction(this);
- fCopyAction = new BuildConsoleAction(bundle, "Editor.Copy.", fTextViewer, ITextOperationTarget.COPY);
- fSelectAllAction = new BuildConsoleAction(bundle, "Editor.SelectAll.", fTextViewer, ITextOperationTarget.SELECT_ALL);
-
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, fCopyAction);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, fSelectAllAction);
-
- fTextViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent e) {
- // ensures that the copyAction updates is doability when the selections tate changes
- fCopyAction.update();
- }
- });
- }
-
- /**
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite parent) {
- fTextViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP | SWT.MULTI);
- fTextViewer.addTextListener(new ITextListener() {
- public void textChanged(TextEvent event) {
- revealEndOfDocument();
- }
- });
- fTextViewer.setEditable(false);
- origTitle = getTitle();
- initializeWidgetFont(fTextViewer.getTextWidget());
-
- initializeActions();
- initializeContextMenu(fTextViewer.getControl());
- initializeToolBar();
-
- WorkbenchHelp.setHelp(fTextViewer.getControl(), ICHelpContextIds.CLEAR_CONSOLE_VIEW);
-
- setProject(getSite().getPage().getSelection());
- setDocument();
- setTitle();
- getSite().getPage().addSelectionListener(this);
- fConsoleManager.addConsoleListener(this);
- }
-
- protected void setProject(ISelection selection) {
- selProject = convertSelectionToProject(selection);
- }
-
- protected void setProject(IProject project) {
- selProject = project;
- }
-
- protected IProject getProject() {
- return selProject;
- }
-
- protected IDocument setDocument() {
- IProject project = getProject();
- if (project != null) {
- fTextViewer.setDocument(fConsoleManager.getConsoleDocument(project));
- }
- return null;
- }
-
- protected void setTitle() {
- String title = origTitle;
- IProject project = getProject();
- if (project != null) {
- title += " [" + project.getName() + "]";
- }
- setTitle(title);
- }
-
- protected void initializeWidgetFont(StyledText styledText) {
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- String prefKey = BuildConsolePreferencePage.PREF_CONSOLE_FONT;
- FontData data = null;
- if (store.contains(prefKey) && !store.isDefault(prefKey)) {
- data = PreferenceConverter.getFontData(store, prefKey);
- } else {
- data = PreferenceConverter.getDefaultFontData(store, prefKey);
- }
- if (data != null) {
- Font font = new Font(styledText.getDisplay(), data);
- styledText.setFont(font);
-
- if (fFont != null)
- fFont.dispose();
-
- fFont = font;
- } else {
- // if all the preferences failed
- styledText.setFont(JFaceResources.getTextFont());
- }
- }
-
- /**
- * @see IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- fTextViewer.getControl().setFocus();
- }
-
- /**
- * Initializes the context menu
- */
- protected void initializeContextMenu(Control parent) {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(parent);
- parent.setMenu(menu);
- }
-
- /**
- * Adds the text manipulation actions to the <code>ConsoleViewer</code>
- */
- protected void fillContextMenu(IMenuManager menu) {
- fCopyAction.update();
- menu.add(fCopyAction);
- menu.add(fSelectAllAction);
- menu.add(new Separator());
- menu.add(fClearOutputAction);
- }
-
- /**
- * Configures the toolBar.
- */
- private void initializeToolBar() {
- IActionBars actionBars = getViewSite().getActionBars();
- actionBars.getToolBarManager().add(fClearOutputAction);
- actionBars.updateActionBars();
- }
- /**
- * Reveals (makes visible) the end of the current document
- */
- protected void revealEndOfDocument() {
- IDocument doc = fTextViewer.getDocument();
- int docLength = doc.getLength();
- if (docLength > 0) {
- fTextViewer.revealRange(docLength - 1, 1);
- StyledText widget = fTextViewer.getTextWidget();
- widget.setCaretOffset(docLength);
- widget.showSelection();
- }
- }
- /**
- * @see WorkbenchPart#dispose()
- */
- public void dispose() {
- super.dispose();
- if (fPropertyChangeListener != null) {
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- store.removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener = null;
- }
- if (fFont != null) {
- fFont.dispose();
- fFont = null;
- }
- getSite().getPage().removeSelectionListener(this);
- fConsoleManager.removeConsoleListener(this);
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- IProject newProject = convertSelectionToProject(selection);
- IProject oldProject = getProject();
- if (oldProject == null || (newProject != null && !newProject.equals(oldProject))) {
- setProject(newProject);
- setDocument();
- setTitle();
- }
- }
-
- public void consoleChange(IBuildConsoleEvent event) {
- if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
- Display display = fTextViewer.getControl().getDisplay();
- selProject = event.getProject();
- if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && selProject != event.getProject()) {
- return;
- }
- display.asyncExec(new Runnable() {
- public void run() {
- setDocument();
- setTitle();
- }
- });
- }
- }
-
- IProject convertSelectionToProject(ISelection selection) {
- IProject project = null;
- if (selection == null || !(selection instanceof IStructuredSelection)) {
- return project;
- }
- IStructuredSelection ssel = (IStructuredSelection) selection;
- Object element = ssel.getFirstElement();
- if (element instanceof IAdaptable) {
- IAdaptable input = (IAdaptable) element;
- if (input != null) {
- IResource resource = null;
- if (input instanceof IResource) {
- resource = (IResource) input;
- } else {
- resource = (IResource) input.getAdapter(IResource.class);
- }
- if (resource != null) {
- project = resource.getProject();
- }
- }
- }
- return project;
- }
-
- /**
- * Clears the console
- */
- void clear() {
- if (selProject != null) {
- fConsoleManager.getConsole(selProject).clear();
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ClearConsoleAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ClearConsoleAction.java
deleted file mode 100644
index eb533fa7509..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ClearConsoleAction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-
-/**
- * Clears the output of the selected launches
- */
-public class ClearConsoleAction extends Action {
-
-
- private BuildConsoleView fConsoleView;
-
-
- public ClearConsoleAction(BuildConsoleView view) {
- super(CUIPlugin.getResourceString("ClearOutputAction.label"));
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_CLEAR_CONSOLE);
- fConsoleView= view;
- setToolTipText(CUIPlugin.getResourceString("ClearOutputAction.tooltip"));
- WorkbenchHelp.setHelp(this, ICHelpContextIds.CLEAR_CONSOLE_ACTION);
- }
-
- /**
- * @see Action
- */
- public void run() {
- fConsoleView.clear();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/AddIncludeOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/AddIncludeOperation.java
deleted file mode 100644
index bc46fea7f6f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/AddIncludeOperation.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package org.eclipse.cdt.internal.ui.codemanipulation;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IInclude;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
-import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
-import org.eclipse.cdt.ui.IRequiredInclude;
-import java.util.ArrayList;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-
-/**
- * Add includes to a translation unit.
- * The input is an array of full qualified type names. No elimination of unnecessary
- * includes is not done. Dublicates are eliminated.
- * If the translation unit is open in an editor, be sure to pass over its working copy.
- */
-public class AddIncludeOperation extends WorkspaceModifyOperation {
-
- private CFileElementWorkingCopy fTranslationUnit;
- private IRequiredInclude[] fIncludes;
- private boolean fDoSave;
- private ITextEditor fEditor;
-
- private IInclude[] fAddedIncludes;
-
- /**
- * Generate import statements for the passed java elements
- * Elements must be of type IType (-> single import) or IPackageFragment
- * (on-demand-import). Other JavaElements are ignored
- */
- public AddIncludeOperation(ITextEditor ed, CFileElementWorkingCopy tu, IRequiredInclude[] includes, boolean save) {
- super();
- fEditor = ed;
- fIncludes= includes;
- fTranslationUnit= tu;
- fAddedIncludes= null;
- fDoSave= save;
- }
-
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- ArrayList toAdd = new ArrayList();
-
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
-
- monitor.beginTask(CEditorMessages.getString("AddIncludesOperation.description"), 2); //$NON-NLS-1$
-
- ICElement root;
- // Look in content outline
- if(fEditor instanceof CEditor) {
- CContentOutlinePage outline = ((CEditor)fEditor).getOutlinePage();
- root = outline.getRoot();
- } else {
- root = fTranslationUnit;
- }
- if (root != null && root instanceof IParent && ((IParent)root).hasChildren()) {
- //// Get children of tu
- // Build list of include statement
- //fTranslationUnit.update();
- //if(fTranslationUnit.hasChildren()) {
- ICElement lastInclude = null;
- ICElement[] elements = ((IParent)root).getChildren();
-
- for(int j = 0; j < fIncludes.length; j++) {
- //System.out.println("Comparing to " + fIncludes[j].getIncludeName());
- toAdd.add(fIncludes[j]);
- }
-
- for(int i = 0; i < elements.length; i++) {
- if(elements[i].getElementType() == ICElement.C_INCLUDE) {
- lastInclude = elements[i];
- //System.out.println("Element " + elements[i].getElementName() + "sys " + ((IInclude)elements[i]).isStandard());
- for(int j = 0; j < toAdd.size(); j++) {
- //System.out.println("Comparing to " + ((IRequiredInclude)toAdd.get(j)).getIncludeName());
- if(elements[i].getElementName().equals(((IRequiredInclude)toAdd.get(j)).getIncludeName())) {
- toAdd.remove(j);
- }
- }
- }
- }
-
- if(toAdd.size() > 0) {
- // So we have our list. Now insert.
- StringBuffer insert = new StringBuffer("");
- for(int j = 0; j < toAdd.size(); j++) {
- insert.append("#include <" + ((IRequiredInclude)toAdd.get(j)).getIncludeName() + ">\n");
- }
- int pos;
-
- if(lastInclude != null) {
- ISourceRange range = ((IInclude)lastInclude).getSourceRange();
- pos = range.getStartPos() + range.getLength();
- } else {
- pos = 0;
- }
-
- IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
- try {
- // Now find the next newline and insert after that
- if(pos > 0) {
- while(document.getChar(pos) != '\n') pos++;
- if(document.getChar(pos) == '\r') pos++;
- pos++;
- }
- document.replace(pos, 0, insert.toString());
- } catch (BadLocationException e) {}
- }
-
- }
-
-
- /*for (int i= 0; i < nImports; i++) {
- IJavaElement imp= fIncludes[i];
- if (imp instanceof IType) {
- IType type= (IType)imp;
- String packageName= type.getPackageFragment().getElementName();
- impStructure.addImport(packageName, type.getElementName());
- } else if (imp instanceof IPackageFragment) {
- String packageName= ((IPackageFragment)imp).getElementName();
- impStructure.addImport(packageName, "*"); //$NON-NLS-1$
- }
- } */
- monitor.worked(1);
- //fAddedImports= impStructure.create(fDoSave, null);
- monitor.worked(1);
- } finally {
- monitor.done();
- }
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/StubUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/StubUtility.java
deleted file mode 100644
index 52497dcce96..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/codemanipulation/StubUtility.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.codemanipulation;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.CoreException;
-
-public class StubUtility {
-
- /**
- * @see org.eclipse.jdt.ui.CodeGeneration#getTypeComment(ICompilationUnit, String, String)
- */
- public static String getHeaderFileContent(ITranslationUnit cu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return "";
- }
- /**
- * @see org.eclipse.jdt.ui.CodeGeneration#getTypeComment(ICompilationUnit, String, String)
- */
- public static String getBodyFileContent(ITranslationUnit cu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return "";
- }
- /*
- * @see org.eclipse.jdt.ui.CodeGeneration#getTypeComment(ICompilationUnit, String, String)
- */
- public static String getClassComment(ITranslationUnit cu, String typeQualifiedName, String lineDelim) throws CoreException {
- return "";
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
deleted file mode 100644
index bcaa258415f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.cdt.internal.ui.compare;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-
-
-import org.eclipse.jface.viewers.Viewer;
-
-
-/**
- * Required when creating a CMergeViewer from the plugin.xml file.
- */
-public class CContentViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new CMergeViewer(parent, SWT.NULL, mp);
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
deleted file mode 100644
index 9e052265eb7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.cdt.internal.ui.compare;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.contentmergeviewer.ITokenComparator;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.compare.internal.TokenComparator;
-
-
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-
-public class CMergeViewer extends TextMergeViewer {
-
- private static final String TITLE= "CMergeViewer.title";
-
-
- public CMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
- super(parent, styles, mp);
- }
-
- public String getTitle() {
- return CUIPlugin.getResourceString(TITLE);
- }
-
-
- protected ITokenComparator createTokenComparator(String s) {
- return new TokenComparator(s);
- }
-
- protected IDocumentPartitioner getDocumentPartitioner() {
- return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner();
- }
-
- protected void configureTextViewer(TextViewer textViewer) {
- if (textViewer instanceof SourceViewer) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- ((SourceViewer)textViewer).configure(new CSourceViewerConfiguration(tools, null));
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
deleted file mode 100644
index a3d523d5d68..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.eclipse.cdt.internal.ui.compare;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CElementImageProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-/**
- *
- */
-
-class CNode extends DocumentRangeNode implements ITypedElement {
-
- private CNode fParent;
-
- public CNode(CNode parent, int type, String id, IDocument doc, int start, int length) {
- super(type, id, doc, start, length);
- fParent= parent;
- if (parent != null) {
- parent.addChild(this);
- }
- }
-
- public CNode(CNode parent, int type, String id, int start, int length) {
- this(parent, type, id, parent.getDocument(), start, length);
- }
-
- /**
- * @see ITypedInput#getName
- */
- public String getName() {
- return getId();
- }
-
- /**
- * @see ITypedInput#getType
- */
- public String getType() {
- return "c2"; //$NON-NLS-1$
- }
-
- /**
- * @see ITypedInput#getImage
- */
- public Image getImage() {
- ImageDescriptor descriptor = CElementImageProvider.getImageDescriptor(getTypeCode());
- return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CParseTreeBuilder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CParseTreeBuilder.java
deleted file mode 100644
index 6c8f545f54d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CParseTreeBuilder.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package org.eclipse.cdt.internal.ui.compare;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Stack;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.ast.ASTClassKind;
-import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.core.parser.ast.IASTMacro;
-import org.eclipse.cdt.core.parser.ast.IASTMethod;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
-import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.jface.text.IDocument;
-
-/**
- *
- */
-public class CParseTreeBuilder extends SourceElementRequestorAdapter {
-
- private Stack fStack = new Stack();
- private IDocument fDocument;
-
- /**
- * Syntax Error.
- */
- public class ParseError extends Error {
- }
-
- public CParseTreeBuilder(CNode root, IDocument doc) {
- fDocument = doc;
- fStack.clear();
- fStack.push(root);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
- String name = classSpecification.getName();
- int start = classSpecification.getStartingOffset();
- if (classSpecification.getClassKind().equals(ASTClassKind.CLASS)) {
- push(ICElement.C_CLASS, name, start);
- } else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT)) {
- push(ICElement.C_STRUCT, name, start);
- } else if (classSpecification.getClassKind().equals(ASTClassKind.UNION)) {
- push(ICElement.C_UNION, name, start);
- } else if (classSpecification.getClassKind().equals(ASTClassKind.ENUM)) {
- push(ICElement.C_ENUMERATION, name, start);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
- push(ICElement.C_UNIT, "Translation Unit", 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void enterFunctionBody(IASTFunction function) {
- push(ICElement.C_FUNCTION, function.getName(), function.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
- public void enterInclusion(IASTInclusion inclusion) {
- push(ICElement.C_INCLUDE, inclusion.getName(), inclusion.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- push(ICElement.C_STORAGE_EXTERN, linkageSpec.getLinkageString(), linkageSpec.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void enterMethodBody(IASTMethod method) {
- push(ICElement.C_METHOD, method.getName(), method.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- push(ICElement.C_NAMESPACE, namespaceDefinition.getName(), namespaceDefinition.getStartingOffset());;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
- push(ICElement.C_TEMPLATE_VARIABLE, "export", declaration.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {
- push(ICElement.C_TEMPLATE_VARIABLE, "template instanciation", instantiation.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
- push(ICElement.C_TEMPLATE_VARIABLE, "template specialization", specialization.getStartingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- pop(classSpecification.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void exitCompilationUnit(IASTCompilationUnit translationUnit) {
- pop(fDocument.getLength());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void exitFunctionBody(IASTFunction function) {
- pop(function.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
- public void exitInclusion(IASTInclusion inclusion) {
- pop(inclusion.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- pop(linkageSpec.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void exitMethodBody(IASTMethod method) {
- pop(method.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- pop(namespaceDefinition.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
- pop(declaration.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
- pop(instantiation.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
- pop(specialization.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
- */
- public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- push(ICElement.C_ENUMERATION, enumeration.getName(), enumeration.getStartingOffset());
- pop(enumeration.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void acceptFunctionDeclaration(IASTFunction function) {
- push(ICElement.C_FUNCTION_DECLARATION, function.getName(), function.getStartingOffset());
- pop(function.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
- */
- public void acceptMacro(IASTMacro macro) {
- push(ICElement.C_MACRO, macro.getName(), macro.getStartingOffset());
- pop(macro.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void acceptMethodDeclaration(IASTMethod method) {
- push(ICElement.C_METHOD_DECLARATION, method.getName(), method.getStartingOffset());
- pop(method.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
- */
- public boolean acceptProblem(IProblem problem) {
- int problemId = problem.getID();
- if (problem.isError() && ((problemId & IProblem.SYNTAX_RELATED) != 0)) {
- throw new ParseError();
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefDeclaration(org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration)
- */
- public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) {
- push(ICElement.C_TYPEDEF, typedef.getName(), typedef.getStartingOffset());
- pop(typedef.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
- */
- public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
- push(ICElement.C_USING, usageDeclaration.usingTypeName(), usageDeclaration.getStartingOffset());
- pop(usageDeclaration.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
- */
- public void acceptUsingDirective(IASTUsingDirective usageDirective) {
- push(ICElement.C_USING, usageDirective.getNamespaceName(), usageDirective.getStartingOffset());
- pop(usageDirective.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
- */
- public void acceptVariable(IASTVariable variable) {
- push(ICElement.C_VARIABLE, variable.getName(), variable.getStartingOffset());
- pop(variable.getEndingOffset());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
- */
- public void acceptField(IASTField field) {
- push(ICElement.C_FIELD, field.getName(), field.getStartingOffset());
- pop(field.getEndingOffset());
- }
-
- private CNode getCurrentContainer() {
- return (CNode) fStack.peek();
- }
-
- /**
- * Adds a new JavaNode with the given type and name to the current container.
- */
- private void push(int type, String name, int declarationStart) {
- fStack.push(new CNode(getCurrentContainer(), type, name, declarationStart, 0));
- }
-
- /**
- * Closes the current Java node by setting its end position
- * and pops it off the stack.
- */
- private void pop(int declarationEnd) {
- CNode current = getCurrentContainer();
- if (current.getTypeCode() == ICElement.C_UNIT) {
- current.setAppendPosition(declarationEnd + 1);
- } else {
- current.setAppendPosition(declarationEnd);
- }
- current.setLength(declarationEnd - current.getRange().getOffset() + 1);
- fStack.pop();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
deleted file mode 100644
index 549a997ec34..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.eclipse.cdt.internal.ui.compare;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.ParserUtil;
-import org.eclipse.cdt.core.parser.IParser;
-import org.eclipse.cdt.core.parser.IScanner;
-import org.eclipse.cdt.core.parser.ISourceElementRequestor;
-import org.eclipse.cdt.core.parser.ParserFactory;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.compare.IEditableContent;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-/**
- *
- */
-public class CStructureCreator implements IStructureCreator {
-
- private static final String NAME = "CStructureCreator.name";
-
- public CStructureCreator() {
- }
-
- /**
- * @see IStructureCreator#getTitle
- */
- public String getName() {
- return CUIPlugin.getResourceString(NAME);
- }
-
- /**
- * @see IStructureCreator#getStructure
- */
- public IStructureComparator getStructure(Object input) {
-
- String s = null;
- if (input instanceof IStreamContentAccessor) {
- try {
- s = readString(((IStreamContentAccessor) input).getContents());
- } catch (CoreException ex) {
- }
- }
-
- if (s == null) {
- s = new String();
- }
- Document doc = new Document(s);
-
- CNode root = new CNode(null, ICElement.C_UNIT, "root", doc, 0, 0);
-
- ISourceElementRequestor builder = new CParseTreeBuilder(root, doc);
- try {
- //Using the CPP parser (was implicit before, now its explicit). If there
- //are bugs while parsing C files, we might want to create a separate Structure
- //compare for c files, but we'll never be completely right about .h files
- IScanner scanner =
- ParserFactory.createScanner(new StringReader(s), "code", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, builder,ParserUtil.getParserLogService());
- IParser parser = ParserFactory.createParser(scanner, builder, ParserMode.QUICK_PARSE, ParserLanguage.CPP, ParserUtil.getParserLogService() );
- parser.parse();
- } catch (Exception e) {
- // What to do when error ?
- // The CParseTreeBuilder will throw CParseTreeBuilder.ParseError
- // for acceptProblem.
-
- //TODO : New : ParserFactoryException gets thrown by ParserFactory primitives
- }
-
- return root;
- }
-
- /**
- * @see IStructureCreator#canSave
- */
- public boolean canSave() {
- return true;
- }
-
- /**
- * @see IStructureCreator#locate
- */
- public IStructureComparator locate(Object path, Object source) {
- return null;
- }
-
- /**
- * @see IStructureCreator#canRewriteTree
- */
- public boolean canRewriteTree() {
- return false;
- }
-
- /**
- * @see IStructureCreator#rewriteTree
- */
- public void rewriteTree(Differencer differencer, IDiffContainer root) {
- }
-
- /**
- * @see IStructureCreator#save
- */
- public void save(IStructureComparator structure, Object input) {
- if (input instanceof IEditableContent && structure instanceof CNode) {
- IDocument doc = ((CNode) structure).getDocument();
- IEditableContent bca = (IEditableContent) input;
- String c = doc.get();
- bca.setContent(c.getBytes());
- }
- }
-
- /**
- * @see IStructureCreator#getContents
- */
- public String getContents(Object node, boolean ignoreWhitespace) {
- if (node instanceof IStreamContentAccessor) {
- IStreamContentAccessor sca = (IStreamContentAccessor) node;
- try {
- return readString(sca.getContents());
- } catch (CoreException ex) {
- }
- }
- return null;
- }
-
- /**
- * Returns null if an error occurred.
- */
- private static String readString(InputStream is) {
- if (is == null)
- return null;
- BufferedReader reader = null;
- try {
- StringBuffer buffer = new StringBuffer();
- char[] part = new char[2048];
- int read = 0;
- reader = new BufferedReader(new InputStreamReader(is));
-
- while ((read = reader.read(part)) != -1)
- buffer.append(part, 0, read);
-
- return buffer.toString();
-
- } catch (IOException ex) {
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ex) {
- }
- }
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java
deleted file mode 100644
index cf2836c9dba..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*******************************************************************************
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * QnX Software Systems - initial implementation base on code from rational/IBM
- ******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.cdt.core.parser.DefaultProblemHandler;
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.ISourceElementRequestor;
-import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTClassReference;
-import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
-import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
-import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumeratorReference;
-import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
-import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.core.parser.ast.IASTMacro;
-import org.eclipse.cdt.core.parser.ast.IASTMethod;
-import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
-import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
-import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
-
-/**
- *
- */
-public class SourceElementRequestorAdapter implements ISourceElementRequestor {
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptAbstractTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration)
- */
- public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
- */
- public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassReference)
- */
- public void acceptClassReference(IASTClassReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
- */
- public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
- */
- public void acceptEnumerationReference(IASTEnumerationReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
- */
- public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
- */
- public void acceptField(IASTField field) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFieldReference(org.eclipse.cdt.core.parser.ast.IASTFieldReference)
- */
- public void acceptFieldReference(IASTFieldReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void acceptFunctionDeclaration(IASTFunction function) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionReference(org.eclipse.cdt.core.parser.ast.IASTFunctionReference)
- */
- public void acceptFunctionReference(IASTFunctionReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
- */
- public void acceptMacro(IASTMacro macro) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void acceptMethodDeclaration(IASTMethod method) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodReference(org.eclipse.cdt.core.parser.ast.IASTMethodReference)
- */
- public void acceptMethodReference(IASTMethodReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptNamespaceReference(org.eclipse.cdt.core.parser.ast.IASTNamespaceReference)
- */
- public void acceptNamespaceReference(IASTNamespaceReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
- */
- public boolean acceptProblem(IProblem problem) {
- return DefaultProblemHandler.ruleOnProblem( problem, ParserMode.QUICK_PARSE );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefDeclaration(org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration)
- */
- public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)
- */
- public void acceptTypedefReference(IASTTypedefReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
- */
- public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
- */
- public void acceptUsingDirective(IASTUsingDirective usageDirective) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
- */
- public void acceptVariable(IASTVariable variable) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariableReference(org.eclipse.cdt.core.parser.ast.IASTVariableReference)
- */
- public void acceptVariableReference(IASTVariableReference reference) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void enterFunctionBody(IASTFunction function) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
- public void enterInclusion(IASTInclusion inclusion) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void enterMethodBody(IASTMethod method) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void exitFunctionBody(IASTFunction function) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
- public void exitInclusion(IASTInclusion inclusion) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void exitMethodBody(IASTMethod method) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
- */
- public void enterCodeBlock(IASTCodeScope scope) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
- */
- public void exitCodeBlock(IASTCodeScope scope) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumeratorReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
- */
- public void acceptEnumeratorReference(IASTEnumeratorReference reference)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
- */
- public void acceptParameterReference(IASTParameterReference reference)
- {
- // TODO Auto-generated method stub
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CElementFilters.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CElementFilters.java
deleted file mode 100644
index d3470f85dea..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CElementFilters.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-
-import org.eclipse.cdt.internal.ui.util.StringMatcher;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * The FiltersContent provides the elements for use by the list dialog
- * for selecting the patterns to apply.
- */
-public class CElementFilters {
- static List definedFilters = null;
- static List defaultFilters = null;
- static StringMatcher [] matchers = null;
- static String FILTERS_TAG= "CElementFilters"; //$NON-NLS-1$
- static String COMMA_SEPARATOR = ","; //$NON-NLS-1$
-
- /**
- * Returns the filters which are enabled by default.
- *
- * @return a list of strings
- */
- public static List getDefaultFilters() {
- if (defaultFilters == null) {
- readFilters();
- }
- return defaultFilters;
- }
-
- /**
- * Returns the filters currently defined for the workbench.
- */
- public static List getDefinedFilters() {
- if (definedFilters == null) {
- // Overide the default by the user preference
- CUIPlugin plugin = CUIPlugin.getDefault();
- String storedPatterns= plugin.getPluginPreferences().getString(FILTERS_TAG);
-
- if (storedPatterns.length() > 0) {
- StringTokenizer entries = new StringTokenizer(storedPatterns, COMMA_SEPARATOR);
- definedFilters = new ArrayList();
-
- while (entries.hasMoreElements()) {
- String nextToken = entries.nextToken();
- definedFilters.add(nextToken);
- }
- } else {
- readFilters();
- }
- }
- return definedFilters;
- }
-
- public static StringMatcher [] getMatchers() {
- if (matchers == null) {
- List list = getDefinedFilters();
- matchers = new StringMatcher[list.size()];
- for (int i = 0; i < matchers.length; i++) {
- matchers[i] = new StringMatcher((String)(list.get(i)), true, false);
- }
- }
- return matchers;
- }
-
- /**
- * Define new Patterns for the Duration of the session.
- */
- public static void setPatterns(String[] newPatterns) {
- //System.out.println ("SetPatterns call");
- matchers = new StringMatcher[newPatterns.length];
- for (int i = 0; i < newPatterns.length; i++) {
- //System.out.println ("Patterns " + newPatterns[i]);
- matchers[i] = new StringMatcher(newPatterns[i], true, false);
- }
- //CElementFactory.getDefault().refreshDeadBranchParents();
- }
-
-
- public static boolean match(String name) {
- StringMatcher [] m = getMatchers();
- if (m == null)
- return false;
- //System.out.println ("Pattern " + name);
- for (int i = 0; i < m.length; i++) {
- if (m[i].match(name)) {
- //System.out.println ("Match " + name);
- return true;
- }
- }
- return false;
- }
-
- private CElementFilters() {
- }
- /**
- * Reads the filters currently defined for the workbench.
- */
- static void readFilters() {
- definedFilters = new ArrayList();
- defaultFilters = new ArrayList();
- CUIPlugin plugin = CUIPlugin.getDefault();
- if (plugin != null) {
- IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(FILTERS_TAG);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for(int i = 0; i < extensions.length; i++){
- IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
- for(int j = 0; j < configElements.length; j++){
- String pattern = configElements[j].getAttribute("pattern"); //$NON-NLS-1$
- if (pattern != null)
- definedFilters.add(pattern);
- String selected = configElements[j].getAttribute("selected"); //$NON-NLS-1$
- if (selected != null && selected.equalsIgnoreCase("true")) //$NON-NLS-1$
- defaultFilters.add(pattern);
- }
- }
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CLibFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CLibFilter.java
deleted file mode 100644
index 64c471e9c3c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CLibFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-import org.eclipse.cdt.core.model.ILibraryReference;
-
-public class CLibFilter extends ViewerFilter {
- private boolean showlib = true;
-
- public boolean getShowLibraries() {
- return showlib;
- }
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof ILibraryReference) {
- return showlib;
- }
- return true;
- }
-
- public void setShowLibraries (boolean show) {
- showlib = show;
- }
-
- /**
- * Creates a new library filter.
- */
- public CLibFilter() {
- super();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CPatternFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CPatternFilter.java
deleted file mode 100644
index 019e2bfb1b0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CPatternFilter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.List;
-import java.util.Vector;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.cdt.internal.ui.util.StringMatcher;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICProject;
-
-public class CPatternFilter extends ViewerFilter {
- private String[] patterns;
- private StringMatcher[] matchers;
-
- static String COMMA_SEPARATOR = ","; //$NON-NLS-1$
- static String FILTERS_TAG= "CElementFilters"; //$NON-NLS-1$
-
- private void initializeFromPreferences() {
- CUIPlugin plugin= CUIPlugin.getDefault();
- String storedPatterns= plugin.getPreferenceStore().getString(FILTERS_TAG);
-
- if (storedPatterns.length() == 0) {
- List defaultFilters= FiltersContentProvider.getDefaultFilters();
- String[] patterns= new String[defaultFilters.size()];
- defaultFilters.toArray(patterns);
- setPatterns(patterns);
- return;
- }
-
- //Get the strings separated by a comma and filter them from the currently
- //defined ones
-
- List definedFilters = FiltersContentProvider.getDefinedFilters();
-
- StringTokenizer entries = new StringTokenizer(storedPatterns, COMMA_SEPARATOR);
- Vector patterns = new Vector();
-
- while (entries.hasMoreElements()) {
- String nextToken = entries.nextToken();
- if (definedFilters.indexOf(nextToken) > -1)
- patterns.addElement(nextToken);
- }
-
- //Convert to an array of Strings
- String[] patternArray = new String[patterns.size()];
- patterns.toArray(patternArray);
- setPatterns(patternArray);
- }
-
- /**
- * Gets the patterns for the receiver. Returns the cached values if there
- * are any - if not look it up.
- */
- public String[] getPatterns() {
- if (patterns == null) {
- initializeFromPreferences();
- }
- return patterns;
- }
-
- /**
- * Sets the patterns to filter out for the receiver.
- */
- public void setPatterns(String[] newPatterns) {
-
- patterns = newPatterns;
- matchers = new StringMatcher[newPatterns.length];
- for (int i = 0; i < newPatterns.length; i++) {
- //Reset the matchers to prevent constructor overhead
- matchers[i] = new StringMatcher(newPatterns[i], true, false);
- }
- }
-
-
- /**
- * Return the currently configured StringMatchers. If there aren't any look
- * them up.
- */
- private StringMatcher[] getMatchers() {
- if (matchers == null)
- initializeFromPreferences();
- return matchers;
- }
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- IResource resource = null;
- if (element instanceof IResource) {
- resource = (IResource) element;
- } else if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- resource = (IResource) adaptable.getAdapter(IResource.class);
- }
-
- // Only apply the rule for Projects and folders.
- if (parentElement instanceof ICProject
- || parentElement instanceof ICContainer) {
- if (resource != null) {
- String name = resource.getName();
- StringMatcher[] testMatchers = getMatchers();
- for (int i = 0; i < testMatchers.length; i++) {
- if (testMatchers[i].match(name))
- return false;
- }
- }
- }
- return true;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
deleted file mode 100644
index 77cefef89a8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
+++ /dev/null
@@ -1,1373 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.IBinaryModule;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.CProject;
-import org.eclipse.cdt.internal.core.model.TranslationUnit;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
-import org.eclipse.cdt.internal.ui.drag.DelegatingDragAdapter;
-import org.eclipse.cdt.internal.ui.drag.FileTransferDragAdapter;
-import org.eclipse.cdt.internal.ui.drag.LocalSelectionTransferDragAdapter;
-import org.eclipse.cdt.internal.ui.drag.ResourceTransferDragAdapter;
-import org.eclipse.cdt.internal.ui.drag.TransferDragSourceListener;
-import org.eclipse.cdt.internal.ui.editor.FileSearchAction;
-import org.eclipse.cdt.internal.ui.editor.FileSearchActionInWorkingSet;
-import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
-import org.eclipse.cdt.internal.ui.editor.SearchDialogAction;
-import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.cdt.ui.CLocalSelectionTransfer;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.GroupMarker;
-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.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeViewerListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeExpansionEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ResourceWorkingSetFilter;
-import org.eclipse.ui.actions.AddBookmarkAction;
-import org.eclipse.ui.actions.BuildAction;
-import org.eclipse.ui.actions.CloseResourceAction;
-import org.eclipse.ui.actions.CopyResourceAction;
-import org.eclipse.ui.actions.DeleteResourceAction;
-import org.eclipse.ui.actions.MoveResourceAction;
-import org.eclipse.ui.actions.NewWizardMenu;
-import org.eclipse.ui.actions.OpenFileAction;
-import org.eclipse.ui.actions.OpenInNewWindowAction;
-import org.eclipse.ui.actions.OpenResourceAction;
-import org.eclipse.ui.actions.OpenSystemEditorAction;
-import org.eclipse.ui.actions.OpenWithMenu;
-import org.eclipse.ui.actions.RefreshAction;
-import org.eclipse.ui.actions.RenameResourceAction;
-import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.ui.part.IShowInTarget;
-import org.eclipse.ui.part.PluginTransfer;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.framelist.BackAction;
-import org.eclipse.ui.views.framelist.ForwardAction;
-import org.eclipse.ui.views.framelist.FrameList;
-import org.eclipse.ui.views.framelist.GoIntoAction;
-import org.eclipse.ui.views.framelist.UpAction;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-
-
-
-
-public class CView extends ViewPart implements IMenuListener, ISetSelectionTarget,
- IPropertyChangeListener, IShowInTarget {
-
- ProblemTreeViewer viewer;
- IMemento memento;
-
- // Actions for Menu context.
- AddBookmarkAction addBookmarkAction;
- CopyResourceAction copyResourceAction;
- DeleteResourceAction deleteResourceAction;
- OpenFileAction openFileAction;
- OpenSystemEditorAction openSystemEditorAction;
- PropertyDialogAction propertyDialogAction;
- RefreshAction refreshAction;
- RenameResourceAction renameResourceAction;
- MoveResourceAction moveResourceAction;
-
- CloseResourceAction closeProjectAction;
- OpenResourceAction openProjectAction;
- BuildAction buildAction;
- BuildAction rebuildAction;
-
- // CElement action
- OpenIncludeAction openIncludeAction;
-
- BackAction backAction;
- ForwardAction forwardAction;
- GoIntoAction goIntoAction;
- UpAction upAction;
- WorkingSetFilterActionGroup wsFilterActionGroup;
-
- FrameList frameList;
- CViewFrameSource frameSource;
-
- CPatternFilter patternFilter = new CPatternFilter ();
- FilterSelectionAction patternFilterAction;
-
- CLibFilter clibFilter = new CLibFilter ();
- ShowLibrariesAction clibFilterAction;
-
- ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter();
-
- ActionContributionItem adjustWorkingSetContributions [] = new ActionContributionItem[5];
-
- // Collapsing
- CollapseAllAction collapseAllAction;
-
- //Search
- FileSearchAction fFileSearchAction;
- FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
- SearchDialogAction fSearchDialogAction;
-
- // Persistance tags.
- static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
- static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$
- static final String TAG_ELEMENT= "element"; //$NON-NLS-1$
- static final String TAG_PATH= "path"; //$NON-NLS-1$
- static final String TAG_VERTICAL_POSITION= "verticalPosition"; //$NON-NLS-1$
- static final String TAG_HORIZONTAL_POSITION= "horizontalPosition"; //$NON-NLS-1$
- static final String TAG_FILTERS = "filters"; //$NON-NLS-1$
- static final String TAG_FILTER = "filter"; //$NON-NLS-1$
- static final String TAG_SHOWLIBRARIES = "showLibraries"; //$NON-NLS-1$
- static final String TAG_WORKINGSET = "workingSet"; //$NON-NLS-1$
-
- //Menu tags
- final String WORKING_GROUP_MARKER = "workingSetGroup";
- final String WORKING_GROUP_MARKER_END = "end-workingSetGroup";
-
- // Menu tags for the build
- final String BUILD_GROUP_MARKER = "buildGroup";
- final String BUILD_GROUP_MARKER_END = "end-buildGroup";
-
- private IPartListener partListener = new IPartListener() {
- public void partActivated(IWorkbenchPart part) {
- if (part instanceof IEditorPart) {
- editorActivated((IEditorPart) part);
- }
- }
- public void partBroughtToTop(IWorkbenchPart part) {}
- public void partClosed(IWorkbenchPart part) {}
- public void partDeactivated(IWorkbenchPart part) {}
- public void partOpened(IWorkbenchPart part) {}
- };
-
- private IPropertyChangeListener workingSetListener = new IPropertyChangeListener() {
- private void doViewerUpdate() {
- viewer.getControl().setRedraw(false);
- viewer.refresh();
- viewer.getControl().setRedraw(true);
- }
-
- public void propertyChange(PropertyChangeEvent ev) {
- String prop = ev.getProperty();
- if(prop == null) {
- return;
- }
-
- if(prop.equals(WorkingSetFilterActionGroup.CHANGE_WORKING_SET)) {
- workingSetFilter.setWorkingSet((IWorkingSet)ev.getNewValue());
- doViewerUpdate();
- } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)){
- if(ev.getOldValue() instanceof IWorkingSet && workingSetFilter.getWorkingSet() != null) {
- if(workingSetFilter.getWorkingSet().equals(ev.getOldValue())) {
- doViewerUpdate();
- }
- }
- } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
- if(ev.getOldValue() instanceof IWorkingSet && workingSetFilter.getWorkingSet() != null) {
- if(workingSetFilter.getWorkingSet().equals(ev.getOldValue())) {
- workingSetFilter.setWorkingSet(null);
- doViewerUpdate();
- }
- }
- }
- }
- };
-
- public CView() {
- super();
- }
-
- /**
- * @see IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- viewer.getTree().setFocus();
- //composite.setFocus ();
- }
-
- /**
- * Reveal and select the passed element selection in self's visual component
- * @see ISetSelectionTarget#selectReveal()
- */
- public void selectReveal(ISelection selection) {
- IStructuredSelection ssel = convertSelectionToCElement(selection);
- if (!ssel.isEmpty()) {
- getResourceViewer().setSelection(ssel, true);
- }
- }
-
- private ITreeViewerListener expansionListener= new ITreeViewerListener() {
- public void treeCollapsed(TreeExpansionEvent event) {
- }
-
- public void treeExpanded(TreeExpansionEvent event) {
- final Object element= event.getElement();
- if (element instanceof IParent) {
- //viewer.refresh (element);
- Control ctrl= viewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.getDisplay().asyncExec(new Runnable() {
- public void run() {
- Control ctrl= viewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- viewer.expandToLevel(element, 1);
- }
- }
- });
- }
- }
- }
- };
-
- /**
- * Handles double clicks in viewer.
- * Opens editor if file double-clicked.
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- IStructuredSelection s = (IStructuredSelection)event.getSelection();
- IAdaptable element = (IAdaptable)s.getFirstElement();
- IEditorPart part = null;
- //System.out.println ("Double click on " + element);
-
- try {
- part = EditorUtility.openInEditor(element);
- if (part != null) {
- IWorkbenchPage page = getSite().getPage();
- page.bringToTop(part);
- if (element instanceof ISourceReference) {
- EditorUtility.revealInEditor(part, (ICElement)element);
- }
- }
- } catch (Exception e) {
- }
- if (part == null && viewer.isExpandable(element)) {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- }
-
- /**
- * Handles key events in viewer.
- */
- void handleKeyPressed(KeyEvent event) {
- if (event.character == SWT.DEL
- && event.stateMask == 0 && deleteResourceAction.isEnabled()) {
- IStructuredSelection isel = deleteResourceAction.getStructuredSelection();
- Object[] array = isel.toArray();
- for (int i = 0; i < array.length; i++){
- if (array[i] instanceof IBinaryContainer
- || array[i] instanceof IArchiveContainer) {
- return;
- }
- }
- deleteResourceAction.run();
- }
- }
-
-
- /* (non-Javadoc)
- * Method declared on IViewPart.
- */
- public void init(IViewSite site,IMemento memento) throws PartInitException {
- super.init(site,memento);
- this.memento = memento;
- }
-
- void initFrameList() {
- frameSource = new CViewFrameSource(this);
- frameList = new FrameList(frameSource);
- frameSource.connectTo(frameList);
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key.equals(ISelectionProvider.class))
- return viewer;
- return super.getAdapter(key);
- }
-
-
- /**
- * Adds drag and drop support to the navigator.
- */
- void initDragAndDrop() {
- int ops = DND.DROP_COPY | DND.DROP_MOVE;
-
- Transfer[] dragTransfers =
- new Transfer[] {
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- CLocalSelectionTransfer.getInstance(),
- PluginTransfer.getInstance()};
-
- TransferDragSourceListener[] dragListeners =
- new TransferDragSourceListener[] {
- new ResourceTransferDragAdapter(viewer),
- new LocalSelectionTransferDragAdapter(viewer),
- new FileTransferDragAdapter(viewer)};
-
- viewer.addDragSupport(ops, dragTransfers, new DelegatingDragAdapter(viewer, dragListeners));
-
- Transfer[] dropTransfers =
- new Transfer[] {
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- LocalSelectionTransfer.getInstance(),
- PluginTransfer.getInstance()};
-
- viewer.addDropSupport(ops, dropTransfers, new CViewDropAdapter(viewer));
-
- }
-
- /**
- * Initializes the default preferences
- */
- public static void initDefaults(IPreferenceStore store) {
- store.setDefault(TAG_SHOWLIBRARIES, true);
- }
-
- void initFilterFromPreferences() {
- CUIPlugin plugin = CUIPlugin.getDefault();
- boolean show = plugin.getPreferenceStore().getBoolean(TAG_SHOWLIBRARIES);
- getLibraryFilter().setShowLibraries(show);
- }
-
- /**
- * Create the KeyListener for doing the refresh on the viewer.
- */
- void initRefreshKey() {
- viewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- if (event.keyCode == SWT.F5) {
- refreshAction.selectionChanged(
- (IStructuredSelection)viewer.getSelection());
- if (refreshAction.isEnabled())
- refreshAction.run();
- }
- }
- });
- }
-
- /**
- * Handles selection changed in viewer.
- * Updates global actions.
- * Links to editor (if option enabled)
- */
- void handleSelectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- updateStatusLine(sel);
- updateActions(sel);
- updateGlobalActions(sel);
- goIntoAction.update();
- linkToEditor(sel);
- }
-
-
- /**
- * @see ContentOutlinePage#createControl
- */
- public void createPartControl (Composite parent) {
-
- viewer = createViewer(parent);
- viewer.setUseHashlookup (true);
- CElementContentProvider provider = createContentProvider();
- viewer.setContentProvider(provider);
- setLabelDecorator(PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
- CUIPlugin.getDefault().getProblemMarkerManager().addListener(viewer);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-
- // FIXME: Add Drag and Drop support.
- initFrameList();
- initRefreshKey();
- updateTitle();
- initDragAndDrop();
- viewer.addFilter(patternFilter);
- viewer.addFilter(workingSetFilter);
- //viewer.addFilter(clibFilter);
- viewer.setSorter(new CViewSorter ());
- // FIXME: Add different Sorting.
- if(memento != null)
- restoreFilters();
- else
- initFilterFromPreferences();
-
- viewer.setInput (CoreModel.getDefault().getCModel());
-
- MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
-
- Control control = viewer.getControl();
- Menu menu = menuMgr.createContextMenu(viewer.getTree ());
- control.setMenu (menu);
-
- // Make the Actions for the Context Menu
- makeActions();
-
- //Add the property changes after all of the UI work has been done.
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- wsmanager.addPropertyChangeListener(workingSetListener);
-
- viewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged(event);
- }
- });
-
- viewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
- });
-
- viewer.addTreeListener(expansionListener);
-
- getSite().registerContextMenu(menuMgr, viewer);
- getSite().setSelectionProvider(viewer);
- getSite().getPage().addPartListener(partListener);
-
- if (memento != null)
- restoreState (memento);
- memento = null;
-
- fillActionBars();
-
- }
-
- protected ProblemTreeViewer createViewer(Composite parent) {
- return new ProblemTreeViewer (parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- }
-
- protected CElementContentProvider createContentProvider() {
- boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren();
- return new CElementContentProvider(showCUChildren, true);
- }
-
- protected StandardCElementLabelProvider createLabelProvider () {
- return new StandardCElementLabelProvider();
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchPart.
- */
- public void dispose() {
- getSite().getPage().removePartListener(partListener);
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- if (viewer != null) {
- viewer.removeTreeListener(expansionListener);
- CUIPlugin.getDefault().getProblemMarkerManager().removeListener(viewer);
- }
- IWorkspace workspace = CUIPlugin.getWorkspace();
- workspace.removeResourceChangeListener(closeProjectAction);
- workspace.removeResourceChangeListener(openProjectAction);
-
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- wsmanager.removePropertyChangeListener(workingSetListener);
-
- super.dispose();
- }
-
- /**
- * An editor has been activated. Set the selection in this navigator
- * to be the editor's input, if linking is enabled.
- */
- void editorActivated(IEditorPart editor) {
- if (!CPluginPreferencePage.isLinkToEditor()) {
- return;
- }
-
- IEditorInput input = editor.getEditorInput();
- if (input instanceof IFileEditorInput) {
- CoreModel factory = CoreModel.getDefault();
- IFileEditorInput fileInput = (IFileEditorInput) input;
- IFile file = fileInput.getFile();
- ICElement celement = factory.create(file);
- if (celement != null) {
- ISelection newSelection = new StructuredSelection(celement);
- if (!viewer.getSelection().equals(newSelection)) {
- viewer.setSelection(newSelection);
- }
- }
- }
- }
-
- CLibFilter getLibraryFilter () {
- return clibFilter;
- }
-
- /**
- * Returns the pattern filter for this view.
- * @return the pattern filter
- */
- CPatternFilter getPatternFilter() {
- return patternFilter;
- }
-
-// /**
-// * Returns the working set filter for this view.
-// * @return the working set filter
-// */
-// CWorkingSetFilter getWorkingSetFilter() {
-// return workingSetFilter;
-// }
-
- TreeViewer getViewer () {
- return viewer;
- }
-
- /**
- * Create self's action objects
- */
- void makeActions() {
- Shell shell = getViewSite().getShell();
-
- openIncludeAction = new OpenIncludeAction (viewer);
- openFileAction = new OpenFileAction(getSite().getPage());
- openSystemEditorAction = new OpenSystemEditorAction(getSite().getPage());
- refreshAction = new RefreshAction(shell);
- buildAction = new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD);
- rebuildAction = new BuildAction(shell, IncrementalProjectBuilder.FULL_BUILD);
- moveResourceAction = new MoveResourceAction (shell);
- copyResourceAction = new CopyResourceAction(shell);
- renameResourceAction = new RenameResourceAction(shell, viewer.getTree());
- deleteResourceAction = new DeleteResourceAction(shell);
-
- IWorkspace workspace = CUIPlugin.getWorkspace();
-
- openProjectAction = new OpenResourceAction(shell);
- workspace.addResourceChangeListener(openProjectAction, IResourceChangeEvent.POST_CHANGE);
- closeProjectAction = new CloseResourceAction(shell);
- workspace.addResourceChangeListener(closeProjectAction, IResourceChangeEvent.POST_CHANGE);
-
- //sortByNameAction = new SortViewAction(this, false);
- //sortByTypeAction = new SortViewAction(this, true);
- patternFilterAction = new FilterSelectionAction(shell, this, "Filters...");
- clibFilterAction = new ShowLibrariesAction(shell, this, "Show Referenced Libs");
-
- wsFilterActionGroup = new WorkingSetFilterActionGroup(getViewSite().getShell(), workingSetListener);
-
- goIntoAction = new GoIntoAction(frameList);
- backAction = new BackAction(frameList);
- forwardAction = new ForwardAction(frameList);
- upAction = new UpAction(frameList);
-
- addBookmarkAction = new AddBookmarkAction(shell);
- //propertyDialogAction = new PropertyDialogAction(shell, viewer);
- propertyDialogAction = new PropertyDialogAction(shell,
- new ISelectionProvider () {
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- viewer.addSelectionChangedListener (listener);
- }
- public ISelection getSelection() {
- return convertSelection (viewer.getSelection ());
- }
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- viewer.removeSelectionChangedListener (listener);
- }
- public void setSelection(ISelection selection) {
- viewer.setSelection (selection);
- }
- });
-
- IActionBars actionBars = getViewSite().getActionBars();
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, deleteResourceAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, addBookmarkAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.REFRESH, refreshAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BUILD_PROJECT, buildAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.REBUILD_PROJECT, rebuildAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.OPEN_PROJECT, openProjectAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.CLOSE_PROJECT, closeProjectAction);
-
- collapseAllAction = new CollapseAllAction(this);
-
- fFileSearchAction = new FileSearchAction(viewer);
- fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(viewer);
- fSearchDialogAction = new SearchDialogAction(viewer, this.getViewSite().getWorkbenchWindow());
- }
-
- /**
- * Updates all actions with the given selection.
- * Necessary when popping up a menu, because some of the enablement criteria
- * may have changed, even if the selection in the viewer hasn't.
- * E.g. A project was opened or closed.
- */
- void updateActions(IStructuredSelection selection) {
- copyResourceAction.selectionChanged(selection);
- refreshAction.selectionChanged(selection);
- moveResourceAction.selectionChanged(selection);
- openFileAction.selectionChanged(selection);
- openSystemEditorAction.selectionChanged(selection);
- propertyDialogAction.selectionChanged(selection);
- renameResourceAction.selectionChanged(selection);
- //sortByTypeAction.selectionChanged(selection);
- //sortByNameAction.selectionChanged(selection);
- }
-
- /**
- * Updates the global actions with the given selection.
- * Be sure to invoke after actions objects have updated, since can* methods delegate to action objects.
- */
- void updateGlobalActions(IStructuredSelection selection) {
- deleteResourceAction.selectionChanged(selection);
- addBookmarkAction.selectionChanged(selection);
-
- // Ensure Copy global action targets correct action,
- // either copyProjectAction or copyResourceAction,
- // depending on selection.
- copyResourceAction.selectionChanged(selection);
- IActionBars actionBars = getViewSite().getActionBars();
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyResourceAction);
- actionBars.updateActionBars();
- renameResourceAction.selectionChanged(selection);
-
- refreshAction.selectionChanged(selection);
- buildAction.selectionChanged(selection);
- rebuildAction.selectionChanged(selection);
- openProjectAction.selectionChanged(selection);
- closeProjectAction.selectionChanged(selection);
-
- }
-
-
- //---- Action handling ----------------------------------------------------------
-
- IStructuredSelection convertSelection(ISelection s) {
- List converted = new ArrayList();
- if (s instanceof StructuredSelection) {
- Object[] elements= ((StructuredSelection)s).toArray();
- for (int i= 0; i < elements.length; i++) {
- Object e = elements[i];
- if (e instanceof IAdaptable) {
- IResource r = (IResource)((IAdaptable)e).getAdapter(IResource.class);
- if (r != null)
- converted.add(r);
- }
- }
- }
- return new StructuredSelection(converted.toArray());
- }
-
- IStructuredSelection convertSelectionToCElement(ISelection s) {
- List converted = new ArrayList();
- if (s instanceof StructuredSelection) {
- Object[] elements= ((StructuredSelection)s).toArray();
- for (int i= 0; i < elements.length; i++) {
- Object e = elements[i];
- if (e instanceof IAdaptable) {
- ICElement c = (ICElement)((IAdaptable)e).getAdapter(ICElement.class);
- if (c != null)
- converted.add(c);
- }
- }
- }
- return new StructuredSelection(converted.toArray());
- }
-
- /**
- * Called when the context menu is about to open.
- * Override to add your own context dependent menu contributions.
- */
- public void menuAboutToShow(IMenuManager menu) {
- IStructuredSelection selection= (IStructuredSelection) viewer.getSelection();
- if (selection.isEmpty()) {
- new NewWizardMenu(menu, getSite().getWorkbenchWindow(), false);
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
- return;
- }
-
- updateActions (convertSelection(selection));
- //updateActions (selection);
- addNewMenu(menu, selection);
- menu.add(new Separator());
- addOpenMenu(menu, selection);
- menu.add(new Separator());
- addBuildMenu(menu, selection);
- menu.add(new Separator ());
- addRefreshMenu (menu, selection);
- menu.add(new Separator());
- addIOMenu(menu, selection);
- menu.add(new Separator());
- addBookMarkMenu (menu, selection);
- menu.add(new Separator());
- addSearchMenu(menu, selection);
- //menu.add(new Separator());
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
- addPropertyMenu(menu, selection);
- }
-
- void addNewMenu (IMenuManager menu, IStructuredSelection selection) {
-
-
- MenuManager newMenu = new MenuManager("New");
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
-
- newMenu.add(goIntoAction);
-
- new NewWizardMenu(newMenu, getSite().getWorkbenchWindow(), false);
-
- menu.add(newMenu);
-
- if (resource == null)
- return;
-
- menu.add (new Separator ());
- if (selection.size() == 1 && resource instanceof IContainer) {
- menu.add(goIntoAction);
- }
-
- MenuManager gotoMenu = new MenuManager("GoTo");
- menu.add(gotoMenu);
- if (viewer.isExpandable(element)) {
- gotoMenu.add(backAction);
- gotoMenu.add(forwardAction);
- gotoMenu.add(upAction);
- }
-
- }
-
- void addOpenMenu(IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null)
- return;
-
- // Create a menu flyout.
- //MenuManager submenu= new MenuManager("Open With"); //$NON-NLS-1$
- //submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));
- //menu.add(submenu);
- if (resource instanceof IFile)
- menu.add(openFileAction);
-
- fillOpenWithMenu(menu, selection);
- fillOpenToMenu(menu, selection);
- }
-
-
- void addBuildMenu(IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null) {
- return;
- }
-
- menu.add(new GroupMarker(BUILD_GROUP_MARKER));
- if (resource instanceof IProject && hasBuilder((IProject) resource)) {
- buildAction.selectionChanged(selection);
- menu.add(buildAction);
- rebuildAction.selectionChanged(selection);
- menu.add(rebuildAction);
- }
-
- menu.add(new GroupMarker(BUILD_GROUP_MARKER_END));
- }
-
- boolean hasBuilder(IProject project) {
- try {
- ICommand[] commands = project.getDescription().getBuildSpec();
- if (commands.length > 0)
- return true;
- }
- catch (CoreException e) {
- // Cannot determine if project has builders. Project is closed
- // or does not exist. Fall through to return false.
- }
- return false;
- }
-
-
- void addRefreshMenu (IMenuManager menu, IStructuredSelection selection) {
- menu.add(refreshAction);
- }
-
- void addIOMenu (IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null)
- return;
-
- menu.add(new Separator ());
-
- if (resource instanceof IProject) {
- menu.add(closeProjectAction);
- }
-
- if (resource instanceof IFile || resource instanceof IFolder) {
- menu.add(copyResourceAction);
- menu.add(moveResourceAction);
- }
-
- if (!(element instanceof IArchiveContainer || element instanceof IBinaryContainer)) {
- menu.add(renameResourceAction);
- menu.add(deleteResourceAction);
- }
-
- }
-
- void addBookMarkMenu (IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null)
- return;
- if (resource instanceof IFile) {
- menu.add(addBookmarkAction);
- }
- }
-
- void addPropertyMenu (IMenuManager menu, IStructuredSelection selection) {
- propertyDialogAction.selectionChanged(convertSelection(selection));
- if (propertyDialogAction.isApplicableForSelection()) {
- menu.add(propertyDialogAction);
- }
- }
-
-
- /**
- * Add "open with" actions to the context sensitive menu.
- * @param menu the context sensitive menu
- * @param selection the current selection in the project explorer
- */
- void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null)
- return;
-
- // If one file is selected get it.
- // Otherwise, do not show the "open with" menu.
- if (selection.size() != 1)
- return;
-
- if (!(resource instanceof IFile))
- return;
-
- // Create a menu flyout.
- MenuManager submenu = new MenuManager("Open With"); //$NON-NLS-1$
- submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));
-
- // Add the submenu.
- menu.add(submenu);
- }
-
- /**
- * Add "open to" actions to the context sensitive menu.
- * @param menu the context sensitive menu
- * @param selection the current selection in the project explorer
- */
- void fillOpenToMenu(IMenuManager menu, IStructuredSelection selection)
- {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
- IResource resource = (IResource)element.getAdapter(IResource.class);
- if (resource == null)
- return;
-
- // If one file is selected get it.
- // Otherwise, do not show the "open with" menu.
- if (selection.size() != 1)
- return;
-
- if (!(resource instanceof IContainer))
- return;
-
- menu.add(new OpenInNewWindowAction(getSite().getWorkbenchWindow(), resource));
- }
-
-
- /**
- * Returns the tool tip text for the given element.
- */
- String getToolTipText(Object element) {
- if (element instanceof IResource) {
- IPath path = ((IResource) element).getFullPath();
- if (path.isRoot()) {
- return "CVIEW"; //$NON-NLS-1$
- } else {
- return path.makeRelative().toString();
- }
- } else {
- return ((ILabelProvider) viewer.getLabelProvider()).getText(element);
- }
- }
-
- /**
- * Returns the message to show in the status line.
- *
- * @param selection the current selection
- * @return the status line message
- */
- String getStatusLineMessage(IStructuredSelection selection) {
- if (selection.size() == 1) {
- Object o = selection.getFirstElement();
- if (o instanceof IResource) {
- return ((IResource) o).getFullPath().makeRelative().toString();
- } else if (o instanceof ICElement) {
- ICElement celement = (ICElement)o;
- IResource res = (IResource)celement.getAdapter(IResource.class);
- if (res != null) {
- return res.getFullPath().toString();
- } else if (celement.getElementType() == ICElement.C_VCONTAINER) {
- if (celement instanceof IBinaryContainer) {
- ICProject cproj = celement.getCProject();
- if (cproj != null) {
- return cproj.getPath() + " - binaries";
- }
- } else if (celement instanceof IArchiveContainer) {
- ICProject cproj = celement.getCProject();
- if (cproj != null) {
- return cproj.getPath() + " - archives";
- }
- } else if (celement instanceof IBinaryModule) {
- IBinary bin = ((IBinaryModule)celement).getBinary();
- return bin.getPath() + ":" + celement.getElementName();
- }
- } else if (celement.getElementType() > ICElement.C_UNIT) {
- return celement.getPath().toString() + " - [" + celement.getElementName() +"]";
- }
- return celement.getElementName();
- } else {
- return "ItemSelected"; //$NON-NLS-1$
- }
- }
- if (selection.size() > 1) {
- return "StatusLine";
- }
- return "";//$NON-NLS-1$
- }
-
- void updateTitle () {
- Object input= getViewer().getInput();
- String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- if (input == null || (input instanceof ICModel)) {
- setTitle(viewName);
- setTitleToolTip(""); //$NON-NLS-1$
- } else {
- ILabelProvider labelProvider = (ILabelProvider) getViewer().getLabelProvider();
- String inputText= labelProvider.getText(input);
- setTitle(inputText);
- setTitleToolTip(getToolTipText(input));
- }
- }
-
- /**
- * Returns the tree viewer which shows the resource hierarchy.
- */
- TreeViewer getResourceViewer() {
- return viewer;
- }
-
- /**
- * Updates the message shown in the status line.
- *
- * @param selection the current selection
- */
- void updateStatusLine(IStructuredSelection selection) {
- String msg = getStatusLineMessage(selection);
- getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
- }
-
-
- void fillActionBars() {
- IActionBars actionBars= getViewSite().getActionBars();
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(backAction);
- toolBar.add(forwardAction);
- toolBar.add(upAction);
- toolBar.add(new Separator());
- toolBar.add(collapseAllAction);
- actionBars.updateActionBars();
-
- wsFilterActionGroup.fillActionBars(actionBars);
-
- IMenuManager menu = actionBars.getMenuManager();
-
- //menu.add (clibFilterAction);
- menu.add (patternFilterAction);
- }
-
- /**
- * Sets the decorator for the package explorer.
- *
- * @param decorator a label decorator or <code>null</code> for no decorations.
- */
- public void setLabelDecorator(ILabelDecorator decorator) {
- ILabelProvider cProvider= createLabelProvider();
- if (decorator == null) {
- viewer.setLabelProvider(cProvider);
- } else {
- viewer.setLabelProvider(new DecoratingLabelProvider(cProvider, decorator));
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (viewer == null)
- return;
-
- boolean refreshViewer= false;
-
- if (event.getProperty() == PreferenceConstants.PREF_SHOW_CU_CHILDREN) {
- boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren();
- ((CElementContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren);
- refreshViewer= true;
- }
-
- if (refreshViewer)
- viewer.refresh();
- }
-
- /**
- * Links to editor (if option enabled)
- */
- void linkToEditor(IStructuredSelection selection) {
- if (!CPluginPreferencePage.isLinkToEditor()) {
- return;
- }
- // ignore selection changes if the package explorer is not the active part.
- // In this case the selection change isn't triggered by a user.
- if (!isActivePart())
- return;
- Object obj= selection.getFirstElement();
-
- if (selection.size() == 1) {
- if (obj instanceof ISourceReference) {
- ITranslationUnit tu = ((ISourceReference)obj).getTranslationUnit();
- if (tu != null) {
- IEditorPart part= EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page= getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof ICElement) {
- EditorUtility.revealInEditor(part, (ICElement) obj);
- }
- }
- }
- }
- }
-
- }
-
- private boolean isActivePart() {
- return this == getSite().getPage().getActivePart();
- }
-
- /* (non-Javadoc)
- * @see IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (viewer != null) {
- return viewer.getInput();
- }
- return null;
- }
-
- public void collapseAll() {
- viewer.getControl().setRedraw(false);
- viewer.collapseToLevel(getViewPartInput(), TreeViewer.ALL_LEVELS);
- viewer.getControl().setRedraw(true);
- }
-
- void restoreFilters() {
- // restore pattern filters
- IMemento filtersMem = memento.getChild(TAG_FILTERS);
- if (filtersMem != null) {
- IMemento children[]= filtersMem.getChildren(TAG_FILTER);
- String filters[]= new String[children.length];
- for (int i = 0; i < children.length; i++) {
- filters[i]= children[i].getString(TAG_ELEMENT);
- }
- getPatternFilter().setPatterns(filters);
- } else {
- getPatternFilter().setPatterns(new String[0]);
- }
-
- //restore library
- String show = memento.getString(TAG_SHOWLIBRARIES);
- if (show != null) {
- getLibraryFilter().setShowLibraries(show.equals("true")); //$NON-NLS-1$
- }
- else
- initFilterFromPreferences();
- }
-
- void restoreState(IMemento memento) {
- //Restore the working set before we re-build the tree
- String wsname = memento.getString(TAG_WORKINGSET);
- if(wsname != null) {
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- IWorkingSet set = wsmanager.getWorkingSet(wsname);
- wsFilterActionGroup.setWorkingSet(set);
- } else {
- wsFilterActionGroup.setWorkingSet(null);
- }
-
- //ICelement container = CElementFactory.getDefault().getRoot();
- CoreModel factory = CoreModel.getDefault();
- IMemento childMem = memento.getChild(TAG_EXPANDED);
- if(childMem != null) {
- ArrayList elements = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (int i = 0; i < elementMem.length; i++){
- String p = elementMem[i].getString(TAG_PATH);
- if (p != null) {
- IPath path = new Path(p);
- ICElement element = factory.create(path);
- if (element != null) {
- elements.add(element);
- }
- }
- }
- viewer.setExpandedElements(elements.toArray());
- }
- childMem = memento.getChild(TAG_SELECTION);
- if(childMem != null) {
- ArrayList list = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (int i = 0; i < elementMem.length; i++){
- String p = elementMem[i].getString(TAG_PATH);
- if (p != null) {
- IPath path = new Path(p);
- ICElement element = factory.create(path);
- if (element != null) {
- list.add(element);
- }
- }
- }
- viewer.setSelection(new StructuredSelection(list));
- }
-
- Tree tree = viewer.getTree();
- //save vertical position
- ScrollBar bar = tree.getVerticalBar();
- if (bar != null) {
- try {
- String posStr = memento.getString(TAG_VERTICAL_POSITION);
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- } catch (NumberFormatException e){}
- }
- bar = tree.getHorizontalBar();
- if (bar != null) {
- try {
- String posStr = memento.getString(TAG_HORIZONTAL_POSITION);
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- } catch (NumberFormatException e){}
- }
- }
-
- public void saveState(IMemento memento) {
- if (viewer == null) {
- if (this.memento != null) { //Keep the old state;
- memento.putMemento(this.memento);
- }
- return;
- }
-
- //save expanded elements
- Tree tree = viewer.getTree();
- Object expandedElements[] = viewer.getExpandedElements();
- if (expandedElements.length > 0) {
- IMemento expandedMem = memento.createChild(TAG_EXPANDED);
- for (int i = 0; i < expandedElements.length; i++) {
- Object o = expandedElements[i];
- // Do not save expanded binary files are libraries.
- if (o instanceof IParent
- && ! (o instanceof IArchiveContainer || o instanceof IBinaryContainer
- || o instanceof IBinary || o instanceof IArchive)) {
- IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
- ICElement e = (ICElement)o;
- IResource res = e.getResource();
- if (res != null) {
- elementMem.putString(TAG_PATH, res.getLocation().toOSString());
- }
- }
- }
- }
-
- //save selection
- Object elements[] = ((IStructuredSelection)viewer.getSelection()).toArray();
- if(elements.length > 0) {
- IMemento selectionMem = memento.createChild(TAG_SELECTION);
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof ICElement) {
- ICElement e = (ICElement)elements[i];
- IResource r = e.getResource();
- if (r != null) {
- IMemento elementMem = selectionMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH,r.getLocation().toString());
- }
- }
- }
- }
-
- //save vertical position
- ScrollBar bar = tree.getVerticalBar();
- int position = bar != null ? bar.getSelection():0;
- memento.putString(TAG_VERTICAL_POSITION,String.valueOf(position));
- //save horizontal position
- bar = tree.getHorizontalBar();
- position = bar != null ? bar.getSelection():0;
- memento.putString(TAG_HORIZONTAL_POSITION,String.valueOf(position));
-
- //save filters
- String filters[] = getPatternFilter().getPatterns();
- if(filters.length > 0) {
- IMemento filtersMem = memento.createChild(TAG_FILTERS);
- for (int i = 0; i < filters.length; i++){
- IMemento child = filtersMem.createChild(TAG_FILTER);
- child.putString(TAG_ELEMENT,filters[i]);
- }
- }
-
- //save library filter
- boolean showLibraries= getLibraryFilter().getShowLibraries();
- String show= "true"; //$NON-NLS-1$
- if (!showLibraries)
- show= "false"; //$NON-NLS-1$
- memento.putString(TAG_SHOWLIBRARIES, show);
-
- //Save the working set away
- if(workingSetFilter.getWorkingSet() != null) {
- String wsname = workingSetFilter.getWorkingSet().getName();
- if(wsname != null) {
- memento.putString(TAG_WORKINGSET, wsname);
- }
- }
- }
-
- void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable)selection.getFirstElement();
-
- if (element instanceof TranslationUnit ||
- element instanceof CProject)
- return;
-
- MenuManager search = new MenuManager("Search", IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
-
- if (SearchDialogAction.canActionBeAdded(selection)){
- search.add(fSearchDialogAction);
- }
-
- if (FileSearchAction.canActionBeAdded(selection)) {
- MenuManager fileSearch = new MenuManager("File Search");
- fileSearch.add(fFileSearchAction);
- fileSearch.add(fFileSearchActionInWorkingSet);
- search.add(fileSearch);
- }
-
- menu.add(search);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
- */
- public boolean show(ShowInContext context) {
- //@@@ Do something with the selection later?
- //ISelection selection = context.getSelection();
- try {
- IEditorInput input = (IEditorInput)context.getInput();
- if(input != null) {
- IResource res = (IResource)input.getAdapter(IResource.class);
- if(res != null) {
- selectReveal(new StructuredSelection(res));
- }
- }
- } catch(Exception ex) {
- /* Ignore */
- }
- return false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewDropAdapter.java
deleted file mode 100644
index acdef8208f7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewDropAdapter.java
+++ /dev/null
@@ -1,446 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
-import org.eclipse.ui.actions.MoveFilesAndFoldersOperation;
-import org.eclipse.ui.actions.ReadOnlyStateChecker;
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.part.PluginDropAdapter;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-;
-
-/**
- * Implements drop behaviour for drag and drop operations
- * that land on the resource navigator.
- */
-class CViewDropAdapter extends PluginDropAdapter implements IOverwriteQuery {
-
- /**
- * A flag indicating that the drop has been cancelled by the user.
- */
- protected boolean isCanceled = false;
- /**
- * A flag indicating that overwrites should always occur.
- */
- protected boolean alwaysOverwrite = false;
-
- /**
- * The last valid operation.
- */
- private int lastValidOperation = DND.DROP_NONE;
-
- /*
- * @see org.eclipse.swt.dnd.DropTargetListener#dragEnter(org.eclipse.swt.dnd.DropTargetEvent)
- */
- public void dragEnter(DropTargetEvent event) {
- if (FileTransfer.getInstance().isSupportedType(event.currentDataType) &&
- event.detail == DND.DROP_DEFAULT) {
- // default to copy when dragging from outside Eclipse. Fixes bug 16308.
- event.detail = DND.DROP_COPY;
- }
- super.dragEnter(event);
- }
-
- /**
- * Returns an error status with the given info.
- */
- protected IStatus error(String message, Throwable exception) {
- return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception);
- }
-
- /**
- * Returns an error status with the given info.
- */
- protected IStatus error(String message) {
- return error(message, null);
- }
-
- /**
- * Returns an error status, indicating why the given source
- * could not be copied or moved.
- */
- protected IStatus error(IResource source, String message) {
- if (getCurrentOperation() == DND.DROP_COPY) {
- return error("Can Not Copy", null); //$NON-NLS-1$
- } else {
- return error("Can Not Move", null); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the actual target of the drop, given the resource
- * under the mouse. If the mouse target is a file, then the drop actually
- * occurs in its parent. If the drop location is before or after the
- * mouse target, the target is also the parent.
- */
- protected IContainer getActualTarget(IResource mouseTarget) {
- /* if cursor is before or after mouseTarget, set target to parent */
- if (getCurrentLocation() == LOCATION_BEFORE || getCurrentLocation() == LOCATION_AFTER) {
- return mouseTarget.getParent();
- }
- /* if cursor is on a file, return the parent */
- if (mouseTarget.getType() == IResource.FILE) {
- return mouseTarget.getParent();
- }
- /* otherwise the mouseTarget is the real target */
- return (IContainer)mouseTarget;
- }
-
- /**
- * Returns the display
- */
- protected Display getDisplay() {
- return getViewer().getControl().getDisplay();
- }
-
- /**
- * Returns the shell
- */
- protected Shell getShell() {
- return getViewer().getControl().getShell();
- }
-
- /**
- * Returns an error status with the given info.
- */
- protected IStatus info(String message) {
- return new Status(IStatus.INFO, PlatformUI.PLUGIN_ID, 0, message, null);
- }
-
- /**
- * CViewDropAction constructor comment.
- */
- public CViewDropAdapter(StructuredViewer viewer) {
- super(viewer);
- }
-
- /**
- * Adds the given status to the list of problems. Discards
- * OK statuses. If the status is a multi-status, only its children
- * are added.
- */
- protected void mergeStatus(MultiStatus status, IStatus toMerge) {
- if (!toMerge.isOK()) {
- status.merge(toMerge);
- }
- }
-
- /**
- * Creates a status object from the given list of problems.
- */
- protected IStatus multiStatus(List problems, String message) {
- IStatus[] children = new IStatus[problems.size()];
- problems.toArray(children);
- if (children.length == 1) {
- return children[0];
- } else {
- return new MultiStatus(PlatformUI.PLUGIN_ID, 0, children, message, null);
- }
- }
-
- /**
- * Returns an status indicating success.
- */
- protected IStatus ok() {
- return new Status(Status.OK, PlatformUI.PLUGIN_ID, 0, "Ok", null); //$NON-NLS-1$
- }
-
- /**
- * Opens an error dialog if necessary. Takes care of
- * complex rules necessary for making the error dialog look nice.
- */
- protected void openError(IStatus status) {
- if (status == null)
- return;
-
- String genericTitle = "Error"; //$NON-NLS-1$
- int codes = IStatus.ERROR | IStatus.WARNING;
-
- //simple case: one error, not a multistatus
- if (!status.isMultiStatus()) {
- ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
- return;
- }
-
- //one error, single child of multistatus
- IStatus[] children = status.getChildren();
- if (children.length == 1) {
- ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes);
- return;
- }
- //several problems
- ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
- }
-
- /**
- * Returns the resource selection from the LocalSelectionTransfer.
- *
- * @return the resource selection from the LocalSelectionTransfer
- */
- private static final int typeMask = IResource.FOLDER | IResource.FILE;
-
- private IResource[] getSelectedResources() {
- ISelection selection = LocalSelectionTransfer.getInstance().getSelection();
- List resources = new ArrayList();
-
- // Sanity checks
- if (selection == null || !(selection instanceof IStructuredSelection) || selection.isEmpty()) {
- return null;
- }
-
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
- // loop through list and look for matching items
- for (Iterator enum = structuredSelection.iterator(); enum.hasNext();) {
- Object object = enum.next();
- IResource resource = null;
-
- if (object instanceof IResource) {
- resource = (IResource) object;
- } else if (object instanceof IAdaptable) {
- resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
- }
- if (resource != null && (resource.getType() & typeMask) != 0) {
- resources.add(resource);
- }
- }
-
- IResource[] result = new IResource[resources.size()];
- resources.toArray(result);
-
- return result;
- }
-
- /**
- * Invoked when an action occurs.
- * Argument context is the Window which contains the UI from which this action was fired.
- * This default implementation prints the name of this class and its label.
- * @see IAction#run
- */
- public boolean performDrop(final Object data) {
- isCanceled = false;
- alwaysOverwrite = false;
- if (getCurrentTarget() == null || data == null) {
- return false;
- }
- boolean result = false;
- IStatus status = null;
- IResource[] resources = null;
- TransferData currentTransfer = getCurrentTransfer();
- if (LocalSelectionTransfer.getInstance().isSupportedType(currentTransfer)) {
- resources = getSelectedResources();
- } else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
- resources = (IResource[]) data;
- } else if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
- status = performFileDrop(data);
- result = status.isOK();
- } else {
- result = super.performDrop(data);
- }
- if (resources != null) {
- if (getCurrentOperation() == DND.DROP_COPY) {
- status = performResourceCopy(getShell(), resources);
- } else {
- status = performResourceMove(resources);
- }
- }
- openError(status);
- return result;
- }
-
- /**
- * Performs a drop using the FileTransfer transfer type.
- */
- private IStatus performFileDrop(Object data) {
- MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0, "ProblemI mporting", null); //$NON-NLS-1$
- mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer()));
-
- Object obj = getCurrentTarget();
- IResource res = null;
- if (obj instanceof IAdaptable) {
- res = (IResource)((IAdaptable) obj).getAdapter(IResource.class);
- }
- final IContainer target = getActualTarget(res);
- final String[] names = (String[]) data;
- // Run the import operation asynchronously.
- // Otherwise the drag source (e.g., Windows Explorer) will be blocked
- // while the operation executes. Fixes bug 16478.
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- getShell().forceActive();
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
- operation.copyFiles(names, target);
- }
- });
- return problems;
- }
-
- /**
- * Performs a resource copy
- */
- private IStatus performResourceCopy(Shell shell, IResource[] sources) {
- MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1, "Problems Moving", null); //$NON-NLS-1$
- mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer()));
-
- Object obj = getCurrentTarget();
- IResource res = null;
- if (obj instanceof IAdaptable) {
- res = (IResource)((IAdaptable) obj).getAdapter(IResource.class);
- }
- IContainer target = getActualTarget(res);
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
- operation.copyResources(sources, target);
-
- return problems;
- }
-
- /**
- * Performs a resource move
- */
- private IStatus performResourceMove(IResource[] sources) {
- MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1, "Problems Moving", null); //$NON-NLS-1$
- mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer()));
-
- Object obj = getCurrentTarget();
- IResource res = null;
- if (obj instanceof IAdaptable) {
- res = (IResource)((IAdaptable) obj).getAdapter(IResource.class);
- }
- IContainer target = getActualTarget(res);
- ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
- getShell(),
- "Move Resource Action", //$NON-NLS-1$
- "Move Resource Action");//$NON-NLS-1$
- sources = checker.checkReadOnlyResources(sources);
- MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
- operation.copyResources(sources, target);
-
- return problems;
- }
-
- /* (non-Javadoc)
- * Method declared on IOverWriteQuery
- */
- public String queryOverwrite(String pathString) {
- final String returnCode[] = {CANCEL};
- final String msg = pathString + " " + CUIPlugin.getResourceString("CViewDragNDrop.txt") ; //$NON-NLS-1$
- final String[] options = {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL};
- getDisplay().syncExec(new Runnable() {
- public void run() {
- MessageDialog dialog = new MessageDialog(getShell(), "Question", null, msg, MessageDialog.QUESTION, options, 0); //$NON-NLS-1$
- dialog.open();
- int returnVal = dialog.getReturnCode();
- String[] returnCodes = {YES, NO, ALL, CANCEL};
- returnCode[0] = returnVal < 0 ? CANCEL : returnCodes[returnVal];
- }
- });
- return returnCode[0];
- }
-
- /**
- * This method is used to notify the action that some aspect of
- * the drop operation has changed.
- */
- public boolean validateDrop(Object target, int dragOperation, TransferData transferType) {
- if (dragOperation != DND.DROP_NONE) {
- lastValidOperation = dragOperation;
- }
- if (FileTransfer.getInstance().isSupportedType(transferType) &&
- lastValidOperation != DND.DROP_COPY) {
- // only allow copying when dragging from outside Eclipse
- return false;
- }
-
- if (super.validateDrop(target, dragOperation, transferType)) {
- return true;
- }
- return validateTarget(target, transferType).isOK();
- }
-
- /**
- * Ensures that the drop target meets certain criteria
- */
- private IStatus validateTarget(Object target, TransferData transferType) {
- if (target instanceof IAdaptable) {
- IResource r = (IResource)((IAdaptable) target).getAdapter(IResource.class);
- if (r == null)
- return info("Target Must Be Resource"); //$NON-NLS-1$
- target = r;
- }
-
- if (!(target instanceof IResource)) {
- return info("Target Must Be Resource"); //$NON-NLS-1$
- }
- IResource resource = (IResource) target;
- if (!resource.isAccessible()) {
- return error("Can Not Drop Into Closed Project"); //$NON-NLS-1$
- }
- IContainer destination = getActualTarget(resource);
- if (destination.getType() == IResource.ROOT) {
- return error("Resources Can Not Be Siblings"); //$NON-NLS-1$
- }
- String message = null;
- // drag within Eclipse?
- if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) {
- IResource[] selectedResources = getSelectedResources();
-
- if (selectedResources == null)
- message = "Drop Operation Error Other"; //$NON-NLS-1$
- else {
- CopyFilesAndFoldersOperation operation;
- if (lastValidOperation == DND.DROP_COPY) {
- operation = new CopyFilesAndFoldersOperation(getShell());
- }
- else {
- operation = new MoveFilesAndFoldersOperation(getShell());
- }
- message = operation.validateDestination(destination, selectedResources);
- }
- } // file import?
- else if (FileTransfer.getInstance().isSupportedType(transferType)) {
- String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType);
- if (sourceNames == null) {
- // source names will be null on Linux. Use empty names to do destination validation.
- // Fixes bug 29778
- sourceNames = new String[0];
- }
- CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
- message = copyOperation.validateImportDestination(destination, sourceNames);
- }
- if (message != null) {
- return error(message);
- }
- return ok();
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
deleted file mode 100644
index 9502681bae5..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
-
-public class CViewFrameSource extends TreeViewerFrameSource {
- private CView cview;
-
- protected TreeFrame createFrame(Object input) {
- TreeFrame frame = super.createFrame(input);
- frame.setToolTipText(cview.getToolTipText(input));
- return frame;
- }
- /**
- * Also updates the title of the packages explorer
- */
- protected void frameChanged(TreeFrame frame) {
- super.frameChanged(frame);
- cview.updateTitle();
- }
- public CViewFrameSource(CView cview) {
- super(cview.getResourceViewer());
- this.cview = cview;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java
deleted file mode 100644
index 50daaf74795..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class CViewMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.cview.CViewMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private CViewMessages() {
- }
-
- 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
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, String[] args) {
- return MessageFormat.format(fgResourceBundle.getString(key), args);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
deleted file mode 100644
index 14f45cd2779..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-CollapseAllAction.label=Collapse All
-CollapseAllAction.tooltip=Collapse All
-CollapseAllAction.description=Collapse All
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewSorter.java
deleted file mode 100644
index a2cd0d0ca63..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewSorter.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IFunction;
-import org.eclipse.cdt.core.model.IFunctionDeclaration;
-import org.eclipse.cdt.core.model.IInclude;
-import org.eclipse.cdt.core.model.ILibraryReference;
-import org.eclipse.cdt.core.model.IMacro;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IUsing;
-import org.eclipse.cdt.core.model.IVariable;
-import org.eclipse.cdt.core.model.IVariableDeclaration;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * A sorter to sort the file and the folders in the C viewer in the following order:
- * 1st Project
- * 2nd BinaryContainer
- * 3nd ArchiveContainer
- * 4 Folder
- * 5 C File
- * 6 the reset
- */
-public class CViewSorter extends ViewerSorter {
-
- private static final int CMODEL = 0;
- private static final int PROJECT = 10;
- private static final int RESOURCE = 200;
-
- public int category (Object element) {
- if (element instanceof ICModel) {
- return CMODEL;
- } else if (element instanceof ICProject) {
- return PROJECT;
- } else if (element instanceof IBinaryContainer) {
- return 20;
- } else if (element instanceof IArchiveContainer) {
- return 30;
- } else if (element instanceof ICContainer) {
- return 40;
- } else if (element instanceof ITranslationUnit) {
- IResource res = null;
- res = ((ITranslationUnit)element).getUnderlyingResource();
- if (res != null) {
- String ext = res.getFileExtension();
- if (ext != null) {
- String[] headers = CoreModel.getDefault().getHeaderExtensions();
- for (int i = 0; i < headers.length; i++) {
- if (ext.equals(headers[i])) {
- return 42;
- }
- }
- String[] sources = CoreModel.getDefault().getSourceExtensions();
- for (int i = 0; i < sources.length; i++) {
- if (ext.equals(sources[i])) {
- return 47;
- }
- }
- return 48;
- }
- return 49;
- }
- return 50;
- } else if (element instanceof IInclude) {
- return 60;
- } else if (element instanceof IMacro) {
- return 70;
- } else if (element instanceof INamespace) {
- return 80;
- } else if (element instanceof IUsing) {
- return 90;
- } else if (element instanceof IFunctionDeclaration && ! (element instanceof IFunction)) {
- return 100;
- } else if (element instanceof IMethodDeclaration && !(element instanceof IMethod)) {
- return 110;
- } else if (element instanceof IVariableDeclaration) {
- return 120;
- } else if (element instanceof IVariable) {
- String name = ((ICElement)element).getElementName();
- if (name.startsWith("__")) {
- return 122;
- }
- if (name.charAt(0) == '_') {
- return 124;
- }
- return 130;
- } else if (element instanceof IFunction) {
- String name = ((ICElement)element).getElementName();
- if (name.startsWith("__")) {
- return 132;
- }
- if (name.charAt(0) == '_') {
- return 134;
- }
- return 140;
- } else if (element instanceof IArchive) {
- return 150;
- } else if (element instanceof IBinary) {
- return 160;
- } else if (element instanceof ILibraryReference) {
- return 170;
- } else if (element instanceof ICElement) {
- String name = ((ICElement)element).getElementName();
- if (name.startsWith("__")) {
- return 172;
- }
- if (name.charAt(0) == '_') {
- return 174;
- }
- return 180;
- }
- return RESOURCE;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2)
- return cat1 - cat2;
-
- // cat1 == cat2
-
- if (cat1 == PROJECT) {
- IWorkbenchAdapter a1= (IWorkbenchAdapter)((IAdaptable)e1).getAdapter(IWorkbenchAdapter.class);
- IWorkbenchAdapter a2= (IWorkbenchAdapter)((IAdaptable)e2).getAdapter(IWorkbenchAdapter.class);
- return getCollator().compare(a1.getLabel(e1), a2.getLabel(e2));
- }
-
- // non - c resources are sorted using the label from the viewers label provider
- if (cat1 == RESOURCE) {
- return compareWithLabelProvider(viewer, e1, e2);
- }
-
- String name1;
- String name2;
-
- if (e1 instanceof ICElement) {
- name1 = ((ICElement)e1).getElementName();
- } else {
- name1 = e1.toString();
- }
- if (e2 instanceof ICElement) {
- name2 = ((ICElement)e2).getElementName();
- } else {
- name2 = e2.toString();
- }
- return getCollator().compare(name1, name2);
- }
-
- private int compareWithLabelProvider(Viewer viewer, Object e1, Object e2) {
- if (viewer == null || !(viewer instanceof ContentViewer)) {
- IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
- if (prov instanceof ILabelProvider) {
- ILabelProvider lprov= (ILabelProvider) prov;
- String name1 = lprov.getText(e1);
- String name2 = lprov.getText(e2);
- if (name1 != null && name2 != null) {
- return getCollator().compare(name1, name2);
- }
- }
- }
- return 0; // can't compare
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java
deleted file mode 100644
index d5581950851..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Collapse all nodes.
- */
-class CollapseAllAction extends Action {
-
- private CView cview;
-
- CollapseAllAction(CView part) {
- super(CViewMessages.getString("CollapseAllAction.label")); //$NON-NLS-1$
- setDescription(CViewMessages.getString("CollapseAllAction.description")); //$NON-NLS-1$
- setToolTipText(CViewMessages.getString("CollapseAllAction.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
- cview = part;
- WorkbenchHelp.setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
- }
-
- public void run() {
- cview.collapseAll();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
deleted file mode 100644
index ff7099d249e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-
-public class DefaultAction extends Action {
-
- Shell shell;
-
- DefaultAction (Shell shell, String s) {
- super (s);
- this.shell = shell;
- }
-
- public void run() {
- MessageBox errorMsg = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
- errorMsg.setText("WIP");
- errorMsg.setMessage ("Work In Progress");
- errorMsg.open();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
deleted file mode 100644
index 51f77ec9e03..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.StringWriter;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.SelectionProviderAction;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-//import org.eclipse.cdt.core.model.CElementFilters;
-
-/**
- * The FilterAction is the class that adds the filter views to a PackagesView.
- */
-class FilterSelectionAction extends SelectionProviderAction {
-
-
- private CView cview;
- private Shell shell;
-
- /**
- * Create a new filter action
- * @param shell the shell that will be used for the list selection
- * @param packages the PackagesExplorerPart
- * @param label the label for the action
- */
- public FilterSelectionAction(Shell shell, CView cview, String label) {
- super(cview.getViewer(), label);
- setToolTipText("Filter Selection Action");
- setEnabled(true);
- this.shell= shell;
- this.cview= cview;
- }
-
- /**
- * Implementation of method defined on <code>IAction</code>.
- */
- public void run() {
- CPatternFilter filter= cview.getPatternFilter();
- FiltersContentProvider contentProvider= new FiltersContentProvider(filter);
-
- ListSelectionDialog dialog =
- new ListSelectionDialog(
- shell,
- cview.getViewer(),
- contentProvider,
- new LabelProvider(),
- "Select the filters to apply (matching files will be hidden):");
-
- dialog.setInitialSelections(contentProvider.getInitialSelections());
- dialog.setTitle("C/C++ File Filters");
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- Object[] results= dialog.getResult();
- String[] selectedPatterns= new String[results.length];
- System.arraycopy(results, 0, selectedPatterns, 0, results.length);
- filter.setPatterns(selectedPatterns);
- CElementFilters.setPatterns(selectedPatterns);
- saveInPreferences(selectedPatterns);
- TreeViewer viewer= cview.getViewer();
- viewer.getControl().setRedraw(false);
- viewer.refresh();
- viewer.getControl().setRedraw(true);
- }
- }
- /**
- * Save the supplied patterns in the preferences for the UIPlugin.
- * They are saved in the format patern,pattern,.
- */
- private void saveInPreferences(String[] patterns) {
- CUIPlugin plugin= CUIPlugin.getDefault();
- StringWriter writer= new StringWriter();
-
- for (int i = 0; i < patterns.length; i++) {
- writer.write(patterns[i]);
- writer.write(CPatternFilter.COMMA_SEPARATOR);
- }
-
- plugin.getPreferenceStore().setValue(
- CPatternFilter.FILTERS_TAG, writer.toString());
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FiltersContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FiltersContentProvider.java
deleted file mode 100644
index e765844cfd9..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FiltersContentProvider.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * The FiltersContentProvider provides the elements for use by the list dialog
- * for selecting the patterns to apply.
- */
-class FiltersContentProvider implements IStructuredContentProvider {
- private static List fgDefinedFilters;
- private static List fgDefaultFilters;
-
- private CPatternFilter filter;
-
- /**
- * Disposes of this content provider.
- * This is called by the viewer when it is disposed.
- */
- public void dispose() {}
- /**
- * Returns the filters which are enabled by default.
- *
- * @return a list of strings
- */
- public static List getDefaultFilters() {
- if (fgDefaultFilters == null) {
- readFilters();
- }
- return fgDefaultFilters;
- }
- /**
- * Returns the filters currently defined for the workbench.
- */
- public static List getDefinedFilters() {
- if (fgDefinedFilters == null) {
- readFilters();
- }
- return fgDefinedFilters;
- }
- /* (non-Jaadoc)
- * Method declared in IStructuredContentProvider.
- */
- public Object[] getElements(Object inputElement) {
- return getDefinedFilters().toArray();
- }
- /**
- * Return the initially selected values
- * @return java.lang.String[]
- */
- public String[] getInitialSelections() {
- return filter.getPatterns();
- }
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- /**
- * Create a FiltersContentProvider using the selections from the suppliec
- * resource filter.
- */
- public FiltersContentProvider(CPatternFilter filter) {
- this.filter= filter;
- }
- /**
- * Reads the filters currently defined for the workbench.
- */
- private static void readFilters() {
- fgDefinedFilters = new ArrayList();
- fgDefaultFilters = new ArrayList();
- CUIPlugin plugin = CUIPlugin.getDefault();
- if (plugin != null) {
- IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(CPatternFilter.FILTERS_TAG);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for(int i = 0; i < extensions.length; i++){
- IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
- for(int j = 0; j < configElements.length; j++){
- String pattern = configElements[j].getAttribute("pattern"); //$NON-NLS-1$
- if (pattern != null)
- fgDefinedFilters.add(pattern);
- String selected = configElements[j].getAttribute("selected"); //$NON-NLS-1$
- if (selected != null && selected.equalsIgnoreCase("true")) //$NON-NLS-1$
- fgDefaultFilters.add(pattern);
- }
- }
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ShowLibrariesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ShowLibrariesAction.java
deleted file mode 100644
index 30b115c3d20..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ShowLibrariesAction.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.cdt.internal.ui.cview;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.SelectionProviderAction;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * The ShowLibrariesAction is the class that adds the filter views to a PackagesView.
- */
-class ShowLibrariesAction extends SelectionProviderAction {
-
- private CView cview;
- private Shell shell;
-
- /**
- * Create a new filter action
- * @param shell the shell that will be used for the list selection
- * @param packages the PackagesExplorerPart
- * @param label the label for the action
- */
- public ShowLibrariesAction(Shell shell, CView cview, String label) {
- super(cview.getViewer(), label);
- this.cview = cview;
- CLibFilter filter = cview.getLibraryFilter();
- setChecked(filter.getShowLibraries());
- updateToolTipText();
- setEnabled(true);
- this.shell= shell;
- }
-
- /**
- * Implementation of method defined on <code>IAction</code>.
- */
- public void run() {
- CLibFilter filter = cview.getLibraryFilter();
- filter.setShowLibraries(isChecked());
- updateToolTipText();
- saveInPreferences();
-
- cview.getViewer().getControl().setRedraw(false);
- cview.getViewer().refresh();
- cview.getViewer().getControl().setRedraw(true);
- }
-
- /**
- * Save the supplied patterns in the preferences for the UIPlugin.
- * They are saved in the format patern,pattern,.
- */
- private void saveInPreferences() {
- CUIPlugin plugin = CUIPlugin.getDefault();
- Boolean b = new Boolean (cview.getLibraryFilter().getShowLibraries());
-
- plugin.getPreferenceStore().putValue(CView.TAG_SHOWLIBRARIES, b.toString());
- }
-
- private void updateToolTipText() {
- CLibFilter filter = cview.getLibraryFilter();
- if (filter.getShowLibraries())
- setToolTipText("Hide Referenced Libs");
- else
- setToolTipText("Show Referenced Libs");
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
deleted file mode 100644
index bf7a17a9866..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
+++ /dev/null
@@ -1,277 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-
-/**
- * A class to select one or more elements out of an indexed property
- */
-public abstract class AbstractElementListSelectionDialog extends SelectionStatusDialog {
-
- private ILabelProvider fRenderer;
- private boolean fIgnoreCase;
- private boolean fIsMultipleSelection;
-
- private SelectionList fSelectionList;
- private Label fMessage;
- private ISelectionValidator fValidator;
-
- private String fMessageText;
- private String fEmptyListMessage;
- private String fNothingSelectedMessage;
-
- private StatusInfo fCurrStatus;
-
- /*
- * @private
- */
- protected void access$superOpen() {
- super.open();
- }
- /*
- * @private
- * @see Dialog#cancelPressed
- */
- protected void cancelPressed() {
- setResult(null);
- super.cancelPressed();
- }
- protected Point computeInitialSize() {
- return new Point(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(18));
- }
- /*
- * @private
- * @see Window#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite contents= (Composite)super.createDialogArea(parent);
-
- fMessage= createMessage(contents);
-
- int flags= fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE;
- fSelectionList= new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
- fRenderer, fIgnoreCase);
-
- fSelectionList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- handleDoubleClick();
- }
- public void widgetSelected(SelectionEvent e) {
- verifyCurrentSelection();
- }
- });
-
- GridData spec= new GridData();
- Point initialSize= computeInitialSize();
- spec.widthHint= initialSize.x;
- spec.heightHint= initialSize.y;
- spec.grabExcessVerticalSpace= true;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.FILL;
- fSelectionList.setLayoutData(spec);
-
- return contents;
- }
- /**
- * Creates the message text widget and sets layout data.
- */
- protected Label createMessage(Composite parent) {
- Label text= new Label(parent, SWT.NULL);
- text.setText(fMessageText);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
- text.setLayoutData(spec);
- return text;
- }
- /*
- * @private
- * @see Window#create(Shell)
- */
- public void create() {
- super.create();
- if (isEmptyList()) {
- fMessage.setEnabled(false);
- fSelectionList.setEnabled(false);
- } else {
- verifyCurrentSelection();
- fSelectionList.selectFilterText();
- fSelectionList.setFocus();
- }
- }
- /**
- * Returns the currently used filter text.
- */
- protected String getFilter() {
- return fSelectionList.getFilter();
- }
- /**
- * Returns the selection indices.
- */
- protected int[] getSelectionIndices() {
- return fSelectionList.getSelectionIndices();
- }
- /**
- * Returns the widget selection. Returns empty list when the widget is not
- * usable.
- */
- protected List getWidgetSelection() {
- if (fSelectionList == null || fSelectionList.isDisposed())
- return new ArrayList(0);
- return fSelectionList.getSelection();
- }
- /**
- * An element as been selected in the list by double clicking on it.
- * Emulate a OK button pressed to close the dialog.
- */
- protected abstract void handleDoubleClick();
- /**
- * Checks whether the list of elements is empty or not.
- */
- protected boolean isEmptyList() {
- if (fSelectionList == null)
- return true;
- return fSelectionList.isEmptyList();
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- super(parent);
- setTitle(title);
- setImage(image);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- fIsMultipleSelection= multipleSelection;
-
- fMessageText= ""; //$NON-NLS-1$
-
- fCurrStatus= new StatusInfo();
-
- fValidator= null;
- fEmptyListMessage= ""; //$NON-NLS-1$
- fNothingSelectedMessage= ""; //$NON-NLS-1$
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
- }
- /*
- * @private
- */
- public int open() {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- access$superOpen();
- }
- });
- return getReturnCode() ;
- }
- /**
- * Refilters the current list according to the filter entered into the
- * text edit field.
- */
- protected void refilter() {
- fSelectionList.filter(true);
- }
- /**
- * If a empty-list message is set, a error message is shown
- * Must be set before widget creation
- */
- public void setEmptyListMessage(String message) {
- fEmptyListMessage= message;
- }
- /**
- * Sets the filter text to the given value.
- */
- protected void setFilter(String text, boolean refilter) {
- fSelectionList.setFilter(text, refilter);
- }
- /**
- * Sets the message to be shown above the match text field.
- * Must be set before widget creation
- */
- public void setMessage(String message) {
- fMessageText= message;
- }
- /**
- * If the selection is empty, this message is shown
- */
- public void setNothingSelectedMessage(String message) {
- fNothingSelectedMessage= message;
- }
- /**
- * Selects the elements in the list determined by the given
- * selection indices.
- */
- protected void setSelection(int[] selection) {
- fSelectionList.setSelection(selection);
- }
- /**
- * Initializes the selection list widget with the given list of
- * elements.
- */
- protected void setSelectionListElements(List elements, boolean refilter) {
- fSelectionList.setElements(elements, refilter);
- }
- /**
- * A validator can be set to check if the current selection
- * is valid
- */
- public void setValidator(ISelectionValidator validator) {
- fValidator= validator;
- }
- /**
- * Verifies the current selection and updates the status line
- * accordingly.
- */
- protected boolean verifyCurrentSelection() {
- List sel= getWidgetSelection();
- int length= sel.size();
- if (length > 0) {
- if (fValidator != null) {
- fValidator.isValid(sel.toArray(), fCurrStatus);
- } else {
- fCurrStatus.setOK();
- }
- } else {
- if (isEmptyList()) {
- fCurrStatus.setError(fEmptyListMessage);
- } else {
- fCurrStatus.setError(fNothingSelectedMessage);
- }
- }
- updateStatus(fCurrStatus);
- return fCurrStatus.isOK();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
deleted file mode 100644
index 830e08ba5e6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-
-/**
- * A class to select one or more elements out of an indexed property
- */
-public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
-
- private List fElements;
-
- /*
- * @private
- */
- protected void computeResult() {
- setResult(getWidgetSelection());
- }
- /*
- * @private
- */
- protected Control createDialogArea(Composite parent) {
- Control result= super.createDialogArea(parent);
-
- setSelectionListElements(fElements, false);
- //a little trick to make the window come up faster
- String initialFilter= null;
- if (getPrimaryInitialSelection() instanceof String)
- initialFilter= (String)getPrimaryInitialSelection();
- if (initialFilter != null)
- setFilter(initialFilter, true);
- else
- refilter();
-
- return result;
- }
- public Object getSelectedElement() {
- return getPrimaryResult();
- }
- public Object[] getSelectedElements() {
- return getResult();
- }
- /*
- * @private
- */
- protected void handleDoubleClick() {
- if (verifyCurrentSelection()) {
- buttonPressed(IDialogConstants.OK_ID);
- }
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upper case
- * @param multipleSelection Allow multiple selection
- */
- public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- super (parent, title, image, renderer, ignoreCase, multipleSelection);
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
- }
- public int open(Object[] elements) {
- return open(Arrays.asList(elements));
- }
- public int open(Object[] elements, String initialSelection) {
- return open(Arrays.asList(elements), initialSelection);
- }
- /**
- * Open the dialog.
- * @param elements The elements to show in the list
- * @return Returns OK or CANCEL
- */
- public int open(List elements) {
- setElements(elements);
- return open();
- }
- /**
- * Open the dialog.
- * @param elements The elements to show in the list
- * @param initialSelection The initial content of the match text box.
- * @return Returns OK or CANCEL
- */
- public int open(List elements, String initialSelection) {
- setElements(elements);
- setInitialSelection(initialSelection);
- return open();
- }
- /**
- * Sets the elements presented by this dialog.
- */
- public void setElements(List elements) {
- fElements= elements;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java
deleted file mode 100644
index cf1849fa205..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-public interface ISelectionValidator {
- void isValid(Object[] selection, StatusInfo res);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
deleted file mode 100644
index f8b0d90cd55..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-
-public interface IStatusChangeListener {
-
- /**
- * Called to annonce that the given status has changed
- */
- void statusChanged(IStatus status);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
deleted file mode 100644
index 9adc3fb1d60..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A message line. It distinguishs between "normal" messages and errors.
- * Setting an error message hides a currently displayed message until
- * <code>clearErrorMessage</code> is called.
- */
-public class MessageLine extends CLabel {
-
- private String fMessageText;
- private String fErrorText;
-
- private Color fDefaultColor;
- private RGB fErrorRGB;
- protected Color fErrorColor;
-
- private static RGB fgErrorRGB= new RGB(200, 0, 0);
-
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage() {
- setErrorMessage(null);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage() {
- setMessage(null);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage() {
- return fErrorText;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage() {
- return fMessageText;
- }
- /**
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown with in the given rgb color.
- */
- public MessageLine(Composite parent, int style, RGB errorRGB) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= errorRGB;
- }
- /**
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown with in the rgb color 200,0,0.
- */
- public MessageLine(Composite parent, int style) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= fgErrorRGB;
- }
- /**
- * Creates a new message line as a child of the given parent.
- * Error message will be shown with in the rgb color 200,0,0.
- */
- public MessageLine(Composite parent) {
- this(parent, SWT.LEFT);
- }
- /**
- * Sets the default error color used by all message lines.
- * Note: a call to this method only affects newly created MessageLines not existing ones.
- */
- public static void setErrorColor(RGB color) {
- fgErrorRGB= color;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message) {
- fErrorText= message;
-
- if (message == null) {
- setMessage(fMessageText);
- } else {
- if (fErrorColor == null) {
- fErrorColor= new Color(getDisplay(), fErrorRGB);
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fErrorColor.dispose();
- }
- });
- }
- setForeground(fErrorColor);
- setText(message);
- }
- }
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message) {
- fMessageText= message;
- if (message == null)
- message= ""; //$NON-NLS-1$
- if (fErrorText == null) {
- setForeground(fDefaultColor);
- setText(message);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
deleted file mode 100644
index b1318f67f99..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
+++ /dev/null
@@ -1,250 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-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.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-
-import org.eclipse.cdt.internal.ui.util.StringMatcher;
-import org.eclipse.cdt.internal.ui.util.TwoArrayQuickSort;
-
-/**
- * A selection widget that consists of a list and a text entry field. The list
- * of elements presented are limited to the pattern entered into the text entry
- * field.
- */
-public class SelectionList extends Composite {
-
- // State
- private Object[] fElements;
- protected ILabelProvider fRenderer;
- private boolean fIgnoreCase;
-
- // Implementation details
- private String[] fRenderedStrings;
- private int[] fFilteredElements;
- private String fRememberedMatchText;
-
- // SWT widgets
- private Table fList;
- private Text fText;
-
- /**
- * Adds a selection change listener to this widget.
- */
- public void addSelectionListener(SelectionListener listener) {
- fList.addSelectionListener(listener);
- }
- private void createList(int style) {
- fList= new Table(this, style);
- fList.setLayoutData(new GridData(GridData.FILL_BOTH));
- fList.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fRenderer.dispose();
- }
- });
- }
- private void createText() {
- fText= new Text(this, SWT.BORDER);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
- fText.setLayoutData(spec);
- Listener l= new Listener() {
- public void handleEvent(Event evt) {
- filter(false);
- }
- };
- fText.addListener(SWT.Modify, l);
- }
- /**
- * Filters the list of elements according to the pattern entered
- * into the text entry field.
- */
- public void filter(boolean forceUpdate) {
- int k= 0;
- String text= fText.getText();
- if (!forceUpdate && text.equals(fRememberedMatchText))
- return;
- fRememberedMatchText= text;
- StringMatcher matcher= new StringMatcher(text+"*", fIgnoreCase, false); //$NON-NLS-1$
- for (int i= 0; i < fElements.length; i++) {
- if (matcher.match(fRenderedStrings[i])) {
- fFilteredElements[k]= i;
- k++;
- }
- }
- fFilteredElements[k]= -1;
- updateListWidget(fFilteredElements, k);
- }
- /**
- * Returns the currently used filter text.
- */
- public String getFilter() {
- return fText.getText();
- }
- /**
- * Returns the selection indices.
- */
- public int[] getSelectionIndices() {
- return fList.getSelectionIndices();
- }
- /**
- * Returns a list of selected elements. Note that the type of the elements
- * returned in the list are the same as the ones passed to the selection list
- * via <code>setElements</code>. The list doesn't contain the rendered strings.
- */
- public List getSelection() {
- if (fList == null || fList.isDisposed() || fList.getSelectionCount() == 0)
- return new ArrayList(0);
- int[] listSelection= fList.getSelectionIndices();
- List selected= new ArrayList(listSelection.length);
- for (int i= 0; i < listSelection.length; i++) {
- selected.add(fElements[fFilteredElements[listSelection[i]]]);
- }
- return selected;
- }
- /**
- * Returns <code>true</code> when the list of elements is empty.
- */
- public boolean isEmptyList() {
- return fElements == null || fElements.length == 0;
- }
- /**
- * Creates new instance of the widget.
- */
- public SelectionList(Composite parent, int style, ILabelProvider renderer, boolean ignoreCase) {
- super(parent, SWT.NONE);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0; layout.marginWidth= 0;
- //XXX: 1G9V58A: ITPUI:WIN2000 - Dialog.convert* methods should be static
- setLayout(layout);
- createText();
- createList(style);
- }
- /**
- * Removes a selection change listener to this widget.
- */
- public void removeSelectionListener(SelectionListener listener) {
- fList.removeSelectionListener(listener);
- }
- private String[] renderStrings() {
- String[] strings= new String[fElements.length];
- for (int i= 0; i < strings.length; i++) {
- strings[i]= fRenderer.getText(fElements[i]);
- }
- TwoArrayQuickSort.sort(strings, fElements, fIgnoreCase);
- return strings;
- }
- /**
- * Select the pattern text.
- */
- public void selectFilterText() {
- fText.selectAll();
- }
- /**
- * Sets the list of elements presented in the widget.
- */
- public void setElements(List elements, boolean refilter) {
- // We copy the list since we sort it.
- if (elements == null)
- fElements= new Object[0];
- else
- fElements= elements.toArray();
- fFilteredElements= new int[fElements.length+1];
- fRenderedStrings= renderStrings();
- if (refilter)
- filter(true);
- }
- /*
- * Non Java-doc
- */
- public void setEnabled(boolean enable) {
- super.setEnabled(enable);
- fText.setEnabled(enable);
- fList.setEnabled(enable);
- }
- /**
- * Sets the filter pattern. Current only prefix filter pattern are supported.
- */
- public void setFilter(String pattern, boolean refilter) {
- fText.setText(pattern);
- if (refilter)
- filter(true);
- }
- /*
- * Non Java-doc
- */
- public boolean setFocus() {
- return fText.setFocus();
- }
- /*
- * Non Java-doc
- */
- public void setFont(Font font) {
- super.setFont(font);
- fText.setFont(font);
- fList.setFont(font);
- }
- /**
- * Selects the elements in the list determined by the given
- * selection indices.
- */
- protected void setSelection(int[] selection) {
- fList.setSelection(selection);
- }
- private void updateListWidget(int[] indices, int size) {
- if (fList == null || fList.isDisposed())
- return;
- fList.setRedraw(false);
- int itemCount= fList.getItemCount();
- if (size < itemCount) {
- fList.remove(0, itemCount-size-1);
- }
-
- TableItem[] items= fList.getItems();
- for (int i= 0; i < size; i++) {
- TableItem ti= null;
- if (i < itemCount) {
- ti= items[i];
- } else {
- ti= new TableItem(fList, i);
- }
- ti.setText(fRenderedStrings[indices[i]]);
- Image img= fRenderer.getImage(fElements[indices[i]]);
- if (img != null)
- ti.setImage(img);
- }
- if (fList.getItemCount() > 0) {
- fList.setSelection(0);
- }
-
- fList.setRedraw(true);
- Event event= new Event();
- fList.notifyListeners(SWT.Selection, event);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
deleted file mode 100644
index 69c8cdd11d6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-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.Shell;
-
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * An abstract base class for dialogs with a status bar and ok/cancel buttons.
- * The status message must be passed over as StatusInfo object and can be
- * an error, warning or ok. The OK button is enabled / disabled depending
- * on the status.
- */
-public abstract class SelectionStatusDialog extends SelectionDialog {
-
- private MessageLine fStatusLine;
- private IStatus fLastStatus;
- private Image fImage;
- private boolean fInitialSelectionSet;
- private boolean fStatusLineAboveButtons= false;
-
-
- /**
- * Compute the result and return it.
- */
- protected abstract void computeResult();
- /* (non-Javadoc)
- * Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (fImage != null)
- shell.setImage(fImage);
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- if (fStatusLineAboveButtons) {
- layout.verticalSpacing= 0;
- } else {
- layout.numColumns= 2;
- }
- layout.marginHeight= 0; layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fStatusLine= new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fStatusLine.setMessage(""); //$NON-NLS-1$
-
- super.createButtonBar(composite);
- return composite;
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- public void create() {
- super.create();
- if (fLastStatus != null) {
- updateStatus(fLastStatus);
- }
- }
- /**
- * Returns the first element of the initial selection or <code>null<code>
- * if there isn't any initial selection.
- * @return the first element of the initial selection.
- */
- protected Object getPrimaryInitialSelection() {
- List result= getInitialElementSelections();
- if (result == null || result.size() == 0)
- return null;
- return result.get(0);
- }
- /**
- * Returns the first element from the list of results. Returns <code>null</code>
- * if no element has been selected.
- *
- * @return the first result element if one exists. Otherwise <code>null</code> is
- * returned.
- */
- public Object getPrimaryResult() {
- Object[] result= getResult();
- if (result == null || result.length == 0)
- return null;
- return result[0];
- }
- public SelectionStatusDialog(Shell parent) {
- super(parent);
- fInitialSelectionSet= false;
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- protected void okPressed() {
- computeResult();
- super.okPressed();
- }
- /**
- * Sets the image for this dialog.
- *
- * @param image the dialog's image
- */
- public void setImage(Image image) {
- fImage= image;
- }
- protected void setInitialSelection(int position, Object element) {
- List l= getInitialElementSelections();
- l.set(position, element);
- fInitialSelectionSet= true;
- }
- /**
- * Sets the initial selection to the given element.
- */
- public void setInitialSelection(Object element) {
- // Allow clients to use set their own initial selection(s)
- if (fInitialSelectionSet && element != null && element.equals("A")) //$NON-NLS-1$
- return;
-
- if (element != null) {
- setInitialSelections(new Object[] { element });
- } else {
- setInitialSelections(new Object[0]);
- }
- }
- public void setInitialSelections(Object[] selectedElements) {
- super.setInitialSelections(selectedElements);
- fInitialSelectionSet= true;
- }
- /**
- * Sets a result element at the given position.
- */
- protected void setResult(int position, Object element) {
- Object[] result= getResult();
- result[position]= element;
- setResult(Arrays.asList(result));
- }
- /**
- * Controls whether status line appears to the left of the buttons (default)
- * or above them.
- *
- * @param aboveButtons if <code>true</code> status line is placed above buttons; if
- * <code>false</code> to the right
- */
- public void setStatusLineAboveButtons(boolean aboveButtons) {
- fStatusLineAboveButtons= aboveButtons;
- }
- /**
- * Update the status of the ok button to reflect the given status. Subclasses
- * may override this method to update additional buttons.
- */
- protected void updateButtonsEnableState(IStatus status) {
- Button okButton= getOkButton();
- if (okButton != null && !okButton.isDisposed())
- okButton.setEnabled(!status.matches(IStatus.ERROR));
- }
- /**
- * Update the dialog's status line to reflect the given status. It is safe to call
- * this method before the dialog has been opened.
- */
- protected void updateStatus(IStatus status) {
- fLastStatus= status;
- if (fStatusLine != null && !fStatusLine.isDisposed()) {
- updateButtonsEnableState(status);
- StatusTool.applyToStatusLine(fStatusLine, status);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java
deleted file mode 100644
index 7064e0caaab..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-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.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * An abstract base class for dialogs with a status bar and ok/cancel buttons.
- * The status message must be passed over as StatusInfo object and can be
- * an error, warning or ok. The OK button is enabled or disabled depending
- * on the status.
- */
-public abstract class StatusDialog extends Dialog {
-
- private Button fOkButton;
- private MessageLine fStatusLine;
- private IStatus fLastStatus;
- private String fTitle;
- private Image fImage;
-
- private boolean fStatusLineAboveButtons;
-
- /**
- * Creates an instane of a status dialog.
- */
- public StatusDialog(Shell parent) {
- super(parent);
- fStatusLineAboveButtons= false;
- }
-
- /**
- * Specifies whether status line appears to the left of the buttons (default)
- * or above them.
- *
- * @param aboveButtons if <code>true</code> status line is placed above buttons; if
- * <code>false</code> to the right
- */
- public void setStatusLineAboveButtons(boolean aboveButtons) {
- fStatusLineAboveButtons= aboveButtons;
- }
-
- /**
- * Update the dialog's status line to reflect the given status.
- * It is save to call this method before the dialog has been opened.
- */
- protected void updateStatus(IStatus status) {
- fLastStatus= status;
- if (fStatusLine != null && !fStatusLine.isDisposed()) {
- updateButtonsEnableState(status);
- fStatusLine.setErrorMessage(status.getMessage());
- }
- }
-
- /**
- * Returns the last status.
- */
- public IStatus getStatus() {
- return fLastStatus;
- }
-
- /**
- * Updates the status of the ok button to reflect the given status.
- * Subclasses may override this method to update additional buttons.
- * @param status the status.
- */
- protected void updateButtonsEnableState(IStatus status) {
- if (fOkButton != null && !fOkButton.isDisposed())
- fOkButton.setEnabled(!status.matches(IStatus.ERROR));
- }
-
- /*
- * @see Window#create(Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (fTitle != null)
- shell.setText(fTitle);
- }
-
- /*
- * @see Window#create()
- */
- public void create() {
- super.create();
- if (fLastStatus != null) {
- // policy: dialogs are not allowed to come up with an error message
- if (fLastStatus.matches(IStatus.ERROR)) {
- StatusInfo status= new StatusInfo();
- status.setError(""); //$NON-NLS-1$
- fLastStatus= status;
- }
- updateStatus(fLastStatus);
- }
- }
-
- /*
- * @see Dialog#createButtonsForButtonBar(Composite)
- */
- protected void createButtonsForButtonBar(Composite parent) {
- fOkButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- /*
- * @see Dialog#createButtonBar(Composite)
- */
- protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fStatusLine= new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fStatusLine.setErrorMessage(null); //$NON-NLS-1$
-
- super.createButtonBar(composite);
- return composite;
- }
-
- /**
- * Sets the title for this dialog.
- * @param title the title.
- */
- public void setTitle(String title) {
- fTitle= title != null ? title : ""; //$NON-NLS-1$
- Shell shell= getShell();
- if ((shell != null) && !shell.isDisposed())
- shell.setText(fTitle);
- }
-
- /**
- * Sets the image for this dialog.
- * @param image the image.
- */
- public void setImage(Image image) {
- fImage= image;
- Shell shell= getShell();
- if ((shell != null) && !shell.isDisposed())
- shell.setImage(fImage);
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
deleted file mode 100644
index 8e531198b71..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.cdt.core.CCorePlugin;
-
-/**
- * A settable IStatus
- * Can be an error, warning, info or ok. For error, info and warning states,
- * a message describes the problem
- */
-public class StatusInfo implements IStatus {
-
- private String fStatusMessage;
- private int fSeverity;
-
- /**
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
- /**
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
- /**
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
- /**
- * @see IStatus#getMessage
- */
- public String getMessage() {
- return fStatusMessage;
- }
- /**
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return CCorePlugin.PLUGIN_ID;
- }
- /**
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
- /**
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
- /**
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
- public void setError(String errorMessage) {
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
- public void setInfo(String infoMessage) {
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
- public void setWarning(String warningMessage) {
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
- public StatusInfo() {
- fStatusMessage= null;
- fSeverity= OK;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
deleted file mode 100644
index 89471bedd91..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.cdt.internal.ui.dialogs;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.dialogs.DialogPage;
-
-public class StatusTool {
-
- /**
- * Applies the status to the status line of a dialog page
- */
- public static void applyToStatusLine(MessageLine messageLine, IStatus status) {
- String[] messages= getErrorMessages(status);
- messageLine.setErrorMessage(messages[0]);
- messageLine.setMessage(messages[1]);
- }
- /**
- * Applies the status to the status line of a dialog page
- */
- public static void applyToStatusLine(DialogPage page, IStatus status) {
- String[] messages= getErrorMessages(status);
- page.setErrorMessage(messages[0]);
- page.setMessage(messages[1]);
- }
- /**
- * Returns error-message / warning-message for a status
- */
- public static String[] getErrorMessages(IStatus status) {
- String message= status.getMessage();
- if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$
- return new String[] { message, null };
- } else if (status.matches(IStatus.WARNING | IStatus.INFO)) {
- return new String[] { null, message };
- } else {
- return new String[] { null, null };
- }
- }
- /**
- * Compare two IStatus. The more severe is returned:
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
- if (s1.getSeverity() > s2.getSeverity()) {
- return s1;
- } else {
- return s2;
- }
- }
- /**
- * Finds the most severe status from a array of status
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
- if (curr.matches(IStatus.ERROR)) {
- return curr;
- }
- if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
- }
- }
- return max;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
deleted file mode 100644
index b1e959d5c1d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.dialogs.DialogPage;
-
-/**
- * A utility class to work with IStatus.
- */
-public class StatusUtil {
-
- /**
- * Compares two instances of <code>IStatus</code>. The more severe is returned:
- * An error is more severe than a warning, and a warning is more severe
- * than ok. If the two stati have the same severity, the second is returned.
- */
- public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
- if (s1.getSeverity() > s2.getSeverity()) {
- return s1;
- } else {
- return s2;
- }
- }
-
- /**
- * Finds the most severe status from a array of stati.
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
- if (curr.matches(IStatus.ERROR)) {
- return curr;
- }
- if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
- }
- }
- return max;
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- */
- public static void applyToStatusLine(DialogPage page, IStatus status) {
- String message= status.getMessage();
- switch (status.getSeverity()) {
- case IStatus.OK:
- page.setMessage(message, DialogPage.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING:
- page.setMessage(message, DialogPage.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO:
- page.setMessage(message, DialogPage.INFORMATION);
- page.setErrorMessage(null);
- break;
- default:
- if (message.length() == 0) {
- message= null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/DelegatingDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/DelegatingDragAdapter.java
deleted file mode 100644
index 42fd8686d85..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/DelegatingDragAdapter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.drag;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * A delegating drag adapter negotiates between a set of <code>TransferDragSourceListener</code>s
- * On <code>dragStart</code> the adapter determines the listener to be used for any further
- * <code>drag*</code> callbacks.
- */
-public class DelegatingDragAdapter implements DragSourceListener {
- private final ISelectionProvider provider;
- private final TransferDragSourceListener[] listeners;
- private final boolean[] actives;
- private TransferDragSourceListener selected;
-
- public DelegatingDragAdapter(
- ISelectionProvider provider,
- TransferDragSourceListener[] listeners) {
- super();
- Assert.isNotNull(provider);
- Assert.isNotNull(listeners);
- this.provider = provider;
- this.listeners = listeners;
- this.actives = new boolean[listeners.length];
- this.selected = null;
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragStart(DragSourceEvent event) {
- selected = null;
-
- if (provider.getSelection().isEmpty()) {
- event.doit = false;
- return;
- }
-
- // Workaround for 1GEUS9V
- final DragSource dragSource = (DragSource) event.widget;
- final Control control = dragSource.getControl();
-
- if (control != control.getDisplay().getFocusControl()) {
- event.doit = false;
- return;
- }
-
- final Object saveData = event.data;
- final boolean saveDoit = event.doit;
- final int listenerCount = listeners.length;
-
- int transferCount = 0;
-
- for (int i = 0; i < listenerCount; ++i) {
- TransferDragSourceListener listener = listeners[i];
-
- event.data = saveData;
- event.doit = saveDoit;
-
- listener.dragStart(event);
-
- if (actives[i] = event.doit)
- ++transferCount;
- }
-
- event.data = saveData;
-
- if (event.doit = (transferCount != 0)) {
- Transfer[] transferArray = new Transfer[transferCount];
-
- for (int i = listenerCount; --i >= 0;)
- if (actives[i])
- transferArray[--transferCount] = listeners[i].getTransfer();
-
- dragSource.setTransfer(transferArray);
- }
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragSetData(DragSourceEvent event) {
- selected = getListener(event.dataType);
-
- if (selected != null)
- selected.dragSetData(event);
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragFinished(DragSourceEvent event) {
- try {
- // If the user presses Escape then we get a dragFinished
- // without getting a dragSetData before.
- if (selected == null)
- selected = getListener(event.dataType);
-
- if (selected != null)
- selected.dragFinished(event);
- } finally {
- Arrays.fill(actives, false);
- selected = null;
- }
- }
-
- private TransferDragSourceListener getListener(TransferData type) {
- if (type != null) {
- for (int i = 0; i < actives.length; ++i) {
- if (actives[i]) {
- TransferDragSourceListener listener = listeners[i];
-
- if (listener.getTransfer().isSupportedType(type))
- return listener;
- }
- }
- }
-
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/FileTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/FileTransferDragAdapter.java
deleted file mode 100644
index 83c559bcc65..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/FileTransferDragAdapter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.drag;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-public class FileTransferDragAdapter implements TransferDragSourceListener {
- private final ISelectionProvider provider;
-
- public FileTransferDragAdapter(ISelectionProvider provider) {
- super();
- this.provider = provider;
- Assert.isNotNull(provider);
- }
-
- public Transfer getTransfer() {
- return FileTransfer.getInstance();
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit = !getResources().isEmpty();
- }
-
- public void dragSetData(DragSourceEvent event) {
- String[] locations = getResourceLocations(getResources());
-
- event.data = locations.length != 0 ? locations : null;
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (event.doit) {
- if (event.detail == DND.DROP_MOVE) {
- // Never delete resources when dragging outside Eclipse.
- // See: http://bugs.eclipse.org/bugs/show_bug.cgi?id=30543
- } else if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_TARGET_MOVE) {
- runOperation(new RefreshOperation(getResources()), true, false);
- }
- }
- }
-
- private static class RefreshOperation extends WorkspaceModifyOperation {
- private final Set roots;
-
- public RefreshOperation(List resources) {
- super();
-
- roots = new HashSet(resources.size());
-
- for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
- IResource resource = (IResource) iterator.next();
- IResource parent = resource.getParent();
-
- roots.add(parent != null ? parent : resource);
- }
- }
-
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(CUIMessages.getString("DragAdapter.refreshing"), roots.size()); //$NON-NLS-1$
- MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.getString("DragAdapter.problem"), null); //$NON-NLS-1$
-
- for (Iterator iterator = roots.iterator(); iterator.hasNext();) {
- IResource resource = (IResource) iterator.next();
-
- try {
- resource.refreshLocal(
- IResource.DEPTH_ONE,
- new SubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- status.add(e.getStatus());
- }
- }
-
- if (!status.isOK())
- throw new CoreException(status);
- } finally {
- monitor.done();
- }
- }
- }
-
- private List getResources() {
- List result = Collections.EMPTY_LIST;
- ISelection selection = provider.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structured = (IStructuredSelection) selection;
-
- result = new ArrayList(structured.size());
-
- for (Iterator iterator = structured.iterator(); iterator.hasNext();) {
- Object object = iterator.next();
- IResource resource = null;
-
- if (object instanceof IResource)
- resource = (IResource) object;
- else if (object instanceof IAdaptable)
- resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
-
- if (resource != null)
- result.add(resource);
- }
- }
-
- return result;
- }
-
- private static String[] getResourceLocations(List resources) {
- final int count = resources.size();
- final List locations = new ArrayList(count);
-
- for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
- IResource resource = (IResource) iterator.next();
- IPath location = resource.getLocation();
-
- if (location != null)
- locations.add(location.toOSString());
- }
-
- String[] result = new String[locations.size()];
-
- locations.toArray(result);
-
- return result;
- }
-
- private static void runOperation(
- IRunnableWithProgress operation,
- boolean fork,
- boolean cancelable) {
- try {
- IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- Shell parent = window.getShell();
-
- new ProgressMonitorDialog(parent).run(fork, cancelable, operation);
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled by user.
- } catch (InvocationTargetException e) {
- String message = CUIMessages.getString("Problem while moving or copying files."); //$NON-NLS-1$
- String title = CUIMessages.getString("Drag & Drop"); //$NON-NLS-1$
-
- ExceptionHandler.handle(e, title, message);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/LocalSelectionTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/LocalSelectionTransferDragAdapter.java
deleted file mode 100644
index ebaadff9067..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/LocalSelectionTransferDragAdapter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.drag;
-
-import org.eclipse.cdt.ui.CLocalSelectionTransfer;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.Transfer;
-
-public class LocalSelectionTransferDragAdapter implements TransferDragSourceListener {
- private final ISelectionProvider provider;
- private final CLocalSelectionTransfer transfer;
-
- public LocalSelectionTransferDragAdapter(ISelectionProvider provider) {
- super();
- this.provider = provider;
- this.transfer = CLocalSelectionTransfer.getInstance();
- Assert.isNotNull(provider);
- Assert.isNotNull(transfer);
- }
-
- /* (non-Javadoc)
- * @see DragSourceListener#dragStart
- */
- public void dragStart(DragSourceEvent event) {
- transfer.setSelection(provider.getSelection());
-
- event.doit = true;
- }
-
- /* (non-Javadoc)
- * @see DragSourceListener#dragSetData
- */
- public void dragSetData(DragSourceEvent event) {
- event.data = transfer.isSupportedType(event.dataType) ? transfer.getSelection() : null;
- }
-
- /* (non-Javadoc)
- * @see DragSourceListener#dragFinished
- */
- public void dragFinished(DragSourceEvent event) {
- transfer.setSelection(null);
- }
-
- /* (non-Javadoc)
- * @see TransferDragSourceListener#getTransfer
- */
- public Transfer getTransfer() {
- return transfer;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/ResourceTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/ResourceTransferDragAdapter.java
deleted file mode 100644
index a1a95d710f6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/ResourceTransferDragAdapter.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.drag;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.ReadOnlyStateChecker;
-import org.eclipse.ui.part.ResourceTransfer;
-
-/**
- * A drag adapter that transfers the current selection as </code>
- * IResource</code>. Only those elements in the selection are part
- * of the transfer which can be converted into an <code>IResource
- * </code>.
- */
-public class ResourceTransferDragAdapter implements TransferDragSourceListener {
- private final ISelectionProvider provider;
-
- /**
- * Creates a new ResourceTransferDragAdapter for the given selection provider.
- *
- * @param provider the selection provider to access the viewer's selection
- */
- public ResourceTransferDragAdapter(ISelectionProvider provider) {
- super();
- this.provider = provider;
- Assert.isNotNull(provider);
- }
-
- public Transfer getTransfer() {
- return ResourceTransfer.getInstance();
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit = false;
-
- ISelection selection = provider.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structured = (IStructuredSelection) selection;
-
- for (Iterator iterator = structured.iterator(); iterator.hasNext();) {
- Object element = iterator.next();
-
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- IResource resource = (IResource) adaptable.getAdapter(IResource.class);
-
- if (resource == null) {
- event.doit = false;
- break;
- }
-
- // this will stick unless a later part of the
- // selection isn't adaptable into a resource
- event.doit = true;
- }
- }
- }
- }
-
- public void dragSetData(DragSourceEvent event) {
- event.data = getSelectedResources();
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (event.doit && event.detail == DND.DROP_MOVE) {
- IResource[] resources = getSelectedResources();
-
- if (resources.length == 0)
- return;
-
- DragSource dragSource = (DragSource) event.widget;
- Control control = dragSource.getControl();
- Shell shell = control.getShell();
- String title = CUIMessages.getString("Drag.move.problem.title"); //$NON-NLS-1$
- String message = CUIMessages.getString("Drag.move.problem.message"); //$NON-NLS-1$
-
- ReadOnlyStateChecker checker = new ReadOnlyStateChecker(shell, title, message);
-
- resources = checker.checkReadOnlyResources(resources);
-
- // delete the old elements
- for (int i = 0; i < resources.length; ++i) {
- try {
- resources[i].delete(IResource.KEEP_HISTORY | IResource.FORCE, null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- private IResource[] getSelectedResources() {
- List resources = Collections.EMPTY_LIST;
- ISelection selection = provider.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structured = (IStructuredSelection) selection;
-
- resources = new ArrayList(structured.size());
-
- for (Iterator iterator = structured.iterator(); iterator.hasNext();) {
- Object element = iterator.next();
-
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- IResource resource = (IResource) adaptable.getAdapter(IResource.class);
-
- if (resource != null)
- resources.add(resource);
- }
- }
- }
-
- IResource[] result = new IResource[resources.size()];
- resources.toArray(result);
-
- return result;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/TransferDragSourceListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/TransferDragSourceListener.java
deleted file mode 100644
index 0c21d10c152..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/drag/TransferDragSourceListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.drag;
-
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.Transfer;
-
-/**
- * A special drag source listener which is typed with a <code>TransferData</code>.
- */
-public interface TransferDragSourceListener extends DragSourceListener {
- /**
- * Returns the transfer used by this drag source.
- */
- public Transfer getTransfer();
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
deleted file mode 100644
index c676d46c052..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
-import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
-import org.eclipse.cdt.internal.ui.codemanipulation.AddIncludeOperation;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.cdt.ui.IRequiredInclude;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IUpdate;
-
-
-public class AddIncludeOnSelectionAction extends Action implements IUpdate {
-
- private ITextEditor fEditor;
-
-
- public AddIncludeOnSelectionAction() {
- this(null);
- }
- public AddIncludeOnSelectionAction(ITextEditor editor) {
- super(CEditorMessages.getString("AddIncludeOnSelection.label")); //$NON-NLS-1$
- setToolTipText(CEditorMessages.getString("AddIncludeOnSelection.tooltip")); //$NON-NLS-1$
- setDescription(CEditorMessages.getString("AddIncludeOnSelection.description")); //$NON-NLS-1$
-
- fEditor= editor;
- //WorkbenchHelp.setHelp(this, new Object[] { IJavaHelpContextIds.ADD_IMPORT_ON_SELECTION_ACTION });
- }
- private void addInclude(IRequiredInclude[] inc, CFileElementWorkingCopy tu) {
- AddIncludeOperation op= new AddIncludeOperation(fEditor, tu, inc, false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(false, true, op);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- MessageDialog.openError(getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message1"), e.getTargetException().getMessage()); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- }
- }
-
- private CFileElementWorkingCopy getTranslationUnit () {
- CFileElementWorkingCopy unit = null;
- if(fEditor != null) {
- IEditorInput editorInput= (IEditorInput)fEditor.getEditorInput();
- IDocumentProvider provider= fEditor.getDocumentProvider();
- try {
- if (editorInput instanceof IFileEditorInput)
- unit = new CFileElementWorkingCopy((IFileEditorInput)editorInput, provider);
- else if (editorInput instanceof IStorageEditorInput)
- unit = new CFileElementWorkingCopy((IStorageEditorInput)editorInput, provider);
- else
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "no Editor Input", null));
-
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- }
- }
- return unit;
- }
-
- protected Shell getShell() {
- return fEditor.getSite().getShell();
- }
-
- private int getNameStart(IDocument doc, int pos) throws BadLocationException {
- if (pos > 0 && doc.getChar(pos - 1) == '.') {
- pos--;
- while (pos > 0) {
- char ch= doc.getChar(pos - 1);
- if (!Character.isJavaIdentifierPart(ch) && ch != '.') {
- return pos;
- }
- pos--;
- }
- }
- return pos;
- }
-
-/* private void removeQualification(IDocument doc, int nameStart, IType type) throws BadLocationException {
- String packName= type.getPackageFragment().getElementName();
- int packLen= packName.length();
- if (packLen > 0) {
- for (int k= 0; k < packLen; k++) {
- if (doc.getChar(nameStart + k) != packName.charAt(k)) {
- return;
- }
- }
- doc.replace(nameStart, packLen + 1, ""); //$NON-NLS-1$
- }
- } */
- /**
- * @see IAction#actionPerformed
- */
- public void run() {
-
- CFileElementWorkingCopy tu= getTranslationUnit();
- if (tu != null) {
- ISelection s= fEditor.getSelectionProvider().getSelection();
- IDocument doc= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
- if (!s.isEmpty() && doc != null) {
- ITextSelection selection= (ITextSelection) s;
- try {
- int selStart= selection.getOffset();
- int nameStart= getNameStart(doc, selStart);
- int len= selStart - nameStart + selection.getLength();
-
- String name= doc.get(nameStart, len).trim();
-
- //IType[] types= StubUtility.findAllTypes(typeName, cu.getJavaProject(), null);
- //IType chosen= selectResult(types, packName, getShell());
- IFunctionSummary fs = CCompletionContributorManager.getDefault().getFunctionInfo(name);
- if(fs != null) {
- IRequiredInclude[] ri = fs.getIncludes();
- if(ri != null && ri.length > 0) {
- addInclude(ri, tu);
- return;
- }
- }
- } catch (BadLocationException e) {
- MessageDialog.openError(getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message3"), CEditorMessages.getString("AddIncludeOnSelection.error.message4") + e.getMessage()); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- }
- getShell().getDisplay().beep();
- }
-/* private IType selectResult(IType[] results, String packName, Shell shell) {
- int nResults= results.length;
-
- if (nResults == 0) {
- return null;
- } else if (nResults == 1) {
- return results[0];
- }
-
- if (packName.length() != 0) {
- for (int i= 0; i < results.length; i++) {
- IType curr= (IType) results[i];
- if (packName.equals(curr.getPackageFragment().getElementName())) {
- return curr;
- }
- }
- }
-
- JavaPlugin plugin= JavaPlugin.getDefault();
-
- int flags= (JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION);
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(flags), true, false);
- dialog.setTitle(JavaEditorMessages.getString("AddImportOnSelection.dialog.title")); //$NON-NLS-1$
- dialog.setMessage(JavaEditorMessages.getString("AddImportOnSelection.dialog.message")); //$NON-NLS-1$
- if (dialog.open(results) == dialog.OK) {
- return (IType) dialog.getSelectedElement();
- }
- return null;
- } */
- public void setContentEditor(ITextEditor editor) {
- fEditor= editor;
- }
- public void update() {
- ISelection selection= fEditor.getSelectionProvider().getSelection();
- setEnabled(!selection.isEmpty());
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
deleted file mode 100644
index dc315dfac11..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
+++ /dev/null
@@ -1,333 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.core.model.WorkingCopy;
-import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
-import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.util.ListenerList;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-
-public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
- private CEditor fEditor;
- //private WorkingCopy fInput;
- private IWorkingCopy fInput;
- private ProblemTreeViewer treeViewer;
- private ListenerList selectionChangedListeners = new ListenerList();
- private TogglePresentationAction fTogglePresentation;
- private String fContextMenuId;
-
- private OpenIncludeAction fOpenIncludeAction;
- private FileSearchAction fFileSearchAction;
- private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
- private SearchDialogAction fSearchDialogAction;
-
- private MemberFilterActionGroup fMemberFilterActionGroup;
-
- public CContentOutlinePage(CEditor editor) {
- this("#TranslationUnitOutlinerContext", editor);
- }
-
- public CContentOutlinePage(String contextMenuID, CEditor editor) {
- super();
- fEditor= editor;
- fInput= null;
- fContextMenuId = contextMenuID;
-
- fTogglePresentation= new TogglePresentationAction();
- fTogglePresentation.setEditor(editor);
-
- fOpenIncludeAction= new OpenIncludeAction(this);
- fFileSearchAction= new FileSearchAction(this);
- fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(this);
- fSearchDialogAction = new SearchDialogAction(this, editor);
- }
-
- public ICElement getRoot() {
- return fInput;
- }
-
- /**
- * Called by the editor to signal that the content has updated.
- */
- public void contentUpdated() {
- if (fInput != null) {
- try {
- //fInput.update();
- fInput.reconcile();
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- fInput= null;
- return;
- }
-
- final TreeViewer treeViewer= getTreeViewer();
- if (treeViewer != null && !treeViewer.getControl().isDisposed()) {
- treeViewer.getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!treeViewer.getControl().isDisposed()) {
- ISelection sel= treeViewer.getSelection();
- treeViewer.getControl().setRedraw(false);
- treeViewer.refresh();
- treeViewer.setSelection(updateSelection(sel));
- treeViewer.getControl().setRedraw(true);
- }
- }
- });
- }
- }
- }
-
- protected ISelection updateSelection(ISelection sel) {
- ArrayList newSelection= new ArrayList();
- if (sel instanceof IStructuredSelection) {
- Iterator iter= ((IStructuredSelection)sel).iterator();
- for (;iter.hasNext();) {
- //ICElement elem= fInput.findEqualMember((ICElement)iter.next());
- ICElement elem = (ICElement)iter.next();
- if (elem != null) {
- newSelection.add(elem);
- }
- }
- }
- return new StructuredSelection(newSelection);
- }
-
- /**
- * called to create the context menu of the outline
- */
- protected void contextMenuAboutToShow(IMenuManager menu) {
- if (OpenIncludeAction.canActionBeAdded(getSelection())) {
- menu.add(fOpenIncludeAction);
- }
-
- if (SearchDialogAction.canActionBeAdded(getSelection())) {
- menu.add(fSearchDialogAction);
- }
-
- if (FileSearchAction.canActionBeAdded(getSelection())) {
- MenuManager fileSearch = new MenuManager("File Search");
- fileSearch.add(fFileSearchAction);
- fileSearch.add(fFileSearchActionInWorkingSet);
- menu.add(fileSearch);
- }
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
- }
-
- /**
- * @see ContentOutlinePage#createControl
- */
- public void createControl(Composite parent) {
- treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- treeViewer.addSelectionChangedListener(this);
-
- //treeViewer.setContentProvider(new CModelContentProvider());
- treeViewer.setContentProvider(new CElementContentProvider(true, true));
- treeViewer.setLabelProvider(new StandardCElementLabelProvider());
- treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
- treeViewer.addSelectionChangedListener(this);
-
- CUIPlugin.getDefault().getProblemMarkerManager().addListener(treeViewer);
-
- MenuManager manager= new MenuManager(fContextMenuId);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- Control control= treeViewer.getControl();
- Menu menu= manager.createContextMenu(control);
- control.setMenu(menu);
-
- // register global actions
- IPageSite site= getSite();
- site.registerContextMenu(fContextMenuId, manager, treeViewer);
- site.setSelectionProvider(treeViewer);
- IActionBars bars= site.getActionBars();
- bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION, fTogglePresentation);
-
- registerToolbarActions();
-
- IEditorInput editorInput= (IEditorInput)fEditor.getEditorInput();
- IDocumentProvider provider= fEditor.getDocumentProvider();
- try {
- if (editorInput instanceof IFileEditorInput){
- IWorkingCopyManager wcManager = CUIPlugin.getDefault().getWorkingCopyManager();
- fInput = (WorkingCopy)wcManager.getWorkingCopy(editorInput);
- if (fInput == null) {
- // XXX This should never happen. Put an assert.
- fInput = new CFileElementWorkingCopy((IFileEditorInput)editorInput, provider);
- }
- } else if (editorInput instanceof IStorageEditorInput){
- // CHECKPOINT: do we create a CFileElementWorkingCopy or just a working copy for the IStorageEditorInput?
- // If it is an IStorage it means that there is no underlying IFile.
- fInput = new CFileElementWorkingCopy((IStorageEditorInput)editorInput, provider);
- } else {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "no Editor Input", null));
- }
- treeViewer.setInput(fInput);
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- fInput= null;
- }
- }
-
- public void dispose() {
- CUIPlugin.getDefault().getProblemMarkerManager().removeListener(treeViewer);
- if (fMemberFilterActionGroup != null) {
- fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
- }
- super.dispose();
- }
-
- /**
- * @see IPage#setActionBars(IActionBars)
- */
- public void setActionBars(IActionBars actionBars) {
- IToolBarManager toolBarManager= actionBars.getToolBarManager();
-
- LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
- toolBarManager.add(action);
- }
-
- /* (non-Javadoc)
- * Method declared on ISelectionProvider.
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- selectionChangedListeners.add(listener);
- }
-
- /**
- * Fires a selection changed event.
- *
- * @param selction the new selection
- */
- protected void fireSelectionChanged(ISelection selection) {
- // create an event
- SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
-
- // fire the event
- Object[] listeners = selectionChangedListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((ISelectionChangedListener) listeners[i]).selectionChanged(event);
- }
- }
- /* (non-Javadoc)
- * Method declared on IPage (and Page).
- */
- public Control getControl() {
- if (treeViewer == null)
- return null;
- return treeViewer.getControl();
- }
- /* (non-Javadoc)
- * Method declared on ISelectionProvider.
- */
- public ISelection getSelection() {
- if (treeViewer == null)
- return StructuredSelection.EMPTY;
- return treeViewer.getSelection();
- }
- /**
- * Returns this page's tree viewer.
- *
- * @return this page's tree viewer, or <code>null</code> if
- * <code>createControl</code> has not been called yet
- */
- protected TreeViewer getTreeViewer() {
- return treeViewer;
- }
- /* (non-Javadoc)
- * Method declared on ISelectionProvider.
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- selectionChangedListeners.remove(listener);
- }
- /* (non-Javadoc)
- * Method declared on ISelectionChangeListener.
- * Gives notification that the tree selection has changed.
- */
- public void selectionChanged(SelectionChangedEvent event) {
- fireSelectionChanged(event.getSelection());
- }
- /**
- * Sets focus to a part in the page.
- */
- public void setFocus() {
- treeViewer.getControl().setFocus();
- }
- /* (non-Javadoc)
- * Method declared on ISelectionProvider.
- */
- public void setSelection(ISelection selection) {
- if (treeViewer != null)
- treeViewer.setSelection(selection);
- }
-
- /**
- * @param unit
- */
- public void setInput(IWorkingCopy unit) {
- fInput = unit;
- if (treeViewer != null) {
- treeViewer.setInput (fInput);
- }
- contentUpdated();
- }
-
- private void registerToolbarActions() {
-
- IToolBarManager toolBarManager= getSite().getActionBars().getToolBarManager();
- if (toolBarManager != null) {
- //toolBarManager.add(new ClassOnlyAction());
- //toolBarManager.add(new LexicalSortingAction());
-
- fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$
- fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
deleted file mode 100644
index 836cb443677..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
+++ /dev/null
@@ -1,425 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IBuffer;
-import org.eclipse.cdt.core.model.IOpenable;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.IBufferFactory;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IEditorInputDelegate;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-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.Status;
-import org.eclipse.jface.text.AbstractDocument;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.GapTextStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-
-public class CDocumentProvider extends FileDocumentProvider {
-
- /**
- * Bundle of all required informations to allow working copy management.
- */
- protected class CDocument extends AbstractDocument {
-
- /**
- * Creates a new empty document.
- */
- public CDocument() {
- super();
- setTextStore(new GapTextStore(50, 300));
- setLineTracker(new DefaultLineTracker());
- completeInitialization();
- }
-
- /**
- * Creates a new document with the given initial content.
- *
- * @param initialContent the document's initial content
- */
- public CDocument(String initialContent) {
- super();
- setTextStore(new GapTextStore(50, 300));
- setLineTracker(new DefaultLineTracker());
- getStore().set(initialContent);
- getTracker().set(initialContent);
- completeInitialization();
- }
- };
-
- /**
- * Bundle of all required informations to allow working copy management.
- */
- protected class TranslationUnitFileInfo extends FileInfo {
-
- IWorkingCopy fCopy;
-
- TranslationUnitFileInfo(IDocument document, IAnnotationModel model, FileSynchronizer fileSynchronizer, IWorkingCopy copy) {
- super(document, model, fileSynchronizer);
- fCopy= copy;
- }
-
- void setModificationStamp(long timeStamp) {
- fModificationStamp= timeStamp;
- }
- };
- /**
- * Creates <code>IBuffer</code>s based on documents.
- */
- protected class BufferFactory implements IBufferFactory {
-
- private IDocument internalGetDocument(IFileEditorInput input) throws CoreException {
- IDocument document= getDocument(input);
- if (document != null)
- return document;
- return CDocumentProvider.this.createDocument(input);
- }
-
- public IBuffer createBuffer(IOpenable owner) {
- if (owner instanceof IWorkingCopy) {
-
- IWorkingCopy unit= (IWorkingCopy) owner;
- ITranslationUnit original= (ITranslationUnit) unit.getOriginalElement();
- IResource resource= original.getResource();
- if (resource instanceof IFile) {
- IFileEditorInput providerKey= new FileEditorInput((IFile) resource);
-
- IDocument document= null;
- IStatus status= null;
-
- try {
- document= internalGetDocument(providerKey);
- } catch (CoreException x) {
- status= x.getStatus();
- document= new Document();
- initializeDocument(document);
- }
-
- DocumentAdapter adapter= new DocumentAdapter(unit, document, new DefaultLineTracker(), CDocumentProvider.this, providerKey);
- adapter.setStatus(status);
- return adapter;
- }
-
- }
- return DocumentAdapter.NULL;
- }
- };
-
-
- /** The buffer factory */
- private IBufferFactory fBufferFactory= new BufferFactory();
- /** Indicates whether the save has been initialized by this provider */
- private boolean fIsAboutToSave= false;
-
- /**
- * @see AbstractDocumentProvider#createDocument(Object)
- */
- protected IDocument createDocument(Object element) throws CoreException {
- IDocument document = null;
- IStorage storage = null;
-
- if (element instanceof IEditorInputDelegate) {
- if (((IEditorInputDelegate) element).getDelegate() != null)
- return createDocument(((IEditorInputDelegate) element).getDelegate());
- else
- storage = ((IEditorInputDelegate) element).getStorage();
- }
-
- if (element instanceof IStorageEditorInput)
- storage= ((IStorageEditorInput) element).getStorage();
-
- if ( storage != null ) {
- document = new CDocument();
- setDocumentContent(document, storage.getContents(), getDefaultEncoding());
- }
-
- //IDocument document= super.createDocument(element);
- initializeDocument(document);
- return document;
- }
-
- /*
- * @see AbstractDocumentProvider#createAnnotationModel(Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- if ( element instanceof IEditorInputDelegate && ((IEditorInputDelegate)element).getDelegate() != null )
- return createAnnotationModel( ((IEditorInputDelegate)element).getDelegate() );
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return new CMarkerAnnotationModel(input.getFile());
- } else if (element instanceof IStorageEditorInput) {
- // Fall back on the adapter.
- IStorageEditorInput input = (IStorageEditorInput) element;
- IResource res = (IResource)input.getAdapter(IResource.class);
- if (res != null && res.exists()) {
- return new CMarkerAnnotationModel(res);
- }
- }
-
- return super.createAnnotationModel(element);
- }
-
- /*
- * @see AbstractDocumentProvider#createElementInfo(Object)
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- if ( !(element instanceof IFileEditorInput))
- return super.createElementInfo(element);
-
- IFileEditorInput input= (IFileEditorInput) element;
- ITranslationUnit original= createTranslationUnit(input.getFile());
- if (original != null) {
-
- try {
-
- try {
- refreshFile(input.getFile());
- } catch (CoreException x) {
- handleCoreException(x, CEditorMessages.getString("TranslationUnitDocumentProvider.error.createElementInfo")); //$NON-NLS-1$
- }
-
- IAnnotationModel m= createAnnotationModel(input);
- IBufferFactory factory = getBufferFactory();
- IWorkingCopy c= (IWorkingCopy) original.getSharedWorkingCopy(getProgressMonitor(), factory);
-
- DocumentAdapter a= null;
- try {
- a= (DocumentAdapter) c.getBuffer();
- } catch (ClassCastException x) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, CStatusConstants.TEMPLATE_IO_EXCEPTION, "Shared working copy has wrong buffer", x); //$NON-NLS-1$
- throw new CoreException(status);
- }
-
- FileSynchronizer f= new FileSynchronizer(input);
- f.install();
-
- TranslationUnitFileInfo info= new TranslationUnitFileInfo(a.getDocument(), m, f, c);
- info.setModificationStamp(computeModificationStamp(input.getFile()));
- info.fStatus= a.getStatus();
- info.fEncoding= getPersistedEncoding(input);
-
- return info;
-
- } catch (CModelException x) {
- throw new CoreException(x.getStatus());
- }
- } else {
- return super.createElementInfo(element);
- }
- }
- /*
- * Creates a translation unit using the core model
- */
- protected ITranslationUnit createTranslationUnit(IFile file) {
- Object element= CoreModel.getDefault().create(file);
- if (element instanceof ITranslationUnit)
- return (ITranslationUnit) element;
- return null;
- }
- /*
- * @see AbstractDocumentProvider#disposeElementInfo(Object, ElementInfo)
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
-
- if (info instanceof TranslationUnitFileInfo) {
- TranslationUnitFileInfo cuInfo= (TranslationUnitFileInfo) info;
- cuInfo.fCopy.destroy();
- }
-
- super.disposeElementInfo(element, info);
- }
-
- /*
- * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
-
- ElementInfo elementInfo= getElementInfo(element);
- if (elementInfo instanceof TranslationUnitFileInfo) {
- TranslationUnitFileInfo info= (TranslationUnitFileInfo) elementInfo;
-
- // update structure, assumes lock on info.fCopy
- info.fCopy.reconcile();
-
- ITranslationUnit original= (ITranslationUnit) info.fCopy.getOriginalElement();
- IResource resource= original.getResource();
-
- if (resource == null) {
- // underlying resource has been deleted, just recreate file, ignore the rest
- super.doSaveDocument(monitor, element, document, overwrite);
- return;
- }
-
- if (resource != null && !overwrite)
- checkSynchronizationState(info.fModificationStamp, resource);
-
-// if (fSavePolicy != null)
-// fSavePolicy.preSave(info.fCopy);
-
- // inform about the upcoming content change
- fireElementStateChanging(element);
- try {
- fIsAboutToSave= true;
- // commit working copy
- info.fCopy.commit(overwrite, monitor);
- } catch (CoreException x) {
- // inform about the failure
- fireElementStateChangeFailed(element);
- throw x;
- } catch (RuntimeException x) {
- // inform about the failure
- fireElementStateChangeFailed(element);
- throw x;
- } finally {
- fIsAboutToSave= false;
- }
-
- // If here, the dirty state of the editor will change to "not dirty".
- // Thus, the state changing flag will be reset.
-
- AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
- model.updateMarkers(info.fDocument);
-
- if (resource != null)
- info.setModificationStamp(computeModificationStamp(resource));
-
-// if (fSavePolicy != null) {
-// ICompilationUnit unit= fSavePolicy.postSave(original);
-// if (unit != null) {
-// IResource r= unit.getResource();
-// IMarker[] markers= r.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
-// if (markers != null && markers.length > 0) {
-// for (int i= 0; i < markers.length; i++)
-// model.updateMarker(markers[i], info.fDocument, null);
-// }
-// }
-// }
-
-
- } else {
- super.doSaveDocument(monitor, element, document, overwrite);
- }
- }
-
- /**
- * Gets the BufferFactory.
- */
- public IBufferFactory getBufferFactory() {
- return fBufferFactory;
- }
-
- /**
- * Returns the underlying resource for the given element.
- *
- * @param the element
- * @return the underlying resource of the given element
- */
- public IResource getUnderlyingResource(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return input.getFile();
- }
- return null;
- }
-
- public IWorkingCopy getWorkingCopy(IEditorInput element) {
-
- ElementInfo elementInfo= getElementInfo(element);
- if (elementInfo instanceof TranslationUnitFileInfo) {
- TranslationUnitFileInfo info= (TranslationUnitFileInfo) elementInfo;
- return info.fCopy;
- }
- return null;
- }
-
- protected void initializeDocument(IDocument document) {
- if (document != null) {
- IDocumentPartitioner partitioner= CUIPlugin.getDefault().getTextTools().createDocumentPartitioner();
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
- }
- }
- /**
- * Saves the content of the given document to the given element.
- * This is only performed when this provider initiated the save.
- *
- * @param monitor the progress monitor
- * @param element the element to which to save
- * @param document the document to save
- * @param overwrite <code>true</code> if the save should be enforced
- */
- public void saveDocumentContent(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
-
- if (!fIsAboutToSave)
- return;
-
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- try {
- String encoding= getEncoding(element);
- if (encoding == null)
- encoding= ResourcesPlugin.getEncoding();
- InputStream stream= new ByteArrayInputStream(document.get().getBytes(encoding));
- IFile file= input.getFile();
- file.setContents(stream, overwrite, true, monitor);
- } catch (IOException x) {
- IStatus s= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, x.getMessage(), x);
- throw new CoreException(s);
- }
- }
- }
-
- /**
- *
- */
- public void shutdown() {
- // TODO Auto-generated method stub
- }
-
- /**
- * @param input
- * @return
- */
- public boolean isConnected(IEditorInput input) {
- return getElementInfo(input) != null;
- }
-
- /**
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#getStatus(Object)
- */
- public IStatus getStatus(Object element) {
- if (element instanceof IEditorInputDelegate) {
- if (((IEditorInputDelegate) element).getDelegate() != null)
- return super.getStatus(((IEditorInputDelegate) element).getDelegate());
- else
- return new Status(IStatus.INFO,CUIPlugin.getPluginId(),0,"",null);
- }
- return super.getStatus(element);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
deleted file mode 100644
index 1fd849d4944..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ /dev/null
@@ -1,941 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
-import org.eclipse.cdt.internal.ui.text.CPairMatcher;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationModel;
-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.OverviewRuler;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.editors.text.TextEditor;
-import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.ContentAssistAction;
-import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
-import org.eclipse.ui.texteditor.DefaultRangeIndicator;
-import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.ui.views.tasklist.TaskList;
-
-
-/**
- * C specific text editor.
- */
-public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource {
-
- /** The outline page */
- protected CContentOutlinePage fOutlinePage;
-
- private FileSearchAction fFileSearchAction;
-
- private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
-
- private SearchDialogAction fSearchDialogAction;
-
- protected ISelectionChangedListener fStatusLineClearer;
-
- /** The property change listener */
- private PropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
-
- protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']' };
-
- protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
-
- /** The editor's tab converter */
- private TabConverter fTabConverter;
-
- private MarkerAnnotationPreferences fAnnotationPreferences;
-
- /** Listener to annotation model changes that updates the error tick in the tab image */
- private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
-
- /* Preference key for matching brackets */
- public final static String MATCHING_BRACKETS = "matchingBrackets";
- /* Preference key for matching brackets color */
- public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor";
- /** Preference key for inserting spaces rather than tabs */
- public final static String SPACES_FOR_TABS = "spacesForTabs";
- /** Preference key for linked position color */
- public final static String LINKED_POSITION_COLOR = "linkedPositionColor"; //$NON-NLS-1$
-
- /** Preference key for compiler task tags */
- private final static String TRANSLATION_TASK_TAGS= CCorePlugin.TRANSLATION_TASK_TAGS;
-
- private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener, org.eclipse.jface.util.IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
- handlePreferencePropertyChanged(event);
- }
- public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
- handlePreferencePropertyChanged(new org.eclipse.jface.util.PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue()));
- }
- };
-
- /**
- * Default constructor.
- */
- public CEditor() {
- super();
- fAnnotationPreferences = new MarkerAnnotationPreferences();
- CTextTools textTools = CUIPlugin.getDefault().getTextTools();
- setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this));
- setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
- setRangeIndicator(new DefaultRangeIndicator());
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
-
- setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$
- setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
-
- fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
- }
-
- /**
- * @see AbstractTextEditor#doSetInput(IEditorInput)
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- // If the file is not a Storage or an IFile use a different
- // DocumentProvider. TODO: Rewrite CDocuemtnProviver to handle this.
- if (!(input instanceof IStorageEditorInput || input instanceof IFileEditorInput)) {
- setDocumentProvider(new TextFileDocumentProvider(null));
- }
- super.doSetInput(input);
- fCEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input));
- setOutlinePageInput(fOutlinePage, input);
- }
-
- /**
- * Update the title image
- */
- public void updatedTitleImage(Image image) {
- setTitleImage(image);
- }
-
- /**
- * Gets the current input
- */
- public IFile getInputFile() {
- //IFileEditorInput editorInput = (IFileEditorInput)getEditorInput();
- IEditorInput editorInput = (IEditorInput) getEditorInput();
- if (editorInput != null) {
- if ((editorInput instanceof IFileEditorInput)) {
- return ((IFileEditorInput) editorInput).getFile();
- }
- }
- return null;
- }
-
- public boolean isSaveAsAllowed() {
- return true;
- }
- /**
- * Gets the outline page of the c-editor
- */
- public CContentOutlinePage getOutlinePage() {
- if (fOutlinePage == null) {
- fOutlinePage = new CContentOutlinePage(this);
- fOutlinePage.addSelectionChangedListener(this);
- }
- return fOutlinePage;
- }
-
- /**
- * @see AbstractTextEditor#getAdapter(Class)
- */
- public Object getAdapter(Class required) {
- if (IContentOutlinePage.class.equals(required)) {
- return getOutlinePage();
- }
- return super.getAdapter(required);
- }
- /**
- * Handles a property change event describing a change
- * of the editor's preference store and updates the preference
- * related editor properties.
- *
- * @param event the property change event
- */
- protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
- AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-
- try {
- if (asv != null) {
-
- String property = event.getProperty();
-
- if (CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH.equals(property)) {
- SourceViewerConfiguration configuration = getSourceViewerConfiguration();
- String[] types = configuration.getConfiguredContentTypes(asv);
- for (int i = 0; i < types.length; i++)
- asv.setIndentPrefixes(configuration.getIndentPrefixes(asv, types[i]), types[i]);
-
- if (fTabConverter != null)
- fTabConverter.setNumberOfSpacesPerTab(
- getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
-
- Object value = event.getNewValue();
-
- if (value instanceof Integer) {
- asv.getTextWidget().setTabs(((Integer) value).intValue());
-
- } else if (value instanceof String) {
- asv.getTextWidget().setTabs(Integer.parseInt((String) value));
- }
- }
-
- if (SPACES_FOR_TABS.equals(property)) {
- if (isTabConversionEnabled())
- startTabConversion();
- else
- stopTabConversion();
- return;
- }
-
- IContentAssistant c= asv.getContentAssistant();
- if (c instanceof ContentAssistant)
- ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
-
- }
- } finally {
- super.handlePreferenceStoreChanged(event);
- }
- }
-
- /**
- * @see ISelectionChangedListener#selectionChanged
- */
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection sel = event.getSelection();
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) sel;
- Object obj = selection.getFirstElement();
- if (obj instanceof ISourceReference) {
- try {
- ISourceRange range = ((ISourceReference) obj).getSourceRange();
- if (range != null) {
- setSelection(range, !isActivePart());
- }
- } catch (CModelException e) {
- }
- }
- }
- }
-
- public void setSelection(ICElement element) {
-
- if (element == null || element instanceof ITranslationUnit) {
- /*
- * If the element is an ITranslationUnit this unit is either the input
- * of this editor or not being displayed. In both cases, nothing should
- * happened.
- */
- return;
- }
- if (element instanceof ISourceReference) {
- ISourceReference reference = (ISourceReference) element;
- // set hightlight range
- setSelection(reference, true);
- // set outliner selection
- //if (fOutlinePage != null) {
- // fOutlinePage.removeSelectionChangedListener(fSelectionChangedListener);
- // fOutlinePage.select(reference);
- // fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
- //}
- }
- }
-
- public void setSelection(ISourceReference element, boolean moveCursor) {
- if (element != null) {
- try {
- setSelection(element.getSourceRange(), moveCursor);
- } catch (CModelException e) {
- }
- }
- }
-
- /**
- * Sets the current editor selection to the source range. Optionally
- * sets the current editor position.
- *
- * @param element the source range to be shown in the editor, can be null.
- * @param moveCursor if true the editor is scrolled to show the range.
- */
- public void setSelection(ISourceRange element, boolean moveCursor) {
-
- if (element == null) {
- return;
- }
-
- try {
- IRegion alternateRegion = null;
- int start = element.getStartPos();
- int length = element.getLength();
-
- // Sanity check sometimes the parser may throw wrong numbers.
- if (start < 0 || length < 0) {
- start = 0;
- length = 0;
- }
-
- // 0 length and start and non-zero start line says we know
- // the line for some reason, but not the offset.
- if (length == 0 && start == 0 && element.getStartLine() > 0) {
- // We have the information in term of lines, we can work it out.
- // Binary elements return the first executable statement so we have to substract -1
- start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
- if (element.getEndLine() > 0) {
- length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
- } else {
- length = start;
- }
- // create an alternate region for the keyword highlight.
- alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
- if (start == length || length < 0) {
- if (alternateRegion != null) {
- start = alternateRegion.getOffset();
- length = alternateRegion.getLength();
- }
- }
- }
- setHighlightRange(start, length, moveCursor);
-
- if (moveCursor) {
- start = element.getIdStartPos();
- length = element.getIdLength();
- if (start == 0 && length == 0 && alternateRegion != null) {
- start = alternateRegion.getOffset();
- length = alternateRegion.getLength();
- }
- if (start > -1 && getSourceViewer() != null) {
- getSourceViewer().revealRange(start, length);
- getSourceViewer().setSelectedRange(start, length);
- }
- updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
- }
- return;
- } catch (IllegalArgumentException x) {
- } catch (BadLocationException e) {
- }
-
- if (moveCursor)
- resetHighlightRange();
- }
-
- private boolean isActivePart() {
- IWorkbenchWindow window = getSite().getWorkbenchWindow();
- IPartService service = window.getPartService();
- return (this == service.getActivePart());
- }
-
- public void dispose() {
-
- if (fCEditorErrorTickUpdater != null) {
- fCEditorErrorTickUpdater.setAnnotationModel(null);
- fCEditorErrorTickUpdater = null;
- }
- if (fBracketMatcher != null) {
- fBracketMatcher.dispose();
- fBracketMatcher = null;
- }
- if (fPropertyChangeListener != null) {
- Preferences preferences = CCorePlugin.getDefault().getPluginPreferences();
- preferences.removePropertyChangeListener(fPropertyChangeListener);
- IPreferenceStore preferenceStore = getPreferenceStore();
- preferenceStore.removePropertyChangeListener(fPropertyChangeListener);
- }
- super.dispose();
- }
-
- protected void createActions() {
- super.createActions();
-
- // Default text editing menu items
-
- IAction action = new TextOperationAction(CEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.COMMENT);
- setAction("Comment", action); //$NON-NLS-1$
- markAsStateDependentAction("Comment", true); //$NON-NLS-1$
-
- action = new TextOperationAction(CEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.UNCOMMENT);
- setAction("Uncomment", action); //$NON-NLS-1$
- markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
-
- action = new TextOperationAction(CEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
- setAction("Format", action); //$NON-NLS-1$
- markAsStateDependentAction("Format", true); //$NON-NLS-1$
-
- action = new ContentAssistAction(CEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", action);
- markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
-
- action = new TextOperationAction(CEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
- setAction("ContentAssistTip", action);
-
- setAction("AddIncludeOnSelection", new AddIncludeOnSelectionAction(this)); //$NON-NLS-1$
-
- action = new OpenDeclarationsAction(this);
- action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
- setAction("OpenDeclarations", action);
-
- fFileSearchAction = new FileSearchAction(getSelectionProvider());
-
- fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(getSelectionProvider());
-
- fSearchDialogAction = new SearchDialogAction(getSelectionProvider(), this);
- }
-
- public void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
-
- addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE);
- addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);
- addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW);
-
- // Code formatting menu items -- only show in C perspective
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Comment"); //$NON-NLS-1$
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Uncomment"); //$NON-NLS-1$
- // @@@ disabled for now until we get it to do something...
- //addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$
-
- MenuManager search = new MenuManager("Search", IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
- menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, search);
-
- if (SearchDialogAction.canActionBeAdded(getSelectionProvider().getSelection())){
- search.add(fSearchDialogAction);
- }
-
- if (FileSearchAction.canActionBeAdded(getSelectionProvider().getSelection())) {
- MenuManager fileSearch = new MenuManager("File Search");
- fileSearch.add(fFileSearchAction);
- fileSearch.add(fFileSearchActionInWorkingSet);
- search.add(fileSearch);
- }
-
- addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_GENERATE, "OpenDeclarations"); //$NON-NLS-1$
- }
-
- public void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
- if (page != null) {
- IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
- page.setInput((IWorkingCopy)manager.getWorkingCopy(input));
- }
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IWorkbenchPart</code> method creates the vertical ruler and
- * source viewer. Subclasses may extend.
- *
- * We attach our own mouseDown listener on the menu bar,
- * and our own listener for cursor/key/selection events to update cursor position in
- * status bar.
- */
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- ISelectionChangedListener sListener = new ISelectionChangedListener() {
- private Runnable fRunnable = new Runnable() {
- public void run() {
- updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
- }
- };
-
- private Display fDisplay;
-
- public void selectionChanged(SelectionChangedEvent event) {
- if (fDisplay == null)
- fDisplay = getSite().getShell().getDisplay();
- fDisplay.asyncExec(fRunnable);
- }
- };
- getSelectionProvider().addSelectionChangedListener(sListener);
-
- if (isTabConversionEnabled())
- startTabConversion();
-
- IPreferenceStore preferenceStore = getPreferenceStore();
- preferenceStore.addPropertyChangeListener(fPropertyChangeListener);
-
- Preferences preferences = CCorePlugin.getDefault().getPluginPreferences();
- preferences.addPropertyChangeListener(fPropertyChangeListener);
- }
-
- private IMarker getNextError(int offset, boolean forward) {
-
- IMarker nextError = null;
-
- IDocument document = getDocumentProvider().getDocument(getEditorInput());
- int endOfDocument = document.getLength();
- int distance = 0;
-
- IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Annotation a = (Annotation) e.next();
- if (a instanceof CMarkerAnnotation) {
- MarkerAnnotation ma = (MarkerAnnotation) a;
- IMarker marker = ma.getMarker();
-
- if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
- Position p = model.getPosition(a);
- if (!p.includes(offset)) {
-
- int currentDistance = 0;
-
- if (forward) {
- currentDistance = p.getOffset() - offset;
- if (currentDistance < 0)
- currentDistance = endOfDocument - offset + p.getOffset();
- } else {
- currentDistance = offset - p.getOffset();
- if (currentDistance < 0)
- currentDistance = offset + endOfDocument - p.getOffset();
- }
-
- if (nextError == null || (currentDistance < distance && currentDistance != 0)) {
- distance = currentDistance;
- if (distance == 0)
- distance = endOfDocument;
- nextError = marker;
- }
- }
- }
- }
- }
- return nextError;
- }
-
- public void gotoError(boolean forward) {
-
- ISelectionProvider provider = getSelectionProvider();
-
- if (fStatusLineClearer != null) {
- provider.removeSelectionChangedListener(fStatusLineClearer);
- fStatusLineClearer = null;
- }
-
- ITextSelection s = (ITextSelection) provider.getSelection();
- IMarker nextError = getNextError(s.getOffset(), forward);
-
- if (nextError != null) {
-
- gotoMarker(nextError);
-
- IWorkbenchPage page = getSite().getPage();
-
- IViewPart view = view = page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
- if (view instanceof TaskList) {
- StructuredSelection ss = new StructuredSelection(nextError);
- ((TaskList) view).setSelection(ss, true);
- }
-
- getStatusLineManager().setErrorMessage(nextError.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-1$
- fStatusLineClearer = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- getSelectionProvider().removeSelectionChangedListener(fStatusLineClearer);
- fStatusLineClearer = null;
- getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$
- }
- };
- provider.addSelectionChangedListener(fStatusLineClearer);
-
- } else {
-
- getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$
-
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
- *
- * This is required by the IShowInSource interface for the "ShowIn"
- * navigation menu generalized in Eclipse.
- */
- public ShowInContext getShowInContext() {
- return new ShowInContext( getEditorInput(), null );
- }
-
- /*
- * Get the dektop's StatusLineManager
- */
- protected IStatusLineManager getStatusLineManager() {
- IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
- if (contributor instanceof EditorActionBarContributor) {
- return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
- }
- return null;
- }
-
- private void startTabConversion() {
- if (fTabConverter == null) {
- fTabConverter = new TabConverter();
- fTabConverter.setNumberOfSpacesPerTab(getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
- AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
- asv.addTextConverter(fTabConverter);
- }
- }
-
- private void stopTabConversion() {
- if (fTabConverter != null) {
- AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
- asv.removeTextConverter(fTabConverter);
- fTabConverter = null;
- }
- }
-
- private boolean isTabConversionEnabled() {
- IPreferenceStore store = getPreferenceStore();
- return store.getBoolean(SPACES_FOR_TABS);
- }
-
- interface ITextConverter {
- void customizeDocumentCommand(IDocument document, DocumentCommand command);
- };
-
- static class TabConverter implements ITextConverter {
-
- private String fTabString = "";
- private int tabRatio = 0;
-
- public void setNumberOfSpacesPerTab(int ratio) {
- tabRatio = ratio;
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < ratio; i++)
- buffer.append(' ');
- fTabString = buffer.toString();
- }
-
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- String text = command.text;
- StringBuffer buffer = new StringBuffer();
- final String TAB = "\t";
- // create tokens including the tabs
- StringTokenizer tokens = new StringTokenizer(text, TAB, true);
-
- int charCount = 0;
- try {
- // get offset of insertion less start of line
- // buffer to determine how many characters
- // are already on this line and adjust tabs accordingly
- charCount = command.offset - (document.getLineInformationOfOffset(command.offset).getOffset());
- } catch (Exception ex) {
-
- }
-
- String nextToken = null;
- int spaces = 0;
- while (tokens.hasMoreTokens()) {
- nextToken = tokens.nextToken();
- if (TAB.equals(nextToken)) {
- spaces = tabRatio - (charCount % tabRatio);
-
- for (int i = 0; i < spaces; i++) {
- buffer.append(' ');
- }
-
- charCount += spaces;
- } else {
- buffer.append(nextToken);
- charCount += nextToken.length();
- }
- }
- command.text = buffer.toString();
- }
- };
-
- /* Source code language to display */
- public final static String LANGUAGE_CPP = "CEditor.language.cpp";
- public final static String LANGUAGE_C = "CEditor.language.c";
-
- /**
- * Adapted source viewer for CEditor
- */
-
- public class AdaptedSourceViewer extends SourceViewer implements ITextViewerExtension {
-
- private List fTextConverters;
- private String fDisplayLanguage;
-
- public AdaptedSourceViewer(
- Composite parent,
- IVerticalRuler ruler,
- int styles,
- IOverviewRuler fOverviewRuler,
- boolean isOverviewRulerShowing,
- String language) {
- super(parent, ruler, fOverviewRuler, isOverviewRulerShowing, styles);
- fDisplayLanguage = language;
- }
- public IContentAssistant getContentAssistant() {
- return fContentAssistant;
- }
-
- /*
- * @see ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (getTextWidget() == null) {
- return;
- }
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- String msg= fContentAssistant.showPossibleCompletions();
- setStatusLineErrorMessage(msg);
- return;
- }
- super.doOperation(operation);
- }
-
- public void insertTextConverter(ITextConverter textConverter, int index) {
- throw new UnsupportedOperationException();
- }
-
- public void addTextConverter(ITextConverter textConverter) {
- if (fTextConverters == null) {
- fTextConverters = new ArrayList(1);
- fTextConverters.add(textConverter);
- } else if (!fTextConverters.contains(textConverter))
- fTextConverters.add(textConverter);
- }
-
- public void removeTextConverter(ITextConverter textConverter) {
- if (fTextConverters != null) {
- fTextConverters.remove(textConverter);
- if (fTextConverters.size() == 0)
- fTextConverters = null;
- }
- }
-
- /*
- * @see TextViewer#customizeDocumentCommand(DocumentCommand)
- */
- protected void customizeDocumentCommand(DocumentCommand command) {
- super.customizeDocumentCommand(command);
- if (fTextConverters != null) {
- for (Iterator e = fTextConverters.iterator(); e.hasNext();)
- ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
- }
- }
-
- public void setDisplayLanguage(String language) {
- fDisplayLanguage = language;
- }
-
- public String getDisplayLanguage() {
- return fDisplayLanguage;
- }
- };
-
- /*
- * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
- */
- protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- // Figure out if this is a C or C++ source file
- String filename = getEditorInput().getName();
- boolean c_file = filename.endsWith(".c");
-
- if (!c_file && filename.endsWith(".h")) {
- // ensure that this .h file is part of a C project & not a CPP project
-
- IFile file = getInputFile();
- if (file != null) {
- IProject project = file.getProject();
- c_file = !CoreModel.getDefault().hasCCNature(project);
- }
- }
- fAnnotationAccess = createAnnotationAccess();
- ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors();
-
- fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors);
- Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference preference = (AnnotationPreference) e.next();
- if (preference.contributesToHeader())
- fOverviewRuler.addHeaderAnnotationType(preference.getAnnotationType());
- }
-
- ISourceViewer sourceViewer =
- new AdaptedSourceViewer(
- parent,
- ruler,
- styles,
- fOverviewRuler,
- isOverviewRulerVisible(),
- c_file ? LANGUAGE_C : LANGUAGE_CPP);
- fSourceViewerDecorationSupport =
- new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors);
- configureSourceViewerDecorationSupport();
- return sourceViewer;
- }
-
- /**
- * Creates the annotation access for this editor.
- * @return the created annotation access
- */
- protected IAnnotationAccess createAnnotationAccess() {
- return new DefaultMarkerAnnotationAccess(fAnnotationPreferences);
- }
-
- protected void configureSourceViewerDecorationSupport() {
- Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
- while (e.hasNext())
- fSourceViewerDecorationSupport.setAnnotationPreference((AnnotationPreference) e.next());
- fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
- DefaultMarkerAnnotationAccess.UNKNOWN,
- TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR,
- TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION,
- TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER,
- 0);
-
- fSourceViewerDecorationSupport.setCharacterPairMatcher(fBracketMatcher);
- fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
-
- fSourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(
- ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
- ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
- fSourceViewerDecorationSupport.setMarginPainterPreferenceKeys(
- ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
- ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
- ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
- fSourceViewerDecorationSupport.setSymbolicFontName(getFontPropertyPreferenceKey());
- }
-
- /** Outliner context menu Id */
- protected String fOutlinerContextMenuId;
-
- /**
- * Sets the outliner's context menu ID.
- */
- protected void setOutlinerContextMenuId(String menuId) {
- fOutlinerContextMenuId = menuId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
- */
- protected void initializeKeyBindingScopes() {
- setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } );
- }
-
- /* (non-Javadoc)
- * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
- */
- protected boolean affectsTextPresentation(PropertyChangeEvent event) {
- CTextTools textTools = CUIPlugin.getDefault().getTextTools();
- AsmTextTools asmTools = CUIPlugin.getDefault().getAsmTextTools();
- return textTools.affectsBehavior(event) || asmTools.affectsBehavior(event);
- }
-
- /**
- * Handles a property change event describing a change
- * of the C core's preferences and updates the preference
- * related editor properties.
- *
- * @param event the property change event
- */
- protected void handlePreferencePropertyChanged(org.eclipse.jface.util.PropertyChangeEvent event) {
- if (TRANSLATION_TASK_TAGS.equals(event.getProperty())) {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer != null && affectsTextPresentation(event))
- sourceViewer.invalidateTextPresentation();
- }
- }
-
- /**
- * Sets the given message as error message to this editor's status line.
- *
- * @param msg message to be set
- */
- protected void setStatusLineErrorMessage(String msg) {
- IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
- if (statusLine != null)
- statusLine.setMessage(true, msg, null);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
deleted file mode 100644
index c3b611aa599..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.editors.text.TextEditorActionContributor;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-public class CEditorActionContributor extends TextEditorActionContributor {
-
- protected static class SelectionAction extends TextEditorAction implements ISelectionChangedListener {
-
- protected int fOperationCode;
- protected ITextOperationTarget fOperationTarget= null;
-
-
- public SelectionAction(String prefix, int operation) {
- super(CEditorMessages.getResourceBundle(), prefix, null);
- fOperationCode= operation;
- setEnabled(false);
- }
-
- /**
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- if (getTextEditor() != null) {
- ISelectionProvider p= getTextEditor().getSelectionProvider();
- if (p != null) p.removeSelectionChangedListener(this);
- }
-
- super.setEditor(editor);
-
- if (editor != null) {
- ISelectionProvider p= editor.getSelectionProvider();
- if (p != null) p.addSelectionChangedListener(this);
- fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
- } else {
- fOperationTarget= null;
- }
-
- selectionChanged(null);
- }
-
- /**
- * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
- setEnabled(isEnabled);
- }
-
- /**
- * @see Action#run()
- */
- public void run() {
- if (fOperationCode != -1 && fOperationTarget != null)
- fOperationTarget.doOperation(fOperationCode);
- }
- };
-
- protected CEditor fCEditor;
- protected RetargetTextEditorAction fContentAssist;
- protected RetargetTextEditorAction fAddInclude;
- protected RetargetTextEditorAction fOpenOnSelection;
- protected SelectionAction fShiftLeft;
- protected SelectionAction fShiftRight;
- private TogglePresentationAction fTogglePresentation;
- //private ToggleTextHoverAction fToggleTextHover;
- private GotoErrorAction fPreviousError;
- private GotoErrorAction fNextError;
-
-
- public CEditorActionContributor() {
- super();
-
- ResourceBundle bundle = CEditorMessages.getResourceBundle();
-
- fShiftRight= new SelectionAction("ShiftRight.", ITextOperationTarget.SHIFT_RIGHT);
- fShiftRight.setActionDefinitionId(ICEditorActionDefinitionIds.SHIFT_RIGHT);
- CPluginImages.setImageDescriptors(fShiftRight, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_RIGHT);
-
- fShiftLeft= new SelectionAction("ShiftLeft.", ITextOperationTarget.SHIFT_LEFT);
- fShiftLeft.setActionDefinitionId(ICEditorActionDefinitionIds.SHIFT_LEFT);
- CPluginImages.setImageDescriptors(fShiftLeft, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
-
- fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal.");
- fContentAssist.setActionDefinitionId(ICEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- CPluginImages.setImageDescriptors(fContentAssist, CPluginImages.T_TOOL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
-
- fAddInclude = new RetargetTextEditorAction(bundle, "AddIncludeOnSelection.");
- fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
-
- fOpenOnSelection = new RetargetTextEditorAction(bundle, "OpenOnSelection.");
-
- // actions that are "contributed" to editors, they are considered belonging to the active editor
- fTogglePresentation= new TogglePresentationAction();
- fTogglePresentation.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION);
-
- //fToggleTextHover= new ToggleTextHoverAction();
-
- fPreviousError= new GotoErrorAction("PreviousError.", false); //$NON-NLS-1$
- fPreviousError.setActionDefinitionId("org.eclipse.ui.navigate.previous"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(fPreviousError, CPluginImages.T_TOOL, CPluginImages.IMG_TOOL_GOTO_PREV_ERROR);
-
- fNextError= new GotoErrorAction("NextError.", true); //$NON-NLS-1$
- fNextError.setActionDefinitionId("org.eclipse.ui.navigate.next"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(fNextError, CPluginImages.T_TOOL, CPluginImages.IMG_TOOL_GOTO_NEXT_ERROR);
- }
-
-
-
- /**
- * @see IActionBarContributor#contributeToMenu(MenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
-
- super.contributeToMenu(menu);
-
- /*
- * Hook in the code assist
- */
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(fShiftRight);
- editMenu.add(fShiftLeft);
-
- editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- editMenu.add(fNextError);
- editMenu.add(fPreviousError);
-
- editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
- editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContentAssist);
- editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fAddInclude);
- editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fOpenOnSelection);
- }
- }
-
- /**
- * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
- */
- public void contributeToToolBar(IToolBarManager tbm) {
- super.contributeToToolBar(tbm);
- tbm.add(new Separator());
- tbm.add(fTogglePresentation);
- //tbm.add(fToggleTextHover);
- tbm.add(fNextError);
- tbm.add(fPreviousError);
- }
-
- /**
- * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
-
- super.setActiveEditor(part);
-
- ITextEditor textEditor= null;
- if (part instanceof ITextEditor)
- textEditor= (ITextEditor) part;
-
- fShiftRight.setEditor(textEditor);
- fShiftLeft.setEditor(textEditor);
- fNextError.setEditor(textEditor);
- fPreviousError.setEditor(textEditor);
- fTogglePresentation.setEditor(textEditor);
-
- //caAction.setEditor(textEditor);
- //caAction.update();
- fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
- fAddInclude.setAction(getAction(textEditor, "AddIncludeOnSelection")); //$NON-NLS-1$
- fOpenOnSelection.setAction(getAction(textEditor, "OpenOnSelection")); //$NON-NLS-1$
- }
-
- /*
- * @see EditorActionBarContributor#contributeToStatusLine(IStatusLineManager)
- *
- * More code here only until we move to 2.0...
- */
- public void contributeeToStatusLine(IStatusLineManager statusLineManager) {
- super.contributeToStatusLine(statusLineManager);
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
deleted file mode 100644
index 55ee1a7614a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CElementImageProvider;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelListener;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.IEditorInput;
-
-/**
- * The <code>JavaEditorErrorTickUpdater</code> will register as a AnnotationModelListener
- * on the annotation model of a Java Editor and update the title images when the annotation
- * model changed.
- */
-public class CEditorErrorTickUpdater implements IAnnotationModelListener {
-
- protected CEditor fCEditor;
- private IAnnotationModel fAnnotationModel;
- private CElementLabelProvider fLabelProvider;
-
- public CEditorErrorTickUpdater(CEditor editor) {
- fCEditor= editor;
- Assert.isNotNull(editor);
- }
-
- /**
- * Defines the annotation model to listen to. To be called when the
- * annotation model changes.
- * @param model The new annotation model or <code>null</code>
- * to uninstall.
- */
- public void setAnnotationModel(IAnnotationModel model) {
- if (fAnnotationModel != null) {
- fAnnotationModel.removeAnnotationModelListener(this);
- }
-
- if (model != null) {
- if (fLabelProvider == null) {
- fLabelProvider= new CElementLabelProvider(0, CElementImageProvider.SMALL_ICONS, CElementLabelProvider.getAdornmentProviders(true, null));
- }
- fAnnotationModel=model;
- fAnnotationModel.addAnnotationModelListener(this);
- modelChanged(fAnnotationModel);
- } else {
- if (fLabelProvider != null) {
- fLabelProvider.dispose();
- }
- fLabelProvider= null;
- fAnnotationModel= null;
- }
- }
-
- /*
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- Image titleImage= fCEditor.getTitleImage();
- if (titleImage == null) {
- return;
- }
- IEditorInput input= fCEditor.getEditorInput();
- if (input != null) { // might run async, tests needed
- ICElement celement= (ICElement) input.getAdapter(ICElement.class);
- if (fLabelProvider != null && celement != null) {
- Image newImage= fLabelProvider.getImage(celement);
- if (titleImage != newImage) {
- updatedTitleImage(newImage);
- }
- }
- }
- }
-
- private void updatedTitleImage(final Image newImage) {
- Shell shell= fCEditor.getEditorSite().getShell();
- if (shell != null && !shell.isDisposed()) {
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- fCEditor.updatedTitleImage(newImage);
- }
- });
- }
- }
-
-}
-
-
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
deleted file mode 100644
index 4d858decf7a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-public class CEditorMessages
-{
- private static final String RESOURCE_BUNDLE = "org.eclipse.cdt.internal.ui.editor.CEditorMessages";
-
-
- private static ResourceBundle fgResourceBundle = ResourceBundle.getBundle( RESOURCE_BUNDLE );
-
-
- private CEditorMessages()
- {
- }
-
-
- public static ResourceBundle getResourceBundle()
- {
- return fgResourceBundle;
- }
-
- public static String getString( String key )
- {
- try
- {
- return fgResourceBundle.getString( key );
- }
- catch( MissingResourceException e )
- {
- return "!" + key + "!";
- }
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
deleted file mode 100644
index fbf2bed9683..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
+++ /dev/null
@@ -1,136 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-AddIncludeOnSelection.description=Add include statement on selection
-AddIncludeOnSelection.dialog.message=&Choose element to generate an include statement for:
-AddIncludeOnSelection.dialog.title=Add Include
-AddIncludeOnSelection.error.message1=Adding include statements failed
-AddIncludeOnSelection.error.message2=Error
-AddIncludeOnSelection.error.message3=Error
-AddIncludeOnSelection.error.message4=BadLocationException:
-AddIncludeOnSelection.label=Add I&nclude@Ctrl+Shift+N
-AddIncludeOnSelection.tooltip=Add Include Statement on Selection
-
-ClassFileEditor.error.invalid_input_message=Invalid input for Class File Editor
-
-ClassFileMarkerAnnotationModel.error.isAcceptable=ClassFileMarkerAnnotationModel.isAcceptable
-ClassFileMarkerAnnotationModel.error.isAffected=ClassFileMarkerAnnotationModel.isAffected
-ClassFileMarkerAnnotationModel.error.resourceChanged=ClassFileMarkerAnnotationModel.resourceChanged
-
-CEditor.error.saving.message=Save could not be completed. {0}
-CEditor.error.saving.title=Problems During Save As...
-
-CEditorPreferencePage.description= C Editor Preferences
-
-DeleteISourceManipulations.description=Delete the selected element in the editor
-DeleteISourceManipulations.error.deleting.message1=Cannot delete element:
-DeleteISourceManipulations.error.deleting.title1=Problems while deleting element
-DeleteISourceManipulations.label=&Delete
-DeleteISourceManipulations.tooltip=Delete the selected element in the editor
-
-EditorDisplay.description=Display
-EditorDisplay.label=D&isplay
-EditorDisplay.tooltip=Display
-EditorDisplay.error.title1=Cannot open Display viewer
-
-JavaOutlinePage.ContextMenu.refactoring.label=&Refactor
-JavaOutlinePage.HideFields.description.checked=Shows Fields
-JavaOutlinePage.HideFields.description.unchecked=Hides Fields
-JavaOutlinePage.HideFields.label=Hide Fields
-JavaOutlinePage.HideFields.tooltip.checked=Show Fields
-JavaOutlinePage.HideFields.tooltip.unchecked=Hide Fields
-JavaOutlinePage.HideNonePublicMembers.description.checked=Shows non-public members
-JavaOutlinePage.HideNonePublicMembers.description.unchecked=Hides non-public members
-JavaOutlinePage.HideNonePublicMembers.label=Show Public Members Only
-JavaOutlinePage.HideNonePublicMembers.tooltip.checked=Show Non-Public Members
-JavaOutlinePage.HideNonePublicMembers.tooltip.unchecked=Hide Non-Public Members
-JavaOutlinePage.HideStaticMembers.description.checked=Shows static members
-JavaOutlinePage.HideStaticMembers.description.unchecked=Hides static members
-JavaOutlinePage.HideStaticMembers.label=Hide Static Members
-JavaOutlinePage.HideStaticMembers.tooltip.checked=Show Static Members
-JavaOutlinePage.HideStaticMembers.tooltip.unchecked=Hide Static Members
-JavaOutlinePage.Sort.description.checked=Disable Sorting
-JavaOutlinePage.Sort.description.unchecked=Enable Sorting
-JavaOutlinePage.Sort.label=Sort
-JavaOutlinePage.Sort.tooltip.checked=Do Not Sort
-JavaOutlinePage.Sort.tooltip.unchecked=Sort
-JavaOutlinePage.error.ChildrenProvider.getChildren.message1=JavaOutlinePage.ChildrenProvider.getChildren
-JavaOutlinePage.error.ChildrenProvider.hasChildren.message1=JavaOutlinePage.ChildrenProvider.hasChildren
-
-OpenHierarchy.description=Show the type hierarchy of the selected element
-OpenHierarchy.dialog.message=&Select the type to open:
-OpenHierarchy.dialog.title=Open Type Hierarchy
-OpenHierarchy.label=Open Type &Hierarchy@F4
-OpenHierarchy.tooltip=Show the type hierarchy of the selected element
-
-OpenDeclarations.description=Open an editor on the selected element's declaration(s)
-OpenDeclarations.dialog.message=&Select or enter the element to open:
-OpenDeclarations.dialog.title=Open Declarations
-OpenDeclarations.label=&Open Declarations@F3
-OpenDeclarations.tooltip=Open an editor on the selected element's declaration(s)
-
-OrganizeImports.description=Evaluate all required imports and replace the current imports
-OrganizeImports.error.message2=Syntax errors in compilation unit prevent correct evaluation\nof type references. Fix errors first.
-OrganizeImports.error.title1=Organize Imports
-OrganizeImports.error.title2=Organize Imports
-OrganizeImports.label=Or&ganize Imports@Ctrl+Shift+O
-OrganizeImports.ok_label=OK
-OrganizeImports.tooltip=Evaluate All Required Imports and Replace the Current Imports
-
-RunToLine.description=Run to line
-RunToLine.error.message1=Unable to process run to line request.
-RunToLine.error.title1=Run to Line
-RunToLine.label=R&un to Line
-RunToLine.tooltip=Run to line
-
-TogglePresentation.label=Show Source of Selected Element Only
-TogglePresentation.tooltip=Show Source of Selected Element Only
-
-ToggleTextHover.label=Show Text Hover
-ToggleTextHover.tooltip=Show Text Hover
-
-NextError.label=Ne&xt Problem
-NextError.tooltip=Go to Next Problem
-NextError.description=Go to next problem
-
-PreviousError.label=Previo&us Problem
-PreviousError.tooltip=Go to Previous Problem
-PreviousError.description=Go to previous problem
-
-ContentAssistProposal.label=Co&ntent Assist@Ctrl+Space
-ContentAssistProposal.tooltip=Content Assist
-ContentAssistProposal.description=Content Assist
-
-RunToLine.label=R&un to Line
-RunToLine.description=Run to line
-RunToLine.error.title1=Run To Line
-RunToLine.error.message1=Unable to process run to line request.
-
-Comment.label=&Comment
-Comment.tooltip=Comment the Selected Lines
-Comment.description=Turn the selected lines into C // style comments
-
-Uncomment.label=Uncommen&t
-Uncomment.tooltip=Uncomment the Selected C // comment Lines
-Uncomment.description=Uncomment the selected C // comment lines
-
-Format.label=F&ormat
-Format.tooltip=Format the Selected Text
-Format.description=Format the selected text
-
-ShiftRight.label=Sh&ift Right@Ctrl+I
-ShiftRight.tooltip=Shift Right
-ShiftRight.description=Shift the selected text to the right
-
-ShiftLeft.label=S&hift Left@Ctrl+Shift+I
-ShiftLeft.tooltip=Shift Left
-ShiftLeft.description=Shift the selected text to the left
-
-CompilationUnitDocumentProvider.error.createElementInfo=CompilationUnitDocumentProvider.createElementInfo
-CompilationUnitDocumentProvider.out_of_sync.message=Compilation unit buffer and document are out of sync
-
-JavaEditor.Inspect.description=Inspect the result of evaluating the selected text
-JavaEditor.Inspect.label=I&nspect
-JavaEditor.Inspect.tooltip=Inspect the Result of Evaluating the Selected Text
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorTextHoverDispatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorTextHoverDispatcher.java
deleted file mode 100644
index 9007d928e9e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorTextHoverDispatcher.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-
-public class CEditorTextHoverDispatcher implements ITextHover
-{
- private IEditorPart fEditor = null;
- private HashMap fTextHovers = null;
- private DefaultCEditorTextHover fDefaultTextHover = null;
-
- /**
- * Constructor for CEditorTextHover
- */
- public CEditorTextHoverDispatcher( IEditorPart editor, HashMap textHovers )
- {
- fEditor = editor;
- fTextHovers = textHovers;
- fDefaultTextHover = new DefaultCEditorTextHover( editor );
- }
-
- /**
- * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
- */
- public String getHoverInfo( ITextViewer textViewer, IRegion region )
- {
- return getCurrentTextHover().getHoverInfo( textViewer, region );
- }
-
- /**
- * @see ITextHover#getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion( ITextViewer textViewer, int offset )
- {
- return getCurrentTextHover().getHoverRegion( textViewer, offset );
- }
-
- private ITextHover getCurrentTextHover()
- {
- IWorkbenchPage page;
- if(fEditor != null && fEditor.getSite() != null &&
- (page = fEditor.getSite().getPage()) != null) {
- Object textHover = fTextHovers.get( page.getPerspective().getId() );
- if ( textHover != null && textHover instanceof ITextHover )
- return (ITextHover)textHover;
- }
- return fDefaultTextHover;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
deleted file mode 100644
index 1cf2df4f909..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-
-import org.eclipse.cdt.core.model.ICModelMarker;
-
-
-public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation {
-
- private boolean fIsProblemMarker;
- private IDocument fDocument;
- private int error_start = -1;
- private int error_length = 0;
- private IDebugModelPresentation fPresentation;
-
- public CMarkerAnnotation(IMarker marker, IDocument document) {
- super(marker);
- fDocument = document;
- if (MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
- fIsProblemMarker = true;
- try {
- String var = (String) getMarker().getAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE);
- if(var != null && fDocument != null) {
- int line = getMarker().getAttribute(IMarker.LOCATION, -1) - 1;
- if(line >= 0) {
- int position = fDocument.getLineOffset(line);
- String text = fDocument.get(position, fDocument.getLineLength(line));
- int start = 0, end, pos;
- pos = 0;
- while(start != -1) {
- start = getStart(text, var, pos);
- if(start >= 0) {
- if(Character.isJavaIdentifierStart(text.charAt(start + var.length())) == false) {
- break;
- }
- }
- pos += var.length();
- }
- //start = text.indexOf(var);
- if(start >= 0) {
- end = start + var.length();
- // We cannot just update the marker attributes as the workspace resource tree is locked
- Map map = marker.getAttributes();
- MarkerUtilities.setCharStart(map, position+start);
- MarkerUtilities.setCharEnd(map, position+end);
- error_start = position+start;
- error_length = end-start;
-
- //getMarker().setAttribute(IMarker.CHAR_START, position+start);
- //getMarker().setAttribute(IMarker.CHAR_END, position+end);
- }
- }
- }
- } catch (CoreException e) {
- } catch (BadLocationException e) {
- }
- }
- }
- /**
- * Ensures that we return a value that is not encased in a String
- */
- private int getStart(String text, String var, int pos){
-
- // determine if there are more than one instance of var in this text
- int count = 0;
- int currentPosition = pos;
- while(currentPosition != -1){
- currentPosition = text.indexOf(var, currentPosition);
- if (currentPosition != -1){
- // found one!
- count++;
- currentPosition += var.length();
- }
- }
- // only one occurrence return its index
- if (count == 1){
- return text.indexOf(var, pos);
- }
-
- // otherwise we need to find the first one not inside of quotes
- int indexOfStringStart = pos;
-
- final String QUOTE = "\"";
- indexOfStringStart = text.indexOf(QUOTE, indexOfStringStart);
- int newPosition = -1;
- currentPosition = pos; // reinitialize currentPosition
-
- if (indexOfStringStart == -1) {
- // No Strings ... return the first occurrence of var
- newPosition = text.indexOf(var, currentPosition);
- } else {
- // we have Strings
- StringTokenizer tokens = new StringTokenizer(text.substring(currentPosition), QUOTE, true);
- String nextToken = null;
- int quoteCount = 0;
- int potentialStart = -1;
- boolean found = false;
-
- while (tokens.hasMoreTokens() && !found){
- nextToken = tokens.nextToken();
- if(QUOTE.equals(nextToken)){
- quoteCount++;
- } else {
- if ((quoteCount % 2) == 0){
- // no open quotes .. we can check this token
- potentialStart = nextToken.indexOf(var, 0);
- if (potentialStart != -1){
- found = true;
- currentPosition += potentialStart;
- newPosition = currentPosition;
- break;
- }
- }// else ... we have an open quote and must
- // throw away this non-quote token
- }
- currentPosition += nextToken.length();
- }
- }
-
- return newPosition;
- }
-
- /**
- * Initializes the annotation's icon representation and its drawing layer
- * based upon the properties of the underlying marker.
- */
- protected void initialize() {
- try {
- IMarker marker= getMarker();
-
- if (MarkerUtilities.isMarkerType(marker, SearchUI.SEARCH_MARKER)) {
- setLayer(2);
- setImage(SearchUI.getSearchMarkerImage());
- fIsProblemMarker= false;
- return;
- }
- else if (MarkerUtilities.isMarkerType(marker, IBreakpoint.LINE_BREAKPOINT_MARKER)) {
- if (fPresentation == null)
- fPresentation= DebugUITools.newDebugModelPresentation();
-
- setLayer(4);
- setImage(fPresentation.getImage(marker));
-
- fIsProblemMarker= false;
- return;
- } else if (MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
- fIsProblemMarker = true;
- String var = (String) marker.getAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE);
- if(var != null && fDocument != null) {
- int line = marker.getAttribute(IMarker.LOCATION, -1);
- if(line >= 0 && line == -1) {
- try {
- int position = fDocument.getLineOffset(line);
- System.out.println("offset " + position);
- String text = fDocument.get(position, fDocument.getLineLength(line));
- System.out.println("text:" + text);
- } catch (BadLocationException e) {}
- }
- }
- } else {
- if(marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) { //|| getMarker().isSubtypeOf(IMarker.SEVERITY_WARNING)) {
- fIsProblemMarker= true;
- } else if (marker.isSubtypeOf(IMarker.TASK) || marker.isSubtypeOf(ICModelMarker.TASK_MARKER)) {
- fIsProblemMarker= false;
- } else
- fIsProblemMarker = true;
- }
-
- } catch (CoreException e) {
- }
-
- super.initialize();
- }
-
- /**
- * @see IProblemAnnotation#getMessage()
- */
- public String getMessage() {
- if (fIsProblemMarker)
- return getMarker().getAttribute(IMarker.MESSAGE, "");
- return "";
- }
-
- /**
- * @see IProblemAnnotation#isError()
- */
- public boolean isError() {
- if (fIsProblemMarker) {
- int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
- return (markerSeverity == IMarker.SEVERITY_ERROR);
- }
- return false;
- }
-
- /**
- * @see IProblemAnnotation#isWarning()
- */
- public boolean isWarning() {
- if (fIsProblemMarker) {
- int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
- return (markerSeverity == IMarker.SEVERITY_WARNING);
- }
- return false;
- }
-
- /**
- * @see IProblemAnnotation#isTemporaryProblem()
- */
- public boolean isTemporaryProblem() {
- return false;
- }
-
- /**
- * @see IProblemAnnotation#getArguments()
- */
- public String[] getArguments() {
- String [] s = {"problem", "here"};
- //if (fIsProblemMarker)
- // return Util.getProblemArgumentsFromMarker(getMarker().getAttribute(CCorePlugin.C_PROBLEMMARKER));
- return s;
- //returnm null;
- }
-
- /**
- * @see IProblemAnnotation#getId()
- */
- public int getId() {
- if (fIsProblemMarker)
- return getMarker().getAttribute(ICModelMarker.C_MODEL_PROBLEM_MARKER, -1);
- return 0;
- }
-
- /**
- * @see IProblemAnnotation#isProblem()
- */
- public boolean isProblem() {
- return fIsProblemMarker;
- }
-
- public int getErrorStart() {
- return error_start;
- }
- public int getErrorLength() {
- return error_length;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java
deleted file mode 100644
index 90f780e1c78..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-
-public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
-
- /**
- * Constructor for CMarkerAnnotationModel
- */
- public CMarkerAnnotationModel(IResource resource) {
- super(resource);
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker)
- */
- protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
- return new CMarkerAnnotation(marker, fDocument);
- }
- /**
- * @see AbstractMarkerAnnotationModel#modifyMarkerAnnotation(IMarker)
- */
- protected void modifyMarkerAnnotation(IMarker marker) {
- MarkerAnnotation a= getMarkerAnnotation(marker);
- if (a == null) {
- // It might not have been good enough before, but now it
- // is, try adding this marker into the model again.
- addMarkerAnnotation(marker);
- }
- super.modifyMarkerAnnotation(marker);
- }
-
-
- /**
- * Adds the given annotation to this model. Associates the
- * annotation with the given position. If requested, all annotation
- * model listeners are informed about this model change. If the annotation
- * is already managed by this model nothing happens.
- *
- * @param annotation the annotation to add
- * @param position the associate position
- * @param fireModelChange indicates whether to notify all model listeners
- */
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged){
- if (!fAnnotations.containsKey(annotation)) {
-
- // @@@ This is an unfortunate hack because we cannot override addAnnotationMarker() and if we
- // update a marker position, there's no way to update the annotation
- if(annotation instanceof CMarkerAnnotation) {
- int start = ((CMarkerAnnotation)annotation).getErrorStart();
- if(start != -1 && start != position.getOffset()) {
- position.setOffset(start);
- position.setLength(((CMarkerAnnotation)annotation).getErrorLength());
- }
- }
- fAnnotations.put(annotation, position);
- try {
- addPosition(fDocument, position);
- } catch (Exception e) {
- }
-
- if (fireModelChanged)
- fireModelChanged();
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTextEditorActionConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTextEditorActionConstants.java
deleted file mode 100644
index a19106d2852..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTextEditorActionConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.ui.IWorkbenchActionConstants;
-
-
-public interface CTextEditorActionConstants extends IWorkbenchActionConstants {
- /**
- * Status category "input position".
- */
- static final String STATUS_CURSOR_POS= "CursorPosition";
-
-
- /**
- * Status category "input mode".
- */
- static final String STATUS_INPUT_MODE= "InputMode";
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultCEditorTextHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultCEditorTextHover.java
deleted file mode 100644
index 02f79870b98..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultCEditorTextHover.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
-import org.eclipse.cdt.internal.ui.text.CWordFinder;
-import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
-import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.IEditorPart;
-
-public class DefaultCEditorTextHover implements ITextHover
-{
- protected IEditorPart fEditor;
-
- /**
- * Constructor for DefaultCEditorTextHover
- */
- public DefaultCEditorTextHover( IEditorPart editor )
- {
- fEditor = editor;
- }
-
- /**
- * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
- */
- public String getHoverInfo( ITextViewer viewer, IRegion region )
- {
- String expression = null;
-
- if(fEditor == null)
- return null;
- try
- {
- expression = viewer.getDocument().get( region.getOffset(), region.getLength() );
- expression = expression.trim();
- if ( expression.length() == 0 )
- return null;
-
- StringBuffer buffer = new StringBuffer();
-
- // We are just doing some C, call the Help to get info
-
- IFunctionSummary fs = CCompletionContributorManager.getDefault().getFunctionInfo(expression);
- if(fs != null) {
- buffer.append("<b>Name:</b> ");
- buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
- buffer.append("<br><b>Protoype:</b> ");
- buffer.append(HTMLPrinter.convertToHTMLContent(fs.getPrototype().getPrototypeString(false)));
- if(fs.getDescription() != null) {
- buffer.append("<br><b>Description:</b><br>");
- //Don't convert this description since it could already be formatted
- buffer.append(fs.getDescription());
- }
-// int i;
-// for(i = 0; i < buffer.length(); i++) {
-// if(buffer.charAt(i) == '\\') {
-// if((i + 1 < buffer.length()) && buffer.charAt(i+1) == 'n') {
-// buffer.replace(i, i + 2, "<br>");
-// }
-// }
-// }
- }
-// else {
-// // Query the C model
-// IndexModel model = IndexModel.getDefault();
-// IEditorInput input = fEditor.getEditorInput();
-// if(input instanceof IFileEditorInput) {
-// IProject project = ((IFileEditorInput)input).getFile().getProject();
-//
-// // Bail out quickly, if the project was deleted.
-// if (!project.exists())
-// throw new CoreException(new Status(0, "", 0, "", null));
-//
-// IProject[] refs = project.getReferencedProjects();
-//
-// ITagEntry[] tags= model.query(project, expression, false, true);
-//
-// if(tags == null || tags.length == 0) {
-// for ( int j= 0; j < refs.length; j++ ) {
-// if (!refs[j].exists())
-// continue;
-// tags= model.query(refs[j], expression, false, true);
-// if(tags != null && tags.length > 0)
-// break;
-// }
-// }
-//
-// if(tags != null && tags.length > 0) {
-// ITagEntry selectedTag = selectTag(tags);
-// // Show only the first element
-// buffer.append("<b> " + TagFlags.value(selectedTag.getKind()) + " " + HTMLPrinter.convertToHTMLContent(expression) +
-// "</b> - " + selectedTag.getIFile().getFullPath().toString() + "[" + selectedTag.getLineNumber()+"]" );
-// // Now add the pattern
-// buffer.append("<br><br>" + HTMLPrinter.convertToHTMLContent(selectedTag.getPattern()));
-// }
-// }
-// }
- if (buffer.length() > 0) {
- HTMLPrinter.insertPageProlog(buffer, 0);
- HTMLPrinter.addPageEpilog(buffer);
- return buffer.toString();
- }
- } catch(Exception ex) {
- /* Ignore */
- }
-
- return null;
- }
-
- /**
- * @see ITextHover#getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion( ITextViewer viewer, int offset )
- {
- Point selectedRange = viewer.getSelectedRange();
- if ( selectedRange.x >= 0 &&
- selectedRange.y > 0 &&
- offset >= selectedRange.x &&
- offset <= selectedRange.x + selectedRange.y )
- return new Region( selectedRange.x, selectedRange.y );
- if ( viewer != null )
- return CWordFinder.findWord( viewer.getDocument(), offset );
- return null;
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
deleted file mode 100644
index 2080cc5f831..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
+++ /dev/null
@@ -1,486 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - Initial API and implementation
-***********************************************************************/
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.BufferChangedEvent;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBuffer;
-import org.eclipse.cdt.core.model.IBufferChangedListener;
-import org.eclipse.cdt.core.model.IOpenable;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
- * same algorithm as the text widget to determine the buffer's line delimiter.
- * All text inserted into the buffer is converted to this line delimiter.
- * This class is <code>public</code> for test purposes only.
- *
- * This class is similar to the JDT DocumentAdapter class.
- */
-public class DocumentAdapter implements IBuffer, IDocumentListener {
-
- /**
- * Internal implementation of a NULL instanceof IBuffer.
- */
- static private class NullBuffer implements IBuffer {
-
- public void addBufferChangedListener(IBufferChangedListener listener) {}
-
- public void append(char[] text) {}
-
- public void append(String text) {}
-
- public void close() {}
-
- public char getChar(int position) {
- return 0;
- }
-
- public char[] getCharacters() {
- return null;
- }
-
- public String getContents() {
- return null;
- }
-
- public int getLength() {
- return 0;
- }
-
- public IOpenable getOwner() {
- return null;
- }
-
- public String getText(int offset, int length) {
- return null;
- }
-
- public IResource getUnderlyingResource() {
- return null;
- }
-
- public boolean hasUnsavedChanges() {
- return false;
- }
-
- public boolean isClosed() {
- return false;
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- public void removeBufferChangedListener(IBufferChangedListener listener) {}
-
- public void replace(int position, int length, char[] text) {}
-
- public void replace(int position, int length, String text) {}
-
- public void save(IProgressMonitor progress, boolean force) throws CModelException {}
-
- public void setContents(char[] contents) {}
-
- public void setContents(String contents) {}
- };
-
-
- /** NULL implementing <code>IBuffer</code> */
- public final static IBuffer NULL= new NullBuffer();
- /*
- * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
- */
- public void addBufferChangedListener(IBufferChangedListener listener) {
- Assert.isNotNull(listener);
- if (!fBufferListeners.contains(listener))
- fBufferListeners.add(listener);
- }
- /**
- * Executes a document set content call in the ui thread.
- */
- protected class DocumentSetCommand implements Runnable {
-
- private String fContents;
-
- public void run() {
- fDocument.set(fContents);
- }
-
- public void set(String contents) {
- fContents= contents;
- Display.getDefault().syncExec(this);
- }
- };
- /**
- * Executes a document replace call in the ui thread.
- */
- protected class DocumentReplaceCommand implements Runnable {
-
- private int fOffset;
- private int fLength;
- private String fText;
-
- public void run() {
- try {
- fDocument.replace(fOffset, fLength, fText);
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- public void replace(int offset, int length, String text) {
- fOffset= offset;
- fLength= length;
- fText= text;
- Display.getDefault().syncExec(this);
- }
- };
-
- private IOpenable fOwner;
- IDocument fDocument;
- private DocumentSetCommand fSetCmd= new DocumentSetCommand();
- private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
-
- private Object fProviderKey;
- private CDocumentProvider fProvider;
- private String fLineDelimiter;
- private ILineTracker fLineTracker;
-
- private List fBufferListeners= new ArrayList(3);
-
- private IStatus fStatus;
-
-
- public DocumentAdapter(IOpenable owner, IDocument document, ILineTracker lineTracker, CDocumentProvider provider, Object providerKey) {
-
- Assert.isNotNull(document);
- Assert.isNotNull(lineTracker);
-
- fOwner= owner;
- fDocument= document;
- fLineTracker= lineTracker;
- fProvider= provider;
- fProviderKey= providerKey;
-
- fDocument.addPrenotifiedDocumentListener(this);
-
- }
- /**
- * Sets the status of this document adapter.
- */
- public void setStatus(IStatus status) {
- fStatus= status;
- }
-
- /**
- * Returns the status of this document adapter.
- */
- public IStatus getStatus() {
- return fStatus;
- }
-
- /**
- * Returns the adapted document.
- *
- * @return the adapted document
- */
- public IDocument getDocument() {
- return fDocument;
- }
- /**
- * Returns the line delimiter of this buffer. As a document has a set of
- * valid line delimiters, this set must be reduced to size 1.
- */
- protected String getLineDelimiter() {
-
- if (fLineDelimiter == null) {
-
- try {
- fLineDelimiter= fDocument.getLineDelimiter(0);
- } catch (BadLocationException x) {
- }
-
- if (fLineDelimiter == null) {
- /*
- * Follow up fix for: 1GF5UU0: ITPJUI:WIN2000 - "Organize Imports" in java editor inserts lines in wrong format
- * The line delimiter must always be a legal document line delimiter.
- */
- String sysLineDelimiter= System.getProperty("line.separator"); //$NON-NLS-1$
- String[] delimiters= fDocument.getLegalLineDelimiters();
- Assert.isTrue(delimiters.length > 0);
- for (int i= 0; i < delimiters.length; i++) {
- if (delimiters[i].equals(sysLineDelimiter)) {
- fLineDelimiter= sysLineDelimiter;
- break;
- }
- }
-
- if (fLineDelimiter == null) {
- // system line delimiter is not a legal document line delimiter
- fLineDelimiter= delimiters[0];
- }
- }
- }
-
- return fLineDelimiter;
- }
-
- /**
- * Converts the given string to the line delimiter of this buffer.
- * This method is <code>public</code> for test purposes only.
- */
- public String normalize(String text) {
- fLineTracker.set(text);
-
- int lines= fLineTracker.getNumberOfLines();
- if (lines <= 1)
- return text;
-
- StringBuffer buffer= new StringBuffer(text);
-
- try {
- IRegion previous= fLineTracker.getLineInformation(0);
- for (int i= 1; i < lines; i++) {
- int lastLineEnd= previous.getOffset() + previous.getLength();
- int lineStart= fLineTracker.getLineInformation(i).getOffset();
- fLineTracker.replace(lastLineEnd, lineStart - lastLineEnd, getLineDelimiter());
- buffer.replace(lastLineEnd, lineStart, getLineDelimiter());
- previous= fLineTracker.getLineInformation(i);
- }
-
- // last line
- String delimiter= fLineTracker.getLineDelimiter(lines -1);
- if (delimiter != null && delimiter.length() > 0)
- buffer.replace(previous.getOffset() + previous.getLength(), buffer.length(), getLineDelimiter());
-
- return buffer.toString();
- } catch (BadLocationException x) {
- }
-
- return text;
- }
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#append(char)
- */
- public void append(char[] text) {
- append(new String(text));
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#append(java.lang.String)
- */
- public void append(String text) {
- fReplaceCmd.replace(fDocument.getLength(), 0, normalize(text));
- }
-
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#close()
- */
- public void close() {
- if (isClosed())
- return;
-
- IDocument d= fDocument;
- fDocument= null;
- d.removePrenotifiedDocumentListener(this);
-
- fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
- fBufferListeners.clear();
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getChar(int)
- */
- public char getChar(int position) {
- try {
- return fDocument.getChar(position);
- } catch (BadLocationException x) {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getCharacters()
- */
- public char[] getCharacters() {
- String content= getContents();
- return content == null ? null : content.toCharArray();
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getContents()
- */
- public String getContents() {
- return fDocument.get();
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getLength()
- */
- public int getLength() {
- return fDocument.getLength();
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner()
- */
- public IOpenable getOwner() {
- return (IOpenable) fOwner;
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getText(int, int)
- */
- public String getText(int offset, int length) {
- try {
- return fDocument.get(offset, length);
- } catch (BadLocationException x) {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#getUnderlyingResource()
- */
- public IResource getUnderlyingResource() {
- //return null;
- return fProvider != null ? fProvider.getUnderlyingResource(fProviderKey) : null;
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#hasUnsavedChanges()
- */
- public boolean hasUnsavedChanges() {
- //return false;
- return fProvider != null ? fProvider.canSaveDocument(fProviderKey) : false;
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#isClosed()
- */
- public boolean isClosed() {
- return fDocument == null;
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#isReadOnly()
- */
- public boolean isReadOnly() {
- //return false;
- IResource resource= getUnderlyingResource();
- return resource == null ? true : resource.isReadOnly();
- }
-
- /*
- * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
- */
- public void removeBufferChangedListener(IBufferChangedListener listener) {
- Assert.isNotNull(listener);
- fBufferListeners.remove(listener);
- }
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, char)
- */
- public void replace(int position, int length, char[] text) {
- replace(position, length, new String(text));
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, java.lang.String)
- */
- public void replace(int position, int length, String text) {
- fReplaceCmd.replace(position, length, normalize(text));
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void save(IProgressMonitor progress, boolean force) throws CModelException {
- if (fProvider != null) {
- try {
- fProvider.saveDocumentContent(progress, fProviderKey, fDocument, force);
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- }
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(char)
- */
- public void setContents(char[] contents) {
- setContents(new String(contents));
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(java.lang.String)
- */
- public void setContents(String contents) {
- int oldLength= fDocument.getLength();
-
- if (contents == null) {
-
- if (oldLength != 0)
- fSetCmd.set(""); //$NON-NLS-1$
-
- } else {
-
- // set only if different
- String newContents= normalize(contents);
- int newLength= newContents.length();
-
- if (oldLength != newLength || !newContents.equals(fDocument.get()))
- fSetCmd.set(newContents);
- }
- }
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- // there is nothing to do here
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
- }
-
- private void fireBufferChanged(BufferChangedEvent event) {
- if (fBufferListeners != null && fBufferListeners.size() > 0) {
- Iterator e= new ArrayList(fBufferListeners).iterator();
- while (e.hasNext())
- ((IBufferChangedListener) e.next()).bufferChanged(event);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchAction.java
deleted file mode 100644
index 3182c305dd7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchAction.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-//import org.eclipse.search.internal.core.text.TextSearchEngine;
-import org.eclipse.search.internal.core.text.TextSearchScope;
-import org.eclipse.search.internal.ui.text.TextSearchOperation;
-import org.eclipse.search.internal.ui.text.TextSearchResultCollector;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.PlatformUI;
-
-
-
-public class FileSearchAction extends Action {
-
-
- private static final String PREFIX= "FileSearchAction.";
-
- private ISelectionProvider fSelectionProvider;
-
- public FileSearchAction(ISelectionProvider provider) {
- super(CUIPlugin.getResourceString(PREFIX + "label"));
- setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
- setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
-
- if(provider instanceof CContentOutlinePage) {
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
- //setText("Search for References"); // $NON-NLS
- }
-
- fSelectionProvider= provider;
- }
-
- public void run() {
- String search_name;
-
- ISelection selection= fSelectionProvider.getSelection();
- if(selection instanceof ITextSelection) {
- search_name = ((ITextSelection)selection).getText();
- if(search_name.length() == 0) return;
- } else {
- ICElement element= getElement(selection);
- if (element == null) {
- return;
- }
- search_name = element.getElementName();
- }
-
- // @@@ we rely on the internal functions of the Search plugin, since
- // none of these are actually exported. This is probably going to change
- // with 2.0.
- TextSearchResultCollector col = new TextSearchResultCollector();
- try {
- //TextSearchPage
- //ProgressMonitor monitor = new ProgressMonitor();
- //col.setProgressMonitor(monitor)
- SearchUI.activateSearchResultView();
- //col.aboutToStart();
-
- // We now have the element, start a search on the string
- //TextSearchEngine engine = new TextSearchEngine();
- TextSearchScope scope= TextSearchScope.newWorkspaceScope();
- // Add the extensions from the C editor definition for now
- // FIXME: For C/C++ not all files rely on extension to be C++ for <cstring>
- String[] cexts = CoreModel.getDefault().getTranslationUnitExtensions();
- for (int i = 0; i < cexts.length; i++) {
- scope.addExtension("*." + cexts[i]);
- }
-// scope.addExtension("*.c");
-// scope.addExtension("*.h");
-// scope.addExtension("*.cc");
-// scope.addExtension("*.hh");
-
- TextSearchOperation op= new TextSearchOperation(
- CUIPlugin.getWorkspace(),
- search_name,
- "",
- scope,
- col);
-
-
- //engine.search(CUIPlugin.getWorkspace(), element.getName(),
- // null, scope, col);
- IRunnableContext context= null;
- //context= getContainer().getRunnableContext();
-
- Shell shell= new Shell(); // getShell();
- if (context == null)
- context= new ProgressMonitorDialog(shell);
-
-
- try {
- context.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, "Error","Error"); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (InterruptedException e) {
- }
- } catch (Exception e) {}
-
- }
-
-
- private static ICElement getElement(ISelection sel) {
- if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List list= ((IStructuredSelection)sel).toList();
- if (list.size() == 1) {
- Object element= list.get(0);
- if (element instanceof ICElement) {
- return (ICElement)element;
- }
- }
- }
- return null;
- }
-
- public static boolean canActionBeAdded(ISelection selection) {
- if(selection instanceof ITextSelection) {
- return (((ITextSelection)selection).getLength() > 0);
- } else {
- return getElement(selection) != null;
- }
- }
-
-
- public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
- if (descriptor != null) {
- return descriptor.getId();
- } else {
- return registry.getDefaultEditor().getId();
- }
- }
- return null;
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchActionInWorkingSet.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchActionInWorkingSet.java
deleted file mode 100644
index 523171c6824..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/FileSearchActionInWorkingSet.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Created on Sep 9, 2003
- */
-package org.eclipse.cdt.internal.ui.editor;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.search.CSearchScopeFactory;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.search.internal.core.SearchScope;
-import org.eclipse.search.internal.ui.text.TextSearchOperation;
-import org.eclipse.search.internal.ui.text.TextSearchResultCollector;
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author bgheorgh
- */
-public class FileSearchActionInWorkingSet extends Action {
-
-
- private static final String PREFIX= "FileSearchActionInWorkingSet.";
-
- private ISelectionProvider fSelectionProvider;
-
- public FileSearchActionInWorkingSet(ISelectionProvider provider) {
- super(CUIPlugin.getResourceString(PREFIX + "label"));
- setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
- setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
-
- if(provider instanceof CContentOutlinePage) {
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
- }
-
- fSelectionProvider= provider;
- }
-
- public void run() {
- String search_name;
-
- ISelection selection= fSelectionProvider.getSelection();
- if(selection instanceof ITextSelection) {
- search_name = ((ITextSelection)selection).getText();
- if(search_name.length() == 0) return;
- } else {
- ICElement element= getElement(selection);
- if (element == null) {
- return;
- }
- search_name = element.getElementName();
- }
-
- // @@@ we rely on the internal functions of the Search plugin, since
- // none of these are actually exported. This is probably going to change
- // with 2.0.
- TextSearchResultCollector col = new TextSearchResultCollector();
- try {
- SearchUI.activateSearchResultView();
-
- IWorkingSet[] workingSets= CSearchScopeFactory.getInstance().queryWorkingSets();
- ArrayList resourceList = new ArrayList();
- for (int i=0; i<workingSets.length; i++){
- IAdaptable[] elements = workingSets[i].getElements();
-
- for (int j=0; j< elements.length; j++){
- IResource resource= (IResource)elements[j].getAdapter(IResource.class);
- if (resource != null){
- resourceList.add(resource);
- }
- }
- }
- IResource[] result = new IResource[resourceList.size()];
- resourceList.toArray(result);
-
- SearchScope scope= new SearchScope("File Search",(IResource []) result);
-
-
- TextSearchOperation op= new TextSearchOperation(
- CUIPlugin.getWorkspace(),
- search_name,
- "",
- scope,
- col);
-
- IRunnableContext context= null;
-
- Shell shell= new Shell(); // getShell();
- if (context == null)
- context= new ProgressMonitorDialog(shell);
-
-
- try {
- context.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, "Error","Error"); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (InterruptedException e) {
- }
- } catch (Exception e) {}
-
-
- }
-
-
- private static ICElement getElement(ISelection sel) {
- if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List list= ((IStructuredSelection)sel).toList();
- if (list.size() == 1) {
- Object element= list.get(0);
- if (element instanceof ICElement) {
- return (ICElement)element;
- }
- }
- }
- return null;
- }
-
- public static boolean canActionBeAdded(ISelection selection) {
- if(selection instanceof ITextSelection) {
- return (((ITextSelection)selection).getLength() > 0);
- } else {
- return getElement(selection) != null;
- }
- }
-
-
- public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
- if (descriptor != null) {
- return descriptor.getId();
- } else {
- return registry.getDefaultEditor().getId();
- }
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoErrorAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoErrorAction.java
deleted file mode 100644
index cfc086874ae..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoErrorAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-
-public class GotoErrorAction extends TextEditorAction {
-
-
- private boolean fForward;
-
-
- public GotoErrorAction(String prefix, boolean forward) {
- super(CEditorMessages.getResourceBundle(), prefix, null);
- fForward= forward;
- }
- /**
- * @see Action#run()
- */
- public void run() {
- CEditor e= (CEditor) getTextEditor();
- e.gotoError(fForward);
- }
- /**
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- if (editor instanceof CEditor)
- super.setEditor(editor);
- }
- /**
- * @see TextEditorAction#update()
- */
- public void update() {
- setEnabled(true);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
deleted file mode 100644
index b5352ec1b1c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-package org.eclipse.cdt.internal.ui.editor;
-
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-
-/**
- * Defines the definition IDs for the C editor actions.
- *
- * <p>
- * This interface is not intended to be implemented or extended.
- * </p>.
- *
- * @since 2.1
- */
-public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
-
- /**
- * Action definition ID of the source -> comment action
- * (value <code>"org.eclipse.cdt.ui.edit.text.c.comment"</code>).
- */
- public static final String COMMENT = "org.eclipse.cdt.ui.edit.text.c.comment"; //$NON-NLS-1$
-
- /**
- * Action definition ID of the source -> uncomment action
- * (value <code>"org.eclipse.cdt.ui.edit.text.c.uncomment"</code>).
- */
- public static final String UNCOMMENT = "org.eclipse.cdt.ui.edit.text.c.uncomment"; //$NON-NLS-1$
-
- /**
- * Action definition ID of the source -> format action
- * (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
- */
- public static final String FORMAT = "org.eclipse.cdt.ui.edit.text.c.format"; //$NON-NLS-1$
-
- /**
- * Action definition ID of the source -> add include action
- * (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
- */
- public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
-
- /**
- * Action definition ID of the toggle presentation toolbar button action
- * (value <code>"org.eclipse.cdt.ui.edit.text.java.toggle.presentation"</code>).
- */
- public static final String TOGGLE_PRESENTATION= "org.eclipse.cdt.ui.edit.text.c.toggle.presentation"; //$NON-NLS-1$
- /**
- * Action definition ID of the open declaration action
- * (value <code>"org.eclipse.cdt.ui.edit.text.java.toggle.presentation"</code>).
- */
- public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPositionManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPositionManager.java
deleted file mode 100644
index bc495ee970a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPositionManager.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.Position;
-
-
-public interface IPositionManager {
-
- void addManagedPosition(Position position);
-
- void removeManagedPosition(Position position);
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
deleted file mode 100644
index 6a0fe829215..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Interface of annotations representing problems.
- */
-public interface IProblemAnnotation {
-
- String getMessage();
-
- int getId();
-
- String[] getArguments();
-
- boolean isTemporaryProblem();
-
- boolean isWarning();
-
- boolean isError();
-
- boolean isProblem();
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
deleted file mode 100644
index b3d416ea79c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-
-public class LexicalSortingAction extends Action {
-
- private static final String ACTION_NAME= "LexicalSortingAction";
- private static final String DIALOG_STORE_KEY= ACTION_NAME + ".sort";
-
- private LexicalCSorter fSorter;
- private TreeViewer fTreeViewer;
-
- public LexicalSortingAction(TreeViewer treeViewer) {
- super(CUIPlugin.getResourceString(ACTION_NAME + ".label"));
-
- setDescription(CUIPlugin.getResourceString(ACTION_NAME + ".description"));
- setToolTipText(CUIPlugin.getResourceString(ACTION_NAME + ".tooltip"));
-
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ALPHA_SORTING);
-
- fTreeViewer= treeViewer;
- fSorter= new LexicalCSorter();
-
- boolean checked= CUIPlugin.getDefault().getDialogSettings().getBoolean(DIALOG_STORE_KEY);
- valueChanged(checked, false);
- }
-
- public void run() {
- valueChanged(isChecked(), true);
- }
-
- private void valueChanged(boolean on, boolean store) {
- setChecked(on);
- fTreeViewer.setSorter(on ? fSorter : null);
-
- String key= ACTION_NAME + ".tooltip" + (on ? ".on" : ".off");
- setToolTipText(CUIPlugin.getResourceString(key));
-
- if (store) {
- CUIPlugin.getDefault().getDialogSettings().put(DIALOG_STORE_KEY, on);
- }
- }
-
- private class LexicalCSorter extends ViewerSorter {
- public boolean isSorterProperty(Object element, Object property) {
- return true;
- }
-
- public int category(Object obj) {
- if (obj instanceof ICElement) {
- ICElement elem= (ICElement)obj;
- switch (elem.getElementType()) {
- case ICElement.C_MACRO: return 1;
- case ICElement.C_INCLUDE: return 2;
-
- case ICElement.C_CLASS: return 3;
- case ICElement.C_STRUCT: return 4;
- case ICElement.C_UNION: return 5;
-
- case ICElement.C_FIELD: return 6;
- case ICElement.C_FUNCTION: return 7;
- }
-
- }
- return 0;
- }
- };
-
-};
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java
deleted file mode 100644
index 8bf7f8a9d8c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.core.search.matching.OrPattern;
-import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-
-/**
- * This action opens a java CEditor on the element represented by text selection of
- * the connected java source viewer.
- *
- * Use action from package org.eclipse.jdt.ui.actions
- */
-public class OpenDeclarationsAction extends Action {
-
- private String fDialogTitle;
- private String fDialogMessage;
- protected CEditor fEditor;
- BasicSearchResultCollector resultCollector = null;
- SearchEngine searchEngine = null;
-
- /**
- * Creates a new action with the given label and image.
- */
- protected OpenDeclarationsAction() {
- super();
-
- setText(CEditorMessages.getString("OpenDeclarations.label")); //$NON-NLS-1$
- setToolTipText(CEditorMessages.getString("OpenDeclarations.tooltip")); //$NON-NLS-1$
- setDescription(CEditorMessages.getString("OpenDeclarations.description")); //$NON-NLS-1$
- setDialogTitle(CEditorMessages.getString("OpenDeclarations.dialog.title")); //$NON-NLS-1$
- setDialogMessage(CEditorMessages.getString("OpenDeclarations.dialog.message")); //$NON-NLS-1$
-
- searchEngine = new SearchEngine();
- resultCollector = new BasicSearchResultCollector();
- }
-
- /**
- * Creates a new action with the given image.
- */
- public OpenDeclarationsAction(ImageDescriptor image) {
- this();
- setImageDescriptor(image);
- }
-
- /**
- * Creates a new action with the given editor
- */
- public OpenDeclarationsAction(CEditor editor) {
- this();
- fEditor = editor;
- }
-
- protected void setDialogTitle(String title) {
- fDialogTitle= title;
- }
-
- protected void setDialogMessage(String message) {
- fDialogMessage= message;
- }
-
- public void setContentEditor(CEditor editor) {
- fEditor= editor;
- }
-
- /**
- * @see IAction#actionPerformed
- */
- public void run() {
-
- IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
- ITranslationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput());
-
- if (fEditor.getSelectionProvider() != null) {
- ITextSelection selection= (ITextSelection) fEditor.getSelectionProvider().getSelection();
- try {
- ArrayList elementsFound = new ArrayList();
- String sel = selection.getText();
- if (sel.equals(""))
- {
- int selStart = selection.getOffset();
-
- IDocumentProvider prov = fEditor.getDocumentProvider();
- IDocument doc = prov.getDocument(fEditor.getEditorInput());
- sel = getSelection(doc, selStart);
- }
-
- IFile file = fEditor.getInputFile();
- if(file == null)
- return;
- IProject project = file.getProject();
- if(project == null)
- return;
-
- ICElement[] projectScopeElement = new ICElement[1];
- projectScopeElement[0] = unit.getCProject();//(ICElement)currentScope.getCProject();
- ICSearchScope scope = SearchEngine.createCSearchScope(projectScopeElement, true);
- OrPattern orPattern = new OrPattern();
- // search for global variables, functions, classes, structs, unions, enums and macros
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.METHOD, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.FIELD, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.TYPEDEF, ICSearchConstants.DECLARATIONS, true ));
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
- elementsFound.addAll(resultCollector.getSearchResults());
-
- if (elementsFound.isEmpty() == false) {
- IMatch selected= selectCElement(elementsFound, getShell(), fDialogTitle, fDialogMessage);
- if (selected != null) {
- open(selected);
- return;
- }
- }
- } catch (Exception x) {
- CUIPlugin.getDefault().log(x);
- }
- }
-
- getShell().getDisplay().beep();
- }
-
- protected Shell getShell() {
- return fEditor.getSite().getShell();
- }
-
-
-
- /**
- * Opens the editor on the given element and subsequently selects it.
- */
- protected void open(IMatch element) throws CModelException, PartInitException {
- IEditorPart part= EditorUtility.openInEditor(element.getResource());
- //int line = element.getStartOffset();
- //if(line > 0) line--;
- if(part instanceof CEditor) {
- CEditor ed = (CEditor)part;
-
- try {
- IDocument document= ed.getDocumentProvider().getDocument(ed.getEditorInput());
- //if(line > 3) {
- // ed.selectAndReveal(document.getLineOffset(line - 3), 0);
- //}
- ed.selectAndReveal(element.getStartOffset() /*document.getLineOffset(line)*/, 0);
- } catch (Exception e) {}
- }
- }
-
- /**
- * Shows a dialog for resolving an ambigous C element.
- * Utility method that can be called by subclassers.
- */
- protected IMatch selectCElement(List elements, Shell shell, String title, String message) {
-
- int nResults= elements.size();
-
- if (nResults == 0)
- return null;
-
- if (nResults == 1)
- return (IMatch) elements.get(0);
-
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new CSearchResultLabelProvider(), false, false);
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.setElements(elements);
-
- if (dialog.open() == Window.OK) {
- Object[] selection= dialog.getResult();
- if (selection != null && selection.length > 0) {
- nResults= selection.length;
- for (int i= 0; i < nResults; i++) {
- Object current= selection[i];
- if (current instanceof IMatch)
- return (IMatch) current;
- }
- }
- }
- return null;
- }
-
-
- public String getSelection(IDocument doc, int fPos){
- int pos= fPos;
- char c;
- int fStartPos =0, fEndPos=0;
- String selectedWord=null;
-
- try{
- while (pos >= 0) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- --pos;
- }
- fStartPos= pos + 1;
-
- pos= fPos;
- int length= doc.getLength();
- while (pos < length) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- ++pos;
- }
- fEndPos= pos;
- selectedWord = doc.get(fStartPos, (fEndPos - fStartPos));
- }
- catch(BadLocationException e){
- }
-
- return selectedWord;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
deleted file mode 100644
index c4dd2af9d3d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.ui.CUIPlugin;
-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.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-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.jface.action.Action;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.PlatformUI;
-
-
-public class OpenIncludeAction extends Action {
-
-
- private static final String PREFIX= "OpenIncludeAction.";
-
- private static final String DIALOG_TITLE= PREFIX + "dialog.title";
- private static final String DIALOG_MESSAGE= PREFIX + "dialog.message";
-
- private ISelectionProvider fSelectionProvider;
-
-
- public OpenIncludeAction(ISelectionProvider provider) {
- super(CUIPlugin.getResourceString(PREFIX + "label"));
- setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
- setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
-
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
-
- fSelectionProvider= provider;
- }
-
- public void run() {
- ICElement include= getIncludeStatement(fSelectionProvider.getSelection());
- if (include == null) {
- return;
- }
-
- try {
- IResource res = include.getUnderlyingResource();
- ArrayList filesFound= new ArrayList(4);
- if (res != null) {
- IProject proj = res.getProject();
- String includeName = include.getElementName();
- // Search in the scannerInfo information
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(proj);
- if (provider != null) {
- IScannerInfo info = provider.getScannerInformation(res);
- // XXXX this should fall back to project by itself
- if (info == null) {
- info = provider.getScannerInformation(proj);
- }
- if (info != null) {
- String[] includePaths = info.getIncludePaths();
- findFile(includePaths, includeName, filesFound);
- }
- if (filesFound.size() == 0) {
- // Fall back and search the project
- findFile(proj, new Path(includeName), filesFound);
- }
- }
- }
- IPath fileToOpen;
- int nElementsFound= filesFound.size();
- if (nElementsFound == 0) {
- fileToOpen= null;
- } else if (nElementsFound == 1) {
- fileToOpen= (IPath) filesFound.get(0);
- } else {
- fileToOpen= chooseFile(filesFound);
- }
-
- if (fileToOpen != null) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(fileToOpen);
- if (file != null) {
- EditorUtility.openInEditor(file);
- } else {
- FileStorage storage = new FileStorage(null, fileToOpen);
- EditorUtility.openInEditor(storage);
- }
- }
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- }
- }
-
- private void findFile(String[] includePaths, String name, ArrayList list) throws CoreException {
- for (int i = 0; i < includePaths.length; i++) {
- IPath path = new Path(includePaths[i] + "/" + name);
- File file = path.toFile();
- if (file.exists()) {
- list.add(path);
- }
- }
- }
-
- /**
- * Recuse in the project.
- * @param parent
- * @param name
- * @param list
- * @throws CoreException
- */
- private void findFile(IContainer parent, final IPath name, final ArrayList list) throws CoreException {
- parent.accept(new IResourceProxyVisitor() {
-
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase(name.lastSegment())) {
- list.add(proxy.requestResource().getLocation());
- return false;
- }
- return true;
- }
- }, 0);
- }
-
-
- private IPath chooseFile(ArrayList filesFound) {
- ILabelProvider renderer= new LabelProvider() {
- public String getText(Object element) {
- if (element instanceof IPath) {
- IPath file= (IPath)element;
- return file.lastSegment() + " - " + file.toString();
- }
- return super.getText(element);
- }
- };
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(CUIPlugin.getDefault().getActiveWorkbenchShell(), renderer, false, false);
- dialog.setTitle(CUIPlugin.getResourceString(DIALOG_TITLE));
- dialog.setMessage(CUIPlugin.getResourceString(DIALOG_MESSAGE));
- dialog.setElements(filesFound);
-
- if (dialog.open() == Window.OK) {
- return (IPath) dialog.getSelectedElement();
- }
- return null;
- }
-
-
- private static ICElement getIncludeStatement(ISelection sel) {
- if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List list= ((IStructuredSelection)sel).toList();
- if (list.size() == 1) {
- Object element= list.get(0);
- if (element instanceof ICElement && ((ICElement)element).getElementType() == ICElement.C_INCLUDE) {
- return (ICElement)element;
- }
- }
- }
- return null;
- }
-
- public static boolean canActionBeAdded(ISelection selection) {
- ICElement include = getIncludeStatement(selection);
- if (include != null) {
- IResource res = include.getUnderlyingResource();
- if (res != null) {
- return true;
- }
- }
- return false;
- }
-
-
- public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
- if (descriptor != null) {
- return descriptor.getId();
- } else {
- return registry.getDefaultEditor().getId();
- }
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
deleted file mode 100644
index 1f9642a6ac0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Iterator;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-
-/**
- * Filters problems based on their types.
- */
-public class ProblemAnnotationIterator implements Iterator {
-
- private Iterator fIterator;
- private IProblemAnnotation fNext;
-
- public ProblemAnnotationIterator(IAnnotationModel model) {
- fIterator= model.getAnnotationIterator();
- skip();
- }
-
- private void skip() {
- while (fIterator.hasNext()) {
- Object next= fIterator.next();
- if (next instanceof IProblemAnnotation) {
- fNext= (IProblemAnnotation) next;
- return;
- }
- }
- fNext= null;
- }
-
- /*
- * @see Iterator#hasNext()
- */
- public boolean hasNext() {
- return fNext != null;
- }
-
- /*
- * @see Iterator#next()
- */
- public Object next() {
- try {
- return fNext;
- } finally {
- skip();
- }
- }
-
- /*
- * @see Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java
deleted file mode 100644
index 215199e9d54..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Created on Aug 12, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.cdt.internal.ui.editor;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * @author bgheorgh
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class SearchDialogAction extends Action {
- private static final String PREFIX= "SearchDialogAction.";
- private static final String C_SEARCH_PAGE_ID= "org.eclipse.cdt.ui.CSearchPage";
-
- private ISelectionProvider fSelectionProvider;
- private ITextEditor fEditor;
- private IWorkbenchWindow fWorkbenchWindow;
-
- public SearchDialogAction(ISelectionProvider provider, CEditor editor) {
- super(CUIPlugin.getResourceString(PREFIX + "label"));
- setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
- setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
-
- if(provider instanceof CContentOutlinePage) {
- setImageDescriptor( CPluginImages.DESC_OBJS_CSEARCH );
- }
-
- fSelectionProvider= provider;
- fEditor = editor;
- }
-
- public SearchDialogAction(ISelectionProvider provider, IWorkbenchWindow window) {
-
- super(CUIPlugin.getResourceString(PREFIX + "label"));
- setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
- setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
-
- if(provider instanceof CContentOutlinePage) {
- setImageDescriptor( CPluginImages.DESC_OBJS_CSEARCH );
- }
-
- fSelectionProvider= provider;
- fWorkbenchWindow = window;
- }
-
- public void run() {
- String search_name;
-
- ISelection selection= fSelectionProvider.getSelection();
- if(selection instanceof ITextSelection) {
- search_name = ((ITextSelection)selection).getText();
- if(search_name.length() == 0) return;
- } else {
- ICElement element= getElement(selection);
- if (element == null) {
- return;
- }
- search_name = element.getElementName();
- }
-
- if (fEditor != null){
- SearchUI.openSearchDialog(fEditor.getEditorSite().getWorkbenchWindow(),C_SEARCH_PAGE_ID);
- }
- else if (fWorkbenchWindow != null){
- SearchUI.openSearchDialog(fWorkbenchWindow,C_SEARCH_PAGE_ID);
- }
-// // @@@ we rely on the internal functions of the Search plugin, since
-// // none of these are actually exported. This is probably going to change
-// // with 2.0.
-// TextSearchResultCollector col = new TextSearchResultCollector();
-// try {
-// //TextSearchPage
-// //ProgressMonitor monitor = new ProgressMonitor();
-// //col.setProgressMonitor(monitor)
-// SearchUI.activateSearchResultView();
-// //col.aboutToStart();
-//
-// // We now have the element, start a search on the string
-// //TextSearchEngine engine = new TextSearchEngine();
-// TextSearchScope scope= TextSearchScope.newWorkspaceScope();
-// // Add the extensions from the C editor definition for now
-// // FIXME: For C/C++ not all files rely on extension to be C++ for <cstring>
-// String[] cexts = CoreModel.getDefault().getTranslationUnitExtensions();
-// for (int i = 0; i < cexts.length; i++) {
-// scope.addExtension("*." + cexts[i]);
-// }
-//// scope.addExtension("*.c");
-//// scope.addExtension("*.h");
-//// scope.addExtension("*.cc");
-//// scope.addExtension("*.hh");
-//
-// TextSearchOperation op= new TextSearchOperation(
-// CUIPlugin.getWorkspace(),
-// search_name,
-// "",
-// scope,
-// col);
-//
-//
-// //engine.search(CUIPlugin.getWorkspace(), element.getName(),
-// // null, scope, col);
-// IRunnableContext context= null;
-// //context= getContainer().getRunnableContext();
-//
-// Shell shell= new Shell(); // getShell();
-// if (context == null)
-// context= new ProgressMonitorDialog(shell);
-//
-//
-// try {
-// context.run(true, true, op);
-// } catch (InvocationTargetException ex) {
-// ExceptionHandler.handle(ex, "Error","Error"); //$NON-NLS-2$ //$NON-NLS-1$
-// } catch (InterruptedException e) {
-// }
-// } catch (Exception e) {}
-//
- }
-
-
- private static ICElement getElement(ISelection sel) {
- if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List list= ((IStructuredSelection)sel).toList();
- if (list.size() == 1) {
- Object element= list.get(0);
- if (element instanceof ICElement) {
- return (ICElement)element;
- }
- }
- }
- return null;
- }
-
- public static boolean canActionBeAdded(ISelection selection) {
- if(selection instanceof ITextSelection) {
- return (((ITextSelection)selection).getLength() > 0);
- } else {
- return getElement(selection) != null;
- }
- }
-
-
- public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
- if (descriptor != null) {
- return descriptor.getId();
- } else {
- //getDefaultEditor is deprecated, The system external editor is the default editor
- return IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
-
- }
- }
- return null;
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SharedTextColors.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SharedTextColors.java
deleted file mode 100644
index 6a1925a5b2a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SharedTextColors.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.editor;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.source.ISharedTextColors;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-/*
- * @see org.eclipse.jface.text.source.ISharedTextColors
- * @since 2.1
- */
-public class SharedTextColors implements ISharedTextColors {
-
- /** The display table. */
- private Map fDisplayTable;
-
- /** Creates an returns a shared color manager. */
- public SharedTextColors() {
- super();
- }
-
- /*
- * @see ISharedTextColors#getColor(RGB)
- */
- public Color getColor(RGB rgb) {
- if (rgb == null)
- return null;
-
- if (fDisplayTable == null)
- fDisplayTable= new HashMap(2);
-
- Display display= Display.getCurrent();
-
- Map colorTable= (Map) fDisplayTable.get(display);
- if (colorTable == null) {
- colorTable= new HashMap(10);
- fDisplayTable.put(display, colorTable);
- }
-
- Color color= (Color) colorTable.get(rgb);
- if (color == null) {
- color= new Color(display, rgb);
- colorTable.put(rgb, color);
- }
-
- return color;
- }
-
- /*
- * @see ISharedTextColors#dispose()
- */
- public void dispose() {
- if (fDisplayTable != null) {
- Iterator j= fDisplayTable.values().iterator();
- while (j.hasNext()) {
- Iterator i= ((Map) j.next()).values().iterator();
- while (i.hasNext())
- ((Color) i.next()).dispose();
- }
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
deleted file mode 100644
index 352d3e923ce..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.editor;
-
-
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-
-/**
- * A toolbar action which toggles the presentation model of the
- * connected text editor. The editor shows either the highlight range
- * only or always the whole document.
- */
-public class TogglePresentationAction extends TextEditorAction implements IPropertyChangeListener {
-
- private IPreferenceStore fStore;
-
- /**
- * Constructs and updates the action.
- */
- public TogglePresentationAction() {
- super(CEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SEGMENT_EDIT);
- setToolTipText(CEditorMessages.getString("TogglePresentation.tooltip")); //$NON-NLS-1$
- setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION);
- WorkbenchHelp.setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION);
- update();
- }
-
- /*
- * @see IAction#actionPerformed
- */
- public void run() {
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- IRegion remembered= editor.getHighlightRange();
- editor.resetHighlightRange();
-
- boolean showAll= !editor.showsHighlightRangeOnly();
- setChecked(showAll);
-
- editor.showHighlightRangeOnly(showAll);
- if (remembered != null)
- editor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true);
-
- fStore.removePropertyChangeListener(this);
- fStore.setValue(PreferenceConstants.EDITOR_SHOW_SEGMENTS, showAll);
- fStore.addPropertyChangeListener(this);
- }
-
- /*
- * @see TextEditorAction#update
- */
- public void update() {
- ITextEditor editor= getTextEditor();
- boolean checked= (editor != null && editor.showsHighlightRangeOnly());
- setChecked(checked);
- setEnabled(editor != null);
- }
-
- /*
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
-
- super.setEditor(editor);
-
- if (editor != null) {
-
- if (fStore == null) {
- fStore= CUIPlugin.getDefault().getPreferenceStore();
- fStore.addPropertyChangeListener(this);
- }
- synchronizeWithPreference(editor);
-
- } else if (fStore != null) {
- fStore.removePropertyChangeListener(this);
- fStore= null;
- }
-
- update();
- }
-
- /**
- * Synchronizes the appearance of the editor with what the preference store tells him.
- */
- private void synchronizeWithPreference(ITextEditor editor) {
-
- if (editor == null)
- return;
-
- boolean showSegments= fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
- setChecked(showSegments);
-
- if (editor.showsHighlightRangeOnly() != showSegments) {
- IRegion remembered= editor.getHighlightRange();
- editor.resetHighlightRange();
- editor.showHighlightRangeOnly(showSegments);
- if (remembered != null)
- editor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true);
- }
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_SHOW_SEGMENTS))
- synchronizeWithPreference(getTextEditor());
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
deleted file mode 100644
index 177b1687b36..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.editor;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.ui.IEditorInput;
-
-
-/**
- * This working copy manager works together with a given compilation unit document provider and
- * additionally offers to "overwrite" the working copy provided by this document provider.
- */
-public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension {
-
- private CDocumentProvider fDocumentProvider;
- private Map fMap;
- private boolean fIsShuttingDown;
-
- /**
- * Creates a new working copy manager that co-operates with the given
- * compilation unit document provider.
- *
- * @param provider the provider
- */
- public WorkingCopyManager(CDocumentProvider provider) {
- Assert.isNotNull(provider);
- fDocumentProvider= provider;
- }
-
- /*
- * @see org.eclipse.cdt.ui.IWorkingCopyManager#connect(org.eclipse.ui.IEditorInput)
- */
- public void connect(IEditorInput input) throws CoreException {
- fDocumentProvider.connect(input);
- }
-
- /*
- * @see org.eclipse.cdt.ui.IWorkingCopyManager#disconnect(org.eclipse.ui.IEditorInput)
- */
- public void disconnect(IEditorInput input) {
- fDocumentProvider.disconnect(input);
- }
-
- /*
- * @see org.eclipse.cdt.ui.IWorkingCopyManager#shutdown()
- */
- public void shutdown() {
- if (!fIsShuttingDown) {
- fIsShuttingDown= true;
- try {
- if (fMap != null) {
- fMap.clear();
- fMap= null;
- }
- fDocumentProvider.shutdown();
- } finally {
- fIsShuttingDown= false;
- }
- }
- }
-
- /*
- * @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
- */
- public IWorkingCopy getWorkingCopy(IEditorInput input) {
- IWorkingCopy unit= fMap == null ? null : (IWorkingCopy) fMap.get(input);
- return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit)
- */
- public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
- if (fDocumentProvider.isConnected(input)) {
- if (fMap == null)
- fMap= new HashMap();
- fMap.put(input, workingCopy);
- }
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#removeWorkingCopy(org.eclipse.ui.IEditorInput)
- */
- public void removeWorkingCopy(IEditorInput input) {
- fMap.remove(input);
- if (fMap.isEmpty())
- fMap= null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
deleted file mode 100644
index 24525b976cf..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.text.AbstractCScanner;
-import org.eclipse.cdt.internal.ui.text.ICColorConstants;
-import org.eclipse.cdt.internal.ui.text.IColorManager;
-import org.eclipse.cdt.internal.ui.text.util.CWhitespaceDetector;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.EndOfLineRule;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.SingleLineRule;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WhitespaceRule;
-import org.eclipse.jface.text.rules.WordPatternRule;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * A C code scanner.
- */
-public final class AsmCodeScanner extends AbstractCScanner {
-
- private static String[] fgKeywords= {
- ".set", ".section",
- ".global",".file",
- ".extern", ".macro", ".endm",
- ".if", ".ifdef", ".ifndef", ".else", ".endif",
- ".include", ".globl",
- ".text",".data", ".rodata", ".common", ".debug", ".ctor", ".dtor",
- ".ascii", ".asciz", ".byte", ".long", ".size", ".align", ".type"
- };
-
-
- private static String[] fgTypes= { "char", "double", "float", "int", "long", "short", "signed", "unsigned", "void"};
-
- private static String[] fgTokenProperties= {
- ICColorConstants.C_KEYWORD,
- ICColorConstants.C_TYPE,
- ICColorConstants.C_STRING,
- ICColorConstants.C_SINGLE_LINE_COMMENT,
- ICColorConstants.C_DEFAULT
- };
-
- /**
- * Creates a C code scanner
- */
- public AsmCodeScanner(IColorManager manager, IPreferenceStore store) {
- super(manager, store);
- initialize();
- }
-
- /*
- * @see AbstractCScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fgTokenProperties;
- }
-
- /*
- * @see AbstractCScanner#createRules()
- */
- protected List createRules() {
-
- List rules= new ArrayList();
-
- // Add rule for strings
- Token token= getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
-
- // Add rule for single line comments.
- rules.add(new EndOfLineRule("#", token));
-
- token= getToken(ICColorConstants.C_STRING);
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("'", "'", token, '\\'));
- //rules.add(new SingleLineRule("\"", "\"", token, '\\'));
-
- Token other= getToken(ICColorConstants.C_DEFAULT);
-
- // Add generic whitespace rule.
- rules.add(new WhitespaceRule(new CWhitespaceDetector()));
-
- // Add word rule for labels
- WordRule labelRule = new WordRule(new AsmWordDetector(false), other) {
- private StringBuffer fBuffer= new StringBuffer();
- /*
- * @see IRule#evaluate
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWordStart((char) c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
-
- fBuffer.setLength(0);
- do {
- fBuffer.append((char) c);
- c= scanner.read();
- } while (fDetector.isWordPart((char) c));
- if(c != ':') {
- unreadBuffer(scanner);
- return fDefaultToken;
- } else {
- fBuffer.append((char) c);
- IToken token= (IToken) fWords.get(":");
- if (token != null)
- return token;
- }
-
- return fDefaultToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
- /**
- * Adds a word and the token to be returned if it is detected.
- *
- * @param word the word this rule will search for, may not be <code>null</code>
- * @param token the token to be returned if the word has been found, may not be <code>null</code>
- */
- public void addWord(String word, IToken token) {
-
- fWords.put(word, token);
- }
- /**
- * Returns the characters in the buffer to the scanner.
- *
- * @param scanner the scanner to be used
- */
- protected void unreadBuffer(ICharacterScanner scanner) {
- for (int i= fBuffer.length() - 1; i >= 0; i--)
- scanner.unread();
- }
- };
-
- token= getToken(ICColorConstants.C_TYPE);
- labelRule.addWord(":", token);
- //wordRule.setColumnConstraint(0);
- rules.add(labelRule);
-
- // Add word rule for keywords and types
- WordRule wordRule= new WordRule(new AsmWordDetector('.'), other);
- for (int i=0; i<fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], token);
- for (int i=0; i<fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], token);
- rules.add(wordRule);
-
- token= getToken(ICColorConstants.C_KEYWORD);
- WordPatternRule regPattern = new WordPatternRule(new AsmWordDetector('%', (char)0), "%", null, token);
- rules.add(regPattern);
-
- setDefaultReturnToken(getToken(ICColorConstants.C_DEFAULT));
- return rules;
- }
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setRules(IRule[] rules) {
-
- super.setRules(rules);
- }
-
- /*
- * @see AbstractCScanner#affectsBehavior(PropertyChangeEvent)
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return super.affectsBehavior(event);
- }
-
- /*
- * @see AbstractCScanner#adaptToPreferenceChange(PropertyChangeEvent)
- */
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
-
- if (super.affectsBehavior(event)) {
- super.adaptToPreferenceChange(event);
- }
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPartitionScanner.java
deleted file mode 100644
index 808439bf0d2..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPartitionScanner.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.text.CPartitionScanner;
-import org.eclipse.cdt.internal.ui.text.ICColorConstants;
-import org.eclipse.jface.text.rules.EndOfLineRule;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IPredicateRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.MultiLineRule;
-import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
-import org.eclipse.jface.text.rules.SingleLineRule;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-
-
-/**
- * This scanner recognizes comments
- */
-public class AsmPartitionScanner extends RuleBasedPartitionScanner {
-
-
- //private final static String SKIP= "__skip";
-
-
- public final static String ASM_MULTILINE_COMMENT= ICColorConstants.C_MULTI_LINE_COMMENT;
- public final static String ASM_SINGLE_LINE_COMMENT= ICColorConstants.C_SINGLE_LINE_COMMENT;
- public final static String ASM_STRING= ICColorConstants.C_STRING;
-
-
- /**
- * Detector for empty comments.
- */
- static class EmptyCommentDetector implements IWordDetector {
-
-
- /**
- * @see IWordDetector#isWordStart
- */
- public boolean isWordStart(char c) {
- return (c == '/');
- }
-
-
- /**
- * @see IWordDetector#isWordPart
- */
- public boolean isWordPart(char c) {
- return (c == '*' || c == '/');
- }
- };
-
- /**
- * Word rule for empty comments.
- */
- static class EmptyCommentRule extends WordRule implements IPredicateRule {
-
- private IToken fSuccessToken;
- /**
- * Constructor for EmptyCommentRule.
- * @param defaultToken
- */
- public EmptyCommentRule(IToken successToken) {
- super(new EmptyCommentDetector());
- fSuccessToken= successToken;
- addWord("/**/", fSuccessToken); //$NON-NLS-1$
- }
-
- /*
- * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- return evaluate(scanner);
- }
-
- /*
- * @see IPredicateRule#getSuccessToken()
- */
- public IToken getSuccessToken() {
- return fSuccessToken;
- }
- };
-
-
- /**
- * Creates the partitioner and sets up the appropriate rules.
- */
- public AsmPartitionScanner() {
- super();
-
- IToken comment= new Token(CPartitionScanner.C_MULTILINE_COMMENT);
- IToken single_comment= new Token(CPartitionScanner.C_SINGLE_LINE_COMMENT);
- IToken string= new Token(CPartitionScanner.C_STRING);
- // IToken skip= new Token(SKIP);
-
-
-
- List rules= new ArrayList();
-
-
- // Minimize the number of rules, since we have duplicate rules
- // in the CCodeScanner...
-
-
- // Add rule for single line comments.
- rules.add(new EndOfLineRule("//", single_comment));
- rules.add(new EndOfLineRule("#", single_comment)); //$NON-NLS-1$
-
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", string, '\\'));
- rules.add(new SingleLineRule("'", "'", string, '\\'));
-
- EmptyCommentRule wordRule= new EmptyCommentRule(comment);
- rules.add(wordRule);
-
-
- // Add rules for multi-line comments.
- rules.add(new MultiLineRule("/*", "*/", comment));
-
-
- IPredicateRule[] result= new IPredicateRule[rules.size()];
- rules.toArray(result);
- setPredicateRules(result);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java
deleted file mode 100644
index 1553b4abf8b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-
-
-public class AsmSourceViewerConfiguration extends SourceViewerConfiguration {
-
-
- private AsmTextEditor fEditor;
- private AsmTextTools fTextTools;
-
- /**
- * Returns the ASM multiline comment scanner for this configuration.
- *
- * @return the ASM multiline comment scanner
- */
- protected RuleBasedScanner getMultilineCommentScanner() {
- return fTextTools.getMultilineCommentScanner();
- }
-
- /**
- * Returns the ASM singleline comment scanner for this configuration.
- *
- * @return the ASM singleline comment scanner
- */
- protected RuleBasedScanner getSinglelineCommentScanner() {
- return fTextTools.getSinglelineCommentScanner();
- }
-
- /**
- * Returns the ASM string scanner for this configuration.
- *
- * @return the ASM string scanner
- */
- protected RuleBasedScanner getStringScanner() {
- return fTextTools.getStringScanner();
- }
-
- /**
- * Constructor for AsmSourceViewerConfiguration
- */
- public AsmSourceViewerConfiguration(AsmTextTools tools, AsmTextEditor editor) {
- super();
- fEditor = editor;
- fTextTools = tools;
- }
-
- /**
- * @see ISourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
- */
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-
-
-
- // CColorManager manager= fTextTools.getColorManager();
- PresentationReconciler reconciler= new PresentationReconciler();
-
-
-
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(fTextTools.getCodeScanner());
- reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
-
-
- dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
- reconciler.setDamager(dr, AsmPartitionScanner.ASM_MULTILINE_COMMENT);
- reconciler.setRepairer(dr, AsmPartitionScanner.ASM_MULTILINE_COMMENT);
-
- dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
- reconciler.setDamager(dr, AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT);
- reconciler.setRepairer(dr, AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT);
-
- dr= new DefaultDamagerRepairer(getStringScanner());
- reconciler.setDamager(dr, AsmPartitionScanner.ASM_STRING);
- reconciler.setRepairer(dr, AsmPartitionScanner.ASM_STRING);
-
-
- return reconciler;
- }
-
- /**
- * @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
- */
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
- AsmPartitionScanner.ASM_MULTILINE_COMMENT,
- AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT,
- AsmPartitionScanner.ASM_STRING };
- }
-
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
deleted file mode 100644
index a8902380226..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-
-import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.SaveAsDialog;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.DefaultRangeIndicator;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.StatusTextEditor;
-
-
-
-
-
-/**
- * Assembly text editor
- */
-public class AsmTextEditor extends StatusTextEditor {
-
- /**
- * Creates a new text editor.
- */
- public AsmTextEditor() {
- super();
- initializeEditor();
- }
- /**
- * Initializes this editor.
- */
- protected void initializeEditor() {
- AsmTextTools textTools= CUIPlugin.getDefault().getAsmTextTools();
- setSourceViewerConfiguration(new AsmSourceViewerConfiguration(textTools, this));
- setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
- setRangeIndicator(new DefaultRangeIndicator());
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- setEditorContextMenuId("#ASMEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#ASMEditorRulerContext"); //$NON-NLS-1$
- //setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
-
- }
- /**
- * The <code>TextEditor</code> implementation of this
- * <code>IEditorPart</code> method returns <code>true</code>.
- */
- public boolean isSaveAsAllowed() {
- return true;
- }
- /**
- * The <code>TextEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method asks the user for the workspace path
- * of a file resource and saves the document there.
- */
- protected void performSaveAs(IProgressMonitor progressMonitor) {
- /*
- * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
- * Changed Behavior to make sure that if called inside a regular save (because
- * of deletion of input element) there is a way to report back to the caller.
- */
-
- Shell shell= getSite().getShell();
-
- SaveAsDialog dialog= new SaveAsDialog(shell);
- dialog.open();
- IPath path= dialog.getResult();
-
- if (path == null) {
- if (progressMonitor != null)
- progressMonitor.setCanceled(true);
- return;
- }
-
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IFile file= workspace.getRoot().getFile(path);
- final IEditorInput newInput= new FileEditorInput(file);
-
- WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
- public void execute(final IProgressMonitor monitor) throws CoreException {
- /*
- * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
- * Changed false to true.
- */
- getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
- }
- };
-
- boolean success= false;
- try {
-
- getDocumentProvider().aboutToChange(newInput);
- new ProgressMonitorDialog(shell).run(false, true, op);
- success= true;
-
- } catch (InterruptedException x) {
- } catch (InvocationTargetException x) {
- // Shared with C editor
- String title= CEditorMessages.getString("CEditor.error.saving.title"); //$NON-NLS-1$
- String msg= MessageFormat.format(CEditorMessages.getString("CEditor.error.saving.message"), new Object[] { x.getTargetException().getMessage() }); //$NON-NLS-1$
- MessageDialog.openError(shell, title, msg);
- } finally {
- getDocumentProvider().changed(newInput);
- if (success)
- setInput(newInput);
- }
-
- if (progressMonitor != null)
- progressMonitor.setCanceled(!success);
- }
-
- /*
- * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
- * Pulled in from 2.0
- */
- protected boolean affectsTextPresentation(PropertyChangeEvent event) {
- // String p= event.getProperty();
-
- boolean affects= false;
- AsmTextTools textTools= CUIPlugin.getDefault().getAsmTextTools();
- affects |= textTools.affectsBehavior(event);
-
- return affects ? affects : super.affectsTextPresentation(event);
- }
-
- /*
- * @see AbstractTextEditor#createActions()
- * @since 2.0
- */
- protected void createActions() {
- super.createActions();
-
- }
-
-
-
- /*
- * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
- * @since 2.0
- */
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_RIGHT);
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_LEFT);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
deleted file mode 100644
index 4f020ccfa07..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.ICColorConstants;
-import org.eclipse.cdt.internal.ui.text.CCommentScanner;
-import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
-import org.eclipse.cdt.internal.ui.text.util.CColorManager;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.jface.text.rules.IPartitionTokenScanner;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * This type shares all scanners and the color manager between
- * its clients.
- */
-public class AsmTextTools {
-
- private class PreferenceListener implements IPropertyChangeListener, Preferences.IPropertyChangeListener {
- public void propertyChange(PropertyChangeEvent event) {
- adaptToPreferenceChange(event);
- }
- public void propertyChange(Preferences.PropertyChangeEvent event) {
- adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue()));
- }
- };
-
- /** The color manager -- use the same as for C code */
- private CColorManager fColorManager;
- /** The Asm source code scanner */
- private AsmCodeScanner fCodeScanner;
- /** The Asm partitions scanner */
- private AsmPartitionScanner fPartitionScanner;
- /** The ASM multiline comment scanner */
- private CCommentScanner fMultilineCommentScanner;
- /** The ASM singleline comment scanner */
- private CCommentScanner fSinglelineCommentScanner;
- /** The ASM string scanner */
- private SingleTokenCScanner fStringScanner;
-
-
- /** The preference store */
- private IPreferenceStore fPreferenceStore;
- /** The core preference store */
- private Preferences fCorePreferenceStore;
- /** The preference change listener */
- private PreferenceListener fPreferenceListener= new PreferenceListener();
-
-
- /**
- * Creates a new Asm text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public AsmTextTools(IPreferenceStore store) {
- this(store, null);
- }
-
- /**
- * Creates a new Asm text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public AsmTextTools(IPreferenceStore store, Preferences coreStore) {
- if(store == null) {
- store = CUIPlugin.getDefault().getPreferenceStore();
- }
-
- fPreferenceStore = store;
- store.addPropertyChangeListener(fPreferenceListener);
-
- fCorePreferenceStore= coreStore;
- if (fCorePreferenceStore != null) {
- fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener);
- }
-
- fColorManager= new CColorManager();
- fCodeScanner= new AsmCodeScanner(fColorManager, store);
- fPartitionScanner= new AsmPartitionScanner();
-
- fMultilineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT);
- fStringScanner= new SingleTokenCScanner(fColorManager, store, ICColorConstants.C_STRING);
- }
-
- /**
- * Creates a new Asm text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public AsmTextTools() {
- this((IPreferenceStore)null);
- }
- /**
- * Disposes all members of this tools collection.
- */
- public void dispose() {
-
- fCodeScanner= null;
- fPartitionScanner= null;
-
- fMultilineCommentScanner= null;
- fSinglelineCommentScanner= null;
- fStringScanner= null;
-
- if (fColorManager != null) {
- fColorManager.dispose();
- fColorManager= null;
- }
-
- if (fPreferenceStore != null) {
- fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
- fPreferenceStore= null;
-
- if (fCorePreferenceStore != null) {
- fCorePreferenceStore.removePropertyChangeListener(fPreferenceListener);
- fCorePreferenceStore= null;
- }
-
- fPreferenceListener= null;
- }
- }
-
- /**
- * Gets the color manager.
- */
- public CColorManager getColorManager() {
- return fColorManager;
- }
-
- /**
- * Gets the code scanner used.
- */
- public RuleBasedScanner getCodeScanner() {
- return fCodeScanner;
- }
-
- /**
- * Gets the partition scanner used.
- */
- public IPartitionTokenScanner getPartitionScanner() {
- return fPartitionScanner;
- }
-
- /**
- * Gets the document provider used.
- */
- public IDocumentPartitioner createDocumentPartitioner() {
-
- String[] types= new String[] {
- AsmPartitionScanner.ASM_MULTILINE_COMMENT,
- AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT,
- AsmPartitionScanner.ASM_STRING
- };
-
- //return new RuleBasedPartitioner(getPartitionScanner(), types);
- return new DefaultPartitioner(getPartitionScanner(), types);
- }
-
- /**
- * Returns a scanner which is configured to scan Java multiline comments.
- *
- * @return a Java multiline comment scanner
- */
- public RuleBasedScanner getMultilineCommentScanner() {
- return fMultilineCommentScanner;
- }
-
- /**
- * Returns a scanner which is configured to scan Java singleline comments.
- *
- * @return a Java singleline comment scanner
- */
- public RuleBasedScanner getSinglelineCommentScanner() {
- return fSinglelineCommentScanner;
- }
-
- /**
- * Returns a scanner which is configured to scan Java strings.
- *
- * @return a Java string scanner
- */
- public RuleBasedScanner getStringScanner() {
- return fStringScanner;
- }
-
-
- /**
- * Determines whether the preference change encoded by the given event
- * changes the behavior of one its contained components.
- *
- * @param event the event to be investigated
- * @return <code>true</code> if event causes a behavioral change
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return fCodeScanner.affectsBehavior(event) ||
- fMultilineCommentScanner.affectsBehavior(event) ||
- fSinglelineCommentScanner.affectsBehavior(event) ||
- fStringScanner.affectsBehavior(event);
- }
-
- /**
- * Adapts the behavior of the contained components to the change
- * encoded in the given event.
- *
- * @param event the event to whch to adapt
- */
- protected void adaptToPreferenceChange(PropertyChangeEvent event) {
- if (fCodeScanner.affectsBehavior(event))
- fCodeScanner.adaptToPreferenceChange(event);
- if (fMultilineCommentScanner.affectsBehavior(event))
- fMultilineCommentScanner.adaptToPreferenceChange(event);
- if (fSinglelineCommentScanner.affectsBehavior(event))
- fSinglelineCommentScanner.adaptToPreferenceChange(event);
- if (fStringScanner.affectsBehavior(event))
- fStringScanner.adaptToPreferenceChange(event);
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
deleted file mode 100644
index 5410d00951b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.eclipse.cdt.internal.ui.editor.asm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.rules.IWordDetector;
-
-
-/**
- * A C aware word detector.
- */
-public class AsmWordDetector implements IWordDetector {
- private char fPrefix = 0;
- private char fExtra = 0;
- private boolean fStrictStart = true;
-
- public AsmWordDetector() {
- }
-
- public AsmWordDetector(boolean strict) {
- fStrictStart = strict;
- }
-
- public AsmWordDetector(char extra) {
- fExtra = extra;
- }
-
- public AsmWordDetector(char prefix, char extra) {
- fPrefix = prefix;
- fExtra = extra;
- }
- /**
- * @see IWordDetector#isWordIdentifierStart
- */
- public boolean isWordStart(char c) {
- if(fPrefix != 0) {
- return (fPrefix == c);
- }
- if(fStrictStart) {
- return (Character.isJavaIdentifierStart(c) || (c == fExtra));
- } else {
- return (Character.isJavaIdentifierPart(c) || (c == fExtra));
- }
- }
-
- /**
- * @see IWordDetector#isWordIdentifierPart
- */
- public boolean isWordPart(char c) {
- return Character.isJavaIdentifierPart(c);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
deleted file mode 100644
index 767bb2d03c0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * (c) Copyright QNX Software System Ltd. 2002.
- * All Rights Reserved.
- */
-package org.eclipse.cdt.internal.ui.preferences;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-public class BuildConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- public static final String PREF_CONSOLE_FONT = "consoleFont";
- private static final String PREF_CLEAR_CONSOLE = "clearConsole";
- private static final String PREF_CONSOLE_ON_TOP = "consoleOnTop";
- private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole";
- public static final String PREF_BUILDCONSOLE_LINES = "buildConsoleLines";
- public static final String PREF_BUILDCONSOLE_LINES_ERROR = "CBasePreferencePage.buildConsole.errorMessage"; //$NON-NLS-1$
-
- private static final String CLEAR_CONSOLE_LABEL= "CBasePreferencePage.clearConsole.label";
- private static final String CONSOLE_ON_TOP_LABEL= "CBasePreferencePage.consoleOnTop.label";
- private static final String AUTO_OPEN_CONSOLE_LABEL= "CBasePreferencePage.autoOpenConsole.label";
- private static final String CONSOLE_FONT_LABEL= "CBasePreferencePage.consoleFont.label";
-
- public BuildConsolePreferencePage() {
- super(GRID);
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- }
-
- protected void createFieldEditors() {
- Composite parent = getFieldEditorParent();
- BooleanFieldEditor clearConsole =
- new BooleanFieldEditor(PREF_CLEAR_CONSOLE, CUIPlugin.getResourceString(CLEAR_CONSOLE_LABEL), parent);
- addField(clearConsole);
-
- BooleanFieldEditor autoOpenConsole =
- new BooleanFieldEditor(PREF_AUTO_OPEN_CONSOLE, CUIPlugin.getResourceString(AUTO_OPEN_CONSOLE_LABEL), parent);
- addField(autoOpenConsole);
- BooleanFieldEditor consoleOnTop =
- new BooleanFieldEditor(PREF_CONSOLE_ON_TOP, CUIPlugin.getResourceString(CONSOLE_ON_TOP_LABEL), parent);
- addField(consoleOnTop);
-
- IntegerFieldEditor buildCount = new IntegerFieldEditor( PREF_BUILDCONSOLE_LINES, "&Build console lines: ", parent );
- buildCount.setErrorMessage(CUIPlugin.getResourceString(PREF_BUILDCONSOLE_LINES_ERROR));
- buildCount.setValidRange( 10, Integer.MAX_VALUE );
- addField( buildCount );
-
- addField(new FontFieldEditor(PREF_CONSOLE_FONT, CUIPlugin.getResourceString(CONSOLE_FONT_LABEL), parent));
- }
-
- /**
- * Returns the current preference setting if the build console should
- * be cleared before each build.
- */
- public static boolean isClearBuildConsole() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CLEAR_CONSOLE);
- }
- public static boolean isAutoOpenConsole() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_AUTO_OPEN_CONSOLE);
- }
-
- public static boolean isConsoleOnTop() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CONSOLE_ON_TOP);
- }
-
- public static int buildConsoleLines() {
- return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_LINES);
- }
-
- public void init(IWorkbench workbench) {
- }
-
- public static void initDefaults(IPreferenceStore prefs) {
- prefs.setDefault(PREF_CLEAR_CONSOLE, true);
- prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, false);
- prefs.setDefault(PREF_CONSOLE_ON_TOP, true);
- prefs.setDefault(PREF_BUILDCONSOLE_LINES, 500);
- Font font = JFaceResources.getTextFont();
- if (font != null) {
- FontData[] data = font.getFontData();
- if (data != null && data.length > 0) {
- PreferenceConverter.setDefault(prefs, PREF_CONSOLE_FONT, data[0]);
- }
- }
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
deleted file mode 100644
index bea282691c3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
+++ /dev/null
@@ -1,1227 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.ICColorConstants;
-import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-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.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
-
-/*
- * The page for setting the editor options.
- */
-public class CEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- protected final String[][] fListModel = new String[][] { { "Multi-line comment", ICColorConstants.C_MULTI_LINE_COMMENT }, {
- "Single-line comment", ICColorConstants.C_SINGLE_LINE_COMMENT }, {
- "Keywords", ICColorConstants.C_KEYWORD }, {
- "Built-in types", ICColorConstants.C_TYPE }, {
- "Strings", ICColorConstants.C_STRING }, {
- "Others", ICColorConstants.C_DEFAULT }, {
- PreferencesMessages.getString("CEditorPreferencePage.cCommentTaskTags"), PreferenceConstants.EDITOR_TASK_TAG_COLOR }
- };
-
- protected final String[][] fAppearanceColorListModel = new String[][] { { "Line number color", ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR }, //$NON-NLS-1$
- {
- "Matching bracket color", CEditor.MATCHING_BRACKETS_COLOR }, //$NON-NLS-1$
- {
- "Current line highlight color", ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR }, //$NON-NLS-1$
- {
- "Print margin color", ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR }, //$NON-NLS-1$
- {
- "Linked position color", CEditor.LINKED_POSITION_COLOR }, //$NON-NLS-1$
- };
-
- protected OverlayPreferenceStore fOverlayStore;
- private CTextTools fCTextTools;
-
- protected Map fColorButtons = new HashMap();
- private SelectionListener fColorButtonListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- ColorEditor editor = (ColorEditor) e.widget.getData();
- PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
- }
- };
-
- protected Map fCheckBoxes = new HashMap();
- private SelectionListener fCheckBoxListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- Button button = (Button) e.widget;
- fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
- protected Map fTextFields = new HashMap();
- private ModifyListener fTextFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text = (Text) e.widget;
- fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
- }
- };
-
- private WorkbenchChainedTextFontFieldEditor fFontEditor;
- protected List fList;
- protected ColorEditor fForegroundColorEditor;
- protected ColorEditor fBackgroundColorEditor;
- private Button fBackgroundDefaultRadioButton;
- protected Button fBackgroundCustomRadioButton;
- protected Button fBackgroundColorButton;
- protected Button fBoldCheckBox;
- protected SourceViewer fPreviewViewer;
-
- protected List fAppearanceColorList;
- protected ColorEditor fAppearanceForegroundColorEditor;
-
- private final String[][] fAnnotationColorListModel;
- private ColorEditor fAnnotationForegroundColorEditor;
- private List fAnnotationList;
- private Button fShowInOverviewRulerCheckBox;
- private Button fShowInTextCheckBox;
-
- public CEditorPreferencePage() {
- setDescription(CUIPlugin.getResourceString("CEditorPreferencePage.description"));
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
- fAnnotationColorListModel = createAnnotationTypeListModel(preferences);
- fOverlayStore = createOverlayStore(preferences);
- }
-
- private OverlayPreferenceStore createOverlayStore(MarkerAnnotationPreferences preferences) {
- ArrayList overlayKeys = new ArrayList();
- Iterator e = preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info = (AnnotationPreference) e.next();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
- overlayKeys.add(
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
- }
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,CEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_MULTI_LINE_COMMENT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_MULTI_LINE_COMMENT + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_SINGLE_LINE_COMMENT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_SINGLE_LINE_COMMENT + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_KEYWORD));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_KEYWORD + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_TYPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_TYPE + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_STRING));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_STRING + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_DEFAULT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_DEFAULT + "_bold"));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SPACES_FOR_TABS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.LINKED_POSITION_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
- //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER));
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return new OverlayPreferenceStore(getPreferenceStore(), keys);
- }
-
- public static void initDefaults(IPreferenceStore store) {
-
- Color color;
- Display display = Display.getDefault();
-
- MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
- Iterator e = preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info = (AnnotationPreference) e.next();
- store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
- store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
- PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
- }
- store.setDefault(CEditor.MATCHING_BRACKETS, true);
- color = display.getSystemColor(SWT.COLOR_GRAY);
- PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, color.getRGB());
-
- store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
- PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224));
-
- store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, true);
- store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
- PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180, 185));
-
- WorkbenchChainedTextFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT);
-
- color = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- PreferenceConverter.setDefault(store, CEditor.PREFERENCE_COLOR_FOREGROUND, color.getRGB());
- store.setDefault(CEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
-
- color = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- PreferenceConverter.setDefault(store, CEditor.PREFERENCE_COLOR_BACKGROUND, color.getRGB());
- store.setDefault(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
-
- store.setDefault(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 4);
-
- store.setDefault(CEditor.SPACES_FOR_TABS, false);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95));
- store.setDefault(ICColorConstants.C_MULTI_LINE_COMMENT + "_bold", false);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_SINGLE_LINE_COMMENT, new RGB(63, 125, 95));
- store.setDefault(ICColorConstants.C_SINGLE_LINE_COMMENT + "_bold", false);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_KEYWORD, new RGB(127, 0, 85));
- store.setDefault(ICColorConstants.C_KEYWORD + "_bold", true);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_TYPE, new RGB(127, 0, 85));
- store.setDefault(ICColorConstants.C_TYPE + "_bold", true);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_STRING, new RGB(42, 0, 255));
- store.setDefault(ICColorConstants.C_STRING + "_bold", false);
-
- PreferenceConverter.setDefault(store, ICColorConstants.C_DEFAULT, new RGB(0, 0, 0));
- store.setDefault(ICColorConstants.C_DEFAULT + "_bold", false);
-
- PreferenceConverter.setDefault(store, CEditor.LINKED_POSITION_COLOR, new RGB(0, 200, 100));
-
- store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
- PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0));
-
- store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
-
- store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
- store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
- store.setDefault(ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE, false);
-
- store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
- store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
- store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
- store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
-
- store.setDefault(ContentAssistPreference.AUTOINSERT, true);
- PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
- PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
- PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
- PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
- //store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C, ".,");
- //store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, "@");
- //store.setDefault(ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, true);
- //store.setDefault(ContentAssistPreference.CASE_SENSITIVITY, false);
- store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
- store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
-
- }
-
- /*
- * @see IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- }
-
- protected void handleListSelection() {
- int i = fList.getSelectionIndex();
- String key = fListModel[i][1];
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- fForegroundColorEditor.setColorValue(rgb);
- fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + "_bold"));
- }
-
- private Control createAnnotationsPage(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
-
- Label label = new Label(composite, SWT.LEFT);
- label.setText("Annotation Presentation Options");
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- label.setLayoutData(gd);
-
- Composite editorComposite = new Composite(composite, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- editorComposite.setLayout(layout);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan = 2;
- editorComposite.setLayoutData(gd);
-
- fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint = convertHeightInCharsToPixels(8);
- fAnnotationList.setLayoutData(gd);
-
- Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- optionsComposite.setLayout(layout);
- optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
- fShowInTextCheckBox.setText("Show In Text");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- gd.horizontalSpan = 2;
- fShowInTextCheckBox.setLayoutData(gd);
-
- fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
- fShowInOverviewRulerCheckBox.setText("Show In Overview Ruler");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- gd.horizontalSpan = 2;
- fShowInOverviewRulerCheckBox.setLayoutData(gd);
-
- label = new Label(optionsComposite, SWT.LEFT);
- label.setText("Annotations Color");
- gd = new GridData();
- gd.horizontalAlignment = GridData.BEGINNING;
- label.setLayoutData(gd);
-
- fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
- Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- fAnnotationList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- handleAnnotationListSelection();
- }
- });
-
- fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i = fAnnotationList.getSelectionIndex();
- String key = fAnnotationColorListModel[i][2];
- fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
- }
- });
-
- fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i = fAnnotationList.getSelectionIndex();
- String key = fAnnotationColorListModel[i][3];
- fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
- }
- });
-
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i = fAnnotationList.getSelectionIndex();
- String key = fAnnotationColorListModel[i][1];
- PreferenceConverter.setValue(fOverlayStore, key, fAnnotationForegroundColorEditor.getColorValue());
- }
- });
-
- WorkbenchHelp.setHelp(composite, ICHelpContextIds.C_EDITOR_ANNOTATIONS_PREF_PAGE);
- return composite;
- }
-
- private void handleAnnotationListSelection() {
- int i = fAnnotationList.getSelectionIndex();
-
- String key = fAnnotationColorListModel[i][1];
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- fAnnotationForegroundColorEditor.setColorValue(rgb);
-
- key = fAnnotationColorListModel[i][2];
- fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
-
- key = fAnnotationColorListModel[i][3];
- fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
- }
-
- private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
- ArrayList listModelItems = new ArrayList();
- Iterator e = preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info = (AnnotationPreference) e.next();
- listModelItems.add(
- new String[] {
- info.getPreferenceLabel(),
- info.getColorPreferenceKey(),
- info.getTextPreferenceKey(),
- info.getOverviewRulerPreferenceKey()});
- }
- String[][] items = new String[listModelItems.size()][];
- listModelItems.toArray(items);
- return items;
- }
-
- private Control createColorPage(Composite parent) {
-
- Composite colorComposite = new Composite(parent, SWT.NULL);
- colorComposite.setLayout(new GridLayout());
-
- Composite backgroundComposite = new Composite(colorComposite, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- backgroundComposite.setLayout(layout);
-
- Label label = new Label(backgroundComposite, SWT.NULL);
- label.setText("Bac&kground Color:");
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- label.setLayoutData(gd);
-
- SelectionListener backgroundSelectionListener = new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean custom = fBackgroundCustomRadioButton.getSelection();
- fBackgroundColorButton.setEnabled(custom);
- fOverlayStore.setValue(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, !custom);
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
-
- fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
- fBackgroundDefaultRadioButton.setText("S&ystem Default");
- gd = new GridData();
- gd.horizontalSpan = 2;
- fBackgroundDefaultRadioButton.setLayoutData(gd);
- fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
-
- fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
- fBackgroundCustomRadioButton.setText("C&ustom");
- fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
-
- fBackgroundColorEditor = new ColorEditor(backgroundComposite);
- fBackgroundColorButton = fBackgroundColorEditor.getButton();
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- fBackgroundColorButton.setLayoutData(gd);
-
- label = new Label(colorComposite, SWT.LEFT);
- label.setText("Fo&reground:");
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite editorComposite = new Composite(colorComposite, SWT.NULL);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- editorComposite.setLayout(layout);
- gd = new GridData(GridData.FILL_BOTH);
- editorComposite.setLayoutData(gd);
-
- fList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL);
- gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = convertHeightInCharsToPixels(5);
- fList.setLayoutData(gd);
-
- Composite stylesComposite = new Composite(editorComposite, SWT.NULL);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- stylesComposite.setLayout(layout);
- stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- label = new Label(stylesComposite, SWT.LEFT);
- label.setText("C&olor:");
- gd = new GridData();
- gd.horizontalAlignment = GridData.BEGINNING;
- label.setLayoutData(gd);
-
- fForegroundColorEditor = new ColorEditor(stylesComposite);
- Button foregroundColorButton = fForegroundColorEditor.getButton();
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- label = new Label(stylesComposite, SWT.LEFT);
- label.setText("&Bold:");
- gd = new GridData();
- gd.horizontalAlignment = GridData.BEGINNING;
- label.setLayoutData(gd);
-
- fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- fBoldCheckBox.setLayoutData(gd);
-
- label = new Label(colorComposite, SWT.LEFT);
- label.setText("Preview:");
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control previewer = createPreviewer(colorComposite);
- gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = convertWidthInCharsToPixels(80);
- gd.heightHint = convertHeightInCharsToPixels(15);
- previewer.setLayoutData(gd);
-
- fList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- handleListSelection();
- }
- });
-
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- int i = fList.getSelectionIndex();
- String key = fListModel[i][1];
-
- PreferenceConverter.setValue(fOverlayStore, key, fForegroundColorEditor.getColorValue());
- }
- });
-
- fBackgroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- PreferenceConverter.setValue(
- fOverlayStore,
- CEditor.PREFERENCE_COLOR_BACKGROUND,
- fBackgroundColorEditor.getColorValue());
- }
- });
-
- fBoldCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- int i = fList.getSelectionIndex();
- String key = fListModel[i][1];
- fOverlayStore.setValue(key + "_bold", fBoldCheckBox.getSelection());
- }
- });
-
- WorkbenchHelp.setHelp(colorComposite, ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE);
- return colorComposite;
- }
-
- private Control createPreviewer(Composite parent) {
-
- fCTextTools = new CTextTools(fOverlayStore);
-
- fPreviewViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL);
- fPreviewViewer.configure(new CSourceViewerConfiguration(fCTextTools, null));
- fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
- fPreviewViewer.setEditable(false);
-
- initializeViewerColors(fPreviewViewer);
-
- String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt");
- IDocument document = new Document(content);
- IDocumentPartitioner partitioner = fCTextTools.createDocumentPartitioner();
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
-
- fPreviewViewer.setDocument(document);
-
- fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- String p = event.getProperty();
- if (p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND)
- || p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
- initializeViewerColors(fPreviewViewer);
- }
-
- fPreviewViewer.getDocument().set(fPreviewViewer.getDocument().get());
- //fPreviewViewer.refresh();
- }
- });
-
- return fPreviewViewer.getControl();
- }
-
- private Color fBackgroundColor;
-
- /**
- * Initializes the given viewer's colors.
- *
- * @param viewer the viewer to be initialized
- */
- protected void initializeViewerColors(ISourceViewer viewer) {
-
- IPreferenceStore store = fOverlayStore;
- if (store != null) {
-
- StyledText styledText = viewer.getTextWidget();
-
- // ---------- background color ----------------------
- Color color =
- store.getBoolean(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, CEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
- styledText.setBackground(color);
-
- if (fBackgroundColor != null)
- fBackgroundColor.dispose();
-
- fBackgroundColor = color;
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
-
- RGB rgb = null;
-
- if (store.contains(key)) {
-
- if (store.isDefault(key))
- rgb = PreferenceConverter.getDefaultColor(store, key);
- else
- rgb = PreferenceConverter.getColor(store, key);
-
- if (rgb != null)
- return new Color(display, rgb);
- }
-
- return null;
- }
-
- // sets enabled flag for a control and all its sub-tree
- protected static void setEnabled(Control control, boolean enable) {
- control.setEnabled(enable);
- if (control instanceof Composite) {
- Composite composite = (Composite) control;
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++)
- setEnabled(children[i], enable);
- }
- }
-
- private ArrayList fNumberFields = new ArrayList();
- private ModifyListener fNumberFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- numberFieldChanged((Text) e.widget);
- }
- };
-
- private Button fBracketHighlightButton;
- private Button fLineHighlightButton;
-
- protected void handleAppearanceColorListSelection() {
- int i = fAppearanceColorList.getSelectionIndex();
- String key = fAppearanceColorListModel[i][1];
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- fAppearanceForegroundColorEditor.setColorValue(rgb);
- }
- private Control createBehaviorPage(Composite parent) {
-
- Composite behaviorComposite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- behaviorComposite.setLayout(layout);
-
- String label = "Text &font:";
- addTextFontEditor(behaviorComposite, label, JFaceResources.TEXT_FONT);
-
- label = "Displayed &tab width:";
- addTextField(behaviorComposite, label, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0, true);
-
- label = "Print margin col&umn:";
- addTextField(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 4, 0, true);
-
- label = "Insert &space for tabs";
- addCheckBox(behaviorComposite, label, CEditor.SPACES_FOR_TABS, 0);
-
- label = "Highlight &matching brackets";
- fBracketHighlightButton = addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0);
-
- label = "Show line numbers"; //$NON-NLS-1$
- addCheckBox(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
-
- label = "Highlight &current line";
- fLineHighlightButton = addCheckBox(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
-
- label = "Show overview ruler"; //$NON-NLS-1$
- addCheckBox(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
-
- label = "Show print &margin";
- addCheckBox(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
-
- Label l = new Label(behaviorComposite, SWT.LEFT);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- gd.heightHint = convertHeightInCharsToPixels(1) / 2;
- l.setLayoutData(gd);
-
- l = new Label(behaviorComposite, SWT.LEFT);
- l.setText("Appearance color options"); //$NON-NLS-1$
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- l.setLayoutData(gd);
-
- Composite editorComposite = new Composite(behaviorComposite, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- editorComposite.setLayout(layout);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan = 2;
- editorComposite.setLayoutData(gd);
-
- fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = convertHeightInCharsToPixels(5);
- fAppearanceColorList.setLayoutData(gd);
-
- Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- stylesComposite.setLayout(layout);
- stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- l = new Label(stylesComposite, SWT.LEFT);
- l.setText("Color:"); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.BEGINNING;
- l.setLayoutData(gd);
-
- fAppearanceForegroundColorEditor = new ColorEditor(stylesComposite);
- Button foregroundColorButton = fAppearanceForegroundColorEditor.getButton();
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- fAppearanceColorList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- handleAppearanceColorListSelection();
- }
- });
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- int i = fAppearanceColorList.getSelectionIndex();
- String key = fAppearanceColorListModel[i][1];
-
- PreferenceConverter.setValue(fOverlayStore, key, fAppearanceForegroundColorEditor.getColorValue());
- }
- });
-
- WorkbenchHelp.setHelp(behaviorComposite, ICHelpContextIds.C_EDITOR_PREF_PAGE);
- return behaviorComposite;
- }
-
- private Control createContentAssistPage(Composite parent) {
-
- Composite contentAssistComposite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- contentAssistComposite.setLayout(layout);
-
- //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
- // The following three radio buttons are grouped together
- String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle");
- Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
-
- label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption");
- addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
-
- label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption");
- addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
-
- label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependenciesOption");
- addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE, 0);
- //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
-
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically");
- addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
-
- label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder");
- addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
-
- //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
- // The following items are grouped for Auto Activation
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle");
- Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot");
- addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow");
- addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon");
- addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationDelay");
- addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
-
- //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
-
- label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor");
- addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0);
-
- label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor");
- addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0);
-
-// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor");
-// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_BACKGROUND, 0);
-//
-// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterForegroundColor");
-// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0);
-
- WorkbenchHelp.setHelp(contentAssistComposite, ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
-
- return contentAssistComposite;
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
-
- fOverlayStore.load();
- fOverlayStore.start();
-
- TabFolder folder = new TabFolder(parent, SWT.NONE);
- folder.setLayout(new TabFolderLayout());
- folder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TabItem item = new TabItem(folder, SWT.NONE);
- item.setText(PreferencesMessages.getString("CEditorPreferencePage.generalTabTitle"));
- item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
- item.setControl(createBehaviorPage(folder));
-
- item = new TabItem(folder, SWT.NONE);
- item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
- item.setText(PreferencesMessages.getString("CEditorPreferencePage.annotationTabTitle"));
- item.setControl(createAnnotationsPage(folder));
-
- item = new TabItem(folder, SWT.NONE);
- item.setText(PreferencesMessages.getString("CEditorPreferencePage.colorsTabTitle"));
- item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
- item.setControl(createColorPage(folder));
-
- item = new TabItem(folder, SWT.NONE);
- item.setText(PreferencesMessages.getString("CEditorPreferencePage.contentAssistTabTitle"));
- item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
- item.setControl(createContentAssistPage(folder));
-
- initialize();
-
- return folder;
- }
-
- private void initialize() {
-
- fFontEditor.setPreferenceStore(getPreferenceStore());
- fFontEditor.setPreferencePage(this);
- fFontEditor.load();
-
- initializeFields();
-
- for (int i = 0; i < fListModel.length; i++)
- fList.add(fListModel[i][0]);
- fList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- fList.select(0);
- handleListSelection();
- }
- });
-
- for (int i = 0; i < fAppearanceColorListModel.length; i++)
- fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
- fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- fAppearanceColorList.select(0);
- handleAppearanceColorListSelection();
- }
- });
-
- for (int i = 0; i < fAnnotationColorListModel.length; i++)
- fAnnotationList.add(fAnnotationColorListModel[i][0]);
- fAnnotationList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
- fAnnotationList.select(0);
- handleAnnotationListSelection();
- }
- }
- });
- }
-
- private void initializeFields() {
-
- Iterator e = fColorButtons.keySet().iterator();
- while (e.hasNext()) {
- ColorEditor c = (ColorEditor) e.next();
- String key = (String) fColorButtons.get(c);
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- c.setColorValue(rgb);
- }
-
- e = fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b = (Button) e.next();
- String key = (String) fCheckBoxes.get(b);
- b.setSelection(fOverlayStore.getBoolean(key));
- }
-
- e = fTextFields.keySet().iterator();
- while (e.hasNext()) {
- Text t = (Text) e.next();
- String key = (String) fTextFields.get(t);
- t.setText(fOverlayStore.getString(key));
- }
-
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, CEditor.PREFERENCE_COLOR_BACKGROUND);
- fBackgroundColorEditor.setColorValue(rgb);
-
- boolean default_ = fOverlayStore.getBoolean(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- fBackgroundDefaultRadioButton.setSelection(default_);
- fBackgroundCustomRadioButton.setSelection(!default_);
- fBackgroundColorButton.setEnabled(!default_);
-
- //updateAutoactivationControls();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- fFontEditor.store();
- fOverlayStore.propagate();
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
-
- fFontEditor.loadDefault();
-
- fOverlayStore.loadDefaults();
- initializeFields();
- handleListSelection();
- handleAppearanceColorListSelection();
-
- super.performDefaults();
-
- fPreviewViewer.invalidateTextPresentation();
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
-
- if (fCTextTools != null) {
- fCTextTools = null;
- }
-
- fFontEditor.setPreferencePage(null);
- fFontEditor.setPreferenceStore(null);
-
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- fOverlayStore = null;
- }
-
- super.dispose();
- }
-
- private Control addColorButton(Composite parent, String label, String key, int indentation) {
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- composite.setLayoutData(gd);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
-
- Label labelControl = new Label(composite, SWT.NONE);
- labelControl.setText(label);
-
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent = indentation;
- labelControl.setLayoutData(gd);
-
- ColorEditor editor = new ColorEditor(composite);
- Button button = editor.getButton();
- button.setData(editor);
-
- gd = new GridData();
- gd.horizontalAlignment = GridData.END;
- button.setLayoutData(gd);
- button.addSelectionListener(fColorButtonListener);
-
- fColorButtons.put(editor, key);
-
- return composite;
- }
-
- private Group addGroupBox(Composite parent, String label, int nColumns ){
- Group group = new Group(parent, SWT.NONE);
- group.setText(label);
- GridLayout layout = new GridLayout();
- layout.numColumns = nColumns;
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return group;
- }
-
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText(label);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent = indentation;
- gd.horizontalSpan = 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- private Button addRadioButton(Composite parent, String label, String key, int indentation) {
- Button radioButton = new Button(parent, SWT.RADIO);
- radioButton.setText(label);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent = indentation;
- gd.horizontalSpan = 2;
- radioButton.setLayoutData(gd);
- radioButton.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(radioButton, key);
-
- return radioButton;
- }
-
- private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
-
- Label labelControl = new Label(composite, SWT.NONE);
- labelControl.setText(label);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = indentation;
- labelControl.setLayoutData(gd);
-
- Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
- textControl.setLayoutData(gd);
- textControl.setTextLimit(textLimit);
- fTextFields.put(textControl, key);
- if (isNumber) {
- fNumberFields.add(textControl);
- textControl.addModifyListener(fNumberFieldListener);
- } else {
- textControl.addModifyListener(fTextFieldListener);
- }
-
- return textControl;
- }
-
- private void addTextFontEditor(Composite parent, String label, String key) {
-
- Composite editorComposite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- editorComposite.setLayout(layout);
- fFontEditor = new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
- fFontEditor.setChangeButtonText("C&hange...");
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- editorComposite.setLayoutData(gd);
- }
-
- private String loadPreviewContentFromFile(String filename) {
- String line;
- String separator = System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer(512);
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
- while ((line = reader.readLine()) != null) {
- buffer.append(line);
- buffer.append(separator);
- }
- } catch (IOException io) {
- CUIPlugin.getDefault().log(io);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- }
- }
- }
- return buffer.toString();
- }
-
- protected void numberFieldChanged(Text textControl) {
- String number = textControl.getText();
- IStatus status = validatePositiveNumber(number);
- if (!status.matches(IStatus.ERROR))
- fOverlayStore.setValue((String) fTextFields.get(textControl), number);
- updateStatus(status);
- }
-
- private IStatus validatePositiveNumber(String number) {
- StatusInfo status = new StatusInfo();
- if (number.length() == 0) {
- status.setError(PreferencesMessages.getString("CEditorPreferencePage.empty_input")); //$NON-NLS-1$
- } else {
- try {
- int value = Integer.parseInt(number);
- if (value < 0)
- status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$
- } catch (NumberFormatException e) {
- status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$
- }
- }
- return status;
- }
-
- private void updateStatus(IStatus status) {
- if (!status.matches(IStatus.ERROR)) {
- for (int i = 0; i < fNumberFields.size(); i++) {
- Text text = (Text) fNumberFields.get(i);
- IStatus s = validatePositiveNumber(text.getText());
- status = StatusUtil.getMoreSevere(s, status);
- }
- }
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
deleted file mode 100644
index b53b8997501..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * The page for setting c plugin preferences.
- */
-public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
-
- private static final String LINK_TO_EDITOR_LABEL= "CBasePreferencePage.linkToEditor.label";
- private static final String SHOW_CU_CHILDREN_LABEL= "CBasePreferencePage.CUChildren.label";
- private static final String USE_STRUCTURAL_PARSE_MODE_LABEL= "CBasePreferencePage.OutlineView.structuralParseMode.label";
-
- public CPluginPreferencePage() {
- super(GRID);
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- }
-
- /**
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE);
- }
-
- /**
- * @see FieldEditorPreferencePage#createControl(Composite)
- */
- protected void createFieldEditors() {
- Composite parent= getFieldEditorParent();
-
- BooleanFieldEditor linkEditor= new BooleanFieldEditor(PreferenceConstants.PREF_LINK_TO_EDITOR, CUIPlugin.getResourceString(LINK_TO_EDITOR_LABEL), parent);
- addField(linkEditor);
-
- BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PreferenceConstants.PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent);
- addField(showCUChildrenEditor);
-
- BooleanFieldEditor useStructuralParseMode= new BooleanFieldEditor(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, CUIPlugin.getResourceString(USE_STRUCTURAL_PARSE_MODE_LABEL), parent);
- addField(useStructuralParseMode);
- }
-
-
- public static boolean isLinkToEditor() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_LINK_TO_EDITOR);
- }
-
- public static boolean showCompilationUnitChildren() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
- }
-
- public static boolean useStructuralParseMode() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
- }
-
- /**
- * @see IWorkbenchPreferencePage#init
- */
- public void init(IWorkbench workbench) {
- CUIPlugin.getDefault().getPreferenceStore().setValue(CCorePlugin.PREF_USE_STRUCTURAL_PARSE_MODE, CCorePlugin.getDefault().useStructuralParseMode());
- }
-
- /**
- * Initializes the default values of this page in the preference bundle.
- */
- public static void initDefaults(IPreferenceStore prefs) {
- prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, true);
- prefs.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true);
- prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, CCorePlugin.getDefault().useStructuralParseMode());
- prefs.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (!super.performOk())
- return false;
- // tell the Core Plugin about this preference
- CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
- return true;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorEditor.java
deleted file mode 100644
index c10fe8c8956..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorEditor.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-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.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-/**
- * A "button" of a certain color determined by the color picker.
- */
-public class ColorEditor {
-
- private Point fExtent;
- protected Image fImage;
- protected RGB fColorValue;
- protected Color fColor;
- protected Button fButton;
-
- public ColorEditor(Composite parent) {
-
- fButton= new Button(parent, SWT.PUSH);
- fExtent= computeImageSize(parent);
- fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y);
-
- GC gc= new GC(fImage);
- gc.setBackground(fButton.getBackground());
- gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
- gc.dispose();
-
- fButton.setImage(fImage);
- fButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- ColorDialog colorDialog= new ColorDialog(fButton.getShell());
- colorDialog.setRGB(fColorValue);
- RGB newColor = colorDialog.open();
- if (newColor != null) {
- fColorValue= newColor;
- updateColorImage();
- }
- }
- });
-
- fButton.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- if (fImage != null) {
- fImage.dispose();
- fImage= null;
- }
- if (fColor != null) {
- fColor.dispose();
- fColor= null;
- }
- }
- });
- }
-
- public RGB getColorValue() {
- return fColorValue;
- }
-
- public void setColorValue(RGB rgb) {
- fColorValue= rgb;
- updateColorImage();
- }
-
- public Button getButton() {
- return fButton;
- }
-
- protected void updateColorImage() {
-
- Display display= fButton.getDisplay();
-
- GC gc= new GC(fImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);
-
- if (fColor != null)
- fColor.dispose();
-
- fColor= new Color(display, fColorValue);
- gc.setBackground(fColor);
- gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
- gc.dispose();
-
- fButton.setImage(fImage);
- }
-
- protected Point computeImageSize(Control window) {
- GC gc= new GC(window);
- Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
- gc.setFont(f);
- int height= gc.getFontMetrics().getHeight();
- gc.dispose();
- Point p= new Point(height * 3 - 6, height);
- return p;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
deleted file mode 100644
index 1a7e359c3dc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * This is sample C code
- */
-#include <stdio.h>
-unsigned static myfunc(int a, char b,) {
- /* This comment may span multiple lines. */
- int integer= 0;
- // This comment may span only this line
- if(integer == 0) printf("zero");
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
deleted file mode 100644
index 8bd10c88d78..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
+++ /dev/null
@@ -1,540 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.corext.template.TemplateMessages;
-import org.eclipse.cdt.internal.corext.template.TemplateTranslator;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
-import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.RGB;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.IUpdate;
-
-
-/**
- * Dialog to edit a template.
- */
-public class EditTemplateDialog extends StatusDialog {
-
- private static class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration {
-
- private final IContentAssistProcessor fProcessor;
-
- SimpleCSourceViewerConfiguration(CTextTools tools, CEditor editor, IContentAssistProcessor processor) {
- super(tools, editor);
- fProcessor= processor;
- }
-
- /*
- * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
-
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
-
- ContentAssistant assistant= new ContentAssistant();
- assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
-
- //assistant.enableAutoInsert(store.getBoolean(ContentAssistPreference.AUTOINSERT));
- boolean enabled = (store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT)
- || store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW)
- || store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON)
- );
- assistant.enableAutoActivation(enabled);
-
- assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY));
- assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- //assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
-
- Display display= sourceViewer.getTextWidget().getDisplay();
-
- Color background= createColor(store, ContentAssistPreference.PROPOSALS_BACKGROUND, display);
- assistant.setContextInformationPopupBackground(background);
- assistant.setContextSelectorBackground(background);
- assistant.setProposalSelectorBackground(background);
-
- Color foreground= createColor(store, ContentAssistPreference.PROPOSALS_FOREGROUND, display);
- assistant.setContextInformationPopupForeground(foreground);
- assistant.setContextSelectorForeground(foreground);
- assistant.setProposalSelectorForeground(foreground);
-
- return assistant;
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
-
- RGB rgb= null;
-
- if (store.contains(key)) {
-
- if (store.isDefault(key))
- rgb= PreferenceConverter.getDefaultColor(store, key);
- else
- rgb= PreferenceConverter.getColor(store, key);
-
- if (rgb != null)
- return new Color(display, rgb);
- }
-
- return null;
- }
- }
-
- private static class TextViewerAction extends Action implements IUpdate {
-
- private int fOperationCode= -1;
- private ITextOperationTarget fOperationTarget;
-
- public TextViewerAction(ITextViewer viewer, int operationCode) {
- fOperationCode= operationCode;
- fOperationTarget= viewer.getTextOperationTarget();
- update();
- }
-
- /**
- * Updates the enabled state of the action.
- * Fires a property change if the enabled state changes.
- *
- * @see Action#firePropertyChange(String, Object, Object)
- */
- public void update() {
-
- boolean wasEnabled= isEnabled();
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
- setEnabled(isEnabled);
-
- if (wasEnabled != isEnabled) {
- firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
- }
- }
-
- /**
- * @see Action#run()
- */
- public void run() {
- if (fOperationCode != -1 && fOperationTarget != null) {
- fOperationTarget.doOperation(fOperationCode);
- }
- }
- }
-
- private final Template fTemplate;
-
- protected Text fNameText;
- private Text fDescriptionText;
- protected Combo fContextCombo;
- protected SourceViewer fPatternEditor;
- private Button fInsertVariableButton;
-
- protected TemplateTranslator fTranslator= new TemplateTranslator();
- protected boolean fSuppressError= true; // #4354
- private Map fGlobalActions= new HashMap(10);
- private List fSelectionActions = new ArrayList(3);
- private Vector fContextTypes= new Vector();
-
- protected final TemplateVariableProcessor fProcessor= new TemplateVariableProcessor();
-
- public EditTemplateDialog(Shell parent, Template template, boolean edit) {
- super(parent);
-
- setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
-
- String title= edit
- ? TemplateMessages.getString("EditTemplateDialog.title.edit") //$NON-NLS-1$
- : TemplateMessages.getString("EditTemplateDialog.title.new"); //$NON-NLS-1$
- setTitle(title);
-
- fTemplate= template;
-
- ContextTypeRegistry registry= ContextTypeRegistry.getInstance();
- for (Iterator iterator= registry.iterator(); iterator.hasNext(); )
- fContextTypes.add(iterator.next());
-
- if (fContextTypes.size() > 0)
- fProcessor.setContextType(ContextTypeRegistry.getInstance().getContextType((String) fContextTypes.get(0)));
- }
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite ancestor) {
- Composite parent= new Composite(ancestor, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createLabel(parent, TemplateMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layout= new GridLayout();
- layout.numColumns= 3;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- fNameText= createText(composite);
- fNameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (fSuppressError && (fNameText.getText().trim().length() != 0))
- fSuppressError= false;
-
- updateButtons();
- }
- });
-
- createLabel(composite, TemplateMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$
- fContextCombo= new Combo(composite, SWT.READ_ONLY);
-
- for (Iterator iterator= fContextTypes.iterator(); iterator.hasNext(); )
- fContextCombo.add((String) iterator.next());
-
- fContextCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String name= fContextCombo.getText();
- fProcessor.setContextType(ContextTypeRegistry.getInstance().getContextType(name));
- }
- });
-
- createLabel(parent, TemplateMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$
- fDescriptionText= createText(parent);
-
- composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createLabel(composite, TemplateMessages.getString("EditTemplateDialog.pattern")); //$NON-NLS-1$
- fPatternEditor= createEditor(parent);
-
- Label filler= new Label(composite, SWT.NONE);
- filler.setLayoutData(new GridData(GridData.FILL_VERTICAL));
-
- fInsertVariableButton= new Button(composite, SWT.NONE);
- fInsertVariableButton.setLayoutData(getButtonGridData(fInsertVariableButton));
- fInsertVariableButton.setText(TemplateMessages.getString("EditTemplateDialog.insert.variable")); //$NON-NLS-1$
- fInsertVariableButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fPatternEditor.getTextWidget().setFocus();
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- });
-
- fNameText.setText(fTemplate.getName());
- fDescriptionText.setText(fTemplate.getDescription());
- fContextCombo.select(getIndex(fTemplate.getContextTypeName()));
-
- initializeActions();
-
- return composite;
- }
-
- private static GridData getButtonGridData(Button button) {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint= SWTUtil.getButtonHeigthHint(button);
-
- return data;
- }
-
- private static Label createLabel(Composite parent, String name) {
- Label label= new Label(parent, SWT.NULL);
- label.setText(name);
- label.setLayoutData(new GridData());
-
- return label;
- }
-
- private static Text createText(Composite parent) {
- Text text= new Text(parent, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- return text;
- }
-
- private SourceViewer createEditor(Composite parent) {
- SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- viewer.configure(new SimpleCSourceViewerConfiguration(tools, null, fProcessor));
- viewer.setEditable(true);
- viewer.setDocument(new Document(fTemplate.getPattern()));
-
- Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
- viewer.getTextWidget().setFont(font);
-
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= convertWidthInCharsToPixels(60);
- data.heightHint= convertHeightInCharsToPixels(5);
- control.setLayoutData(data);
-
- viewer.addTextListener(new ITextListener() {
- public void textChanged(TextEvent event) {
- try {
- fTranslator.translate(event.getDocumentEvent().getDocument().get());
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- // XXX dialog
- }
-
- updateUndoAction();
- updateButtons();
- }
- });
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateSelectionDependentActions();
- }
- });
-
- if (viewer instanceof ITextViewerExtension) {
- ((ITextViewerExtension) viewer).prependVerifyKeyListener(new VerifyKeyListener() {
- public void verifyKey(VerifyEvent event) {
- handleVerifyKeyPressed(event);
- }
- });
- } else {
- viewer.getTextWidget().addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
-
- public void keyReleased(KeyEvent e) {}
- });
- }
-
- return viewer;
- }
-
- protected void handleKeyPressed(KeyEvent event) {
- if (event.stateMask != SWT.CTRL)
- return;
-
- switch (event.character) {
- case ' ':
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- break;
-
- // CTRL-Z
- case (int) 'z' - (int) 'a' + 1:
- fPatternEditor.doOperation(ITextOperationTarget.UNDO);
- break;
- }
- }
-
- protected void handleVerifyKeyPressed(VerifyEvent event) {
- if (!event.doit)
- return;
-
- if (event.stateMask != SWT.CTRL)
- return;
-
- switch (event.character) {
- case ' ':
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- event.doit= false;
- break;
-
- // CTRL-Z
- case (int) 'z' - (int) 'a' + 1:
- fPatternEditor.doOperation(ITextOperationTarget.UNDO);
- event.doit= false;
- break;
- }
- }
-
- private void initializeActions() {
- TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
- action.setText(TemplateMessages.getString("EditTemplateDialog.undo")); //$NON-NLS-1$
- fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
- action.setText(TemplateMessages.getString("EditTemplateDialog.cut")); //$NON-NLS-1$
- fGlobalActions.put(ITextEditorActionConstants.CUT, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
- action.setText(TemplateMessages.getString("EditTemplateDialog.copy")); //$NON-NLS-1$
- fGlobalActions.put(ITextEditorActionConstants.COPY, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
- action.setText(TemplateMessages.getString("EditTemplateDialog.paste")); //$NON-NLS-1$
- fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
- action.setText(TemplateMessages.getString("EditTemplateDialog.select.all")); //$NON-NLS-1$
- fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
-
- action= new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
- action.setText(TemplateMessages.getString("EditTemplateDialog.content.assist")); //$NON-NLS-1$
- fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$
-
- fSelectionActions.add(ITextEditorActionConstants.CUT);
- fSelectionActions.add(ITextEditorActionConstants.COPY);
- fSelectionActions.add(ITextEditorActionConstants.PASTE);
-
- // create context menu
- MenuManager manager= new MenuManager(null, null);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager mgr) {
- fillContextMenu(mgr);
- }
- });
-
- StyledText text= fPatternEditor.getTextWidget();
- Menu menu= manager.createContextMenu(text);
- text.setMenu(menu);
- }
-
- protected void fillContextMenu(IMenuManager menu) {
- menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO));
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.CUT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.COPY));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
-
- menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
- menu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$
- }
-
- protected void updateSelectionDependentActions() {
- Iterator iterator= fSelectionActions.iterator();
- while (iterator.hasNext())
- updateAction((String)iterator.next());
- }
-
- protected void updateUndoAction() {
- IAction action= (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO);
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- }
-
- protected void updateAction(String actionId) {
- IAction action= (IAction) fGlobalActions.get(actionId);
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- }
-
- private int getIndex(String context) {
- ContextTypeRegistry registry= ContextTypeRegistry.getInstance();
- registry.getContextType(context);
-
- if (context == null)
- return -1;
-
- return fContextTypes.indexOf(context);
- }
-
- protected void okPressed() {
- fTemplate.setName(fNameText.getText());
- fTemplate.setDescription(fDescriptionText.getText());
- fTemplate.setContext(fContextCombo.getText());
- fTemplate.setPattern(fPatternEditor.getTextWidget().getText());
-
- super.okPressed();
- }
-
- protected void updateButtons() {
- boolean valid= fNameText.getText().trim().length() != 0;
-
- StatusInfo status= new StatusInfo();
-
- if (!valid) {
- if (fSuppressError)
- status.setError(""); //$NON-NLS-1$
- else
- status.setError(TemplateMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$
- } else if (fTranslator.getErrorMessage() != null) {
- status.setError(fTranslator.getErrorMessage());
- }
-
- updateStatus(status);
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
deleted file mode 100644
index 633c9130a2b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.ui.IEditorInput;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
-
-/**
- */
-public abstract class OptionsConfigurationBlock {
-
- protected static class ControlData {
- private String fKey;
- private String[] fValues;
-
- public ControlData(String key, String[] values) {
- fKey= key;
- fValues= values;
- }
-
- public String getKey() {
- return fKey;
- }
-
- public String getValue(boolean selection) {
- int index= selection ? 0 : 1;
- return fValues[index];
- }
-
- public String getValue(int index) {
- return fValues[index];
- }
-
- public int getSelection(String value) {
- for (int i= 0; i < fValues.length; i++) {
- if (value.equals(fValues[i])) {
- return i;
- }
- }
- throw new IllegalArgumentException();
- }
- }
-
-
- protected Map fWorkingValues;
-
- protected ArrayList fCheckBoxes;
- protected ArrayList fComboBoxes;
- protected ArrayList fTextBoxes;
-
- private SelectionListener fSelectionListener;
- private ModifyListener fTextModifyListener;
-
- protected IStatusChangeListener fContext;
- protected ICProject fProject; // project or null
-
- private Shell fShell;
-
- public OptionsConfigurationBlock(IStatusChangeListener context, ICProject project) {
- fContext= context;
- fProject= project;
-
- fWorkingValues= getOptions(true);
-
- fCheckBoxes= new ArrayList();
- fComboBoxes= new ArrayList();
- fTextBoxes= new ArrayList(2);
- }
-
- protected abstract String[] getAllKeys();
-
- protected Map getOptions(boolean inheritCCoreOptions) {
- if (fProject != null) {
- return fProject.getOptions(inheritCCoreOptions);
- } else {
- return CCorePlugin.getOptions();
- }
- }
-
- protected Map getDefaultOptions() {
- return CCorePlugin.getDefaultOptions();
- }
-
- public final boolean hasProjectSpecificOptions() {
- if (fProject != null) {
- Map settings= fProject.getOptions(false);
- String[] allKeys= getAllKeys();
- for (int i= 0; i < allKeys.length; i++) {
- if (settings.get(allKeys[i]) != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- protected final void setOptions(Map map) {
- if (fProject != null) {
- fProject.setOptions(map);
- } else {
- CCorePlugin.setOptions((HashMap) map);
- }
- }
-
- protected Shell getShell() {
- return fShell;
- }
-
- protected void setShell(Shell shell) {
- fShell= shell;
- }
-
- protected abstract Control createContents(Composite parent);
-
- protected void addCheckBox(Composite parent, String label, String key, String[] values, int indent) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.horizontalIndent= indent;
-
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(label);
- checkBox.setData(data);
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(getSelectionListener());
-
- String currValue= (String)fWorkingValues.get(key);
- checkBox.setSelection(data.getSelection(currValue) == 0);
-
- fCheckBoxes.add(checkBox);
- }
-
- protected void addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels, int indent) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indent;
-
- Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
- labelControl.setText(label);
- labelControl.setLayoutData(gd);
-
- Combo comboBox= new Combo(parent, SWT.READ_ONLY);
- comboBox.setItems(valueLabels);
- comboBox.setData(data);
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- comboBox.addSelectionListener(getSelectionListener());
-
- String currValue= (String)fWorkingValues.get(key);
- comboBox.select(data.getSelection(currValue));
-
- fComboBoxes.add(comboBox);
- }
-
- protected Text addTextField(Composite parent, String label, String key, int indent, int widthHint) {
- Label labelControl= new Label(parent, SWT.NONE);
- labelControl.setText(label);
- labelControl.setLayoutData(new GridData());
-
- Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
- textBox.setData(key);
- textBox.setLayoutData(new GridData());
-
- String currValue= (String) fWorkingValues.get(key);
- textBox.setText(currValue);
- textBox.addModifyListener(getTextModifyListener());
-
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- if (widthHint != 0) {
- data.widthHint= widthHint;
- }
- data.horizontalIndent= indent;
- textBox.setLayoutData(data);
-
- fTextBoxes.add(textBox);
- return textBox;
- }
-
- protected SelectionListener getSelectionListener() {
- if (fSelectionListener == null) {
- fSelectionListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged(e.widget);
- }
- };
- }
- return fSelectionListener;
- }
-
- protected ModifyListener getTextModifyListener() {
- if (fTextModifyListener == null) {
- fTextModifyListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textChanged((Text) e.widget);
- }
- };
- }
- return fTextModifyListener;
- }
-
- protected void controlChanged(Widget widget) {
- ControlData data= (ControlData) widget.getData();
- String newValue= null;
- if (widget instanceof Button) {
- newValue= data.getValue(((Button)widget).getSelection());
- } else if (widget instanceof Combo) {
- newValue= data.getValue(((Combo)widget).getSelectionIndex());
- } else {
- return;
- }
- fWorkingValues.put(data.getKey(), newValue);
-
- validateSettings(data.getKey(), newValue);
- }
-
- protected void textChanged(Text textControl) {
- String key= (String) textControl.getData();
- String number= textControl.getText();
- fWorkingValues.put(key, number);
- validateSettings(key, number);
- }
-
- protected boolean checkValue(String key, String value) {
- return value.equals(fWorkingValues.get(key));
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected abstract void validateSettings(String changedKey, String newValue);
-
-
- protected String[] getTokens(String text, String separator) {
- StringTokenizer tok= new StringTokenizer(text, separator); //$NON-NLS-1$
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken().trim();
- }
- return res;
- }
-
-
- public boolean performOk(boolean enabled) {
- String[] allKeys= getAllKeys();
- Map actualOptions= getOptions(false);
-
- // preserve other options
- boolean hasChanges= false;
- for (int i= 0; i < allKeys.length; i++) {
- String key= allKeys[i];
- String oldVal= (String) actualOptions.get(key);
- String val= null;
- if (enabled) {
- val= (String) fWorkingValues.get(key);
- if (!val.equals(oldVal)) {
- hasChanges= true;
- actualOptions.put(key, val);
- }
- } else {
- if (oldVal != null) {
- actualOptions.remove(key);
- hasChanges= true;
- }
- }
- }
-
-
- if (hasChanges) {
- boolean doReParse = false;
- String[] strings = getFullReParseDialogStrings(fProject == null);
- if (strings != null) {
- MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
- int res= dialog.open();
- if (res == 0) {
- doReParse = true;
- } else if (res != 1) {
- return false; // cancel pressed
- }
- }
- setOptions(actualOptions);
- if (doReParse) {
- doFullReParse();
- }
- }
- return true;
- }
-
- protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings);
- protected abstract String[] getFullReParseDialogStrings(boolean workspaceSettings);
-
- protected void doFullBuild() {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- monitor.beginTask("", 1); //$NON-NLS-1$
- try {
- if (fProject != null) {
- monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.buildproject.taskname", fProject.getElementName())); //$NON-NLS-1$
- fProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1));
- } else {
- monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.buildall.taskname")); //$NON-NLS-1$
- CUIPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1));
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InterruptedException e) {
- // cancelled by user
- } catch (InvocationTargetException e) {
- String title= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.title"); //$NON-NLS-1$
- String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- }
-
- protected void doFullReParse() {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- monitor.beginTask("", 1); //$NON-NLS-1$
-
- if (fProject != null) {
- monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.parseproject.taskname", fProject.getElementName())); //$NON-NLS-1$
- reParseHierarchy(fProject.getResource(), monitor);
- } else {
- monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.parseall.taskname")); //$NON-NLS-1$
- reParseHierarchy(CUIPlugin.getWorkspace().getRoot(), monitor);
- }
-
- monitor.done();
- }
- });
- } catch (InterruptedException e) {
- // cancelled by user
- } catch (InvocationTargetException e) {
- String title= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.title"); //$NON-NLS-1$
- String message= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- }
-
- protected void reParseHierarchy(IResource root, final IProgressMonitor monitor) {
- try {
- root.accept(
- new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) {
- switch(proxy.getType()) {
- case IResource.FILE :
- IFile file = (IFile)proxy.requestResource();
- CoreModel cModel = CCorePlugin.getDefault().getCoreModel();
-
- if (cModel.isTranslationUnit(file)) {
- ITranslationUnit translationUnit = (ITranslationUnit)cModel.create(file);
-
- try {
- IEditorInput input = EditorUtility.getEditorInput(file);
- if (input != null) {
- ITranslationUnit workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
- if (workingCopy != null) {
- // We have a copy in an editor - use it
- translationUnit = workingCopy;
- }
- }
-
- translationUnit.makeConsistent(monitor, true /*forced*/);
- } catch (CModelException e) {
- }
- }
-
- return false; // Do not look into file's structure
- }
-
- return true;
- }
- }
- , IResource.NONE);
- } catch (CoreException e) {
- }
- }
-
- public void performDefaults() {
- fWorkingValues= getDefaultOptions();
- updateControls();
- validateSettings(null, null);
- }
-
- protected void updateControls() {
- // update the UI
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Button curr= (Button) fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
-
- String currValue= (String) fWorkingValues.get(data.getKey());
- curr.setSelection(data.getSelection(currValue) == 0);
- }
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Combo curr= (Combo) fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
-
- String currValue= (String) fWorkingValues.get(data.getKey());
- curr.select(data.getSelection(currValue));
- }
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Text curr= (Text) fTextBoxes.get(i);
- String key= (String) curr.getData();
-
- String currValue= (String) fWorkingValues.get(key);
- curr.setText(currValue);
- }
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
deleted file mode 100644
index 093c549d997..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
+++ /dev/null
@@ -1,447 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-/**
- * An overlaying preference store.
- */
-public class OverlayPreferenceStore implements IPreferenceStore {
-
-
- public static final class TypeDescriptor {
- protected TypeDescriptor() {
- }
- };
-
- public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
- public static final TypeDescriptor DOUBLE= new TypeDescriptor();
- public static final TypeDescriptor FLOAT= new TypeDescriptor();
- public static final TypeDescriptor INT= new TypeDescriptor();
- public static final TypeDescriptor LONG= new TypeDescriptor();
- public static final TypeDescriptor STRING= new TypeDescriptor();
-
- public static class OverlayKey {
-
- TypeDescriptor fDescriptor;
- String fKey;
-
- public OverlayKey(TypeDescriptor descriptor, String key) {
- fDescriptor= descriptor;
- fKey= key;
- }
- };
-
- private class PropertyListener implements IPropertyChangeListener {
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- OverlayKey key= findOverlayKey(event.getProperty());
- if (key != null)
- propagateProperty(fParent, key, fStore);
- }
- };
-
-
- protected IPreferenceStore fParent;
- protected IPreferenceStore fStore;
- private OverlayKey[] fOverlayKeys;
-
- private PropertyListener fPropertyListener;
-
-
- public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
- fParent= parent;
- fOverlayKeys= overlayKeys;
- fStore= new PreferenceStore();
- }
-
- protected OverlayKey findOverlayKey(String key) {
- for (int i= 0; i < fOverlayKeys.length; i++) {
- if (fOverlayKeys[i].fKey.equals(key))
- return fOverlayKeys[i];
- }
- return null;
- }
-
- private boolean covers(String key) {
- return (findOverlayKey(key) != null);
- }
-
- protected void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
-
- if (orgin.isDefault(key.fKey)) {
- if (!target.isDefault(key.fKey))
- target.setToDefault(key.fKey);
- return;
- }
-
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- boolean originValue= orgin.getBoolean(key.fKey);
- boolean targetValue= target.getBoolean(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (DOUBLE == d) {
-
- double originValue= orgin.getDouble(key.fKey);
- double targetValue= target.getDouble(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (FLOAT == d) {
-
- float originValue= orgin.getFloat(key.fKey);
- float targetValue= target.getFloat(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (INT == d) {
-
- int originValue= orgin.getInt(key.fKey);
- int targetValue= target.getInt(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (LONG == d) {
-
- long originValue= orgin.getLong(key.fKey);
- long targetValue= target.getLong(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (STRING == d) {
-
- String originValue= orgin.getString(key.fKey);
- String targetValue= target.getString(key.fKey);
- if (targetValue != null && originValue != null && !targetValue.equals(originValue))
- target.setValue(key.fKey, originValue);
-
- }
- }
-
- public void propagate() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- propagateProperty(fStore, fOverlayKeys[i], fParent);
- }
-
- private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, true);
- target.setValue(key.fKey, orgin.getBoolean(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
-
- } else if (DOUBLE == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0D);
- target.setValue(key.fKey, orgin.getDouble(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
-
- } else if (FLOAT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0F);
- target.setValue(key.fKey, orgin.getFloat(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
-
- } else if (INT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1);
- target.setValue(key.fKey, orgin.getInt(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
-
- } else if (LONG == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1L);
- target.setValue(key.fKey, orgin.getLong(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
-
- } else if (STRING == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, "1");
- target.setValue(key.fKey, orgin.getString(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
-
- }
- }
-
- public void load() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- loadProperty(fParent, fOverlayKeys[i], fStore, true);
- }
-
- public void loadDefaults() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- setToDefault(fOverlayKeys[i].fKey);
- }
-
- public void start() {
- if (fPropertyListener == null) {
- fPropertyListener= new PropertyListener();
- fParent.addPropertyChangeListener(fPropertyListener);
- }
- }
-
- public void stop() {
- if (fPropertyListener != null) {
- fParent.removePropertyChangeListener(fPropertyListener);
- fPropertyListener= null;
- }
- }
-
- /*
- * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- fStore.addPropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fStore.removePropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- fStore.firePropertyChangeEvent(name, oldValue, newValue);
- }
-
- /*
- * @see IPreferenceStore#contains(String)
- */
- public boolean contains(String name) {
- return fStore.contains(name);
- }
-
- /*
- * @see IPreferenceStore#getBoolean(String)
- */
- public boolean getBoolean(String name) {
- return fStore.getBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultBoolean(String)
- */
- public boolean getDefaultBoolean(String name) {
- return fStore.getDefaultBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultDouble(String)
- */
- public double getDefaultDouble(String name) {
- return fStore.getDefaultDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultFloat(String)
- */
- public float getDefaultFloat(String name) {
- return fStore.getDefaultFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultInt(String)
- */
- public int getDefaultInt(String name) {
- return fStore.getDefaultInt(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultLong(String)
- */
- public long getDefaultLong(String name) {
- return fStore.getDefaultLong(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultString(String)
- */
- public String getDefaultString(String name) {
- return fStore.getDefaultString(name);
- }
-
- /*
- * @see IPreferenceStore#getDouble(String)
- */
- public double getDouble(String name) {
- return fStore.getDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getFloat(String)
- */
- public float getFloat(String name) {
- return fStore.getFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getInt(String)
- */
- public int getInt(String name) {
- return fStore.getInt(name);
- }
-
- /*
- * @see IPreferenceStore#getLong(String)
- */
- public long getLong(String name) {
- return fStore.getLong(name);
- }
-
- /*
- * @see IPreferenceStore#getString(String)
- */
- public String getString(String name) {
- return fStore.getString(name);
- }
-
- /*
- * @see IPreferenceStore#isDefault(String)
- */
- public boolean isDefault(String name) {
- return fStore.isDefault(name);
- }
-
- /*
- * @see IPreferenceStore#needsSaving()
- */
- public boolean needsSaving() {
- return fStore.needsSaving();
- }
-
- /*
- * @see IPreferenceStore#putValue(String, String)
- */
- public void putValue(String name, String value) {
- if (covers(name))
- fStore.putValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, double)
- */
- public void setDefault(String name, double value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, float)
- */
- public void setDefault(String name, float value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, int)
- */
- public void setDefault(String name, int value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, long)
- */
- public void setDefault(String name, long value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, String)
- */
- public void setDefault(String name, String value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, boolean)
- */
- public void setDefault(String name, boolean value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setToDefault(String)
- */
- public void setToDefault(String name) {
- fStore.setToDefault(name);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, double)
- */
- public void setValue(String name, double value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, float)
- */
- public void setValue(String name, float value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, int)
- */
- public void setValue(String name, int value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, long)
- */
- public void setValue(String name, long value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, String)
- */
- public void setValue(String name, String value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, boolean)
- */
- public void setValue(String name, boolean value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
deleted file mode 100644
index 5910c5af1c6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class PreferencesMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private PreferencesMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static String getFormattedString(String key, String arg) {
- return getFormattedString(key, new String[] { arg });
- }
-
- public static String getFormattedString(String key, String[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
deleted file mode 100644
index 646204593c4..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
+++ /dev/null
@@ -1,86 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-OptionsConfigurationBlock.builderror.title=Preference Changes
-OptionsConfigurationBlock.builderror.message=Problem while building. Check log for details.
-
-OptionsConfigurationBlock.buildall.taskname=Build all...
-OptionsConfigurationBlock.buildproject.taskname=Build project ''{0}''...
-
-
-OptionsConfigurationBlock.parseerror.title=Preference Changes
-OptionsConfigurationBlock.parseerror.message=Problem while parsing. Check log for details.
-
-OptionsConfigurationBlock.parseall.taskname=Parse all...
-OptionsConfigurationBlock.parseproject.taskname=Parse project ''{0}''...
-
-
-TodoTaskPreferencePage.title=Task Tags
-
-TodoTaskPropertyPage.useworkspacesettings.label=Use &workspace settings
-TodoTaskPropertyPage.useworkspacesettings.change=&Configure Workspace Settings...
-TodoTaskPropertyPage.useprojectsettings.label=Use pr&oject settings
-
-TodoTaskConfigurationBlock.markers.tasks.high.priority=High
-TodoTaskConfigurationBlock.markers.tasks.normal.priority=Normal
-TodoTaskConfigurationBlock.markers.tasks.low.priority=Low
-TodoTaskConfigurationBlock.markers.tasks.label=&Strings indicating tasks in Java comments:
-TodoTaskConfigurationBlock.markers.tasks.add.button=Ne&w...
-TodoTaskConfigurationBlock.markers.tasks.remove.button=Remo&ve
-TodoTaskConfigurationBlock.markers.tasks.edit.button=Edi&t...
-TodoTaskConfigurationBlock.markers.tasks.name.column=Tag
-TodoTaskConfigurationBlock.markers.tasks.priority.column=Priority
-
-TodoTaskConfigurationBlock.needsbuild.title=Task Tags Settings Changed
-TodoTaskConfigurationBlock.needsfullbuild.message=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now?
-TodoTaskConfigurationBlock.needsprojectbuild.message=The task tags settings have changed. A rebuild of the project is required to make changes effective. Do the project build now?
-
-TodoTaskConfigurationBlock.needsparse.title=Task Tags Settings Changed
-TodoTaskConfigurationBlock.needsfullparse.message=The task tags settings have changed. A full re-parse is required to make changes effective. Do the full re-parse now?
-TodoTaskConfigurationBlock.needsprojectparse.message=The task tags settings have changed. Re-parsing of the project is required to make changes effective. Do the project re-parse now?
-
-TodoTaskInputDialog.new.title=New Task Tag
-TodoTaskInputDialog.edit.title=Edit Task Tag
-TodoTaskInputDialog.name.label=T&ag:
-TodoTaskInputDialog.priority.label=&Priority:
-TodoTaskInputDialog.priority.high=High
-TodoTaskInputDialog.priority.normal=Normal
-TodoTaskInputDialog.priority.low=Low
-TodoTaskInputDialog.error.enterName=Enter task tag name.
-TodoTaskInputDialog.error.comma=Name cannot contain a comma.
-TodoTaskInputDialog.error.entryExists=Entry with the same name already exists.
-TodoTaskInputDialog.error.noSpace=Name can not start or end with a whitespace.
-
-CEditorPreferencePage.cCommentTaskTags=Task Tags
-
-CEditorPreferencePage.generalTabTitle=&General
-CEditorPreferencePage.annotationTabTitle= &Annotations
-CEditorPreferencePage.colorsTabTitle=&Colors
-CEditorPreferencePage.contentAssistTabTitle=Content A&ssist
-
-CEditorPreferencePage.invalid_input=Invalid input.
-CEditorPreferencePage.empty_input=Empty input
-
-CEditorPreferencePage.ContentAssistPage.searchGroupTitle=Search scope for completion proposals:
-CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption=&Search current file and included files
-CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption=Search current &project
-CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependenciesOption=Search current project and &dependent projects
-CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=Insert single &proposals automatically
-CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt
-CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
-CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle=Auto activation:
-CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot=Enable . as trigger
-CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable -> as trigger
-CEditorPreferencePage.ContentAssistPage.autoActivationDelay=dela&y (in milli seconds)
-CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor=&Background for completion proposals:
-CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor=&Foreground for completion proposals:
-CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor=Bac&kground for method parameters:
-CEditorPreferencePage.ContentAssistPage.parameterForegroundColor=Fo&reground for method parameters: \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
deleted file mode 100644
index 6edbbb0587b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
+++ /dev/null
@@ -1,591 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.corext.template.TemplateMessages;
-import org.eclipse.cdt.internal.corext.template.TemplateSet;
-import org.eclipse.cdt.internal.corext.template.Templates;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.template.TemplateContentProvider;
-import org.eclipse.cdt.internal.ui.text.template.TemplateLabelProvider;
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-
-public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- // preference store keys
- private static final String PREF_FORMAT_TEMPLATES= CUIPlugin.PLUGIN_ID + ".template.format"; //$NON-NLS-1$
-
- private Templates fTemplates;
-
- private CheckboxTableViewer fTableViewer;
- private Button fAddButton;
- private Button fEditButton;
- private Button fImportButton;
- private Button fExportButton;
- private Button fExportAllButton;
- private Button fRemoveButton;
- private Button fEnableAllButton;
- private Button fDisableAllButton;
-
- private SourceViewer fPatternViewer;
- //private Button fFormatButton;
-
- public TemplatePreferencePage() {
- super();
-
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$
-
- fTemplates= Templates.getInstance();
- }
-
- /**
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite ancestor) {
- Composite parent= new Composite(ancestor, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- parent.setLayout(layout);
-
- Table table= new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= convertWidthInCharsToPixels(80);
- data.heightHint= convertHeightInCharsToPixels(10);
- table.setLayoutData(data);
-
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- TableLayout tableLayout= new TableLayout();
- table.setLayout(tableLayout);
-
- TableColumn column1= new TableColumn(table, SWT.NONE);
- column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$
-
- TableColumn column2= new TableColumn(table, SWT.NONE);
- column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.context")); //$NON-NLS-1$
-
- TableColumn column3= new TableColumn(table, SWT.NONE);
- column3.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$
-
- tableLayout.addColumnData(new ColumnWeightData(30));
- tableLayout.addColumnData(new ColumnWeightData(20));
- tableLayout.addColumnData(new ColumnWeightData(70));
-
- fTableViewer= new CheckboxTableViewer(table);
- fTableViewer.setLabelProvider(new TemplateLabelProvider());
- fTableViewer.setContentProvider(new TemplateContentProvider());
-
- fTableViewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object object1, Object object2) {
- if ((object1 instanceof Template) && (object2 instanceof Template)) {
- Template left= (Template) object1;
- Template right= (Template) object2;
- int result= left.getName().compareToIgnoreCase(right.getName());
- if (result != 0)
- return result;
- return left.getDescription().compareToIgnoreCase(right.getDescription());
- }
- return super.compare(viewer, object1, object2);
- }
-
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
- });
-
- fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent e) {
- edit();
- }
- });
-
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent e) {
- selectionChanged1();
- }
- });
-
- fTableViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- Template template= (Template) event.getElement();
- template.setEnabled(event.getChecked());
- }
- });
-
- Composite buttons= new Composite(parent, SWT.NULL);
- buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- buttons.setLayout(layout);
-
- fAddButton= new Button(buttons, SWT.PUSH);
- fAddButton.setLayoutData(getButtonGridData(fAddButton));
- fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$
- fAddButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- add();
- }
- });
-
- fEditButton= new Button(buttons, SWT.PUSH);
- fEditButton.setLayoutData(getButtonGridData(fEditButton));
- fEditButton.setText(TemplateMessages.getString("TemplatePreferencePage.edit")); //$NON-NLS-1$
- fEditButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- edit();
- }
- });
-
- fRemoveButton= new Button(buttons, SWT.PUSH);
- fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton));
- fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$
- fRemoveButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- remove();
- }
- });
-
- createSpacer(buttons);
-
- fImportButton= new Button(buttons, SWT.PUSH);
- fImportButton.setLayoutData(getButtonGridData(fImportButton));
- fImportButton.setText(TemplateMessages.getString("TemplatePreferencePage.import")); //$NON-NLS-1$
- fImportButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- import_();
- }
- });
-
- fExportButton= new Button(buttons, SWT.PUSH);
- fExportButton.setLayoutData(getButtonGridData(fExportButton));
- fExportButton.setText(TemplateMessages.getString("TemplatePreferencePage.export")); //$NON-NLS-1$
- fExportButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- export();
- }
- });
-
- fExportAllButton= new Button(buttons, SWT.PUSH);
- fExportAllButton.setLayoutData(getButtonGridData(fExportAllButton));
- fExportAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.export.all")); //$NON-NLS-1$
- fExportAllButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- exportAll();
- }
- });
-
- createSpacer(buttons);
-
- fEnableAllButton= new Button(buttons, SWT.PUSH);
- fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton));
- fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$
- fEnableAllButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- enableAll(true);
- }
- });
-
- fDisableAllButton= new Button(buttons, SWT.PUSH);
- fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton));
- fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$
- fDisableAllButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- enableAll(false);
- }
- });
-
- fPatternViewer= createViewer(parent);
-
- createSpacer(parent);
-
- //fFormatButton= new Button(parent, SWT.CHECK);
- //fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$
-
- fTableViewer.setInput(fTemplates);
- fTableViewer.setAllChecked(false);
- fTableViewer.setCheckedElements(getEnabledTemplates());
-
- //IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
- //fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES));
-
- updateButtons();
-
- WorkbenchHelp.setHelp(parent, ICHelpContextIds.TEMPLATE_PREFERENCE_PAGE);
-
- return parent;
- }
-
- private Template[] getEnabledTemplates() {
- Template[] templates= fTemplates.getTemplates();
-
- List list= new ArrayList(templates.length);
-
- for (int i= 0; i != templates.length; i++)
- if (templates[i].isEnabled())
- list.add(templates[i]);
-
- return (Template[]) list.toArray(new Template[list.size()]);
- }
-
- private SourceViewer createViewer(Composite parent) {
- Label label= new Label(parent, SWT.NONE);
- label.setText("Preview:");
- GridData data= new GridData();
- data.horizontalSpan= 2;
- label.setLayoutData(data);
-
- SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- viewer.configure(new CSourceViewerConfiguration(tools, null));
- viewer.setEditable(false);
- viewer.setDocument(new Document());
- viewer.getTextWidget().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
-
- Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
- viewer.getTextWidget().setFont(font);
-
- Control control= viewer.getControl();
- data= new GridData(GridData.FILL_BOTH);
- data.heightHint= convertHeightInCharsToPixels(5);
- control.setLayoutData(data);
-
- return viewer;
- }
-
- public void createSpacer(Composite parent) {
- Label spacer= new Label(parent, SWT.NONE);
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.verticalAlignment= GridData.BEGINNING;
- data.heightHint= 4;
- spacer.setLayoutData(data);
- }
-
- private static GridData getButtonGridData(Button button) {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= SWTUtil.getButtonWidthHint(button);
- data.heightHint= SWTUtil.getButtonHeigthHint(button);
-
- return data;
- }
-
- protected void selectionChanged1() {
- IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
-
- if (selection.size() == 1) {
- Template template= (Template) selection.getFirstElement();
- fPatternViewer.getTextWidget().setText(template.getPattern());
- } else {
- fPatternViewer.getTextWidget().setText(""); //$NON-NLS-1$
- }
-
- updateButtons();
- }
-
- private void updateButtons() {
- int selectionCount= ((IStructuredSelection) fTableViewer.getSelection()).size();
- int itemCount= fTableViewer.getTable().getItemCount();
-
- fEditButton.setEnabled(selectionCount == 1);
- fExportButton.setEnabled(selectionCount > 0);
- fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount);
- fEnableAllButton.setEnabled(itemCount > 0);
- fDisableAllButton.setEnabled(itemCount > 0);
- }
-
- protected void add() {
-
- Template template= new Template();
-
- ContextTypeRegistry registry=ContextTypeRegistry.getInstance();
- ContextType type= registry.getContextType(ITemplateEditor.TemplateContextKind.C_GLOBAL_CONTEXT_TYPE);
-
- String contextTypeName;
- if (type != null)
- contextTypeName= type.getName();
- else {
- Iterator iterator= registry.iterator();
- contextTypeName= (String) iterator.next();
- }
- template.setContext(contextTypeName); //$NON-NLS-1$
-
- EditTemplateDialog dialog= new EditTemplateDialog(getShell(), template, false);
- if (dialog.open() == Window.OK) {
- fTemplates.add(template);
- fTableViewer.refresh();
- fTableViewer.setChecked(template, template.isEnabled());
- fTableViewer.setSelection(new StructuredSelection(template));
- }
- }
-
- protected void edit() {
- IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
-
- Object[] objects= selection.toArray();
- if ((objects == null) || (objects.length != 1))
- return;
-
- Template template= (Template) selection.getFirstElement();
- edit(template);
- }
-
- private void edit(Template template) {
- Template newTemplate= new Template(template);
- EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, true);
- if (dialog.open() == Window.OK) {
-
- if (!newTemplate.getName().equals(template.getName()) &&
- MessageDialog.openQuestion(getShell(),
- TemplateMessages.getString("TemplatePreferencePage.question.create.new.title"),
- TemplateMessages.getString("TemplatePreferencePage.question.create.new.message")))
- {
- template= newTemplate;
- fTemplates.add(template);
- fTableViewer.refresh();
- } else {
- template.setName(newTemplate.getName());
- template.setDescription(newTemplate.getDescription());
- template.setContext(newTemplate.getContextTypeName());
- template.setPattern(newTemplate.getPattern());
- fTableViewer.refresh(template);
- }
- fTableViewer.setChecked(template, template.isEnabled());
- fTableViewer.setSelection(new StructuredSelection(template));
- }
- }
-
- protected void import_() {
- FileDialog dialog= new FileDialog(getShell());
- dialog.setText(TemplateMessages.getString("TemplatePreferencePage.import.title")); //$NON-NLS-1$
- dialog.setFilterExtensions(new String[] {TemplateMessages.getString("TemplatePreferencePage.import.extension")}); //$NON-NLS-1$
- String path= dialog.open();
-
- if (path == null)
- return;
-
- try {
- fTemplates.addFromFile(new File(path));
-
- fTableViewer.refresh();
- fTableViewer.setAllChecked(false);
- fTableViewer.setCheckedElements(getEnabledTemplates());
-
- } catch (CoreException e) {
- openReadErrorDialog(e);
- }
- }
-
- protected void exportAll() {
- export(fTemplates);
- }
-
- protected void export() {
- IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
- Object[] templates= selection.toArray();
-
- TemplateSet templateSet= new TemplateSet();
- for (int i= 0; i != templates.length; i++)
- templateSet.add((Template) templates[i]);
-
- export(templateSet);
- }
-
- private void export(TemplateSet templateSet) {
- FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(TemplateMessages.getFormattedString("TemplatePreferencePage.export.title", new Integer(templateSet.getTemplates().length))); //$NON-NLS-1$
- dialog.setFilterExtensions(new String[] {TemplateMessages.getString("TemplatePreferencePage.export.extension")}); //$NON-NLS-1$
- dialog.setFileName(TemplateMessages.getString("TemplatePreferencePage.export.filename")); //$NON-NLS-1$
- String path= dialog.open();
-
- if (path == null)
- return;
-
- File file= new File(path);
-
- if (!file.exists() || confirmOverwrite(file)) {
- try {
- templateSet.saveToFile(file);
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openWriteErrorDialog(e);
- }
- }
- }
-
- private boolean confirmOverwrite(File file) {
- return MessageDialog.openQuestion(getShell(),
- TemplateMessages.getString("TemplatePreferencePage.export.exists.title"),
- TemplateMessages.getFormattedString("TemplatePreferencePage.export.exists.message", file.getAbsolutePath()));
- }
-
- protected void remove() {
- IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
-
- Iterator elements= selection.iterator();
- while (elements.hasNext()) {
- Template template= (Template) elements.next();
- fTemplates.remove(template);
- }
-
- fTableViewer.refresh();
- }
-
- protected void enableAll(boolean enable) {
- Template[] templates= fTemplates.getTemplates();
- for (int i= 0; i != templates.length; i++)
- templates[i].setEnabled(enable);
-
- fTableViewer.setAllChecked(enable);
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {}
-
- /*
- * @see Control#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible)
- setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- //IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
- //fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES));
-
- try {
- fTemplates.restoreDefaults();
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openReadErrorDialog(e);
- }
-
- // refresh
- fTableViewer.refresh();
- fTableViewer.setAllChecked(false);
- fTableViewer.setCheckedElements(getEnabledTemplates());
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- //IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
- //prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection());
-
- try {
- fTemplates.save();
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openWriteErrorDialog(e);
- }
-
- return super.performOk();
- }
-
- /*
- * @see PreferencePage#performCancel()
- */
- public boolean performCancel() {
- try {
- fTemplates.reset();
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openReadErrorDialog(e);
- }
-
- return super.performCancel();
- }
-
- /**
- * Initializes the default values of this page in the preference bundle.
- * Will be called on startup of the JavaPlugin
- */
- public static void initDefaults(IPreferenceStore prefs) {
- prefs.setDefault(PREF_FORMAT_TEMPLATES, true);
- }
-
- public static boolean useCodeFormatter() {
- IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
- return prefs.getBoolean(PREF_FORMAT_TEMPLATES);
- }
-
- private void openReadErrorDialog(CoreException e) {
- ErrorDialog.openError(getShell(),
- TemplateMessages.getString("TemplatePreferencePage.error.read.title"), //$NON-NLS-1$
- null, e.getStatus());
- }
-
- private void openWriteErrorDialog(CoreException e) {
- ErrorDialog.openError(getShell(),
- TemplateMessages.getString("TemplatePreferencePage.error.write.title"), //$NON-NLS-1$
- null, e.getStatus());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
deleted file mode 100644
index 81ca19108ee..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.ICProject;
-
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.util.PixelConverter;
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-
-/**
- */
-public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final String PREF_TRANSLATION_TASK_TAGS= CCorePlugin.TRANSLATION_TASK_TAGS;
- private static final String PREF_TRANSLATION_TASK_PRIORITIES= CCorePlugin.TRANSLATION_TASK_PRIORITIES;
-
- private static final String PRIORITY_HIGH= CCorePlugin.TRANSLATION_TASK_PRIORITY_HIGH;
- private static final String PRIORITY_NORMAL= CCorePlugin.TRANSLATION_TASK_PRIORITY_NORMAL;
- private static final String PRIORITY_LOW= CCorePlugin.TRANSLATION_TASK_PRIORITY_LOW;
-
- public static class TodoTask {
- public String name;
- public String priority;
- }
-
- private static class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return getColumnText(element, 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- TodoTask task= (TodoTask) element;
- if (columnIndex == 0) {
- return task.name;
- } else {
- if (PRIORITY_HIGH.equals(task.priority)) {
- return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.high.priority"); //$NON-NLS-1$
- } else if (PRIORITY_NORMAL.equals(task.priority)) {
- return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.normal.priority"); //$NON-NLS-1$
- } else if (PRIORITY_LOW.equals(task.priority)) {
- return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.low.priority"); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- }
-
- }
-
- private PixelConverter fPixelConverter;
-
- private IStatus fTaskTagsStatus;
- private ListDialogField fTodoTasksList;
-
- public TodoTaskConfigurationBlock(IStatusChangeListener context, ICProject project) {
- super(context, project);
-
- TaskTagAdapter adapter= new TaskTagAdapter();
- String[] buttons= new String[] {
- /* 0 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.add.button"), //$NON-NLS-1$
- /* 1 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.remove.button"), //$NON-NLS-1$
- null,
- /* 3 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.edit.button"), //$NON-NLS-1$
- };
- fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider());
- fTodoTasksList.setDialogFieldListener(adapter);
- fTodoTasksList.setLabelText(PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.label")); //$NON-NLS-1$
- fTodoTasksList.setRemoveButtonIndex(1);
-
- String[] columnsHeaders= new String[] {
- PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.name.column"), //$NON-NLS-1$
- PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.priority.column"), //$NON-NLS-1$
- };
-
- fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
- unpackTodoTasks();
- if (fTodoTasksList.getSize() > 0) {
- fTodoTasksList.selectFirstElement();
- } else {
- fTodoTasksList.enableButton(3, false);
- }
-
- fTaskTagsStatus= new StatusInfo();
- }
-
- protected final String[] getAllKeys() {
- return new String[] {
- PREF_TRANSLATION_TASK_TAGS, PREF_TRANSLATION_TASK_PRIORITIES
- };
- }
-
- public class TaskTagAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(ListDialogField field) {
- return field.getSelectedElements().size() == 1;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doTodoButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- field.enableButton(3, canEdit(field));
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field)) {
- doTodoButtonPressed(3);
- }
- }
-
- public void dialogFieldChanged(DialogField field) {
- validateSettings(PREF_TRANSLATION_TASK_TAGS, null);
- }
-
- }
-
- protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
- setShell(parent.getShell());
-
- Composite markersComposite= createMarkersTabContent(parent);
-
- validateSettings(null, null);
-
- return markersComposite;
- }
-
- private Composite createMarkersTabContent(Composite folder) {
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
-
- Composite markersComposite= new Composite(folder, SWT.NULL);
- markersComposite.setLayout(layout);
-
- fTodoTasksList.doFillIntoGrid(markersComposite, 3);
- LayoutUtil.setHorizontalSpan(fTodoTasksList.getLabelControl(null), 2);
-
- Table table= fTodoTasksList.getTableViewer().getTable();
- GridData data= (GridData)fTodoTasksList.getListControl(null).getLayoutData();
- data.grabExcessHorizontalSpace= true;
- data.verticalAlignment= 0;
- data.heightHint= SWTUtil.getTableHeightHint(table, 6);
-
- return markersComposite;
- }
-
- protected void validateSettings(String changedKey, String newValue) {
- if (changedKey != null) {
- if (PREF_TRANSLATION_TASK_TAGS.equals(changedKey)) {
- fTaskTagsStatus= validateTaskTags();
- } else {
- return;
- }
- } else {
- fTaskTagsStatus= validateTaskTags();
- }
- IStatus status= fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus });
- fContext.statusChanged(status);
- }
-
- private IStatus validateTaskTags() {
- return new StatusInfo();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performOk(boolean)
- */
- public boolean performOk(boolean enabled) {
- packTodoTasks();
- return super.performOk(enabled);
- }
-
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
- String message;
- if (fProject == null) {
- message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
- } else {
- message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
- }
- return new String[] { title, message };
- }
-
- protected String[] getFullReParseDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsparse.title"); //$NON-NLS-1$
- String message;
- if (fProject == null) {
- message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullparse.message"); //$NON-NLS-1$
- } else {
- message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectparse.message"); //$NON-NLS-1$
- }
- return new String[] { title, message };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
- */
- protected void updateControls() {
- unpackTodoTasks();
- }
-
- private void unpackTodoTasks() {
- String currTags= (String) fWorkingValues.get(PREF_TRANSLATION_TASK_TAGS);
- String currPrios= (String) fWorkingValues.get(PREF_TRANSLATION_TASK_PRIORITIES);
- String[] tags= getTokens(currTags, ","); //$NON-NLS-1$
- String[] prios= getTokens(currPrios, ","); //$NON-NLS-1$
- ArrayList elements= new ArrayList(tags.length);
- for (int i= 0; i < tags.length; i++) {
- TodoTask task= new TodoTask();
- task.name= tags[i].trim();
- task.priority= (i < prios.length) ? prios[i] : PRIORITY_NORMAL;
- elements.add(task);
- }
- fTodoTasksList.setElements(elements);
- }
-
- private void packTodoTasks() {
- StringBuffer tags= new StringBuffer();
- StringBuffer prios= new StringBuffer();
- List list= fTodoTasksList.getElements();
- for (int i= 0; i < list.size(); i++) {
- if (i > 0) {
- tags.append(',');
- prios.append(',');
- }
- TodoTask elem= (TodoTask) list.get(i);
- tags.append(elem.name);
- prios.append(elem.priority);
- }
- fWorkingValues.put(PREF_TRANSLATION_TASK_TAGS, tags.toString());
- fWorkingValues.put(PREF_TRANSLATION_TASK_PRIORITIES, prios.toString());
- }
-
- private void doTodoButtonPressed(int index) {
- TodoTask edited= null;
- if (index != 0) {
- edited= (TodoTask) fTodoTasksList.getSelectedElements().get(0);
- }
-
- TodoTaskInputDialog dialog= new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
- if (dialog.open() == TodoTaskInputDialog.OK) {
- if (edited != null) {
- fTodoTasksList.replaceElement(edited, dialog.getResult());
- } else {
- fTodoTasksList.addElement(dialog.getResult());
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
deleted file mode 100644
index ee630116f17..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.cdt.core.CCorePlugin;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.preferences.TodoTaskConfigurationBlock.TodoTask;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ComboDialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
-
-/**
- * Dialog to enter a na new task tag
- */
-public class TodoTaskInputDialog extends StatusDialog {
-
- private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
- public void dialogFieldChanged(DialogField field) {
- doValidation();
- }
- }
-
- private StringDialogField fNameDialogField;
- private ComboDialogField fPriorityDialogField;
-
- private List fExistingNames;
-
- public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) {
- super(parent);
-
- fExistingNames= new ArrayList(existingEntries.size());
- for (int i= 0; i < existingEntries.size(); i++) {
- TodoTask curr= (TodoTask) existingEntries.get(i);
- if (!curr.equals(task)) {
- fExistingNames.add(curr.name);
- }
- }
-
- if (task == null) {
- setTitle(PreferencesMessages.getString("TodoTaskInputDialog.new.title")); //$NON-NLS-1$
- } else {
- setTitle(PreferencesMessages.getString("TodoTaskInputDialog.edit.title")); //$NON-NLS-1$
- }
-
- CompilerTodoTaskInputAdapter adapter= new CompilerTodoTaskInputAdapter();
-
- fNameDialogField= new StringDialogField();
- fNameDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.name.label")); //$NON-NLS-1$
- fNameDialogField.setDialogFieldListener(adapter);
-
- fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
-
- String[] items= new String[] {
- PreferencesMessages.getString("TodoTaskInputDialog.priority.high"), //$NON-NLS-1$
- PreferencesMessages.getString("TodoTaskInputDialog.priority.normal"), //$NON-NLS-1$
- PreferencesMessages.getString("TodoTaskInputDialog.priority.low") //$NON-NLS-1$
- };
-
- fPriorityDialogField= new ComboDialogField(SWT.READ_ONLY);
- fPriorityDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.priority.label")); //$NON-NLS-1$
- fPriorityDialogField.setItems(items);
- if (task != null) {
- if (CCorePlugin.TRANSLATION_TASK_PRIORITY_HIGH.equals(task.priority)) {
- fPriorityDialogField.selectItem(0);
- } else if (CCorePlugin.TRANSLATION_TASK_PRIORITY_NORMAL.equals(task.priority)) {
- fPriorityDialogField.selectItem(1);
- } else {
- fPriorityDialogField.selectItem(2);
- }
- } else {
- fPriorityDialogField.selectItem(1);
- }
- }
-
- public TodoTask getResult() {
- TodoTask task= new TodoTask();
- task.name= fNameDialogField.getText().trim();
- switch (fPriorityDialogField.getSelectionIndex()) {
- case 0 :
- task.priority= CCorePlugin.TRANSLATION_TASK_PRIORITY_HIGH;
- break;
- case 1 :
- task.priority= CCorePlugin.TRANSLATION_TASK_PRIORITY_NORMAL;
- break;
- default :
- task.priority= CCorePlugin.TRANSLATION_TASK_PRIORITY_LOW;
- break;
- }
- return task;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- inner.setLayout(layout);
-
- fNameDialogField.doFillIntoGrid(inner, 2);
- fPriorityDialogField.doFillIntoGrid(inner, 2);
-
- LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
- LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
-
- fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
- return composite;
- }
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fNameDialogField.getText();
- if (newText.length() == 0) {
- status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.enterName")); //$NON-NLS-1$
- } else {
- if (newText.indexOf(',') != -1) {
- status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.comma")); //$NON-NLS-1$
- } else if (fExistingNames.contains(newText)) {
- status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.entryExists")); //$NON-NLS-1$
- } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
- status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.noSpace")); //$NON-NLS-1$
- }
- }
- updateStatus(status);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- WorkbenchHelp.setHelp(newShell, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
deleted file mode 100644
index 61a03d9d461..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
-
-/*
- * The page to configure the compiler options.
- */
-public class TodoTaskPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener {
-
- public static final String ID= "org.eclipse.cdt.ui.propertyPages.TodoTaskPropertyPage"; //$NON-NLS-1$
-
- private TodoTaskConfigurationBlock fConfigurationBlock;
-
- public TodoTaskPreferencePage() {
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.getString("TodoTaskPreferencePage.description")); //$NON-NLS-1$
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.getString("TodoTaskPreferencePage.title")); //$NON-NLS-1$
-
- fConfigurationBlock= new TodoTaskConfigurationBlock(this, null);
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- // added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.TODO_TASK_PREFERENCE_PAGE);
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Control result= fConfigurationBlock.createContents(parent);
- Dialog.applyDialogFont(result);
- return result;
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (!fConfigurationBlock.performOk(true)) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- fConfigurationBlock.performDefaults();
- super.performDefaults();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
- */
- public void statusChanged(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java
deleted file mode 100644
index f7a87a8fc2a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceNode;
-import org.eclipse.jface.preference.IPreferencePage;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.preference.PreferenceManager;
-import org.eclipse.jface.preference.PreferenceNode;
-
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-
-/**
- * Property page used to configure project specific task tags settings
- */
-public class TodoTaskPropertyPage extends PropertyPage {
-
- private TodoTaskConfigurationBlock fConfigurationBlock;
- private Control fConfigurationBlockControl;
- private ControlEnableState fBlockEnableState;
- private SelectionButtonDialogField fUseWorkspaceSettings;
- private SelectionButtonDialogField fChangeWorkspaceSettings;
- private SelectionButtonDialogField fUseProjectSettings;
- private IStatus fBlockStatus;
-
-
- public TodoTaskPropertyPage() {
- fBlockStatus= new StatusInfo();
- fBlockEnableState= null;
-
- IDialogFieldListener listener= new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
- };
-
- fUseWorkspaceSettings= new SelectionButtonDialogField(SWT.RADIO);
- fUseWorkspaceSettings.setDialogFieldListener(listener);
- fUseWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.label")); //$NON-NLS-1$
-
- fChangeWorkspaceSettings= new SelectionButtonDialogField(SWT.PUSH);
- fChangeWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.change")); //$NON-NLS-1$
- fChangeWorkspaceSettings.setDialogFieldListener(listener);
-
- fUseWorkspaceSettings.attachDialogField(fChangeWorkspaceSettings);
-
- fUseProjectSettings= new SelectionButtonDialogField(SWT.RADIO);
- fUseProjectSettings.setDialogFieldListener(listener);
- fUseProjectSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useprojectsettings.label")); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.TODO_TASK_PROPERTY_PAGE);
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- IStatusChangeListener listener= new IStatusChangeListener() {
- public void statusChanged(IStatus status) {
- fBlockStatus= status;
- doStatusChanged();
- }
- };
- fConfigurationBlock= new TodoTaskConfigurationBlock(listener, getProject());
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 1;
- composite.setLayout(layout);
-
- fUseWorkspaceSettings.doFillIntoGrid(composite, 1);
- LayoutUtil.setHorizontalGrabbing(fUseWorkspaceSettings.getSelectionButton(null));
-
- fChangeWorkspaceSettings.doFillIntoGrid(composite, 1);
- GridData data= (GridData) fChangeWorkspaceSettings.getSelectionButton(null).getLayoutData();
- data.horizontalIndent= convertWidthInCharsToPixels(3);
- data.horizontalAlignment= GridData.BEGINNING;
-
- fUseProjectSettings.doFillIntoGrid(composite, 1);
-
- data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL );
- data.horizontalSpan= 1;
- data.horizontalIndent= convertWidthInCharsToPixels(2);
-
- fConfigurationBlockControl= fConfigurationBlock.createContents(composite);
- fConfigurationBlockControl.setLayoutData(data);
-
- boolean useProjectSettings= fConfigurationBlock.hasProjectSpecificOptions();
-
- fUseProjectSettings.setSelection(useProjectSettings);
- fUseWorkspaceSettings.setSelection(!useProjectSettings);
-
- updateEnableState();
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- private boolean useProjectSettings() {
- return fUseProjectSettings.isSelected();
- }
-
- private void doDialogFieldChanged(DialogField field) {
- if (field == fChangeWorkspaceSettings) {
- TodoTaskPreferencePage page= new TodoTaskPreferencePage();
- showPreferencePage(TodoTaskPreferencePage.ID, page);
- } else {
- updateEnableState();
- doStatusChanged();
- }
- }
- /**
- * Method statusChanged.
- */
- private void doStatusChanged() {
- updateStatus(useProjectSettings() ? fBlockStatus : new StatusInfo());
- }
-
- /**
- * Method getProject.
- */
- private ICProject getProject() {
- return (ICProject) getElement().getAdapter(ICElement.class);
- }
-
- private void updateEnableState() {
- if (useProjectSettings()) {
- if (fBlockEnableState != null) {
- fBlockEnableState.restore();
- fBlockEnableState= null;
- }
- } else {
- if (fBlockEnableState == null) {
- fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- if (useProjectSettings()) {
- fUseProjectSettings.setSelection(false);
- fUseWorkspaceSettings.setSelection(true);
- fConfigurationBlock.performDefaults();
- }
- super.performDefaults();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- return fConfigurationBlock.performOk(useProjectSettings());
- }
-
- private void updateStatus(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- private boolean showPreferencePage(String id, IPreferencePage page) {
- final IPreferenceNode targetNode = new PreferenceNode(id, page);
-
- PreferenceManager manager = new PreferenceManager();
- manager.addToRoot(targetNode);
- final PreferenceDialog dialog = new PreferenceDialog(getShell(), manager);
- final boolean [] result = new boolean[] { false };
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- dialog.create();
- dialog.setMessage(targetNode.getLabelText());
- result[0]= (dialog.open() == PreferenceDialog.OK);
- }
- });
- return result[0];
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CElementLabels.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
deleted file mode 100644
index d9b4137ad13..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 24, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CElementLabels {
-
- /**
- * Method names contain parameter types.
- * e.g. <code>foo(int)</code>
- */
- public final static int M_PARAMETER_TYPES= 1 << 0;
-
- /**
- * Method names contain parameter names.
- * e.g. <code>foo(index)</code>
- */
- public final static int M_PARAMETER_NAMES= 1 << 1;
-
- /**
- * Method names contain thrown exceptions.
- * e.g. <code>foo throw( IOException )</code>
- */
- public final static int M_EXCEPTIONS= 1 << 2;
-
- /**
- * Method names contain return type (appended)
- * e.g. <code>foo : int</code>
- */
- public final static int M_APP_RETURNTYPE= 1 << 3;
-
- /**
- * Method names contain return type (appended)
- * e.g. <code>int foo</code>
- */
- public final static int M_PRE_RETURNTYPE= 1 << 4;
-
- /**
- * Method names are fully qualified.
- * e.g. <code>java.util.Vector.size</code>
- */
- public final static int M_FULLY_QUALIFIED= 1 << 5;
-
- /**
- * Method names are post qualified.
- * e.g. <code>size - java.util.Vector</code>
- */
- public final static int M_POST_QUALIFIED= 1 << 6;
-
- /**
- * Initializer names are fully qualified.
- * e.g. <code>java.util.Vector.{ ... }</code>
- */
- public final static int I_FULLY_QUALIFIED= 1 << 7;
-
- /**
- * Type names are post qualified.
- * e.g. <code>{ ... } - java.util.Map</code>
- */
- public final static int I_POST_QUALIFIED= 1 << 8;
-
- /**
- * Field names contain the declared type (appended)
- * e.g. <code>int fHello</code>
- */
- public final static int F_APP_TYPE_SIGNATURE= 1 << 9;
-
- /**
- * Field names contain the declared type (prepended)
- * e.g. <code>fHello : int</code>
- */
- public final static int F_PRE_TYPE_SIGNATURE= 1 << 10;
-
- /**
- * Fields names are fully qualified.
- * e.g. <code>java.lang.System.out</code>
- */
- public final static int F_FULLY_QUALIFIED= 1 << 11;
-
- /**
- * Fields names are post qualified.
- * e.g. <code>out - java.lang.System</code>
- */
- public final static int F_POST_QUALIFIED= 1 << 12;
-
- /**
- * Type names are fully qualified.
- * e.g. <code>java.util.Map.MapEntry</code>
- */
- public final static int T_FULLY_QUALIFIED= 1 << 13;
-
- /**
- * Type names are type container qualified.
- * e.g. <code>Map.MapEntry</code>
- */
- public final static int T_CONTAINER_QUALIFIED= 1 << 14;
-
- /**
- * Type names are post qualified.
- * e.g. <code>MapEntry - java.util.Map</code>
- */
- public final static int T_POST_QUALIFIED= 1 << 15;
-
- /**
- * Declarations (import container / declarartion, package declarartion) are qualified.
- * e.g. <code>java.util.Vector.class/import container</code>
- */
- public final static int D_QUALIFIED= 1 << 16;
-
- /**
- * Declarations (import container / declarartion, package declarartion) are post qualified.
- * e.g. <code>import container - java.util.Vector.class</code>
- */
- public final static int D_POST_QUALIFIED= 1 << 17;
-
- /**
- * Class file names are fully qualified.
- * e.g. <code>java.util.Vector.class</code>
- */
- public final static int CF_QUALIFIED= 1 << 18;
-
- /**
- * Class file names are post qualified.
- * e.g. <code>Vector.class - java.util</code>
- */
- public final static int CF_POST_QUALIFIED= 1 << 19;
-
- /**
- * Compilation unit names are fully qualified.
- * e.g. <code>java.util.Vector.java</code>
- */
- public final static int CU_QUALIFIED= 1 << 20;
-
- /**
- * Compilation unit names are post qualified.
- * e.g. <code>Vector.java - java.util</code>
- */
- public final static int CU_POST_QUALIFIED= 1 << 21;
-
- /**
- * Package names are qualified.
- * e.g. <code>MyProject/src/java.util</code>
- */
- public final static int P_QUALIFIED= 1 << 22;
-
- /**
- * Package names are post qualified.
- * e.g. <code>java.util - MyProject/src</code>
- */
- public final static int P_POST_QUALIFIED= 1 << 23;
-
- /**
- * Package Fragment Roots contain variable name if from a variable.
- * e.g. <code>JRE_LIB - c:\java\lib\rt.jar</code>
- */
- public final static int ROOT_VARIABLE= 1 << 24;
-
- /**
- * Package Fragment Roots contain the project name if not an archive (prepended).
- * e.g. <code>MyProject/src</code>
- */
- public final static int ROOT_QUALIFIED= 1 << 25;
-
- /**
- * Package Fragment Roots contain the project name if not an archive (appended).
- * e.g. <code>src - MyProject</code>
- */
- public final static int ROOT_POST_QUALIFIED= 1 << 26;
-
- /**
- * Add root path to all elements except Package Fragment Roots and Java projects.
- * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
- * Option only applies to getElementLabel
- */
- public final static int APPEND_ROOT_PATH= 1 << 27;
-
- /**
- * Add root path to all elements except Package Fragment Roots and Java projects.
- * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
- * Option only applies to getElementLabel
- */
- public final static int PREPEND_ROOT_PATH= 1 << 28;
-
- /**
- * Package names are compressed.
- * e.g. <code>o*.e*.search</code>
- */
- public final static int P_COMPRESSED= 1 << 29;
-
- /**
- * Post qualify referenced package fragement roots. For example
- * <code>jdt.jar - org.eclipse.jdt.ui</code> if the jar is referenced
- * from another project.
- */
- public final static int REFERENCED_ROOT_POST_QUALIFIED= 1 << 30;
-
- /**
- * Qualify all elements
- */
- public final static int ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED | P_QUALIFIED | ROOT_QUALIFIED;
-
- /**
- * Post qualify all elements
- */
- public final static int ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED | P_POST_QUALIFIED | ROOT_POST_QUALIFIED;
-
- /**
- * Default options (M_PARAMETER_TYPES enabled)
- */
- public final static int ALL_DEFAULT= M_PARAMETER_TYPES;
-
- /**
- * Default qualify options (All except Root and Package)
- */
- public final static int DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED;
-
- /**
- * Default post qualify options (All except Root and Package)
- */
- public final static int DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED;
-
-
- public final static String CONCAT_STRING= CSearchMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
- public final static String COMMA_STRING = CSearchMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$
- public final static String DECL_STRING = CSearchMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
-
- public static String getTextLabel(Object obj, int flags) {
- if (obj instanceof ICElement) {
- return getElementLabel((ICElement) obj, flags);
- } else if (obj instanceof IAdaptable) {
- IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
- if (wbadapter != null) {
- return wbadapter.getLabel(obj);
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- public static String getElementLabel(ICElement element, int flags) {
- StringBuffer buf= new StringBuffer(60);
- getElementLabel(element, flags, buf);
- return buf.toString();
- }
-
- public static void getElementLabel(ICElement element, int flags, StringBuffer buf) {
- int type= element.getElementType();
-
- switch( type ){
- case ICElement.C_METHOD :
- getMethodLabel( (IMethod) element, flags, buf );
- break;
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- // getTypeLabel( (IType) element, flags, buf );
- }
- }
-
- public static void getMethodLabel( IMethod method, int flags, StringBuffer buf ) {
- //return type
- if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) {
- buf.append( method.getReturnType() );
- buf.append( ' ' );
- }
-
- //qualification
- if( getFlag( flags, M_FULLY_QUALIFIED ) ){
- getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
- buf.append( "::" );
- }
-
- buf.append( method.getElementName() );
-
- //parameters
- if( getFlag( flags, M_PARAMETER_TYPES | M_PARAMETER_NAMES ) ) {
- buf.append('(');
-
- String[] types = getFlag(flags, M_PARAMETER_TYPES) ? method.getParameterTypes() : null;
- String[] names = null;//(getFlag(flags, M_PARAMETER_NAMES) && method.exists()) ? method.getParameterNames() : null;
-
- int nParams = ( types != null ) ? types.length : names.length;
-
- for (int i= 0; i < nParams; i++) {
- if (i > 0) {
- buf.append( COMMA_STRING ); //$NON-NLS-1$
- }
-
- if (types != null) {
- buf.append( types[i] );
- }
-
- if (names != null) {
- if (types != null) {
- buf.append(' ');
- }
- buf.append( names[i] );
- }
- }
- buf.append(')');
- }
-
- //exceptions
- if( getFlag( flags, M_EXCEPTIONS ) && method.exists() ){
- String [] types = method.getExceptions();
- if (types.length > 0) {
- buf.append(" throw( "); //$NON-NLS-1$
- for (int i= 0; i < types.length; i++) {
- if (i > 0) {
- buf.append(COMMA_STRING);
- }
- buf.append( types[i] );
- }
- buf.append( " )" );
- }
- }
-
- if( getFlag( flags, M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor()) {
- buf.append( DECL_STRING );
- buf.append( method.getReturnType() );
- }
-
- // post qualification
- if( getFlag(flags, M_POST_QUALIFIED)) {
- buf.append( CONCAT_STRING );
- getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
- }
- }
-
- public static void getTypeLabel(ICElement type, int flags, StringBuffer buf) {
- if( !(type instanceof IStructure) ){
- return;
- }
- }
-
-
- private static boolean getFlag(int flags, int flag) {
- return (flags & flag) != 0;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
deleted file mode 100644
index 7d0ead2bf6a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchMessages {
- private static final String RESOURCE_BUNDLE= CSearchMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private CSearchMessages() {
- }
-
- 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
- */
- 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);
- }
-
- /**
- * 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
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
deleted file mode 100644
index 55a28c8b7d6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
+++ /dev/null
@@ -1,172 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-group.search=S&earch
-group.declarations= Dec&larations
-group.references= Re&ferences
-group.readReferences= &Read Access
-group.writeReferences= &Write Access
-group.implementors= &Implementors
-
-Search.Error.search.title=Search Error
-Search.Error.search.message=An error occurred during the search operation
-
-Search.Error.javaElementAccess.title=Search Error
-Search.Error.javaElementAccess.message=An error occurred while accessing a Java element
-
-Search.Error.markerAttributeAccess.title=Search Error
-Search.Error.markerAttributeAccess.message=An error occurred while accessing a marker attribute
-
-Search.Error.createJavaElement.title=Search Error
-Search.Error.createJavaElement.message=An error occurred while creating a Java element
-
-Search.Error.openEditor.title=Search Error
-Search.Error.openEditor.message=Could not open the editor
-
-Search.Error.codeResolve= Code resolve error
-
-Search.Error.setDescription.title=Search Error
-Search.Error.setDescription.message=Cannot save workspace description
-
-SearchElementSelectionDialog.title=Search
-SearchElementSelectionDialog.message=Select the element to search for.
-
-CSearchResultCollector.match= 1 match
-CSearchResultCollector.matches= {0} matches
-CSearchResultCollector.done= Search done: {0}.
-CSearchResultCollector.searching= Searching...
-
-Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
-Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
-Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
-
-CSearchPage.searchFor.label= Search For
-CSearchPage.searchFor.type= &Type
-CSearchPage.searchFor.namespace= Names&pace
-CSearchPage.searchFor.method= &Method
-CSearchPage.searchFor.function= F&unction
-CSearchPage.searchFor.field= &Field
-CSearchPage.searchFor.variable= &Variable
-CSearchPage.searchFor.class= &Class
-CSearchPage.searchFor.struct= &Struct
-CSearchPage.searchFor.union= U&nion
-CSearchPage.searchFor.enum= &Enumeration
-CSearchPage.searchFor.any= An&y Element
-CSearchPage.searchFor.classStruct= &Class / Struct
-
-CSearchPage.limitTo.label= Limit To
-CSearchPage.limitTo.declarations= Dec&larations
-CSearchPage.limitTo.definitions= &Definitions
-CSearchPage.limitTo.references= &References
-CSearchPage.limitTo.allOccurrences= All &Occurrences
-
-CSearchPage.expression.label= Se&arch string (* = any string, ? = any character):
-CSearchPage.expression.caseSensitive= Case sens&itive
-
-# Concatenate two working set names e.g. "Source, Lib"
-SearchUtil.workingSetConcatenation= {0}, {1}
-
-Search.FindDeclarationAction.label= &Workspace
-Search.FindDeclarationAction.tooltip= Search for Declarations of the Selected Element in the Workspace
-
-Search.FindDeclarationsInWorkingSetAction.label= Working &Set...
-Search.FindDeclarationsInWorkingSetAction.tooltip= Search for Declarations of the Selected Element in a Working Set
-
-Search.FindHierarchyDeclarationsAction.label= &Hierarchy
-Search.FindHierarchyDeclarationsAction.tooltip= Search for Declarations of the Selected Element in its Hierarchy
-
-Search.FindImplementorsAction.label= &Workspace
-Search.FindImplementorsAction.tooltip= Search for Implementors of the Selected Interface
-
-Search.FindImplementorsInWorkingSetAction.label= Working &Set...
-Search.FindImplementorsInWorkingSetAction.tooltip= Search for Implementors of the Selected Interface in a Working Set
-
-Search.FindReferencesAction.label= &Workspace
-Search.FindReferencesAction.tooltip= Search for References to the Selected Element in the Workspace
-
-Search.FindReferencesAction.BinPrimConstWarnDialog.title= Search for References to a Binary Constant
-Search.FindReferencesAction.BinPrimConstWarnDialog.message= Matches to this constant will only be discovered in source files and binary files where the constant value is not inlined.
-
-Search.FindReferencesInWorkingSetAction.label= Working &Set...
-Search.FindReferencesInWorkingSetAction.tooltip= Search for References to the Selected Element in a Working Set
-
-Search.FindHierarchyReferencesAction.label= &Hierarchy
-Search.FindHierarchyReferencesAction.tooltip= Search for References of the Selected Element in its Hierarchy
-
-Search.FindReadReferencesAction.label= &Workspace
-Search.FindReadReferencesAction.tooltip= Search for Read References to the Selected Element in the Workspace
-
-Search.FindReadReferencesInWorkingSetAction.label= Working &Set...
-Search.FindReadReferencesInWorkingSetAction.tooltip= Search for Read References to the Selected Element in a Working Set
-
-Search.FindReadReferencesInHierarchyAction.label= &Hierarchy
-Search.FindReadReferencesInHierarchyAction.tooltip= Search for Read References of the Selected Element in its Hierarchy
-
-Search.FindWriteReferencesAction.label= &Workspace
-Search.FindWriteReferencesAction.tooltip= Search for Write References to the Selected Element in the Workspace
-
-Search.FindWriteReferencesInWorkingSetAction.label= Working &Set...
-Search.FindWriteReferencesInWorkingSetAction.tooltip= Search for Write References to the Selected Element in a Working Set
-
-Search.FindWriteReferencesInHierarchyAction.label= &Hierarchy
-Search.FindWriteReferencesInHierarchyAction.tooltip= Search for Write References of the Selected Element in its Hierarchy
-
-Search.FindOccurrencesInFile.label= Occurre&nces in File
-Search.FindOccurrencesInFile.tooltip= Find occurrences of selected element in the editor
-
-FindOccurrencesEngine.noSource.text= No source available. To perform this operation you need to attach source.
-FindOccurrencesEngine.noJavaElement.text= Cannot search for the current selection. Please select a valid Java element name.
-FindOccurrencesEngine.cannotParse.text= Cannot analyze the compilation unit or class file.
-
-
-JavaSearchOperation.default_package=(default package)
-
-# The first argument will be replaced by the pattern and the second by the scope
-CSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
-CSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
-CSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
-CSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
-CSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
-CSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
-
-# The first argument will be replaced by the pattern, the second by the count and the last by the scope
-CSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
-CSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
-CSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
-CSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
-CSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
-CSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
-
-
-# The first argument will be replaced by the element name and the second one by the file name
-JavaSearchInFile.singularPostfix={0} - 1 Occurrence in {1}
-# The first argument will be replaced by the element name, the second by the count and the last by the file name
-JavaSearchInFile.pluralPostfix={0} - {1} Occurrences in {2}
-
-JavaElementAction.typeSelectionDialog.title=Search
-JavaElementAction.typeSelectionDialog.message=&Select the type to search:
-JavaElementAction.error.open.message=An exception occurred while opening the type.
-
-JavaElementAction.operationUnavailable.title= Operation Unavailable
-JavaElementAction.operationUnavailable.generic= The operation is unavailable on the current selection. Please select a valid Java element name.
-JavaElementAction.operationUnavailable.field= The operation is unavailable on the current selection. Please select the name of a field.
-JavaElementAction.operationUnavailable.interface= The operation is unavailable on the current selection. Please select the name of an interface.
-
-CSearchResultLabelProvider.potentialMatch= \ (inexact)
-
-WorkspaceScope= Workspace
-WorkingSetScope= Working Set - {0}
-SelectionScope= Selection
-HierarchyScope= Hierarchy - {0}
-
-CElementLabels.concat_string=\ -\
-CElementLabels.comma_string=,\
-CElementLabels.declseparator_string=\ :\ \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
deleted file mode 100644
index 79f62ccf2b1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.core.search.matching.OrPattern;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchOperation implements IRunnableWithProgress,ICSearchConstants{
- public CSearchOperation(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector) {
- this( workspace, limitTo, scope, scopeDescription, collector );
- _stringPattern = pattern;
- _caseSensitive = caseSensitive;
- _searchFor = searchFor;
- }
-
- public CSearchOperation(IWorkspace workspace, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector ){
- _workspace = workspace;
- _limitTo = limitTo;
- _scope = scope;
- _scopeDescription = scopeDescription;
- _collector = collector;
- _collector.setOperation( this );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void run(IProgressMonitor monitor)throws InvocationTargetException
- {
- _collector.setProgressMonitor( monitor );
-
- SearchEngine engine = new SearchEngine( CUIPlugin.getSharedWorkingCopies() );
-
- ICSearchPattern pattern = null;
- if( _searchFor.size() > 1 ){
- OrPattern orPattern = new OrPattern();
- for (Iterator iter = _searchFor.iterator(); iter.hasNext();) {
- SearchFor element = (SearchFor)iter.next();
- orPattern.addPattern( SearchEngine.createSearchPattern( _stringPattern, element, _limitTo, _caseSensitive ) );
- }
-
- pattern = orPattern;
-
- } else {
- Iterator iter = _searchFor.iterator();
- pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
- }
-
- engine.search( _workspace, pattern, _scope, _collector, false );
-
-
- }
-
- /**
- * @return
- */
- public String getSingularLabel() {
- String desc = null;
-
- //if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- //} else {
- desc = _stringPattern;
- //}
-
- String [] args = new String [] { desc, _scopeDescription };
-
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularDeclarationsPostfix", args ); //$NON_NLS-1$
- } else if( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurrencesPostfix", args ); //$NON_NLS-1$
- }
- }
-
- /**
- * @return
- */
- public String getPluralLabelPattern() {
- String desc = null;
-
- // if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- // } else {
- desc = _stringPattern;
- // }
-
- String [] args = new String [] { desc, "{0}", _scopeDescription };
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralDeclarationsPostfix", args ); //$NON_NLS-1$
- } else if ( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurrencesPostfix", args ); //$NON_NLS-1$
- }
- }
-
- /**
- * @return
- */
- public ImageDescriptor getImageDescriptor() {
- if( _limitTo == ICSearchConstants.DECLARATIONS ){
- return CPluginImages.DESC_OBJS_SEARCH_DECL;
- } else {
- return CPluginImages.DESC_OBJS_SEARCH_REF;
- }
- }
-
- private CSearchResultCollector _collector;
- private IWorkspace _workspace;
- //private ICElement _elementPattern;
- private ICSearchScope _scope;
- private String _stringPattern;
- private String _scopeDescription;
- private boolean _caseSensitive;
- private LimitTo _limitTo;
- private List _searchFor;
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
deleted file mode 100644
index 8340503eec7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
+++ /dev/null
@@ -1,671 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 10, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.search.internal.ui.util.RowLayouter;
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-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.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.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchPage extends DialogPage implements ISearchPage, ICSearchConstants {
-
- public static final String EXTENSION_POINT_ID= "org.eclipse.cdt.ui.CSearchPage"; //$NON-NLS-1$
-
- public boolean performAction() {
- SearchUI.activateSearchResultView();
-
- SearchPatternData data = getPatternData();
- IWorkspace workspace = CUIPlugin.getWorkspace();
-
- ICSearchScope scope = null;
- String scopeDescription = ""; //$NON-NLS-1$
-
- switch( getContainer().getSelectedScope() ) {
- case ISearchPageContainer.SELECTION_SCOPE:
- if( fStructuredSelection != null && fStructuredSelection.iterator().hasNext() ){
- scopeDescription = CSearchMessages.getString("SelectionScope"); //$NON-NLS-1$
- scope = CSearchScopeFactory.getInstance().createCSearchScope(fStructuredSelection);
- break;
- }
- /* else fall through to workspace scope */
- case ISearchPageContainer.WORKSPACE_SCOPE:
- scopeDescription = CSearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
- scope = SearchEngine.createWorkspaceScope();
- break;
- case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- // should not happen - just to be sure
- if (workingSets == null || workingSets.length < 1)
- return false;
- scopeDescription = CSearchMessages.getFormattedString("WorkingSetScope", CSearchUtil.toString(workingSets)); //$NON-NLS-1$
- scope= CSearchScopeFactory.getInstance().createCSearchScope(getContainer().getSelectedWorkingSets());
- CSearchUtil.updateLRUWorkingSets(getContainer().getSelectedWorkingSets());
- }
-
- data.cElement= null;
-
- CSearchResultCollector collector= new CSearchResultCollector();
-
- List searching = null;
-
- if( data.searchFor.contains( UNKNOWN_SEARCH_FOR ) ){
- //UNKNOWN_SEARCH_FOR means search for anything, make a list with everything
- searching = new LinkedList();
- for( int i = 0; i < fSearchFor.length - 1; i++ ){
- searching.add( fSearchForValues[ i ] );
- }
-
- //include those items not represented in the UI
- searching.add( MACRO );
- searching.add( TYPEDEF );
- } else {
- searching = data.searchFor;
- }
-
- CSearchOperation op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, searching, data.limitTo, scope, scopeDescription, collector);
-
-
- try {
- getContainer().getRunnableContext().run(true, true, op);
- } catch (InvocationTargetException ex) {
- Shell shell = getControl().getShell();
- //ExceptionHandler.handle(ex, shell, CSearchMessages.getString("Search.Error.search.title"), CSearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return false;
- } catch (InterruptedException ex) {
- return false;
- }
- return true;
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits( parent );
- readConfiguration();
-
- GridData gd;
- Composite result = new Composite( parent, SWT.NONE );
- GridLayout layout = new GridLayout( 2, false );
- layout.horizontalSpacing = 10;
- result.setLayout( layout );
- result.setLayoutData( new GridData(GridData.FILL_HORIZONTAL) );
-
- RowLayouter layouter = new RowLayouter( layout.numColumns );
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
-
- layouter.setDefaultGridData( gd, 0 );
- layouter.setDefaultGridData( gd, 1 );
- layouter.setDefaultSpan();
-
- layouter.perform( createExpression(result) );
- layouter.perform( createSearchFor(result), createLimitTo(result), -1 );
-
- SelectionAdapter cElementInitializer = new SelectionAdapter() {
- public void widgetSelected( SelectionEvent event ) {
- if( getSearchFor() == fInitialData.searchFor )
- fCElement= fInitialData.cElement;
- else
- fCElement= null;
- handleAllElements( event );
- setLimitTo( getSearchFor() );
- updateCaseSensitiveCheckbox();
- }
- };
-
- for( int i = 0; i < fSearchFor.length; i++ ){
- fSearchFor[ i ].addSelectionListener( cElementInitializer );
- }
-
- setControl( result );
-
- Dialog.applyDialogFont( result );
- WorkbenchHelp.setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);
- }
-
- private Control createExpression( Composite parent ) {
- Composite result = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- result.setLayout(layout);
- GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL );
- gd.horizontalSpan = 2;
- gd.horizontalIndent = 0;
- result.setLayoutData( gd );
-
- // Pattern text + info
- Label label = new Label( result, SWT.LEFT );
- label.setText( CSearchMessages.getString( "CSearchPage.expression.label" ) ); //$NON-NLS-1$
- gd = new GridData( GridData.BEGINNING );
- gd.horizontalSpan = 2;
- label.setLayoutData( gd );
-
- // Pattern combo
- fPattern = new Combo( result, SWT.SINGLE | SWT.BORDER );
- fPattern.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- handlePatternSelected();
- }
- });
-
- fPattern.addModifyListener( new ModifyListener() {
- public void modifyText( ModifyEvent e ) {
- getContainer().setPerformActionEnabled( getPattern().length() > 0 );
- updateCaseSensitiveCheckbox();
- }
- });
-
- gd = new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL );
- gd.horizontalIndent = -gd.horizontalIndent;
- fPattern.setLayoutData( gd );
-
-
- // Ignore case checkbox
- fCaseSensitive= new Button(result, SWT.CHECK);
- fCaseSensitive.setText(CSearchMessages.getString("CSearchPage.expression.caseSensitive")); //$NON-NLS-1$
- gd= new GridData();
- fCaseSensitive.setLayoutData(gd);
- fCaseSensitive.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- fIsCaseSensitive= fCaseSensitive.getSelection();
- writeConfiguration();
- }
- });
-
- return result;
- }
-
- private void handleAllElements( SelectionEvent event ){
- Button allElements = fSearchFor[ fSearchFor.length - 1 ];
- if( event.widget == allElements ){
- for( int i = 0; i < fSearchFor.length - 1; i++ )
- fSearchFor[i].setEnabled( ! allElements.getSelection() );
- }
- }
-
- private void handlePatternSelected() {
- if( fPattern.getSelectionIndex() < 0 )
- return;
-
- int index = fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();
- fInitialData = (SearchPatternData) fgPreviousSearchPatterns.get( index );
-
- updateSelections();
-
- if( fInitialData.workingSets != null )
- getContainer().setSelectedWorkingSets( fInitialData.workingSets );
- else
- getContainer().setSelectedScope( fInitialData.scope );
- }
-
- private String getPattern() {
- return fPattern.getText();
- }
-
- private Control createLimitTo( Composite parent ) {
- Group result = new Group(parent, SWT.NONE);
- result.setText( CSearchMessages.getString("CSearchPage.limitTo.label") ); //$NON-NLS-1$
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- result.setLayout( layout );
-
- fLimitTo = new Button[fLimitToText.length];
- for( int i = 0; i < fLimitToText.length; i++ ){
- Button button = new Button(result, SWT.RADIO);
- button.setText( fLimitToText[i] );
- fLimitTo[i] = button;
- }
-
- // Fill with dummy radio buttons
- Button filler= new Button(result, SWT.RADIO);
- filler.setVisible(false);
- filler= new Button(result, SWT.RADIO);
- filler.setVisible(false);
-
- return result;
- }
-
- private LimitTo getLimitTo() {
- for (int i= 0; i < fLimitTo.length; i++) {
- if (fLimitTo[i].getSelection())
- return fLimitToValues[ i ];
- }
- return null;
- }
-
- private void setLimitTo( List searchFor ) {
- HashSet set = new HashSet();
-
- set.add( DECLARATIONS );
- set.add( REFERENCES );
- set.add( ALL_OCCURRENCES );
-
- for (Iterator iter = searchFor.iterator(); iter.hasNext();) {
- SearchFor element = (SearchFor) iter.next();
- if( element == FUNCTION || element == METHOD || element == VAR ||
- element == FIELD || element == NAMESPACE || element == UNKNOWN_SEARCH_FOR ){
- set.add( DEFINITIONS );
- break;
- }
- }
-
- for( int i = 0; i < fLimitTo.length; i++ )
- fLimitTo[ i ].setEnabled( set.contains( fLimitToValues[ i ] ) );
- }
-
- private Control createSearchFor(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.getString("CSearchPage.searchFor.label")); //$NON-NLS-1$
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- result.setLayout(layout);
-
- fSearchFor= new Button[fSearchForText.length];
- for (int i= 0; i < fSearchForText.length; i++) {
- Button button= new Button(result, SWT.CHECK);
- button.setText(fSearchForText[i]);
- fSearchFor[i]= button;
- }
-
- return result;
- }
-
- private List getSearchFor() {
- List search = new LinkedList( );
-
-// boolean all = fSearchFor[ fSearchFor.length - 1 ].getSelection();
-
- for (int i= 0; i < fSearchFor.length; i++) {
- if( fSearchFor[i].getSelection() /*|| all */)
- search.add( fSearchForValues[i] );
- }
-
- return search;
- }
-
- public void setContainer(ISearchPageContainer container) {
- fContainer = container;
- }
-
- private ISearchPageContainer getContainer() {
- return fContainer;
- }
-
-
- private IDialogSettings getDialogSettings() {
- IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
- fDialogSettings = settings.getSection( PAGE_NAME );
- if( fDialogSettings == null )
- fDialogSettings = settings.addNewSection( PAGE_NAME );
-
- return fDialogSettings;
- }
-
- private void readConfiguration() {
- IDialogSettings s = getDialogSettings();
- fIsCaseSensitive = s.getBoolean( STORE_CASE_SENSITIVE );
- }
-
- private void writeConfiguration() {
- IDialogSettings s = getDialogSettings();
- s.put( STORE_CASE_SENSITIVE, fIsCaseSensitive );
- }
-
- public void setVisible(boolean visible) {
- if (visible && fPattern != null) {
- if (fFirstTime) {
- fFirstTime= false;
- // Set item and text here to prevent page from resizing
- fPattern.setItems(getPreviousSearchPatterns());
- initSelections();
- }
- fPattern.setFocus();
- getContainer().setPerformActionEnabled(fPattern.getText().length() > 0);
- }
- super.setVisible(visible);
- }
-
- private void updateCaseSensitiveCheckbox() {
- if (fInitialData != null && getPattern().equals(fInitialData.pattern) && fCElement != null) {
- fCaseSensitive.setEnabled(false);
- fCaseSensitive.setSelection(true);
- }
- else {
- fCaseSensitive.setEnabled(true);
- fCaseSensitive.setSelection(fIsCaseSensitive);
- }
- }
-
- private void initSelections() {
- fStructuredSelection = asStructuredSelection();
- fInitialData = tryStructuredSelection( fStructuredSelection );
- updateSelections();
- }
-
- private void updateSelections(){
- if (fInitialData == null)
- fInitialData = trySimpleTextSelection( getContainer().getSelection() );
- if (fInitialData == null)
- fInitialData = getDefaultInitValues();
-
- fCElement = fInitialData.cElement;
- fIsCaseSensitive = fInitialData.isCaseSensitive;
- fCaseSensitive.setSelection( fInitialData.isCaseSensitive );
- fCaseSensitive.setEnabled( fInitialData.cElement == null );
-
- HashSet set = new HashSet( fInitialData.searchFor );
-
- boolean enabled = ! set.contains( fSearchForValues[ fSearchFor.length - 1 ] );
-
- for (int i = 0; i < fSearchFor.length; i++){
- fSearchFor[i].setSelection( set.contains( fSearchForValues[i] ) );
- fSearchFor[i].setEnabled( enabled );
- }
-
- if( !enabled )
- fSearchFor[ fSearchFor.length - 1 ].setEnabled( true );
-
- setLimitTo( fInitialData.searchFor );
-
- for (int i = 0; i < fLimitTo.length; i++)
- fLimitTo[i].setSelection( fLimitToValues[i] == fInitialData.limitTo );
-
- fPattern.setText( fInitialData.pattern );
- }
-
- private SearchPatternData tryStructuredSelection( IStructuredSelection selection ) {
- if( selection == null || selection.size() > 1 )
- return null;
-
- Object o = selection.getFirstElement();
- if( o instanceof ICElement ) {
- return determineInitValuesFrom( (ICElement)o );
- } else if( o instanceof ISearchResultViewEntry ) {
- ICElement element = CSearchUtil.getCElement( ((ISearchResultViewEntry)o).getSelectedMarker() );
- return determineInitValuesFrom( element );
- //} else if( o instanceof LogicalPackage ) {
- // LogicalPackage lp = (LogicalPackage)o;
- // return new SearchPatternData( PACKAGE, REFERENCES, fIsCaseSensitive, lp.getElementName(), null );
- } else if( o instanceof IAdaptable ) {
- ICElement element = (ICElement)((IAdaptable)o).getAdapter( ICElement.class );
- if( element != null ) {
- return determineInitValuesFrom( element );
- } else {
- IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter( IWorkbenchAdapter.class );
- if( adapter != null ){
- List searchFor = new LinkedList();
- searchFor.add( UNKNOWN_SEARCH_FOR );
- return new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, adapter.getLabel(o), null );
- }
- }
- }
- return null;
- }
-
- /**
- * try to initialize the Search pattern data based on the current text selection.
- * @param selection
- * @return
- */
- private SearchPatternData trySimpleTextSelection(ISelection selection) {
- SearchPatternData result= null;
- if (selection instanceof ITextSelection) {
- BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));
- String text;
- try {
- text= reader.readLine();
- if (text == null)
- text= ""; //$NON-NLS-1$
- } catch (IOException ex) {
- text= ""; //$NON-NLS-1$
- }
-
- List searchFor = new LinkedList();
- searchFor.add( UNKNOWN_SEARCH_FOR );
- result= new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, text, null);
- }
- return result;
- }
-
- private SearchPatternData getDefaultInitValues() {
- List searchFor = new LinkedList();
- searchFor.add( CLASS_STRUCT );
- return new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, "", null); //$NON-NLS-1$
- }
-
- private String[] getPreviousSearchPatterns() {
- // Search results are not persistent
- int patternCount= fgPreviousSearchPatterns.size();
- String [] patterns= new String[patternCount];
- for (int i= 0; i < patternCount; i++)
- patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;
- return patterns;
- }
-
- private IStructuredSelection asStructuredSelection() {
- IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (wbWindow != null) {
- IWorkbenchPage page= wbWindow.getActivePage();
- if (page != null) {
- IWorkbenchPart part= page.getActivePart();
- if (part != null){
- ISelectionProvider provider = part.getSite().getSelectionProvider();
- if( provider != null ){
- ISelection selection = provider.getSelection();
- if( selection instanceof IStructuredSelection ){
- return (IStructuredSelection)selection;
- }
- }
- }
- }
- }
- return StructuredSelection.EMPTY;
- }
-
- private SearchPatternData determineInitValuesFrom( ICElement element ) {
- if( element == null )
- return null;
-
- List searchFor = new LinkedList();
-
- //outliune view will confuse methods with functions, so if the
- //name contains a "::", treat it as a method
- String pattern = element.getElementName();
- boolean forceMethod = ( pattern.indexOf("::") != -1 );
-
- switch ( element.getElementType() ){
- case ICElement.C_TEMPLATE_FUNCTION: /*fall through to function */
- case ICElement.C_FUNCTION_DECLARATION: /*fall through to function */
- case ICElement.C_FUNCTION: if( forceMethod ) searchFor.add( METHOD );
- else searchFor.add( FUNCTION );
- break;
-
- case ICElement.C_VARIABLE: searchFor.add( VAR ); break;
-
- case ICElement.C_TEMPLATE_CLASS:/* fall through to CLASS */
- case ICElement.C_STRUCT: /* fall through to CLASS */
- case ICElement.C_CLASS: searchFor.add( CLASS_STRUCT ); break;
-
- case ICElement.C_UNION: searchFor.add( UNION ); break;
-
- case ICElement.C_ENUMERATOR: /* fall through to FIELD */
- case ICElement.C_FIELD: searchFor.add( FIELD ); break;
-
- case ICElement.C_TEMPLATE_METHOD : /*fall through to METHOD */
- case ICElement.C_METHOD_DECLARATION : /*fall through to METHOD */
- case ICElement.C_METHOD: searchFor.add( METHOD ); break;
-
- case ICElement.C_NAMESPACE: searchFor.add( NAMESPACE ); break;
-
- case ICElement.C_ENUMERATION: searchFor.add( ENUM ); break;
-
- default: searchFor.add( UNKNOWN_SEARCH_FOR ); break;
- }
-
- LimitTo limitTo = ALL_OCCURRENCES;
-
- return new SearchPatternData( searchFor, limitTo, true, pattern, element );
- }
-
- private SearchPatternData getPatternData() {
- String pattern= getPattern();
- SearchPatternData match= null;
- int i= 0;
- int size= fgPreviousSearchPatterns.size();
- while (match == null && i < size) {
- match= (SearchPatternData) fgPreviousSearchPatterns.get(i);
- i++;
- if (!pattern.equals(match.pattern))
- match= null;
- };
- if (match == null) {
- match= new SearchPatternData(
- getSearchFor(),
- getLimitTo(),
- pattern,
- fCaseSensitive.getSelection(),
- fCElement,
- getContainer().getSelectedScope(),
- getContainer().getSelectedWorkingSets());
- fgPreviousSearchPatterns.add(match);
- }
- else {
- match.searchFor= getSearchFor();
- match.limitTo= getLimitTo();
- match.isCaseSensitive= fCaseSensitive.getSelection();
- match.cElement= fCElement;
- match.scope= getContainer().getSelectedScope();
- match.workingSets= getContainer().getSelectedWorkingSets();
- };
- return match;
- }
-
- private static class SearchPatternData {
- List searchFor;
- LimitTo limitTo;
- String pattern;
- boolean isCaseSensitive;
- ICElement cElement;
- int scope;
- IWorkingSet[] workingSets;
-
- public SearchPatternData(List s, LimitTo l, boolean i, String p, ICElement element) {
- this(s, l, p, i, element, ISearchPageContainer.WORKSPACE_SCOPE, null);
- }
-
- public SearchPatternData(List s, LimitTo l, String p, boolean i, ICElement element, int scope, IWorkingSet[] workingSets) {
- searchFor= s;
- limitTo= l;
- pattern= p;
- isCaseSensitive= i;
- cElement= element;
- this.scope = scope;
- this.workingSets = workingSets;
- }
- }
-
- //Dialog store id constants
- private final static String PAGE_NAME= "CSearchPage"; //$NON-NLS-1$
- private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE"; //$NON-NLS-1$
-
- private static List fgPreviousSearchPatterns = new ArrayList(20);
-
- private Button[] fSearchFor;
- private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, NAMESPACE, UNKNOWN_SEARCH_FOR };
-
- private String[] fSearchForText= {
- CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.function"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.variable"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.union"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.method"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.field"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.enum"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.namespace"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.searchFor.any") }; //$NON-NLS-1$
-
-
- private Button[] fLimitTo;
- private LimitTo[] fLimitToValues = { DECLARATIONS, DEFINITIONS, REFERENCES, ALL_OCCURRENCES };
- private String[] fLimitToText= {
- CSearchMessages.getString("CSearchPage.limitTo.declarations"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.limitTo.definitions"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.limitTo.references"), //$NON-NLS-1$
- CSearchMessages.getString("CSearchPage.limitTo.allOccurrences") }; //$NON-NLS-1$
- //CSearchMessages.getString("CSearchPage.limitTo.readReferences"), //$NON-NLS-1$
- //CSearchMessages.getString("CSearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
-
- private SearchPatternData fInitialData;
- private IStructuredSelection fStructuredSelection;
- private ICElement fCElement;
- private boolean fFirstTime= true;
- private IDialogSettings fDialogSettings;
- private boolean fIsCaseSensitive;
-
- private Combo fPattern;
- private ISearchPageContainer fContainer;
- private Button fCaseSensitive;
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
deleted file mode 100644
index 60bfb127698..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.ui.*;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.SearchUI;
-
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchResultCollector extends BasicSearchResultCollector{
-
- public static final String IMATCH = "IMatchObject";
-
- /**
- *
- */
- public CSearchResultCollector() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
- */
- public void aboutToStart() {
- super.aboutToStart();
-
- _matchCount = 0;
-
- _view = SearchUI.getSearchResultView();
-
-
- CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
- labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
-
- _computer = new GroupByKeyComputer();
-
- if( _view != null ){
- _view.searchStarted(
- null,//new ActionGroupFactory(),
- _operation.getSingularLabel(),
- _operation.getPluralLabelPattern(),
- _operation.getImageDescriptor(),
- CSearchPage.EXTENSION_POINT_ID,
- labelProvider,
- new GotoMarkerAction(),
- _computer,
- _operation
- );
- }
-
- if( getProgressMonitor() != null && !getProgressMonitor().isCanceled() ){
- getProgressMonitor().subTask( SEARCHING );
- }
- }
-
- public boolean acceptMatch( IMatch match ) throws CoreException
- {
- BasicSearchMatch searchMatch = (BasicSearchMatch) match;
-
- if( !super.acceptMatch( match ) )
- return false;
-
- if( searchMatch.resource == null )
- return false;
-
- IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
-
- HashMap markerAttributes = new HashMap( 2 );
-
- //we can hang any other info we want off the marker
- markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) );
- markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) );
- markerAttributes.put( IMATCH, searchMatch );
-
- marker.setAttributes( markerAttributes );
-
- if( _view != null ){
- _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), searchMatch.resource, marker );
- }
-
- _matchCount++;
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#done()
- */
- public void done() {
- if( !getProgressMonitor().isCanceled() ){
- String matchesString;
- if( _matchCount == 1 ){
- matchesString = MATCH;
- } else {
- matchesString = MessageFormat.format( MATCHES, new Integer[]{ new Integer(_matchCount) } );
- }
-
- getProgressMonitor().setTaskName( MessageFormat.format( DONE, new String[]{ matchesString } ) );
- }
-
- if( _view != null ){
- _view.searchFinished();
- }
-
- _view = null;
- _monitor = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- return _monitor;
- }
-
- public void setProgressMonitor(IProgressMonitor monitor) {
- this._monitor = monitor;
- }
-
- public void setOperation( CSearchOperation operation ) {
- _operation = operation;
- }
-
- private static final String SEARCHING = CSearchMessages.getString("CSearchResultCollector.searching"); //$NON-NLS-1$
- private static final String MATCH = CSearchMessages.getString("CSearchResultCollector.match"); //$NON-NLS-1$
- private static final String MATCHES = CSearchMessages.getString("CSearchResultCollector.matches"); //$NON-NLS-1$
- private static final String DONE = CSearchMessages.getString("CSearchResultCollector.done"); //$NON-NLS-1$
-
- private IProgressMonitor _monitor;
- private CSearchOperation _operation;
- private ISearchResultView _view;
- private IGroupByKeyComputer _computer;
- private int _matchCount;
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java
deleted file mode 100644
index 892c6ca24ff..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 12, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchScopeFactory {
- private static CSearchScopeFactory fgInstance;
- private static ICSearchScope EMPTY_SCOPE= SearchEngine.createCSearchScope(new ICElement[]{});
- /**
- *
- */
- public CSearchScopeFactory() {
- super();
- }
-
- public static CSearchScopeFactory getInstance() {
- if (fgInstance == null)
- fgInstance = new CSearchScopeFactory();
- return fgInstance;
- }
- /**
- * @param sets
- * @return
- */
- public ICSearchScope createCSearchScope(IWorkingSet[] sets) {
- if (sets == null || sets.length < 1)
- return EMPTY_SCOPE;
-
- Set cElements= new HashSet(sets.length * 10);
- for (int i= 0; i < sets.length; i++)
- addCElements(cElements, sets[i]);
- return createCSearchScope(cElements);
- }
- /**
- * @param cElements
- * @return
- */
- private ICSearchScope createCSearchScope(Set cElements) {
- return SearchEngine.createCSearchScope((ICElement[])cElements.toArray(new ICElement[cElements.size()]));
- }
- /**
- * @param cElements
- * @param set
- */
- private void addCElements(Set cElements, IWorkingSet set) {
- if (set == null)
- return;
-
- IAdaptable[] elements= set.getElements();
- for (int i= 0; i < elements.length; i++) {
- if (elements[i] instanceof ICElement)
- addCElements(cElements, (ICElement)elements[i]);
- else
- addCElements(cElements, elements[i]);
- }
- }
- /**
- * @param cElements
- * @param adaptable
- */
- private void addCElements(Set cElements, IAdaptable resource) {
- ICElement cElement= (ICElement)resource.getAdapter(ICElement.class);
- if (cElement == null)
- // not an ICElement resource
- return;
-
- addCElements(cElements, cElement);
- }
- /**
- * @param cElements
- * @param element
- */
- private void addCElements(Set cElements, ICElement element) {
- cElements.add(element);
- }
-
- /**
- * @param fStructuredSelection
- * @return
- */
- public ICSearchScope createCSearchScope(IStructuredSelection fStructuredSelection) {
- Set cElements = new HashSet( fStructuredSelection.size() );
-
- Iterator iter = fStructuredSelection.iterator();
- while( iter.hasNext() ){
- addCElements( cElements, (IAdaptable)iter.next() );
- }
-
- return createCSearchScope( cElements );
- }
-
-
- public IWorkingSet[] queryWorkingSets() {
- Shell shell= CUIPlugin.getDefault().getActiveWorkbenchShell();
- if (shell == null)
- return null;
- IWorkingSetSelectionDialog dialog= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, true);
- if (dialog.open() == Window.OK) {
- IWorkingSet[] workingSets= dialog.getSelection();
- if (workingSets.length > 0)
- return workingSets;
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
deleted file mode 100644
index 4d866b61527..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 12, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkingSet;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchUtil {
-
- /**
- *
- */
- public CSearchUtil() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param sets
- */
- public static void updateLRUWorkingSets(IWorkingSet[] sets) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param object
- * @param shell
- */
- public static void warnIfBinaryConstant( ICElement element, Shell shell) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param workingSets
- * @return
- */
- public static Object toString(IWorkingSet[] workingSets) {
- if( workingSets != null & workingSets.length > 0 ){
- String string = new String();
- for( int i = 0; i < workingSets.length; i++ ){
- if( i > 0 )
- string += ", "; //$NON-NLS-1$
- string += workingSets[i].getName();
- }
-
- return string;
- }
-
- return null;
- }
-
- /**
- * @param marker
- * @return
- */
- public static ICElement getCElement(IMarker marker) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
deleted file mode 100644
index c6083e4dc49..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.ui.actions.ActionGroup;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchViewActionGroup extends ActionGroup {
-
- /**
- * @param part
- */
- public CSearchViewActionGroup(ISearchResultView part) {
-
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
deleted file mode 100644
index 2e8bbae4b75..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 24, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class ElementNameSorter extends ViewerSorter {
-
- public int compare( Viewer viewer, Object e1, Object e2 ){
- String name1 = null, name2 = null;
-
- ISearchResultViewEntry entry1 = null;
- ISearchResultViewEntry entry2 = null;
-
- if (e1 instanceof ISearchResultViewEntry){
- name1 = _labelProvider.getText(e1);
- entry1 = (ISearchResultViewEntry)e1;
- }
-
- if (e2 instanceof ISearchResultViewEntry){
- name2 = _labelProvider.getText(e2);
- entry2 = (ISearchResultViewEntry)e2;
- }
-
- if (name1 == null)
- name1= ""; //$NON-NLS-1$
-
- if (name2 == null)
- name2= ""; //$NON-NLS-1$
-
- int compare = getCollator().compare( name1, name2 );
-
- if( compare == 0 ){
- int startPos1 = -1;
- int startPos2 = -1;
- IMarker marker1 = entry1.getSelectedMarker();
- IMarker marker2 = entry2.getSelectedMarker();
-
- if (marker1 != null)
- startPos1 = marker1.getAttribute( IMarker.CHAR_START, -1 );
- if (marker2 != null)
- startPos2 = marker2.getAttribute( IMarker.CHAR_START, -1 );
-
- compare = startPos1 - startPos2;
- }
-
- return compare;
- }
-
- public boolean isSorterProperty( Object element, String property ){
- return true;
- }
-
- public void sort( Viewer viewer, Object[] elements ) {
- // Set label provider to show "element - path"
- ISearchResultView view = SearchUI.getSearchResultView();
- if (view == null)
- return;
-
- _labelProvider = view.getLabelProvider();
-
- if( _labelProvider instanceof CSearchResultLabelProvider ) {
- ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_ELEMENT_CONTAINER );
- super.sort( viewer, elements );
- }
- }
-
- private ILabelProvider _labelProvider;
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
deleted file mode 100644
index c32010233d6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.IDE;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class GotoMarkerAction extends Action {
-
- public GotoMarkerAction(){
-
- }
-
- public void run() {
- ISearchResultView view = SearchUI.getSearchResultView();
- Object element = SelectionUtil.getSingleElement( view.getSelection() );
- if( element instanceof ISearchResultViewEntry ) {
- ISearchResultViewEntry entry = (ISearchResultViewEntry) element;
- show( entry.getSelectedMarker() );
- }
- }
-
- private void show( IMarker marker ){
- IResource resource = marker.getResource();
- if( resource == null || !resource.exists() ){
- return;
- }
-
- IWorkbenchPage page = CUIPlugin.getActivePage();
- ICElement element = CSearchUtil.getCElement( marker );
-
- if( SearchUI.reuseEditor() ){
- showWithReuse( marker, resource, element, page );
- } else {
- showWithoutReuse( marker, element, page );
- }
- }
-
- private void showWithoutReuse( IMarker marker, ICElement element, IWorkbenchPage page ){
- IEditorPart editor = null;
- try{
- Object objectToOpen = ( element != null ) ? (Object) element : (Object) marker.getResource();
- editor = EditorUtility.openInEditor( objectToOpen, false );
- } catch ( CoreException e ) {
- //boo
- }
- if( editor != null ){
- IDE.gotoMarker(editor, marker);
- }
- }
-
- private void showWithReuse( IMarker marker, IResource resource, ICElement element, IWorkbenchPage page ) {
- if( !(resource instanceof IFile) ){
- return;
- }
-
- IEditorPart editor = EditorUtility.isOpenInEditor( element );
- if( editor != null ){
- page.bringToTop( editor );
- } else {
-
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
deleted file mode 100644
index b1b43cfd20b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class GroupByKeyComputer implements IGroupByKeyComputer {
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IGroupByKeyComputer#computeGroupByKey(org.eclipse.core.resources.IMarker)
- */
-
- public Object computeGroupByKey(IMarker marker) {
- if( marker == null ){
- return null;
- }
-
- IMatch match = null;
-
- try {
- match = (IMatch) marker.getAttribute(CSearchResultCollector.IMATCH);
- } catch (CoreException e) {
- }
-
- return match.getParentName() + "::" + match.getName() + " - " + match.getLocation(); }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
deleted file mode 100644
index c99ff3ccbad..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Created on Jul 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * @author bgheorgh
- */
-public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate {
-
- private static final String C_SEARCH_PAGE_ID= "org.eclipse.cdt.ui.CSearchPage";
-
- private IWorkbenchWindow fWindow;
-
- public OpenCSearchPageAction() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- public void run(IAction action) {
- if (fWindow == null || fWindow.getActivePage() == null) {
- beep();
- return;
- }
- SearchUI.openSearchDialog(fWindow, C_SEARCH_PAGE_ID);
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing since the action isn't selection dependent.
- }
-
- public void dispose() {
- fWindow= null;
- }
-
- protected void beep() {
- Shell shell= CUIPlugin.getDefault().getActiveWorkbenchShell();
- if (shell != null && shell.getDisplay() != null)
- shell.getDisplay().beep();
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
deleted file mode 100644
index 2b8000e70dc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 24, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class ParentNameSorter extends ViewerSorter {
-
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1= null;
- String name2= null;
-
- ISearchResultViewEntry entry1 = null;
- ISearchResultViewEntry entry2 = null;
-
- if (e1 instanceof ISearchResultViewEntry){
- name1 = _labelProvider.getText(e1);
- entry1 = (ISearchResultViewEntry)e1;
- }
-
- if (e2 instanceof ISearchResultViewEntry){
- name2 = _labelProvider.getText(e2);
- entry2 = (ISearchResultViewEntry)e2;
- }
-
- if (name1 == null)
- name1= ""; //$NON-NLS-1$
-
- if (name2 == null)
- name2= ""; //$NON-NLS-1$
-
- int compare = getCollator().compare( name1, name2 );
-
- if( compare == 0 ){
- int startPos1 = -1;
- int startPos2 = -1;
- IMarker marker1 = entry1.getSelectedMarker();
- IMarker marker2 = entry2.getSelectedMarker();
-
- if (marker1 != null)
- startPos1 = marker1.getAttribute( IMarker.CHAR_START, -1 );
- if (marker2 != null)
- startPos2 = marker2.getAttribute( IMarker.CHAR_START, -1 );
-
- compare = startPos1 - startPos2;
- }
-
- return compare;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public void sort(Viewer viewer, Object[] elements) {
- // Set label provider to show "path - resource"
- ISearchResultView view = SearchUI.getSearchResultView();
- if (view == null)
- return;
-
- _labelProvider = view.getLabelProvider();
-
- if( _labelProvider instanceof CSearchResultLabelProvider )
- ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_CONTAINER_ELEMENT );
-
- super.sort( viewer, elements );
- }
-
- private ILabelProvider _labelProvider;
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
deleted file mode 100644
index ea55a52dc75..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 24, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class PathNameSorter extends ViewerSorter {
-
- /*
- * Overrides method from ViewerSorter
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1 = null;
- String name2 = null;
- ISearchResultViewEntry entry1 = null;
- ISearchResultViewEntry entry2 = null;
- IMatch match1 = null;
- IMatch match2 = null;
-
- if( e1 instanceof ISearchResultViewEntry ) {
- entry1 = (ISearchResultViewEntry)e1;
- try {
- match1 = (IMatch)entry1.getSelectedMarker().getAttribute( CSearchResultCollector.IMATCH );
- } catch (CoreException e) {
- }
- name1 = match1.getLocation().toString();
- }
- if( e2 instanceof ISearchResultViewEntry ) {
- entry2 = (ISearchResultViewEntry)e2;
- try {
- match2 = (IMatch)entry2.getSelectedMarker().getAttribute( CSearchResultCollector.IMATCH );
- } catch (CoreException e) {
- }
- //name2 = _labelProvider.getText( e2 );
- name2 = match2.getLocation().toString();
- }
-
- if( name1 == null )
- name1 = ""; //$NON-NLS-1$
-
- if( name2 == null )
- name2 = ""; //$NON-NLS-1$
-
- int compare = getCollator().compare( name1, name2 );
-
- if( compare == 0 ){
- int startPos1 = -1;
- int startPos2 = -1;
-
- if (match1 != null)
- startPos1 = match1.getStartOffset();
- if (match2 != null)
- startPos2 = match2.getStartOffset();
-
- compare = startPos1 - startPos2;
- }
-
- return compare;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-
- /*
- * Overrides method from ViewerSorter
- */
- public void sort( Viewer viewer, Object[] elements ) {
- // Set label provider to show "path - resource"
- ISearchResultView view = SearchUI.getSearchResultView();
- if( view == null )
- return;
-
- _labelProvider = view.getLabelProvider();
- if( _labelProvider instanceof CSearchResultLabelProvider )
- ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_PATH );
- super.sort( viewer, elements );
- }
-
- private ILabelProvider _labelProvider;
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java
deleted file mode 100644
index b00c070511b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.StringConverter;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * Initialized with a color manager and a preference store, its subclasses are
- * only responsible for providing a list of preference keys based on which tokens
- * are generated and to use this tokens to define the rules controlling this scanner.
- */
-public abstract class AbstractCScanner extends BufferedRuleBasedScanner {
-
-
- private IColorManager fColorManager;
- private IPreferenceStore fPreferenceStore;
-
- private Map fTokenMap= new HashMap();
- private String[] fPropertyNamesColor;
- private String[] fPropertyNamesStyle;
-
- private IToken fDefaultToken;
-
-
- /**
- * Returns the list of preference keys which define the tokens
- * used in the rules of this scanner.
- */
- abstract protected String[] getTokenProperties();
-
- /**
- * Creates the list of rules controlling this scanner.
- */
- abstract protected List createRules();
-
-
- /**
- * Creates an abstract Java scanner.
- */
- public AbstractCScanner(IColorManager manager, IPreferenceStore store) {
- super();
- fColorManager= manager;
- fPreferenceStore= store;
- }
-
- /**
- * Creates an abstract Java scanner.
- */
- public AbstractCScanner(IColorManager manager, IPreferenceStore store, int bufsize) {
- super(bufsize);
- fColorManager= manager;
- fPreferenceStore= store;
- }
- /**
- * Must be called after the constructor has been called.
- */
- public final void initialize() {
-
- fPropertyNamesColor= getTokenProperties();
- int length= fPropertyNamesColor.length;
- fPropertyNamesStyle= new String[length];
- for (int i= 0; i < length; i++) {
- fPropertyNamesStyle[i]= fPropertyNamesColor[i] + "_bold"; //$NON-NLS-1$
- addToken(fPropertyNamesColor[i], fPropertyNamesStyle[i]);
- }
-
- initializeRules();
- }
-
- private void addToken(String colorKey, String styleKey) {
- RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
- if (fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
- ext.unbindColor(colorKey);
- ext.bindColor(colorKey, rgb);
- }
-
- boolean bold= fPreferenceStore.getBoolean(styleKey);
- fTokenMap.put(colorKey, new Token(new TextAttribute(fColorManager.getColor(colorKey), null, bold ? SWT.BOLD : SWT.NORMAL)));
- }
-
- protected Token getToken(String key) {
- return (Token) fTokenMap.get(key);
- }
-
- private void initializeRules() {
- List rules= createRules();
- if (rules != null) {
- IRule[] result= new IRule[rules.size()];
- rules.toArray(result);
- setRules(result);
- }
- }
-
- private int indexOf(String property) {
- if (property != null) {
- int length= fPropertyNamesColor.length;
- for (int i= 0; i < length; i++) {
- if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesStyle[i]))
- return i;
- }
- }
- return -1;
- }
-
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return indexOf(event.getProperty()) >= 0;
- }
-
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
- String p= event.getProperty();
- int index= indexOf(p);
- Token token = getToken(fPropertyNamesColor[index]);
- if (fPropertyNamesColor[index].equals(p))
- adaptToColorChange(token, event);
- else
- adaptToStyleChange(token, event);
- }
-
- private void adaptToColorChange(Token token, PropertyChangeEvent event) {
- RGB rgb= null;
-
- Object value= event.getNewValue();
- if (value instanceof RGB)
- rgb= (RGB) value;
- else if (value instanceof String) {
- rgb= StringConverter.asRGB((String) value);
- }
-
- if (rgb != null) {
-
- String property= event.getProperty();
-
- if (fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
- ext.unbindColor(property);
- ext.bindColor(property, rgb);
- }
-
- Object data= token.getData();
- if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
- token.setData(new TextAttribute(fColorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle()));
- }
- }
- }
-
- private void adaptToStyleChange(Token token, PropertyChangeEvent event) {
- boolean bold= false;
- Object value= event.getNewValue();
- if (value instanceof Boolean)
- bold= ((Boolean) value).booleanValue();
- else if (value instanceof String) {
- String s= (String) value;
- if (IPreferenceStore.TRUE.equals(s))
- bold= true;
- else if (IPreferenceStore.FALSE.equals(s))
- bold= false;
- }
-
- Object data= token.getData();
- if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
- boolean isBold= (oldAttr.getStyle() == SWT.BOLD);
- if (isBold != bold)
- token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), bold ? SWT.BOLD : SWT.NORMAL));
- }
- }
-
- /**
- * Returns the next token in the document.
- *
- * @return the next token in the document
- */
- public IToken nextToken() {
-
- IToken token;
-
- while (true) {
-
- fTokenOffset= fOffset;
- fColumn= UNDEFINED;
-
- for (int i= 0; i < fRules.length; i++) {
- token= (fRules[i].evaluate(this));
- if (!token.isUndefined())
- return token;
- }
- if (read() == EOF)
- return Token.EOF;
- else
- return fDefaultToken;
- }
- }
-
- public void setDefaultReturnToken(IToken token) {
- fDefaultToken = token;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
deleted file mode 100644
index cfcd123c2a3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.util.Assert;
-
-/**
- * A buffered document scanner. The buffer always contains a section
- * of a fixed size of the document to be scanned.
- */
-public final class BufferedDocumentScanner implements ICharacterScanner {
-
- /** The document being scanned. */
- private IDocument fDocument;
- /** The offset of the document range to scan. */
- private int fRangeOffset;
- /** The length of the document range to scan. */
- private int fRangeLength;
- /** The delimiters of the document. */
- private char[][] fDelimiters;
-
- /** The buffer. */
- private final char[] fBuffer;
- /** The offset of the buffer within the document. */
- private int fBufferOffset;
- /** The valid length of the buffer for access. */
- private int fBufferLength;
- /** The offset of the scanner within the buffer. */
- private int fOffset;
-
- /**
- * Creates a new buffered document scanner.
- * The buffer size is set to the given number of characters.
- *
- * @param size the buffer size
- */
- public BufferedDocumentScanner(int size) {
- Assert.isTrue(size >= 1);
- fBuffer= new char[size];
- }
-
- /**
- * Fills the buffer with the contents of the document starting at the given offset.
- *
- * @param offset the document offset at which the buffer starts
- */
- private final void updateBuffer(int offset) {
-
- // Clamp at start of the file document range
- if (offset < 0)
- offset = 0;
-
- fBufferOffset= offset;
- fBufferLength= fBuffer.length;
-
- // assert(offset >= fRangeOffset && offset < fRangeOffset + fRangeLength);
-
- if (fBufferOffset + fBufferLength > fRangeOffset + fRangeLength)
- fBufferLength= fRangeOffset + fRangeLength - fBufferOffset;
-
- try {
- final String content= fDocument.get(fBufferOffset, fBufferLength);
- content.getChars(0, fBufferLength, fBuffer, 0);
-
- } catch (BadLocationException e) {
- }
- }
-
- /**
- * Configures the scanner by providing access to the document range over which to scan.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- */
- public final void setRange(IDocument document, int offset, int length) {
-
- fDocument= document;
- fRangeOffset= offset;
- fRangeLength= length;
-
- // Clamp at end of the real document
- if (fRangeLength + fRangeOffset > fDocument.getLength())
- fRangeLength = fDocument.getLength() - fRangeOffset;
-
- String[] delimiters= document.getLegalLineDelimiters();
- fDelimiters= new char[delimiters.length][];
- for (int i= 0; i < delimiters.length; i++)
- fDelimiters[i]= delimiters[i].toCharArray();
-
- updateBuffer(offset);
- fOffset= 0;
- }
-
- /*
- * @see ICharacterScanner#read()
- */
- public final int read() {
-
- if (fOffset >= fBufferLength) {
- if (fBufferOffset + fBufferLength >= fRangeOffset + fRangeLength)
- return EOF;
- else {
- updateBuffer(fBufferOffset + fBufferLength);
- fOffset= 0;
- }
- }
-
- return fBuffer[fOffset++];
- }
-
- /*
- * @see ICharacterScanner#unread
- */
- public final void unread() {
-
- if (fOffset <= 0) {
- if (fBufferOffset <= fRangeOffset) {
- // error: BOF
- } else {
- updateBuffer(fBufferOffset - fBuffer.length);
- fOffset = fBuffer.length - 1; // should always be a valid place
- }
- } else {
- --fOffset;
- }
- }
-
- /*
- * @see ICharacterScanner#getColumn()
- */
- public final int getColumn() {
-
- try {
- final int offset= fBufferOffset + fOffset;
- final int line= fDocument.getLineOfOffset(offset);
- final int start= fDocument.getLineOffset(line);
-
- return offset - start;
-
- } catch (BadLocationException e) {
- }
-
- return -1;
- }
-
- /*
- * @see ICharacterScanner#getLegalLineDelimiters()
- */
- public final char[][] getLegalLineDelimiters() {
- return fDelimiters;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAnnotationHover.java
deleted file mode 100644
index 3f52ee21437..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAnnotationHover.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-
-public class CAnnotationHover implements IAnnotationHover {
-
- /**
- * Returns the distance to the ruler line.
- */
- protected int compareRulerLine(Position position, IDocument document, int line) {
-
- if (position.getOffset() > -1 && position.getLength() > -1) {
- try {
- int markerLine= document.getLineOfOffset(position.getOffset());
- if (line == markerLine)
- return 1;
- if (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
- return 2;
- } catch (BadLocationException x) {
- }
- }
-
- return 0;
- }
-
- /**
- * Selects a set of markers from the two lists. By default, it just returns
- * the set of exact matches.
- */
- protected List select(List exactMatch, List including) {
- return exactMatch;
- }
-
- /**
- * Returns one marker which includes the ruler's line of activity.
- */
- protected List getMarkersForLine(ISourceViewer viewer, int line) {
-
- IDocument document= viewer.getDocument();
- IAnnotationModel model= viewer.getAnnotationModel();
-
- if (model == null)
- return null;
-
- List exact= new ArrayList();
- List including= new ArrayList();
-
- Iterator e= model.getAnnotationIterator();
- while (e.hasNext()) {
- Object o= e.next();
- if (o instanceof MarkerAnnotation) {
- MarkerAnnotation a= (MarkerAnnotation) o;
- switch (compareRulerLine(model.getPosition(a), document, line)) {
- case 1:
- exact.add(a.getMarker());
- break;
- case 2:
- including.add(a.getMarker());
- break;
- }
- }
- }
-
- return select(exact, including);
- }
-
- /*
- * @see IVerticalRulerHover#getHoverInfo(ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- List markers= getMarkersForLine(sourceViewer, lineNumber);
- if (markers != null) {
-
- if (markers.size() == 1) {
-
- // optimization
- IMarker marker= (IMarker) markers.get(0);
- String message= marker.getAttribute(IMarker.MESSAGE, (String) null);
- if (message != null && message.trim().length() > 0)
- return formatSingleMessage(message);
-
- } else {
-
- List messages= new ArrayList();
-
- Iterator e= markers.iterator();
- while (e.hasNext()) {
- IMarker marker= (IMarker) e.next();
- String message= marker.getAttribute(IMarker.MESSAGE, (String) null);
- if (message != null && message.trim().length() > 0)
- messages.add(message.trim());
- }
-
- if (messages.size() == 1)
- return formatSingleMessage((String) messages.get(0));
-
- if (messages.size() > 1)
- return formatMultipleMessages(messages);
- }
- }
-
- return null;
- }
-
-
- private int getHoverWidth(Display display) {
- Rectangle displayBounds= display.getBounds();
- int hoverWidth= displayBounds.width - (display.getCursorLocation().x - displayBounds.x);
- hoverWidth-= 12; // XXX: Add some space to the border, Revisit
- if (hoverWidth < 200) {
- hoverWidth= 200;
- }
- return hoverWidth;
- }
-
- /*
- * Formats a message as HTML text.
- */
- private String formatSingleMessage(String message) {
- StringBuffer buffer= new StringBuffer();
- HTMLPrinter.addPageProlog(buffer);
- HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
- HTMLPrinter.addPageEpilog(buffer);
- return buffer.toString();
- }
-
- /*
- * Formats several message as HTML text.
- */
- private String formatMultipleMessages(List messages) {
- StringBuffer buffer= new StringBuffer();
- HTMLPrinter.addPageProlog(buffer);
- HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent("Multiple markers at this line"));
-
- HTMLPrinter.startBulletList(buffer);
- Iterator e= messages.iterator();
- while (e.hasNext())
- HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String) e.next()));
- HTMLPrinter.endBulletList(buffer);
-
- HTMLPrinter.addPageEpilog(buffer);
- return buffer.toString();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
deleted file mode 100644
index 0c18f9800f8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
+++ /dev/null
@@ -1,225 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IDocument;
-
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * Auto indent strategy sensitive to brackets.
- */
-public class CAutoIndentStrategy extends DefaultAutoIndentStrategy {
-
-
- public CAutoIndentStrategy() {
- }
-
- // evaluate the line with the opening bracket that matches the closing bracket on the given line
- protected int findMatchingOpenBracket(IDocument d, int line, int end, int closingBracketIncrease) throws BadLocationException {
-
-
- int start= d.getLineOffset(line);
- int brackcount= getBracketCount(d, start, end, false) - closingBracketIncrease;
-
-
- // sum up the brackets counts of each line (closing brackets count negative,
- // opening positive) until we find a line the brings the count to zero
- while (brackcount < 0) {
- line--;
- if (line < 0) {
- return -1;
- }
- start= d.getLineOffset(line);
- end= start + d.getLineLength(line) - 1;
- brackcount += getBracketCount(d, start, end, false);
- }
- return line;
- }
-
-
- private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
- int bracketcount= 0;
- while (start < end) {
- char curr= d.getChar(start);
- start++;
- switch (curr) {
- case '/' :
- if (start < end) {
- char next= d.getChar(start);
- if (next == '*') {
- // a comment starts, advance to the comment end
- start= getCommentEnd(d, start + 1, end);
- } else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
- start= end;
- }
- }
- break;
- case '*' :
- if (start < end) {
- char next= d.getChar(start);
- if (next == '/') {
- // we have been in a comment: forget what we read before
- bracketcount= 0;
- start++;
- }
- }
- break;
- case '{' :
- bracketcount++;
- ignoreCloseBrackets= false;
- break;
- case '}' :
- if (!ignoreCloseBrackets) {
- bracketcount--;
- }
- break;
- case '"' :
- case '\'' :
- start= getStringEnd(d, start, end, curr);
- break;
- default :
- }
- }
- return bracketcount;
- }
-
- // ----------- bracket counting ------------------------------------------------------
-
-
- private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
- while (pos < end) {
- char curr= d.getChar(pos);
- pos++;
- if (curr == '*') {
- if (pos < end && d.getChar(pos) == '/') {
- return pos + 1;
- }
- }
- }
- return end;
- }
-
- protected String getIndentOfLine(IDocument d, int line) throws BadLocationException {
- if (line > -1) {
- int start= d.getLineOffset(line);
- int end= start + d.getLineLength(line) - 1;
- int whiteend= findEndOfWhiteSpace(d, start, end);
- return d.get(start, whiteend - start);
- } else {
- return "";
- }
- }
-
- private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
- while (pos < end) {
- char curr= d.getChar(pos);
- pos++;
- if (curr == '\\') {
- // ignore escaped characters
- pos++;
- } else if (curr == ch) {
- return pos;
- }
- }
- return end;
- }
-
- protected void smartInsertAfterBracket(IDocument d, DocumentCommand c) {
- if (c.offset == -1 || d.getLength() == 0)
- return;
-
- try {
- int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
- int line= d.getLineOfOffset(p);
- int start= d.getLineOffset(line);
- int whiteend= findEndOfWhiteSpace(d, start, c.offset);
-
-
- // shift only when line does not contain any text up to the closing bracket
- if (whiteend == c.offset) {
- // evaluate the line with the opening bracket that matches out closing bracket
- int indLine= findMatchingOpenBracket(d, line, c.offset, 1);
- if (indLine != -1 && indLine != line) {
- // take the indent of the found line
- StringBuffer replaceText= new StringBuffer(getIndentOfLine(d, indLine));
- // add the rest of the current line including the just added close bracket
- replaceText.append(d.get(whiteend, c.offset - whiteend));
- replaceText.append(c.text);
- // modify document command
- c.length= c.offset - start;
- c.offset= start;
- c.text= replaceText.toString();
- }
- }
- } catch (BadLocationException excp) {
- CUIPlugin.getDefault().log(excp);
- }
- }
-
- protected void smartIndentAfterNewLine(IDocument d, DocumentCommand c) {
- int docLength= d.getLength();
- if (c.offset == -1 || docLength == 0)
- return;
-
- try {
- int p= (c.offset == docLength ? c.offset - 1 : c.offset);
- int line= d.getLineOfOffset(p);
-
-
- StringBuffer buf= new StringBuffer(c.text);
- if (c.offset < docLength && d.getChar(c.offset) == '}') {
- int indLine= findMatchingOpenBracket(d, line, c.offset, 0);
- if (indLine == -1) {
- indLine= line;
- }
- buf.append(getIndentOfLine(d, indLine));
- } else {
- int start= d.getLineOffset(line);
- int whiteend= findEndOfWhiteSpace(d, start, c.offset);
- buf.append(d.get(start, whiteend - start));
- if (getBracketCount(d, start, c.offset, true) > 0) {
- buf.append('\t');
- }
- }
- c.text= buf.toString();
-
-
- } catch (BadLocationException excp) {
- CUIPlugin.getDefault().log(excp);
- }
- }
-
- /**
- * Returns whether the text ends with one of the given search strings.
- */
- private boolean endsWithDelimiter(IDocument d, String txt) {
- String[] delimiters= d.getLegalLineDelimiters();
-
- for (int i= 0; i < delimiters.length; i++) {
- if (txt.endsWith(delimiters[i]))
- return true;
- }
- return false;
- }
-
-
- /**
- * @see IAutoIndentStrategy#customizeDocumentCommand
- */
- public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
- if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))
- smartIndentAfterNewLine(d, c);
- else if ("}".equals(c.text)) {
- smartInsertAfterBracket(d, c);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
deleted file mode 100644
index 13de07bfd48..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Reads from a document either forwards or backwards. May be configured to
- * skip comments and strings.
- */
-public class CCodeReader extends SingleCharReader {
-
- /** The EOF character */
- public static final int EOF= -1;
-
- private boolean fSkipComments= false;
- private boolean fSkipStrings= false;
- private boolean fForward= false;
-
- private IDocument fDocument;
- private int fOffset;
-
- private int fEnd= -1;
- private int fCachedLineNumber= -1;
- private int fCachedLineOffset= -1;
-
-
- public CCodeReader() {
- }
-
- /**
- * Returns the offset of the last read character. Should only be called after read has been called.
- */
- public int getOffset() {
- return fForward ? fOffset -1 : fOffset;
- }
-
- public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException {
- fDocument= document;
- fOffset= offset;
- fSkipComments= skipComments;
- fSkipStrings= skipStrings;
-
- fForward= true;
- fEnd= Math.min(fDocument.getLength(), fOffset + length);
- }
-
- public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException {
- fDocument= document;
- fOffset= offset;
- fSkipComments= skipComments;
- fSkipStrings= skipStrings;
-
- fForward= false;
- try {
- fCachedLineNumber= fDocument.getLineOfOffset(fOffset);
- } catch (BadLocationException x) {
- throw new IOException(x.getMessage());
- }
- }
-
- /*
- * @see Reader#close()
- */
- public void close() throws IOException {
- fDocument= null;
- }
-
- /*
- * @see SingleCharReader#read()
- */
- public int read() throws IOException {
- try {
- return fForward ? readForwards() : readBackwards();
- } catch (BadLocationException x) {
- throw new IOException(x.getMessage());
- }
- }
-
- private void gotoCommentEnd() throws BadLocationException {
- while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
- if (current == '*') {
- if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') {
- ++ fOffset;
- return;
- }
- }
- }
- }
-
- private void gotoStringEnd(char delimiter) throws BadLocationException {
- while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
- if (current == '\\') {
- // ignore escaped characters
- ++ fOffset;
- } else if (current == delimiter) {
- return;
- }
- }
- }
-
- private void gotoLineEnd() throws BadLocationException {
- int line= fDocument.getLineOfOffset(fOffset);
- fOffset= fDocument.getLineOffset(line + 1);
- }
-
- private int readForwards() throws BadLocationException {
- while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
-
- switch (current) {
- case '/':
-
- if (fSkipComments && fOffset < fEnd) {
- char next= fDocument.getChar(fOffset);
- if (next == '*') {
- // a comment starts, advance to the comment end
- ++ fOffset;
- gotoCommentEnd();
- continue;
- } else if (next == '/') {
- // '//'-comment starts, advance to the line end
- gotoLineEnd();
- continue;
- }
- }
-
- return current;
-
- case '"':
- case '\'':
-
- if (fSkipStrings) {
- gotoStringEnd(current);
- continue;
- }
-
- return current;
- }
-
- return current;
- }
-
- return EOF;
- }
-
- private void handleSingleLineComment() throws BadLocationException {
- int line= fDocument.getLineOfOffset(fOffset);
- if (line < fCachedLineNumber) {
- fCachedLineNumber= line;
- fCachedLineOffset= fDocument.getLineOffset(line);
- int offset= fOffset;
- while (fCachedLineOffset < offset) {
- char current= fDocument.getChar(offset--);
- if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') {
- fOffset= offset;
- return;
- }
- }
- }
- }
-
- private void gotoCommentStart() throws BadLocationException {
- while (0 < fOffset) {
- char current= fDocument.getChar(fOffset--);
- if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/')
- return;
- }
- }
-
- private void gotoStringStart(char delimiter) throws BadLocationException {
- while (0 < fOffset) {
- char current= fDocument.getChar(fOffset);
- if (current == delimiter) {
- if ( !(0 <= fOffset && fDocument.getChar(fOffset -1) == '\\'))
- return;
- }
- -- fOffset;
- }
- }
-
- private int readBackwards() throws BadLocationException {
-
- while (0 < fOffset) {
- -- fOffset;
-
- handleSingleLineComment();
-
- char current= fDocument.getChar(fOffset);
- switch (current) {
- case '/':
-
- if (fSkipComments && fOffset > 1) {
- char next= fDocument.getChar(fOffset - 1);
- if (next == '*') {
- // a comment ends, advance to the comment start
- fOffset -= 2;
- gotoCommentStart();
- continue;
- }
- }
-
- return current;
-
- case '"':
- case '\'':
-
- if (fSkipStrings) {
- -- fOffset;
- gotoStringStart(current);
- continue;
- }
-
- return current;
- }
-
- return current;
- }
-
- return EOF;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
deleted file mode 100644
index 6159a8d6153..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.SingleLineRule;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * A C code scanner.
- */
-public final class CCodeScanner extends AbstractCScanner {
-
-
- private static String[] fgKeywords= {
- "asm", "auto",
- "break",
- "case",
- "const", "continue",
- "default", "do",
- "else", "enum", "extern",
- "for",
- "goto",
- "if", "inline",
- "register", "return", "restrict",
- "sizeof", "static", "struct", "switch",
- "typedef",
- "union",
- "volatile",
- "while", "_Pragma"
- };
-
-
- private static String[] fgTypes= { "char", "double", "float", "int", "long", "short", "signed", "unsigned", "void", "_Bool", "_Complex", "_Imaginary"};
- private static String[] fgConstants= { "NULL", "__DATE__", "__LINE__", "__TIME__", "__FILE__", "__STDC__"};
- private static String[] fgPreprocessor= { "#define", "#undef", "#include", "#error", "#warning", "#pragma", "#ifdef", "#ifndef", "#if", "#else", "#elif", "#endif", "#line"};
-
-
- private static String[] fgTokenProperties= {
- ICColorConstants.C_KEYWORD,
- ICColorConstants.C_TYPE,
- ICColorConstants.C_STRING,
- ICColorConstants.C_DEFAULT
- };
-
-
- /**
- * Creates a C code scanner
- */
- public CCodeScanner(IColorManager manager, IPreferenceStore store) {
- super(manager, store);
- initialize();
- }
-
- /*
- * @see AbstractCScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fgTokenProperties;
- }
-
- /*
- * @see AbstractCScanner#createRules()
- */
- protected List createRules() {
-
- List rules= new ArrayList();
-
- // Add rule for strings
- Token token= getToken(ICColorConstants.C_STRING);
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("'", "'", token, '\\'));
-
-
- // Add generic whitespace rule.
- //rules.add(new WhitespaceRule(new CWhitespaceDetector()));
-
-
- // Add word rule for keywords, types, and constants.
- token= getToken(ICColorConstants.C_DEFAULT);
- WordRule wordRule= new WordRule(new CWordDetector(), token);
-
- token= getToken(ICColorConstants.C_KEYWORD);
- for (int i=0; i<fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], token);
- token= getToken(ICColorConstants.C_TYPE);
- for (int i=0; i<fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], token);
- for (int i=0; i<fgConstants.length; i++)
- wordRule.addWord(fgConstants[i], token);
- rules.add(wordRule);
-
- token = getToken(ICColorConstants.C_TYPE);
- PreprocessorRule preprocessorRule = new PreprocessorRule(new CWordDetector(), token);
-
- for (int i=0; i<fgPreprocessor.length; i++) {
- preprocessorRule.addWord(fgPreprocessor[i], token);
- }
- rules.add(preprocessorRule);
-
- setDefaultReturnToken(getToken(ICColorConstants.C_DEFAULT));
- return rules;
- }
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setRules(IRule[] rules) {
- super.setRules(rules);
- }
-
- /*
- * @see AbstractCScanner#affectsBehavior(PropertyChangeEvent)
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return super.affectsBehavior(event);
- }
-
- /*
- * @see AbstractCScanner#adaptToPreferenceChange(PropertyChangeEvent)
- */
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
-
- if (super.affectsBehavior(event)) {
- super.adaptToPreferenceChange(event);
- }
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentAutoIndentStrategy.java
deleted file mode 100644
index 2c857e9fa96..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentAutoIndentStrategy.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Auto indent strategy for java doc comments
- */
-public class CCommentAutoIndentStrategy extends DefaultAutoIndentStrategy {
-
- public CCommentAutoIndentStrategy() {
- }
-
- /**
- * Returns whether the text ends with one of the given search strings.
- */
- private boolean endsWithDelimiter(IDocument d, String txt) {
- String[] delimiters= d.getLegalLineDelimiters();
-
- for (int i= 0; i < delimiters.length; i++) {
- if (txt.endsWith(delimiters[i]))
- return true;
- }
-
- return false;
- }
-
- /**
- * Copies the indentation of the previous line and add a star
- * If the javadoc just started on tis line add also a blank
- *
- * @param d the document to work on
- * @param c the command to deal with
- */
- private void jdocIndentAfterNewLine(IDocument d, DocumentCommand c) {
-
- if (c.offset == -1 || d.getLength() == 0)
- return;
-
- try {
- // find start of line
- int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
- IRegion info= d.getLineInformationOfOffset(p);
- int start= info.getOffset();
-
- // find white spaces
- int end= findEndOfWhiteSpace(d, start, c.offset);
-
- StringBuffer buf= new StringBuffer(c.text);
- if (end >= start) { // 1GEYL1R: ITPJUI:ALL - java doc edit smartness not work for class comments
- // append to input
- buf.append(d.get(start, end - start));
- if (end < c.offset) {
- if (d.getChar(end) == '/') {
- // javadoc started on this line
- buf.append(" * "); //$NON-NLS-1$
- } else if (d.getChar(end) == '*') {
- buf.append("* "); //$NON-NLS-1$
- }
- }
- }
-
-
- c.text= buf.toString();
-
- } catch (BadLocationException excp) {
- // stop work
- }
- }
-
- protected void jdocIndentForCommentEnd(IDocument d, DocumentCommand c) {
- if (c.offset < 2 || d.getLength() == 0) {
- return;
- }
- try {
- if ("* ".equals(d.get(c.offset - 2, 2))) { //$NON-NLS-1$
- // modify document command
- c.length++;
- c.offset--;
- }
- } catch (BadLocationException excp) {
- // stop work
- }
- }
-
- /*
- * @see IAutoIndentStrategy#customizeDocumentCommand
- */
- public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
- if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))
- jdocIndentAfterNewLine(d, c);
- else if ("/".equals(c.text)) { //$NON-NLS-1$
- jdocIndentForCommentEnd(d, c);
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
deleted file mode 100644
index e8c9f852c05..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.text;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.cdt.core.CCorePlugin;
-
-import org.eclipse.cdt.internal.ui.text.IColorManager;
-import org.eclipse.cdt.internal.ui.text.ICColorConstants;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * CCommentScanner.java
- */
-public class CCommentScanner extends AbstractCScanner
-{
- private static class TaskTagDetector implements IWordDetector {
-
- public boolean isWordStart(char c) {
- return Character.isLetter(c);
- }
-
- public boolean isWordPart(char c) {
- return Character.isLetter(c);
- }
- };
-
- private class TaskTagRule extends WordRule {
-
- private IToken fToken;
-
- public TaskTagRule(IToken token) {
- super(new TaskTagDetector(), Token.UNDEFINED);
- fToken= token;
- }
-
- public void clearTaskTags() {
- fWords.clear();
- }
-
- public void addTaskTags(String value) {
- String[] tasks= split(value, ","); //$NON-NLS-1$
- for (int i= 0; i < tasks.length; i++) {
- if (tasks[i].length() > 0) {
- addWord(tasks[i], fToken);
- }
- }
- }
-
- private String[] split(String value, String delimiters) {
- StringTokenizer tokenizer= new StringTokenizer(value, delimiters);
- int size= tokenizer.countTokens();
- String[] tokens= new String[size];
- int i= 0;
- while (i < size)
- tokens[i++]= tokenizer.nextToken();
- return tokens;
- }
- }
-
- private static final String TRANSLATION_TASK_TAGS= CCorePlugin.TRANSLATION_TASK_TAGS;
- protected static final String TASK_TAG= ICColorConstants.TASK_TAG;
-
- private TaskTagRule fTaskTagRule;
- private Preferences fCorePreferenceStore;
- private String fDefaultTokenProperty;
- private String[] fTokenProperties;
-
- public CCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
- this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
- }
-
- public CCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) {
- super(manager, store);
-
- fCorePreferenceStore= coreStore;
- fDefaultTokenProperty= defaultTokenProperty;
- fTokenProperties= tokenProperties;
-
- initialize();
- }
-
- /*
- * @see AbstractCScanner#createRules()
- */
- protected List createRules() {
- List list= new ArrayList();
-
- if (fCorePreferenceStore != null) {
- // Add rule for Task Tags.
- fTaskTagRule= new TaskTagRule(getToken(TASK_TAG));
- String tasks= fCorePreferenceStore.getString(TRANSLATION_TASK_TAGS);
- fTaskTagRule.addTaskTags(tasks);
- list.add(fTaskTagRule);
- }
-
- setDefaultReturnToken(getToken(fDefaultTokenProperty));
-
- return list;
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return event.getProperty().equals(TRANSLATION_TASK_TAGS) || super.affectsBehavior(event);
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
- if (fTaskTagRule != null && event.getProperty().equals(TRANSLATION_TASK_TAGS)) {
- Object value= event.getNewValue();
-
- if (value instanceof String) {
- fTaskTagRule.clearTaskTags();
- fTaskTagRule.addTaskTags((String) value);
- }
-
- } else if (super.affectsBehavior(event)) {
- super.adaptToPreferenceChange(event);
- }
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fTokenProperties;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
deleted file mode 100644
index 0ea6dd1075d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextViewer;
-
-/**
- * Double click strategy aware of C identifier syntax rules.
- */
-public class CDoubleClickSelector implements ITextDoubleClickStrategy {
-
- protected ITextViewer fText;
- protected int fPos;
- protected int fStartPos;
- protected int fEndPos;
-
-
- protected static char[] fgBrackets= {'{', '}', '(', ')', '[', ']', '"', '"'};
-
- public CDoubleClickSelector() {
- super();
- }
-
-
- /**
- * @see ITextDoubleClickStrategy#doubleClicked
- */
- public void doubleClicked(ITextViewer text) {
- fPos= text.getSelectedRange().x;
-
-
- if (fPos < 0)
- return;
-
-
- fText= text;
-
-
- if (!selectBracketBlock())
- selectWord();
- }
-
-
- protected boolean matchBracketsAt() {
- char prevChar, nextChar;
-
-
- int i;
- int bracketIndex1= fgBrackets.length;
- int bracketIndex2= fgBrackets.length;
-
-
- fStartPos= -1;
- fEndPos= -1;
-
- // get the chars preceding and following the start position
- try {
- IDocument doc= fText.getDocument();
-
-
- prevChar= doc.getChar(fPos - 1);
- nextChar= doc.getChar(fPos);
-
-
- // is the char either an open or close bracket?
- for (i= 0; i < fgBrackets.length; i= i + 2) {
- if (prevChar == fgBrackets[i]) {
- fStartPos= fPos - 1;
- bracketIndex1= i;
- }
- }
- for (i= 1; i < fgBrackets.length; i= i + 2) {
- if (nextChar == fgBrackets[i]) {
- fEndPos= fPos;
- bracketIndex2= i;
- }
- }
-
-
- if (fStartPos > -1 && bracketIndex1 < bracketIndex2) {
- fEndPos= searchForClosingBracket(fStartPos, prevChar, fgBrackets[bracketIndex1 + 1], doc);
- if (fEndPos > -1)
- return true;
- else
- fStartPos= -1;
- } else if (fEndPos > -1) {
- fStartPos= searchForOpenBracket(fEndPos, fgBrackets[bracketIndex2 - 1], nextChar, doc);
- if (fStartPos > -1)
- return true;
- else
- fEndPos= -1;
- }
- } catch (BadLocationException x) {
- }
-
-
- return false;
- }
-
-
- protected boolean matchWord() {
- IDocument doc= fText.getDocument();
- try {
- int pos= fPos;
- char c;
-
-
- while (pos >= 0) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- --pos;
- }
- fStartPos= pos;
-
-
- pos= fPos;
- int length= doc.getLength();
-
-
- while (pos < length) {
- c= doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
- ++pos;
- }
- fEndPos= pos;
-
-
- return true;
-
-
- } catch (BadLocationException x) {
- }
- return false;
- }
-
-
- protected int searchForClosingBracket(int startPos, char openBracket, char closeBracket, IDocument doc) throws BadLocationException {
- int stack= 1;
- int closePos= startPos + 1;
- int length= doc.getLength();
- char nextChar;
-
-
- while (closePos < length && stack > 0) {
- nextChar= doc.getChar(closePos);
- if (nextChar == openBracket && nextChar != closeBracket)
- stack++;
- else if (nextChar == closeBracket)
- stack--;
- closePos++;
- }
-
-
- if (stack == 0)
- return closePos - 1;
- else
- return -1;
- }
-
-
- protected int searchForOpenBracket(int startPos, char openBracket, char closeBracket, IDocument doc) throws BadLocationException {
- int stack= 1;
- int openPos= startPos - 1;
- char nextChar;
-
- while (openPos >= 0 && stack > 0) {
- nextChar= doc.getChar(openPos);
- if (nextChar == closeBracket && nextChar != openBracket)
- stack++;
- else if (nextChar == openBracket)
- stack--;
- openPos--;
- }
-
-
- if (stack == 0)
- return openPos + 1;
- else
- return -1;
- }
-
-
- protected boolean selectBracketBlock() {
- if (matchBracketsAt()) {
- if (fStartPos == fEndPos)
- fText.setSelectedRange(fStartPos, 0);
- else
- fText.setSelectedRange(fStartPos + 1, fEndPos - fStartPos - 1);
-
-
- return true;
- }
- return false;
- }
-
-
- protected void selectWord() {
- if (matchWord()) {
- if (fStartPos == fEndPos)
- fText.setSelectedRange(fStartPos, 0);
- else
- fText.setSelectedRange(fStartPos + 1, fEndPos - fStartPos - 1);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
deleted file mode 100644
index 531826dc8e3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.formatter.IFormattingStrategy;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-
-import org.eclipse.cdt.internal.formatter.CCodeFormatter;
-
-
-public class CFormattingStrategy implements IFormattingStrategy {
-
-
- private String fInitialIndentation;
- private ISourceViewer fViewer;
-
-
- public CFormattingStrategy(ISourceViewer viewer) {
- fViewer = viewer;
- }
- /**
- * @see IFormattingStrategy#format(String, boolean, String, int[])
- */
- public String format(String content, boolean isLineStart, String indentation, int[] positions) {
- //ConfigurableOption[] options= CUIPlugin.getDefault().getCodeFormatterOptions();
- CCodeFormatter formatter= new CCodeFormatter(/* null options */);
-
- //IDocument doc= fViewer.getDocument();
- //String lineDelimiter= getLineDelimiterFor(doc);
- //formatter.options.setLineSeparator(lineDelimiter);
-
-
- //formatter.setPositionsToMap(positions);
- return formatter.formatSourceString(content);
- }
- /**
- * @see IFormattingStrategy#formatterStarts(String)
- */
- public void formatterStarts(String initialIndentation) {
- fInitialIndentation= initialIndentation;
- }
- /**
- * @see IFormattingStrategy#formatterStops()
- */
- public void formatterStops() {
- }
-
- /**
- * Embodies the policy which line delimiter to use when inserting into
- * a document
- */
- private static String getLineDelimiterFor(IDocument doc) {
- String lineDelim= null;
- try {
- lineDelim= doc.getLineDelimiter(0);
- } catch (BadLocationException e) {
- }
- if (lineDelim == null) {
- String systemDelimiter= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- String[] lineDelims= doc.getLegalLineDelimiters();
- for (int i= 0; i < lineDelims.length; i++) {
- if (lineDelims[i].equals(systemDelimiter)) {
- lineDelim= systemDelimiter;
- break;
- }
- }
- if (lineDelim == null) {
- lineDelim= lineDelims.length > 0 ? lineDelims[0] : systemDelimiter;
- }
- }
- return lineDelim;
- }
-
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
deleted file mode 100644
index 6f7dfc80381..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.ICharacterPairMatcher;
-
-/**
- * Helper class for match pairs of characters.
- */
-public class CPairMatcher implements ICharacterPairMatcher {
-
- protected char[] fPairs;
- protected IDocument fDocument;
- protected int fOffset;
-
- protected int fStartPos;
- protected int fEndPos;
- protected int fAnchor;
-
- protected CCodeReader fReader = new CCodeReader();
-
- public CPairMatcher(char[] pairs) {
- fPairs = pairs;
- }
-
- public IRegion match(IDocument document, int offset) {
-
- fOffset = offset;
-
- if (fOffset < 0)
- return null;
-
- fDocument = document;
-
- if (matchPairsAt() && fStartPos != fEndPos)
- return new Region(fStartPos, fEndPos - fStartPos + 1);
-
- return null;
- }
-
- public int getAnchor() {
- return fAnchor;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear()
- */
- public void clear() {
- if (fReader != null) {
- try {
- fReader.close();
- } catch (IOException x) {
- // ignore
- }
- }
- }
-
- public void dispose() {
- clear();
- fDocument = null;
- fReader = null;
- }
- protected boolean matchPairsAt() {
-
- int i;
- int pairIndex1= fPairs.length;
- int pairIndex2= fPairs.length;
-
- fStartPos= -1;
- fEndPos= -1;
-
- // get the chars preceding and following the start position
- try {
-
- char prevChar= fDocument.getChar(Math.max(fOffset - 1, 0));
-// modified behavior for http://dev.eclipse.org/bugs/show_bug.cgi?id=16879
-// char nextChar= fDocument.getChar(fOffset);
-
- // search for opening peer character next to the activation point
- for (i= 0; i < fPairs.length; i= i + 2) {
-// if (nextChar == fPairs[i]) {
-// fStartPos= fOffset;
-// pairIndex1= i;
-// } else
- if (prevChar == fPairs[i]) {
- fStartPos= fOffset - 1;
- pairIndex1= i;
- }
- }
-
- // search for closing peer character next to the activation point
- for (i= 1; i < fPairs.length; i= i + 2) {
- if (prevChar == fPairs[i]) {
- fEndPos= fOffset - 1;
- pairIndex2= i;
- }
-// else if (nextChar == fPairs[i]) {
-// fEndPos= fOffset;
-// pairIndex2= i;
-// }
- }
-
- if (fEndPos > -1) {
- fAnchor= RIGHT;
- fStartPos= searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
- if (fStartPos > -1)
- return true;
- else
- fEndPos= -1;
- } else if (fStartPos > -1) {
- fAnchor= LEFT;
- fEndPos= searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument);
- if (fEndPos > -1)
- return true;
- else
- fStartPos= -1;
- }
-
- } catch (BadLocationException x) {
- } catch (IOException x) {
- }
-
- return false;
- }
-
-
-
-// protected boolean matchPairsAt() {
-//
-// int i;
-// int pairIndex1 = fPairs.length;
-// int pairIndex2 = fPairs.length;
-//
-// fStartPos = -1;
-// fEndPos = -1;
-//
-// // get the chars preceding and following the start position
-// try {
-//
-// /*
-// A quick hack to get around the fact that we can't bracket
-// match on the very first element of a document. We make the
-// character to match a null character which is unlikely to match.
-// */
-// char prevChar = (fOffset > 0) ? fDocument.getChar(fOffset - 1) : '\0';
-// char nextChar = fDocument.getChar(fOffset);
-//
-// // search for opening peer character next to the activation point
-// for (i = 0; i < fPairs.length; i = i + 2) {
-// if (nextChar == fPairs[i]) {
-// fStartPos = fOffset;
-// pairIndex1 = i;
-// } else if (prevChar == fPairs[i]) {
-// fStartPos = fOffset - 1;
-// pairIndex1 = i;
-// }
-// }
-//
-// // search for closing peer character next to the activation point
-// for (i = 1; i < fPairs.length; i = i + 2) {
-// if (prevChar == fPairs[i]) {
-// fEndPos = fOffset - 1;
-// pairIndex2 = i;
-// } else if (nextChar == fPairs[i]) {
-// fEndPos = fOffset;
-// pairIndex2 = i;
-// }
-// }
-//
-// if (fEndPos > -1) {
-// fAnchor = RIGHT;
-// fStartPos = searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
-// if (fStartPos > -1)
-// return true;
-// else
-// fEndPos = -1;
-// } else if (fStartPos > -1) {
-// fAnchor = LEFT;
-// fEndPos = searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument);
-// if (fEndPos > -1)
-// return true;
-// else
-// fStartPos = -1;
-// }
-//
-// } catch (BadLocationException x) {
-// } catch (IOException x) {
-// }
-//
-// return false;
-// }
-
- protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
-
- fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true);
-
- int stack = 1;
- int c = fReader.read();
- while (c != CCodeReader.EOF) {
- if (c == openingPeer && c != closingPeer)
- stack++;
- else if (c == closingPeer)
- stack--;
-
- if (stack == 0)
- return fReader.getOffset();
-
- c = fReader.read();
- }
-
- return -1;
- }
-
- protected int searchForOpeningPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
-
- fReader.configureBackwardReader(document, offset, true, true);
-
- int stack = 1;
- int c = fReader.read();
- while (c != CCodeReader.EOF) {
- if (c == closingPeer && c != openingPeer)
- stack++;
- else if (c == openingPeer)
- stack--;
-
- if (stack == 0)
- return fReader.getOffset();
-
- c = fReader.read();
- }
-
- return -1;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
deleted file mode 100644
index 71dd825e4b7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-/**
- * This class provides the function parameter parsing for the C/C++ Editor hover
- * It is based heavily on the Java class JavaParameterListValidator
- *
- * @author thomasf
- *
- */
-public class CParameterListValidator implements IContextInformationValidator, IContextInformationPresenter {
- private int fPosition;
- private ITextViewer fViewer;
- private IContextInformation fInformation;
-
- private int fCurrentParameter;
-
- public CParameterListValidator() {
- }
-
- /**
- * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
- * @see IContextInformationPresenter#install(IContextInformation, ITextViewer, int)
- */
- public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
-
- fPosition= documentPosition;
- fViewer= viewer;
- fInformation= info;
-
- fCurrentParameter= -1;
- }
-
- private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
- while (pos < end) {
- char curr= d.getChar(pos);
- pos++;
- if (curr == '*') {
- if (pos < end && d.getChar(pos) == '/') {
- return pos + 1;
- }
- }
- }
- return end;
- }
-
- private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
- while (pos < end) {
- char curr= d.getChar(pos);
- pos++;
- if (curr == '\\') {
- // ignore escaped characters
- pos++;
- } else if (curr == ch) {
- return pos;
- }
- }
- return end;
- }
-
- private int getCharCount(IDocument document, int start, int end,
- char increment, char decrement, boolean considerNesting) throws BadLocationException {
-
- Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
-
- int nestingLevel= 0;
- int charCount= 0;
- while (start < end) {
- char curr= document.getChar(start++);
- switch (curr) {
- case '/':
- if (start < end) {
- char next= document.getChar(start);
- if (next == '*') {
- // a comment starts, advance to the comment end
- start= getCommentEnd(document, start + 1, end);
- } else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
- start= end;
- }
- }
- break;
- case '*':
- if (start < end) {
- char next= document.getChar(start);
- if (next == '/') {
- // we have been in a comment: forget what we read before
- charCount= 0;
- ++ start;
- }
- }
- break;
- case '"':
- case '\'':
- start= getStringEnd(document, start, end, curr);
- break;
- default:
-
- if (considerNesting) {
-
- if ('(' == curr)
- ++ nestingLevel;
- else if (')' == curr)
- -- nestingLevel;
-
- if (nestingLevel != 0)
- break;
- }
-
- if (increment != 0) {
- if (curr == increment)
- ++ charCount;
- }
-
- if (decrement != 0) {
- if (curr == decrement)
- -- charCount;
- }
- }
- }
-
- return charCount;
- }
-
- /**
- * @see IContextInformationValidator#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int position) {
-
- try {
- if (position < fPosition)
- return false;
-
- IDocument document= fViewer.getDocument();
- IRegion line= document.getLineInformationOfOffset(fPosition);
-
- if (position > line.getOffset() + line.getLength())
- return false;
-
- return (getCharCount(document, fPosition, position, '(', ')', false) >= 0);
-
- } catch (BadLocationException x) {
- return false;
- }
- }
-
- /**
- * @see IContextInformationPresenter#updatePresentation(int, TextPresentation)
- */
- public boolean updatePresentation(int position, TextPresentation presentation) {
-
- int currentParameter= -1;
-
- try {
- currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
- } catch (BadLocationException x) {
- return false;
- }
-
- if (fCurrentParameter != -1) {
- if (currentParameter == fCurrentParameter)
- return false;
- }
-
- presentation.clear();
- fCurrentParameter= currentParameter;
-
- //Don't presume what has been done to the string, rather use as is
- String s= fInformation.getInformationDisplayString();
-
- //@@@ This is obviously going to have problems with functions such
- //int myfunction(int (*function_argument)(void * extra, int param), void * extra)
- //int myfunction(/*A comment, indeed */int a);
- int start= 0;
- int occurrences= 0;
- while (occurrences < fCurrentParameter) {
- int found= s.indexOf(',', start);
- if (found == -1)
- break;
- start= found + 1;
- ++ occurrences;
- }
-
- if (occurrences < fCurrentParameter) {
- presentation.addStyleRange(new StyleRange(0, s.length(), null, null, SWT.NORMAL));
- return true;
- }
-
- if (start == -1)
- start= 0;
-
- int end= s.indexOf(',', start);
- if (end == -1)
- end= s.length();
-
- if (start > 0)
- presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
-
- if (end > start)
- presentation.addStyleRange(new StyleRange(start, end - start, null, null, SWT.BOLD));
-
- if (end < s.length())
- presentation.addStyleRange(new StyleRange(end, s.length() - end, null, null, SWT.NORMAL));
-
- return true;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java
deleted file mode 100644
index 2dc995fe0b5..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.rules.EndOfLineRule;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IPredicateRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.MultiLineRule;
-import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
-import org.eclipse.jface.text.rules.SingleLineRule;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-
-
-/**
- * This scanner recognizes comments
- */
-public class CPartitionScanner extends RuleBasedPartitionScanner {
-
-
- private final static String SKIP= "__skip";
-
-
- public final static String C_MULTILINE_COMMENT= "c_multi_line_comment";
- public final static String C_SINGLE_LINE_COMMENT= "c_single_line_comment";
- public final static String C_STRING= "c_string";
-
-
- /**
- * Detector for empty comments.
- */
- static class EmptyCommentDetector implements IWordDetector {
-
- /*
- * @see IWordDetector#isWordStart
- */
- public boolean isWordStart(char c) {
- return (c == '/');
- }
-
- /*
- * @see IWordDetector#isWordPart
- */
- public boolean isWordPart(char c) {
- return (c == '*' || c == '/');
- }
- };
-
- /**
- * Word rule for empty comments.
- */
- static class EmptyCommentRule extends WordRule implements IPredicateRule {
-
- private IToken fSuccessToken;
- /**
- * Constructor for EmptyCommentRule.
- * @param defaultToken
- */
- public EmptyCommentRule(IToken successToken) {
- super(new EmptyCommentDetector());
- fSuccessToken= successToken;
- addWord("/**/", fSuccessToken); //$NON-NLS-1$
- }
-
- /*
- * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- return evaluate(scanner);
- }
-
- /*
- * @see IPredicateRule#getSuccessToken()
- */
- public IToken getSuccessToken() {
- return fSuccessToken;
- }
- };
-
- /**
- * Creates the partitioner and sets up the appropriate rules.
- */
- public CPartitionScanner() {
- super();
-
- IToken comment= new Token(C_MULTILINE_COMMENT);
- IToken single_comment= new Token(C_SINGLE_LINE_COMMENT);
- IToken string= new Token(C_STRING);
- IToken skip= new Token(SKIP);
-
-
-
- List rules= new ArrayList();
-
-
- // Minimize the number of rules, since we have duplicate rules
- // in the CCodeScanner...
-
-
- // Add rule for single line comments.
- rules.add(new EndOfLineRule("//", single_comment));
-
-
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", string, '\\'));
- rules.add(new SingleLineRule("'", "'", skip, '\\'));
-
- // Add special case word rule.
- EmptyCommentRule wordRule= new EmptyCommentRule(comment);
- rules.add(wordRule);
-
-
- // Add rules for multi-line comments.
- rules.add(new MultiLineRule("/*", "*/", comment));
-
- IPredicateRule[] result= new IPredicateRule[rules.size()];
- rules.toArray(result);
- setPredicateRules(result);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
deleted file mode 100644
index 0f2db79926d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-
-public class CReconcilingStrategy implements IReconcilingStrategy {
-
-
- private CContentOutlinePage fOutliner;
- private ITextEditor fEditor;
- private IWorkingCopyManager fManager;
- private IDocumentProvider fDocumentProvider;
- private IProgressMonitor fProgressMonitor;
-
-
- public CReconcilingStrategy(CEditor editor) {
- fOutliner= editor.getOutlinePage();
- fEditor= editor;
- fManager= CUIPlugin.getDefault().getWorkingCopyManager();
- fDocumentProvider= CUIPlugin.getDefault().getDocumentProvider();
- }
-
- /**
- * @see IReconcilingStrategy#reconcile(document)
- */
- public void setDocument(IDocument document) {
- }
-
-
- /*
- * @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
- }
-
- /**
- * @see IReconcilingStrategy#reconcile(region)
- */
- public void reconcile(IRegion region) {
- reconcile();
- }
-
-
- /**
- * @see IReconcilingStrategy#reconcile(dirtyRegion, region)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion region) {
- reconcile();
- }
-
- private void reconcile() {
- boolean doUpdate = false;
- try {
- ITranslationUnit tu = fManager.getWorkingCopy(fEditor.getEditorInput());
- if (tu != null && tu.isWorkingCopy()) {
- IWorkingCopy workingCopy = (IWorkingCopy)tu;
- // reconcile
- synchronized (workingCopy) {
- doUpdate = workingCopy.reconcile(true, fProgressMonitor);
- }
- }
- if(doUpdate){
- fOutliner.contentUpdated();
- }
- } catch(CModelException e) {
-
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
deleted file mode 100644
index d14712aec04..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-import java.util.Vector;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.editor.CEditorTextHoverDispatcher;
-import org.eclipse.cdt.internal.ui.text.contentassist.*;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.ICDTConstants;
-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.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IAutoIndentStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.ContentFormatter;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.IFormattingStrategy;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.reconciler.IReconciler;
-import org.eclipse.jface.text.reconciler.Reconciler;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-
-
-/**
- * Configuration for an <code>SourceViewer</code> which shows C code.
- */
-public class CSourceViewerConfiguration extends SourceViewerConfiguration {
-
- /** Key used to look up display tab width */
- public final static String PREFERENCE_TAB_WIDTH= "org.eclipse.cdt.editor.tab.width"; //$NON-NLS-1$
- /** Key used to look up code formatter tab size */
- private final static String CODE_FORMATTER_TAB_SIZE= "org.eclipse.cdt.formatter.tabulation.size"; //$NON-NLS-1$
- /** Key used to look up code formatter tab character */
- private final static String CODE_FORMATTER_TAB_CHAR= "org.eclipse.cdt.formatter.tabulation.char"; //$NON-NLS-1$
-
- private CTextTools fTextTools;
- private CEditor fEditor;
-
- /**
- * Creates a new C source viewer configuration for viewers in the given editor using
- * the given C tools collection.
- *
- * @param tools the C text tools collection to be used
- * @param editor the editor in which the configured viewer will reside
- */
- public CSourceViewerConfiguration(CTextTools tools, CEditor editor) {
- fTextTools= tools;
- fEditor= editor;
- }
-
- /**
- * Returns the C multiline comment scanner for this configuration.
- *
- * @return the C multiline comment scanner
- */
- protected RuleBasedScanner getMultilineCommentScanner() {
- return fTextTools.getMultilineCommentScanner();
- }
-
- /**
- * Returns the C singleline comment scanner for this configuration.
- *
- * @return the C singleline comment scanner
- */
- protected RuleBasedScanner getSinglelineCommentScanner() {
- return fTextTools.getSinglelineCommentScanner();
- }
-
- /**
- * Returns the C string scanner for this configuration.
- *
- * @return the C string scanner
- */
- protected RuleBasedScanner getStringScanner() {
- return fTextTools.getStringScanner();
- }
-
- /**
- * Returns the color manager for this configuration.
- *
- * @return the color manager
- */
- protected IColorManager getColorManager() {
- return fTextTools.getColorManager();
- }
-
- /**
- * Returns the editor in which the configured viewer(s) will reside.
- *
- * @return the enclosing editor
- */
- protected ITextEditor getEditor() {
- return fEditor;
- }
-
- /**
- * @see ISourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
- */
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-
- PresentationReconciler reconciler= new PresentationReconciler();
-
- RuleBasedScanner scanner;
-
- if(sourceViewer instanceof CEditor.AdaptedSourceViewer) {
- String language = ((CEditor.AdaptedSourceViewer)sourceViewer).getDisplayLanguage();
- if(language != null && language.equals(CEditor.LANGUAGE_CPP)) {
- scanner= fTextTools.getCppCodeScanner();
- } else {
- scanner= fTextTools.getCCodeScanner();
- }
- } else {
- scanner= fTextTools.getCCodeScanner();
- }
-
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
-
- reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
- //TextAttribute attr = new TextAttribute(manager.getColor(ICColorConstants.C_DEFAULT));
-
- dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
- reconciler.setDamager(dr, CPartitionScanner.C_SINGLE_LINE_COMMENT);
- reconciler.setRepairer(dr, CPartitionScanner.C_SINGLE_LINE_COMMENT);
-
- dr= new DefaultDamagerRepairer(getStringScanner());
- reconciler.setDamager(dr, CPartitionScanner.C_STRING);
- reconciler.setRepairer(dr, CPartitionScanner.C_STRING);
-
- dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
- reconciler.setDamager(dr, CPartitionScanner.C_MULTILINE_COMMENT);
- reconciler.setRepairer(dr, CPartitionScanner.C_MULTILINE_COMMENT);
-
- return reconciler;
- }
-
-
- /**
- * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- if(getEditor() == null) {
- return null;
- }
-
- ContentAssistant assistant = new ContentAssistant();
-
- IContentAssistProcessor processor = new CCompletionProcessor(getEditor());
- assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
-
- //Will this work as a replacement for the configuration lines below?
- ContentAssistPreference.configure(assistant, getPreferenceStore());
-
- assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
-
- return assistant;
- }
-
-
- /**
- * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
- */
- public IReconciler getReconciler(ISourceViewer sourceViewer) {
- if (fEditor != null && fEditor.isEditable()) {
- Reconciler reconciler= new Reconciler();
- reconciler.setDelay(1000);
- reconciler.setIsIncrementalReconciler(false);
- reconciler.setReconcilingStrategy(new CReconcilingStrategy(fEditor), IDocument.DEFAULT_CONTENT_TYPE);
- return reconciler;
- }
- return null;
- }
-
-
- /**
- * @see SourceViewerConfiguration#getAutoIndentStrategy(ISourceViewer, String)
- */
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- if(CPartitionScanner.C_MULTILINE_COMMENT.equals(contentType))
- return new CCommentAutoIndentStrategy();
- return new CAutoIndentStrategy();
- }
-
-
- /**
- * @see SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer, String)
- */
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- return new CDoubleClickSelector();
- }
-
- /**
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDefaultPrefixes(ISourceViewer, String)
- */
- public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
- return new String[] { "//", "" };
- }
-
- /**
- * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
- */
- public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
- if(IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
- return "//";
- if(CPartitionScanner.C_SINGLE_LINE_COMMENT.equals(contentType))
- return "//";
- if(CPartitionScanner.C_MULTILINE_COMMENT.equals(contentType))
- return "//";
- return null;
- }
-
-
- /*
- * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
- */
- public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
-
- Vector vector= new Vector();
-
- // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
- int tabWidth= getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
- boolean useSpaces= getPreferenceStore().getBoolean(CEditor.SPACES_FOR_TABS); //$NON-NLS-1$
-
- for (int i= 0; i <= tabWidth; i++) {
- StringBuffer prefix= new StringBuffer();
-
- if (useSpaces) {
- for (int j= 0; j + i < tabWidth; j++)
- prefix.append(' ');
-
- if (i != 0)
- prefix.append('\t');
- } else {
- for (int j= 0; j < i; j++)
- prefix.append(' ');
-
- if (i != tabWidth)
- prefix.append('\t');
- }
-
- vector.add(prefix.toString());
- }
-
- vector.add(""); //$NON-NLS-1$
-
- return (String[]) vector.toArray(new String[vector.size()]);
- }
-
-
- /**
- * @see SourceViewerConfiguration#getTabWidth(ISourceViewer)
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
- }
-
-
- /**
- * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
- return new CAnnotationHover();
- }
-
-
- /**
- * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
- HashMap textHovers = new HashMap( 3 );
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint( CUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- ICDTConstants.EP_TEXT_HOVERS );
- if ( point != null )
- {
- IExtension[] extensions = point.getExtensions();
- for ( int i = 0; i < extensions.length; i++ )
- {
- IExtension currentExtension = extensions[i];
- IConfigurationElement[] configElements = currentExtension.getConfigurationElements();
- for ( int j = 0; j < configElements.length; j++ )
- {
- IConfigurationElement config = configElements[j];
- if ( config.getName().equals( ICDTConstants.TAG_TEXT_HOVER ) )
- {
- processTextHoverElement( textHovers, config );
- }
- }
- }
- }
-
- return new CEditorTextHoverDispatcher( fEditor, textHovers );
- }
-
- private void processTextHoverElement( HashMap textHovers, IConfigurationElement element ) {
- String perspId = element.getAttribute( ICDTConstants.ATT_PERSPECTIVE );
- ITextHover textHover = null;
- try {
- textHover = (ITextHover)element.createExecutableExtension( ICDTConstants.ATT_CLASS );
- } catch (CoreException e) {
- }
- if ( perspId != null ) {
- textHovers.put( perspId, textHover );
- }
- }
-
- /**
- * @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
- */
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
- CPartitionScanner.C_MULTILINE_COMMENT,
- CPartitionScanner.C_SINGLE_LINE_COMMENT,
- CPartitionScanner.C_STRING };
- }
-
- /**
- * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
- */
- public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- String[] types= new String[] {
- DefaultPartitioner.CONTENT_TYPES_CATEGORY
- };
-
- ContentFormatter formatter= new ContentFormatter();
- IFormattingStrategy strategy= new CFormattingStrategy(sourceViewer);
-
- formatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
- formatter.enablePartitionAwareFormatting(false);
- formatter.setPartitionManagingPositionCategories(types);
-
- return formatter;
- }
-
- protected IPreferenceStore getPreferenceStore() {
- return CUIPlugin.getDefault().getPreferenceStore();
- }
-
- /*
- * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer)
- * @since 2.0
- */
- public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
- return getInformationControlCreator(sourceViewer, true);
- }
-
-
- public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer, final boolean cutDown) {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
- return new DefaultInformationControl(parent, style, new HTMLTextPresenter(cutDown));
- // return new HoverBrowserControl(parent);
- }
- };
- }
-
- public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
- return super.getInformationPresenter(sourceViewer);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
deleted file mode 100644
index e6fe8426818..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.util.CColorManager;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.core.runtime.Preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.jface.text.rules.IPartitionTokenScanner;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * This type shares all scanners and the color manager between
- * its clients.
- */
-public class CTextTools {
-
- private class PreferenceListener implements IPropertyChangeListener, Preferences.IPropertyChangeListener {
- public void propertyChange(PropertyChangeEvent event) {
- adaptToPreferenceChange(event);
- }
- public void propertyChange(Preferences.PropertyChangeEvent event) {
- adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue()));
- }
- };
-
- /** The color manager */
- private CColorManager fColorManager;
- /** The C source code scanner */
- private CCodeScanner fCodeScanner;
- /** The C++ source code scanner */
- private CppCodeScanner fCppCodeScanner;
- /** The C partitions scanner */
- private FastCPartitionScanner fPartitionScanner;
- /** The Java multiline comment scanner */
- private CCommentScanner fMultilineCommentScanner;
- /** The Java singleline comment scanner */
- private CCommentScanner fSinglelineCommentScanner;
- /** The Java string scanner */
- private SingleTokenCScanner fStringScanner;
-
- /** The preference store */
- private IPreferenceStore fPreferenceStore;
- /** The core preference store */
- private Preferences fCorePreferenceStore;
- /** The preference change listener */
- private PreferenceListener fPreferenceListener= new PreferenceListener();
-
-
- /**
- * Creates a new C text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public CTextTools(IPreferenceStore store) {
- this(store, null);
- }
-
- /**
- * Creates a new C text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public CTextTools(IPreferenceStore store, Preferences coreStore) {
- if(store == null) {
- store = CUIPlugin.getDefault().getPreferenceStore();
- }
- fPreferenceStore = store;
- fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
-
- fCorePreferenceStore= coreStore;
- if (fCorePreferenceStore != null) {
- fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener);
- }
-
- fColorManager= new CColorManager();
- fCodeScanner= new CCodeScanner(fColorManager, store);
- fCppCodeScanner= new CppCodeScanner(fColorManager, store);
- fPartitionScanner= new FastCPartitionScanner();
-
- fMultilineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT);
- fStringScanner= new SingleTokenCScanner(fColorManager, store, ICColorConstants.C_STRING);
- }
-
- /**
- * Creates a new C text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public CTextTools() {
- this((IPreferenceStore)null);
- }
-
- /**
- * Disposes all members of this tools collection.
- */
- public void dispose() {
-
- fCodeScanner= null;
- fPartitionScanner= null;
-
-
- fMultilineCommentScanner= null;
- fSinglelineCommentScanner= null;
- fStringScanner= null;
-
- if (fColorManager != null) {
- fColorManager.dispose();
- fColorManager= null;
- }
-
- if (fPreferenceStore != null) {
- fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
- fPreferenceStore= null;
-
- if (fCorePreferenceStore != null) {
- fCorePreferenceStore.removePropertyChangeListener(fPreferenceListener);
- fCorePreferenceStore= null;
- }
-
- fPreferenceListener= null;
- }
- }
-
- /**
- * Gets the color manager.
- */
- public CColorManager getColorManager() {
- return fColorManager;
- }
-
- /**
- * Gets the code scanner used.
- */
- public RuleBasedScanner getCCodeScanner() {
- return fCodeScanner;
- }
-
- /**
- * Gets the code scanner used.
- */
- public RuleBasedScanner getCppCodeScanner() {
- return fCppCodeScanner;
- }
-
- /**
- * Returns a scanner which is configured to scan
- * C-specific partitions, which are multi-line comments,
- * and regular C source code.
- *
- * @return a C partition scanner
- */
- public IPartitionTokenScanner getPartitionScanner() {
- return fPartitionScanner;
- }
-
- /**
- * Gets the document provider used.
- */
- public IDocumentPartitioner createDocumentPartitioner() {
-
- String[] types= new String[] {
- CPartitionScanner.C_MULTILINE_COMMENT,
- CPartitionScanner.C_SINGLE_LINE_COMMENT,
- CPartitionScanner.C_STRING
- };
-
- return new DefaultPartitioner(getPartitionScanner(), types);
- }
-
- /**
- * Returns a scanner which is configured to scan C multiline comments.
- *
- * @return a C multiline comment scanner
- */
- public RuleBasedScanner getMultilineCommentScanner() {
- return fMultilineCommentScanner;
- }
-
- /**
- * Returns a scanner which is configured to scan C singleline comments.
- *
- * @return a C singleline comment scanner
- */
- public RuleBasedScanner getSinglelineCommentScanner() {
- return fSinglelineCommentScanner;
- }
-
- /**
- * Returns a scanner which is configured to scan Java strings.
- *
- * @return a Java string scanner
- */
- public RuleBasedScanner getStringScanner() {
- return fStringScanner;
- }
-
-
- /**
- * Determines whether the preference change encoded by the given event
- * changes the behavior of one its contained components.
- *
- * @param event the event to be investigated
- * @return <code>true</code> if event causes a behavioral change
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return fCodeScanner.affectsBehavior(event) ||
- fCppCodeScanner.affectsBehavior(event) ||
- fMultilineCommentScanner.affectsBehavior(event) ||
- fSinglelineCommentScanner.affectsBehavior(event) ||
- fStringScanner.affectsBehavior(event);
- }
-
- /**
- * Adapts the behavior of the contained components to the change
- * encoded in the given event.
- *
- * @param event the event to whch to adapt
- */
- protected void adaptToPreferenceChange(PropertyChangeEvent event) {
- if (fCodeScanner.affectsBehavior(event))
- fCodeScanner.adaptToPreferenceChange(event);
- if (fCppCodeScanner.affectsBehavior(event))
- fCppCodeScanner.adaptToPreferenceChange(event);
- if (fMultilineCommentScanner.affectsBehavior(event))
- fMultilineCommentScanner.adaptToPreferenceChange(event);
- if (fSinglelineCommentScanner.affectsBehavior(event))
- fSinglelineCommentScanner.adaptToPreferenceChange(event);
- if (fStringScanner.affectsBehavior(event))
- fStringScanner.adaptToPreferenceChange(event);
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
deleted file mode 100644
index 010cd6f6c6b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-
-/**
- * This is a helper class for the text editor to be able to determine,
- * given a particular offset in a document, various candidates segments
- * for things like context help, proposals and hovering.
- */
-public class CWordFinder
-{
- /**
- * This method determines for a given offset into a given document
- * what the region is which defines the current word. A word is
- * defined as the set of non "C" identifiers. So assuming that !
- * indicated the current cursor postion:
- * !afunction(int a, int b) --> word = length 0
- * afunc!tion(int a, int b) --> word = afunction
- * afunction!(int a, int b) --> word = afunction
- * afunction(!int a, int b) --> word = length 0
- * afunction(int a,! int b) --> word = length 0
- * afunction(!) --> word = length 0
- * @param document The document to be examined
- * @param offset The offset into the document where a word should
- * be idendified.
- * @return The region defining the current word, which may be a
- * region of length 0 if the offset is not in a word, or null if
- * there is an error accessing the docment data.
- */
- public static IRegion findWord( IDocument document, int offset )
- {
- int start = -1;
- int end = -1;
-
- try
- {
- int pos = offset;
- char c;
-
- while( pos >= 0 )
- {
- c = document.getChar( pos );
- if ( !Character.isJavaIdentifierPart( c ) )
- break;
- --pos;
- }
-
- start = pos;
-
- pos = offset;
- int length = document.getLength();
-
- while( pos < length )
- {
- c = document.getChar( pos );
- if ( !Character.isJavaIdentifierPart( c ) )
- break;
- ++pos;
- }
-
- end = pos;
-
- }
- catch( BadLocationException x )
- {
- }
-
- if ( start > -1 && end > -1 )
- {
- if ( start == offset && end == offset )
- return new Region( offset, 0 );
- else if ( start == offset )
- return new Region( start, end - start );
- else
- return new Region( start + 1, end - start - 1 );
- }
-
- return null;
- }
-
- /**
- * This method will determine the region for the name of the function
- * within which the current offset is contained.
- * @param document The document to be examined
- * @param offset The offset into the document where a word should
- * be idendified.
- * @return The region defining the current word, which may be a
- * region of length 0 if the offset is not in a function, or null if
- * there is an error accessing the docment data.
- */
- public static IRegion findFunction( IDocument document, int offset )
- {
- int leftbracket = -1;
- int leftbracketcount = 0;
- int rightbracket = -1;
- int rightbracketcount = 0;
- int functionstart = -1;
- int functionend = -1;
-
-
- try
- {
- int length = document.getLength();
- int pos;
- char c;
-
- //Find most relevant right bracket from our position
- pos = offset;
- rightbracketcount = leftbracketcount = 0;
- while(pos < length) {
- c = document.getChar( pos );
-
- if( c == ')') {
- rightbracketcount++;
- if(rightbracketcount >= leftbracketcount) {
- rightbracket = pos;
- break;
- }
- }
-
- if(c == '(') {
- leftbracketcount++;
- }
-
- if(c == ';') {
- break;
- }
-
- pos++;
- }
-
- if ( rightbracket == -1 ) {
- return new Region(offset, 0);
- }
-
- //Now backtrack our way from the rightbracket to the left
- pos = rightbracket;
- rightbracketcount = leftbracketcount = 0;
- while(pos >= 0) {
- c = document.getChar( pos );
-
- if( c == ')') {
- rightbracketcount++;
- }
-
- if(c == '(') {
- leftbracketcount++;
- if(leftbracketcount >= rightbracketcount) {
- leftbracket = pos;
- break;
- }
- }
-
- if(c == ';') {
- break;
- }
-
- pos--;
- }
-
- if ( leftbracket == -1 ) {
- return new Region(offset, 0);
- }
-
- //Now work our way to the function name
- pos = leftbracket - 1;
- while(pos >= 0) {
- c = document.getChar( pos );
- if(functionend == -1 && c == ' ' ) {
- pos--;
- continue;
- }
-
- if(!Character.isJavaIdentifierPart(c)) {
- break;
- }
-
- functionstart = pos;
- if(functionend == -1) {
- functionend = pos;
- }
-
- pos--;
- }
- } catch( BadLocationException x ) {
- /* Ignore */
- }
-
- if (functionstart > -1 && functionend > -1) {
- return new Region(functionstart, functionend - functionstart + 1);
- }
-
- return null;
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CppCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CppCodeScanner.java
deleted file mode 100644
index 5fc2ccd3a8b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CppCodeScanner.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.SingleLineRule;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * A C code scanner.
- */
-public final class CppCodeScanner extends AbstractCScanner {
-
- private static String[] fgKeywords= {
- "and", "and_eq", "asm", "auto",
- "bitand", "bitor", "break",
- "case", "catch", "class", "compl", "const", "const_cast", "continue",
- "default", "delete", "do", "dynamic_cast",
- "else", "enum", "explicit", "export", "extern",
- "false", "final", "finally", "for", "friend",
- "goto",
- "if", "inline",
- "mutable",
- "namespace", "new", "not", "not_eq",
- "operator", "or", "or_eq",
- "private", "protected", "public",
- "redeclared", "register", "reinterpret_cast", "return", "restrict",
- "sizeof", "static", "static_cast", "struct", "switch",
- "template", "this", "throw", "true", "try", "typedef", "typeid", "typename",
- "union", "using",
- "virtual", "volatile",
- "while",
- "xor", "xor_eq"
-
- };
-
-
- private static String[] fgTypes= { "bool", "char", "double", "float", "int", "long", "short", "signed", "unsigned", "void", "wchar_t", "_Bool", "_Complex", "_Imaginary"};
- private static String[] fgConstants= { "false", "NULL", "true", "__DATE__", "__LINE__", "__TIME__", "__FILE__", "__STDC__"};
- private static String[] fgPreprocessor= { "#define", "#undef", "#include", "#error", "#warning", "#pragma", "#ifdef", "#ifndef", "#line", "#undef", "#if", "#else", "#elif", "#endif"};
-
-
- private static String[] fgTokenProperties= {
- ICColorConstants.C_KEYWORD,
- ICColorConstants.C_TYPE,
- ICColorConstants.C_STRING,
- ICColorConstants.C_DEFAULT
- };
-
-
- /**
- * Creates a C++ code scanner
- */
- public CppCodeScanner(IColorManager manager, IPreferenceStore store) {
- super(manager, store);
- initialize();
- }
-
- /*
- * @see AbstractCScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fgTokenProperties;
- }
-
- /*
- * @see AbstractCScanner#createRules()
- */
- protected List createRules() {
-
- List rules= new ArrayList();
-
- // Add rule for strings
- Token token= getToken(ICColorConstants.C_STRING);
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("'", "'", token, '\\'));
-
-
-
- // Add generic whitespace rule.
- //rules.add(new WhitespaceRule(new CWhitespaceDetector()));
-
-
- // Add word rule for keywords, types, and constants.
- token= getToken(ICColorConstants.C_DEFAULT);
- WordRule wordRule= new WordRule(new CWordDetector(), token);
-
- token= getToken(ICColorConstants.C_KEYWORD);
- for (int i=0; i<fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], token);
- token= getToken(ICColorConstants.C_TYPE);
- for (int i=0; i<fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], token);
- for (int i=0; i<fgConstants.length; i++)
- wordRule.addWord(fgConstants[i], token);
- rules.add(wordRule);
-
- token = getToken(ICColorConstants.C_TYPE);
- PreprocessorRule preprocessorRule = new PreprocessorRule(new CWordDetector(), token);
-
- for (int i=0; i<fgPreprocessor.length; i++) {
- preprocessorRule.addWord(fgPreprocessor[i], token);
- }
- rules.add(preprocessorRule);
-
- setDefaultReturnToken(getToken(ICColorConstants.C_DEFAULT));
- return rules;
- }
-
- /*
- * @see RuleBasedScanner#setRules(IRule[])
- */
- public void setRules(IRule[] rules) {
- super.setRules(rules);
- }
-
- /*
- * @see AbstractCScanner#affectsBehavior(PropertyChangeEvent)
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return super.affectsBehavior(event);
- }
-
- /*
- * @see AbstractCScanner#adaptToPreferenceChange(PropertyChangeEvent)
- */
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
-
- if (super.affectsBehavior(event)) {
- super.adaptToPreferenceChange(event);
- }
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
deleted file mode 100644
index 6c177aa3886..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
+++ /dev/null
@@ -1,485 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IPartitionTokenScanner;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-
-/**
- * This scanner recognizes the C multi line comments, C single line comments,
- * C strings and C characters.
- */
-public class FastCPartitionScanner implements IPartitionTokenScanner {
-
- private final static String SKIP= "__skip"; //$NON-NLS-1$
- public final static String C_STRING= "c_string"; //$NON-NLS-1$
- public final static String C_SINGLE_LINE_COMMENT= "c_single_line_comment"; //$NON-NLS-1$
- public final static String C_MULTI_LINE_COMMENT= "c_multi_line_comment"; //$NON-NLS-1$
-
- // states
- private static final int CCODE= 0;
- private static final int SINGLE_LINE_COMMENT= 1;
- private static final int MULTI_LINE_COMMENT= 2;
- private static final int CHARACTER= 3;
- private static final int STRING= 4;
-
- // beginning of prefixes and postfixes
- private static final int NONE= 0;
- private static final int BACKSLASH= 1; // postfix for STRING and CHARACTER
- private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE or JAVADOC
- private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT or JAVADOC
- private static final int STAR= 4; // postfix for MULTI_LINE_COMMENT or JAVADOC
- private static final int CARRIAGE_RETURN=5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
-
- /** The scanner. */
-// private final BufferedRuleBasedScanner fScanner= new BufferedRuleBasedScanner(1000);
- private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000); // faster implementation
-
- /** The offset of the last returned token. */
- private int fTokenOffset;
- /** The length of the last returned token. */
- private int fTokenLength;
-
- /** The state of the scanner. */
- private int fState;
- /** The last significant characters read. */
- private int fLast;
- /** The amount of characters already read on first call to nextToken(). */
- private int fPrefixLength;
-
- // emulate CPartitionScanner
- private static final boolean fgEmulate= false;
- private int fCOffset;
- private int fCLength;
-
- private final IToken[] fTokens= new IToken[] {
- new Token(null),
- new Token(C_SINGLE_LINE_COMMENT),
- new Token(C_MULTI_LINE_COMMENT),
- new Token(SKIP),
- new Token(C_STRING)
- };
-
- /*
- * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
- // emulate CPartitionScanner
- if (fgEmulate) {
- if (fCOffset != -1 && fTokenOffset + fTokenLength != fCOffset + fCLength) {
- fTokenOffset += fTokenLength;
- return fTokens[CCODE];
- } else {
- fCOffset= -1;
- fCLength= 0;
- }
- }
-
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
-
- while (true) {
- final int ch= fScanner.read();
-
- // characters
- switch (ch) {
- case ICharacterScanner.EOF:
- if (fTokenLength > 0) {
- fLast= NONE; // ignore last
- return preFix(fState, CCODE, NONE, 0);
-
- } else {
- fLast= NONE;
- fPrefixLength= 0;
- return Token.EOF;
- }
-
- case '\r':
- // emulate CPartitionScanner
- if (!fgEmulate && fLast != CARRIAGE_RETURN) {
- fLast= CARRIAGE_RETURN;
- fTokenLength++;
- continue;
-
- } else {
-
- switch (fState) {
- case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
- if (fTokenLength > 0) {
- IToken token= fTokens[fState];
-
- // emulate CPartitionScanner
- if (fgEmulate) {
- fTokenLength++;
- fLast= NONE;
- fPrefixLength= 0;
- } else {
- fLast= CARRIAGE_RETURN;
- fPrefixLength= 1;
- }
-
- fState= CCODE;
- return token;
-
- } else {
- consume();
- continue;
- }
-
- default:
- consume();
- continue;
- }
- }
-
- case '\n':
- switch (fState) {
- case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
- // assert(fTokenLength > 0);
- return postFix(fState);
-
- default:
- consume();
- continue;
- }
-
- default:
- if (!fgEmulate && fLast == CARRIAGE_RETURN) {
- switch (fState) {
- case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
-
- int last;
- int newState;
- switch (ch) {
- case '/':
- last= SLASH;
- newState= CCODE;
- break;
-
- case '*':
- last= STAR;
- newState= CCODE;
- break;
-
- case '\'':
- last= NONE;
- newState= CHARACTER;
- break;
-
- case '"':
- last= NONE;
- newState= STRING;
- break;
-
- case '\r':
- last= CARRIAGE_RETURN;
- newState= CCODE;
- break;
-
- case '\\':
- last= BACKSLASH;
- newState= CCODE;
- break;
-
- default:
- last= NONE;
- newState= CCODE;
- break;
- }
-
- fLast= NONE; // ignore fLast
- return preFix(fState, newState, last, 1);
-
- default:
- break;
- }
- }
- }
-
- // states
- switch (fState) {
- case CCODE:
- switch (ch) {
- case '/':
- if (fLast == SLASH) {
- if (fTokenLength - getLastLength(fLast) > 0) {
- return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
- } else {
- preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- } else {
- fTokenLength++;
- fLast= SLASH;
- break;
- }
-
- case '*':
- if (fLast == SLASH) {
- if (fTokenLength - getLastLength(fLast) > 0)
- return preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
- else {
- preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- } else {
- consume();
- break;
- }
-
- case '\'':
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0)
- return preFix(CCODE, CHARACTER, NONE, 1);
- else {
- preFix(CCODE, CHARACTER, NONE, 1);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- case '"':
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0)
- return preFix(CCODE, STRING, NONE, 1);
- else {
- preFix(CCODE, STRING, NONE, 1);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- default:
- consume();
- break;
- }
- break;
-
- case SINGLE_LINE_COMMENT:
- consume();
- break;
-
- case MULTI_LINE_COMMENT:
- switch (ch) {
- case '*':
- fTokenLength++;
- fLast= STAR;
- break;
-
- case '/':
- if (fLast == STAR) {
- return postFix(MULTI_LINE_COMMENT);
- } else {
- consume();
- break;
- }
-
- default:
- consume();
- break;
- }
- break;
-
- case STRING:
- switch (ch) {
- case '\\':
- fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
- fTokenLength++;
- break;
-
- case '\"':
- if (fLast != BACKSLASH) {
- return postFix(STRING);
-
- } else {
- consume();
- break;
- }
-
- default:
- consume();
- break;
- }
- break;
-
- case CHARACTER:
- switch (ch) {
- case '\\':
- fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
- fTokenLength++;
- break;
-
- case '\'':
- if (fLast != BACKSLASH) {
- return postFix(CHARACTER);
-
- } else {
- consume();
- break;
- }
-
- default:
- consume();
- break;
- }
- break;
- }
- }
- }
-
- private static final int getLastLength(int last) {
- switch (last) {
- default:
- return -1;
-
- case NONE:
- return 0;
-
- case CARRIAGE_RETURN:
- case BACKSLASH:
- case SLASH:
- case STAR:
- return 1;
-
- case SLASH_STAR:
- return 2;
-
- }
- }
-
- private final void consume() {
- fTokenLength++;
- fLast= NONE;
- }
-
- private final IToken postFix(int state) {
- fTokenLength++;
- fLast= NONE;
- fState= CCODE;
- fPrefixLength= 0;
- return fTokens[state];
- }
-
- private final IToken preFix(int state, int newState, int last, int prefixLength) {
- // emulate CPartitionScanner
- if (fgEmulate && state == CCODE && (fTokenLength - getLastLength(fLast) > 0)) {
- fTokenLength -= getLastLength(fLast);
- fCOffset= fTokenOffset;
- fCLength= fTokenLength;
- fTokenLength= 1;
- fState= newState;
- fPrefixLength= prefixLength;
- fLast= last;
- return fTokens[state];
-
- } else {
- fTokenLength -= getLastLength(fLast);
- fLast= last;
- fPrefixLength= prefixLength;
- IToken token= fTokens[state];
- fState= newState;
- return token;
- }
- }
-
- private static int getState(String contentType) {
-
- if (contentType == null)
- return CCODE;
-
- else if (contentType.equals(C_SINGLE_LINE_COMMENT))
- return SINGLE_LINE_COMMENT;
-
- else if (contentType.equals(C_MULTI_LINE_COMMENT))
- return MULTI_LINE_COMMENT;
-
- else if (contentType.equals(C_STRING))
- return STRING;
-
- else if (contentType.equals(SKIP))
- return CHARACTER;
-
- else
- return CCODE;
- }
-
- /*
- * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
- */
- public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
-
- fScanner.setRange(document, offset, length);
- fTokenOffset= partitionOffset;
- fTokenLength= 0;
- fPrefixLength= offset - partitionOffset;
- fLast= NONE;
-
- if (offset == partitionOffset) {
- // restart at beginning of partition
- fState= CCODE;
- } else {
- fState= getState(contentType);
- }
-
- // emulate CPartitionScanner
- if (fgEmulate) {
- fCOffset= -1;
- fCLength= 0;
- }
- }
-
- /*
- * @see ITokenScanner#setRange(IDocument, int, int)
- */
- public void setRange(IDocument document, int offset, int length) {
-
- fScanner.setRange(document, offset, length);
- fTokenOffset= offset;
- fTokenLength= 0;
- fPrefixLength= 0;
- fLast= NONE;
- fState= CCODE;
-
- // emulate CPartitionScanner
- if (fgEmulate) {
- fCOffset= -1;
- fCLength= 0;
- }
- }
-
- /*
- * @see ITokenScanner#getTokenLength()
- */
- public int getTokenLength() {
- return fTokenLength;
- }
-
- /*
- * @see ITokenScanner#getTokenOffset()
- */
- public int getTokenOffset() {
- return fTokenOffset;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java
deleted file mode 100644
index 1d8bfc62c6f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.io.IOException;
-import java.io.PushbackReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-
-
-/**
- * Reads the text contents from a reader of HTML contents and translates
- * the tags or cut them out.
- */
-public class HTML2TextReader extends SubstitutionTextReader {
-
-
- private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- private static final Map fgEntityLookup;
- private static final Set fgTags;
-
- static {
-
- fgTags= new HashSet();
- fgTags.add("b"); //$NON-NLS-1$
- fgTags.add("br"); //$NON-NLS-1$
- fgTags.add("h5"); //$NON-NLS-1$
- fgTags.add("p"); //$NON-NLS-1$
- fgTags.add("dl"); //$NON-NLS-1$
- fgTags.add("dt"); //$NON-NLS-1$
- fgTags.add("dd"); //$NON-NLS-1$
- fgTags.add("li"); //$NON-NLS-1$
- fgTags.add("ul"); //$NON-NLS-1$
-
- fgEntityLookup= new HashMap(7);
- fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$
- fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private int fCounter= 0;
- private TextPresentation fTextPresentation;
- private int fBold= 0;
- private int fStartOffset= -1;
- private boolean fInParagraph= false;
-
- /**
- * Transforms the html text from the reader to formatted text.
- * @param presentation If not <code>null</code>, formattings will be applied to
- * the presentation.
- */
- public HTML2TextReader(Reader reader, TextPresentation presentation) {
- super(new PushbackReader(reader));
- fTextPresentation= presentation;
- }
-
- public int read() throws IOException {
- int c= super.read();
- if (c != -1)
- ++ fCounter;
- return c;
- }
-
- protected void startBold() {
- if (fBold == 0)
- fStartOffset= fCounter;
- ++ fBold;
- }
-
- protected void stopBold() {
- -- fBold;
- if (fBold == 0) {
- if (fTextPresentation != null) {
- fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD));
- }
- fStartOffset= -1;
- }
- }
-
- /**
- * @see SubstitutionTextReader#computeSubstitution(char)
- */
- protected String computeSubstitution(int c) throws IOException {
- if (c == '<')
- return processHTMLTag();
- else if (c == '&')
- return processEntity();
-
- return null;
- }
-
- private String html2Text(String html) {
-
- String tag= html;
- if ('/' == tag.charAt(0))
- tag= tag.substring(1);
-
- if (!fgTags.contains(tag))
- return ""; //$NON-NLS-1$
-
- if ("b".equals(html)) { //$NON-NLS-1$
- startBold();
- return ""; //$NON-NLS-1$
- }
-
- if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- startBold();
- return ""; //$NON-NLS-1$
- }
-
- if ("dl".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- if ("dd".equals(html)) //$NON-NLS-1$
- return "\t"; //$NON-NLS-1$
-
- if ("li".equals(html)) //$NON-NLS-1$
- return LINE_DELIM + "\t" + "-";
-
- if ("/b".equals(html)) { //$NON-NLS-1$
- stopBold();
- return ""; //$NON-NLS-1$
- }
-
- if ("p".equals(html)) { //$NON-NLS-1$
- fInParagraph= true;
- return LINE_DELIM;
- }
-
- if ("br".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- if ("/p".equals(html)) { //$NON-NLS-1$
- boolean inParagraph= fInParagraph;
- fInParagraph= false;
- return inParagraph ? "" : LINE_DELIM; //$NON-NLS-1$
- }
-
- if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- stopBold();
- return LINE_DELIM;
- }
-
- if ("/dd".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- return ""; //$NON-NLS-1$
- }
-
- /*
- * A '<' has been read. Process a html tag
- */
- private String processHTMLTag() throws IOException {
-
- StringBuffer buf= new StringBuffer();
- int ch;
- do {
-
- ch= nextChar();
-
- while (ch != -1 && ch != '>') {
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- if (ch == '"'){
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- while (ch != -1 && ch != '"'){
- buf.append(Character.toLowerCase((char) ch));
- ch= nextChar();
- }
- }
- if (ch == '<'){
- unread(ch);
- return '<' + buf.toString();
- }
- }
-
- if (ch == -1)
- return null;
-
- int tagLen= buf.length();
- // needs special treatment for comments
- if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$
- && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$
- // unfinished comment
- buf.append(ch);
- } else {
- break;
- }
- } while (true);
-
- return html2Text(buf.toString());
- }
-
- private void unread(int ch) throws IOException {
- ((PushbackReader) getReader()).unread(ch);
- }
-
- protected String entity2Text(String symbol) {
- if (symbol.length() > 1 && symbol.charAt(0) == '#') {
- int ch;
- try {
- if (symbol.charAt(1) == 'x') {
- ch= Integer.parseInt(symbol.substring(2), 16);
- } else {
- ch= Integer.parseInt(symbol.substring(1), 10);
- }
- return "" + (char)ch; //$NON-NLS-1$
- } catch (NumberFormatException e) {
- }
- } else {
- String str= (String) fgEntityLookup.get(symbol);
- if (str != null) {
- return str;
- }
- }
- return "&" + symbol; // not found //$NON-NLS-1$
- }
-
- /*
- * A '&' has been read. Process a entity
- */
- private String processEntity() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch= nextChar();
- while (Character.isLetterOrDigit((char)ch) || ch == '#') {
- buf.append((char) ch);
- ch= nextChar();
- }
-
- if (ch == ';')
- return entity2Text(buf.toString());
-
- buf.insert(0, '&');
- if (ch != -1)
- buf.append((char) ch);
- return buf.toString();
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
deleted file mode 100644
index 70748b21002..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * Provides a set of convenience methods for creating HTML pages.
- */
-public class HTMLPrinter {
-
- private HTMLPrinter() {
- }
-
- private static String replace(String text, char c, String s) {
-
- int previous= 0;
- int current= text.indexOf(c, previous);
-
- if (current == -1)
- return text;
-
- StringBuffer buffer= new StringBuffer();
- while (current > -1) {
- buffer.append(text.substring(previous, current));
- buffer.append(s);
- previous= current + 1;
- current= text.indexOf(c, previous);
- }
- buffer.append(text.substring(previous));
-
- return buffer.toString();
- }
-
- public static String convertToHTMLContent(String content) {
- content= replace(content, '<', "&lt;"); //$NON-NLS-1$
- return replace(content, '>', "&gt;"); //$NON-NLS-1$
- }
-
- public static String read(Reader rd) {
-
- StringBuffer buffer= new StringBuffer();
- char[] readBuffer= new char[2048];
-
- try {
- int n= rd.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= rd.read(readBuffer);
- }
- return buffer.toString();
- } catch (IOException x) {
- }
-
- return null;
- }
-
- public static void insertPageProlog(StringBuffer buffer, int position) {
- buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
- }
-
- public static void addPageProlog(StringBuffer buffer) {
- insertPageProlog(buffer, buffer.length());
- }
-
- public static void addPageEpilog(StringBuffer buffer) {
- buffer.append("</font></body></html>"); //$NON-NLS-1$
- }
-
- public static void startBulletList(StringBuffer buffer) {
- buffer.append("<ul>"); //$NON-NLS-1$
- }
-
- public static void endBulletList(StringBuffer buffer) {
- buffer.append("</ul>"); //$NON-NLS-1$
- }
-
- public static void addBullet(StringBuffer buffer, String bullet) {
- if (bullet != null) {
- buffer.append("<li>"); //$NON-NLS-1$
- buffer.append(bullet);
- buffer.append("</li>"); //$NON-NLS-1$
- }
- }
-
- public static void addSmallHeader(StringBuffer buffer, String header) {
- if (header != null) {
- buffer.append("<h5>"); //$NON-NLS-1$
- buffer.append(header);
- buffer.append("</h5>"); //$NON-NLS-1$
- }
- }
-
- public static void addParagraph(StringBuffer buffer, String paragraph) {
- if (paragraph != null) {
- buffer.append("<p>"); //$NON-NLS-1$
- buffer.append(paragraph);
- }
- }
-
- public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
- if (paragraphReader != null)
- addParagraph(buffer, read(paragraphReader));
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java
deleted file mode 100644
index 8f8bcf35ede..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-import java.util.Iterator;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-
-
-public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
-
- private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private int fCounter;
- private boolean fEnforceUpperLineLimit;
-
- public HTMLTextPresenter(boolean enforceUpperLineLimit) {
- super();
- fEnforceUpperLineLimit= enforceUpperLineLimit;
- }
-
- public HTMLTextPresenter() {
- this(true);
- }
-
- protected Reader createReader(String hoverInfo, TextPresentation presentation) {
- return new HTML2TextReader(new StringReader(hoverInfo), presentation);
- }
-
- protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {
-
- int yoursStart= offset;
- int yoursEnd= offset + insertLength -1;
- yoursEnd= Math.max(yoursStart, yoursEnd);
-
- Iterator e= presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
-
- StyleRange range= (StyleRange) e.next();
-
- int myStart= range.start;
- int myEnd= range.start + range.length -1;
- myEnd= Math.max(myStart, myEnd);
-
- if (myEnd < yoursStart)
- continue;
-
- if (myStart < yoursStart)
- range.length += insertLength;
- else
- range.start += insertLength;
- }
- }
-
- private void append(StringBuffer buffer, String string, TextPresentation presentation) {
-
- int length= string.length();
- buffer.append(string);
-
- if (presentation != null)
- adaptTextPresentation(presentation, fCounter, length);
-
- fCounter += length;
- }
-
- private String getIndent(String line) {
- int length= line.length();
-
- int i= 0;
- while (i < length && Character.isWhitespace(line.charAt(i))) ++i;
-
- return (i == length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$
- }
-
- /*
- * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int)
- */
- public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
-
- if (hoverInfo == null)
- return null;
-
- GC gc= new GC(display);
- try {
-
- StringBuffer buffer= new StringBuffer();
- int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight());
-
- fCounter= 0;
- LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);
-
- boolean lastLineFormatted= false;
- String lastLineIndent= null;
-
- String line=reader.readLine();
- boolean lineFormatted= reader.isFormattedLine();
- boolean firstLineProcessed= false;
-
- while (line != null) {
-
- if (fEnforceUpperLineLimit && maxNumberOfLines <= 0)
- break;
-
- if (firstLineProcessed) {
- if (!lastLineFormatted)
- append(buffer, LINE_DELIM, null);
- else {
- append(buffer, LINE_DELIM, presentation);
- if (lastLineIndent != null)
- append(buffer, lastLineIndent, presentation);
- }
- }
-
- append(buffer, line, null);
- firstLineProcessed= true;
-
- lastLineFormatted= lineFormatted;
- if (!lineFormatted)
- lastLineIndent= null;
- else if (lastLineIndent == null)
- lastLineIndent= getIndent(line);
-
- line= reader.readLine();
- lineFormatted= reader.isFormattedLine();
-
- maxNumberOfLines--;
- }
-
- if (line != null) {
- append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
- append(buffer, (""), presentation);
- }
-
- return trim(buffer, presentation);
-
- } catch (IOException e) {
-
- CUIPlugin.getDefault().log(e);
- return null;
-
- } finally {
- gc.dispose();
- }
- }
-
- private String trim(StringBuffer buffer, TextPresentation presentation) {
-
- int length= buffer.length();
-
- int end= length -1;
- while (end >= 0 && Character.isWhitespace(buffer.charAt(end)))
- -- end;
-
- if (end == -1)
- return ""; //$NON-NLS-1$
-
- if (end < length -1)
- buffer.delete(end + 1, length);
- else
- end= length;
-
- int start= 0;
- while (start < end && Character.isWhitespace(buffer.charAt(start)))
- ++ start;
-
- buffer.delete(0, start);
- presentation.setResultWindow(new Region(start, buffer.length()));
- return buffer.toString();
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java
deleted file mode 100644
index 729c1f33b3b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-
-/*
- * Color constants that we use for the preferences
- */
-
-public interface ICColorConstants {
- /* The prefix all color constants start with */
- String PREFIX= "c_"; //$NON-NLS-1$
-
- /* The color key for multi-line comments in C code. */
- String C_MULTI_LINE_COMMENT= "c_multi_line_comment"; //$NON-NLS-1$
- /* The color key for single-line comments in C code. */
- String C_SINGLE_LINE_COMMENT= "c_single_line_comment"; //$NON-NLS-1$
- /* The color key for keywords in C code. */
- String C_KEYWORD= "c_keyword"; //$NON-NLS-1$
- /* The color key for builtin types in C code. */
- String C_TYPE= "c_type"; //$NON-NLS-1$
- /* The color key for string and character literals in C code. */
- String C_STRING= "c_string"; //$NON-NLS-1$
- /* The color key for everthing in C code for which no other color is specified. */
- String C_DEFAULT= "c_default"; //$NON-NLS-1$
-
- /**
- * The color key for task tags in C comments
- * (value <code>"c_comment_task_tag"</code>).
- */
- String TASK_TAG= "c_comment_task_tag"; //$NON-NLS-1$
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java
deleted file mode 100644
index 18e13141ebc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-
-/**
- * Manages SWT color objects for given color keys and
- * given <code>RGB</code> objects. Until the <code>dispose</code>
- * method is called, the same color object is returned for
- * equal keys and equal <code>RGB</code> values.
- * <p>
- * This interface may be implemented by clients.
- * </p>
- *
- * @see IJavaColorConstants
- */
-public interface IColorManager {
-
- /**
- * Returns a color object for the given key. The color objects
- * are remembered internally; the same color object is returned
- * for equal keys.
- *
- * @param key the color key
- * @return the color object for the given key
- */
- Color getColor(String key);
-
- /**
- * Returns the color object for the value represented by the given
- * <code>RGB</code> object.
- *
- * @param rgb the rgb color specification
- * @return the color object for the given rgb value
- */
- Color getColor(RGB rgb);
-
- /**
- * Disposes all color objects remembered by this color manager.
- */
- void dispose();
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java
deleted file mode 100644
index 2f81ca0286c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.RGB;
-
-
-/**
- * For internal use only. Not API. <p>
- * A color manager extension is for extending
- * <code>IColorManager</code> instances with new functionality.
- */
-public interface IColorManagerExtension {
-
- /**
- * Remembers the given color specification under the given key.
- *
- * @param key the color key
- * @param rgb the color specification
- * @exception UnsupportedOperationException if there is already a
- * color specification remembered under the given key
- */
- void bindColor(String key, RGB rgb);
-
-
- /**
- * Forgets the color specification remembered under the given key.
- * @param key the color key
- */
- void unbindColor(String key);
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineBreakingReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineBreakingReader.java
deleted file mode 100644
index ab2683af5cf..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineBreakingReader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-
-import java.text.BreakIterator;
-import org.eclipse.swt.graphics.GC;
-
-/*
- * Not a real reader. Could change if requested
- */
-public class LineBreakingReader {
-
- private BufferedReader fReader;
- private GC fGC;
- private int fMaxWidth;
-
- private String fLine;
- private int fOffset;
-
- private BreakIterator fLineBreakIterator;
- private int findNextBreakOffset(int currOffset) {
- int currWidth= 0;
- int nextOffset= fLineBreakIterator.following(currOffset);
- while (nextOffset != BreakIterator.DONE) {
- String word= fLine.substring(currOffset, nextOffset);
- int wordWidth= fGC.textExtent(word).x;
- int nextWidth= wordWidth + currWidth;
- if (nextWidth > fMaxWidth) {
- if (currWidth > 0) {
- return currOffset;
- } else {
- return nextOffset;
- }
- }
- currWidth= nextWidth;
- currOffset= nextOffset;
- nextOffset= fLineBreakIterator.next();
- }
- return nextOffset;
- }
- private int findWordBegin(int idx) {
- while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) {
- idx++;
- }
- return idx;
- }
- /**
- * Creates a reader that breaks an input text to fit in a given width.
- * @param reader Reader of the input text
- * @param gc The graphic context that defines the currently used font sizes
- * @param maxLineWidth The max width (pixes) where the text has to fit in
- */
- public LineBreakingReader(Reader reader, GC gc, int maxLineWidth) {
- fReader= new BufferedReader(reader);
- fGC= gc;
- fMaxWidth= maxLineWidth;
- fOffset= 0;
- fLine= null;
- fLineBreakIterator= BreakIterator.getLineInstance();
- }
-
- public boolean isFormattedLine() {
- return fLine != null;
- }
-
- /**
- * Reads the next line. The lengths of the line will not exceed the gived maximum
- * width.
- */
- public String readLine() throws IOException {
- if (fLine == null) {
- String line= fReader.readLine();
- if (line == null) {
- return null;
- }
-
- int lineLen= fGC.textExtent(line).x;
- if (lineLen < fMaxWidth) {
- return line;
- }
- fLine= line;
- fLineBreakIterator.setText(line);
- fOffset= 0;
- }
- int breakOffset= findNextBreakOffset(fOffset);
- String res;
- if (breakOffset != BreakIterator.DONE) {
- res= fLine.substring(fOffset, breakOffset);
- fOffset= findWordBegin(breakOffset);
- if (fOffset == fLine.length()) {
- fLine= null;
- }
- } else {
- res= fLine.substring(fOffset);
- fLine= null;
- }
- return res;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
deleted file mode 100644
index 39839c9ba6e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-/**
- * Implementation of <code>IRule</code> for C/C++ preprocessor scanning.
- * It is capable of detecting a pattern which begins with 0 or more whitespaces
- * at the beginning of the string, then '#' sign, then 0 or more whitespaces
- * again, and then directive itself.
- */
-public class PreprocessorRule extends WordRule implements IRule {
-
- private StringBuffer fBuffer = new StringBuffer();
-
- /**
- * Creates a rule which, with the help of a word detector, will return the token
- * associated with the detected word. If no token has been associated, the scanner
- * will be rolled back and an undefined token will be returned in order to allow
- * any subsequent rules to analyze the characters.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- *
- * @see #addWord
- */
- public PreprocessorRule(IWordDetector detector) {
- this(detector, Token.UNDEFINED);
- }
-
- /**
- * Creates a rule which, with the help of an word detector, will return the token
- * associated with the detected word. If no token has been associated, the
- * specified default token will be returned.
- *
- * @param detector the word detector to be used by this rule, may not be <code>null</code>
- * @param defaultToken the default token to be returned on success
- * if nothing else is specified, may not be <code>null</code>
- *
- * @see #addWord
- */
- public PreprocessorRule(IWordDetector detector, IToken defaultToken) {
- super(detector, defaultToken);
- }
-
- /*
- * @see IRule#evaluate
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c;
- int nCharsToRollback = 0;
- boolean hashSignDetected = false;
-
- if (scanner.getColumn() > 0)
- return Token.UNDEFINED;
-
- do {
- c = scanner.read();
- nCharsToRollback++;
- } while (Character.isWhitespace((char) c));
-
-
- // Di- and trigraph support
- if (c == '#') {
- hashSignDetected = true;
- } else if (c == '%') {
- c = scanner.read();
- nCharsToRollback++;
- if (c == ':') {
- hashSignDetected = true;
- }
- } else if (c == '?') {
- c = scanner.read();
- nCharsToRollback++;
- if (c == '?') {
- c = scanner.read();
- nCharsToRollback++;
- if (c == '=') {
- hashSignDetected = true;
- }
- }
- }
-
- if (hashSignDetected) {
-
- do {
- c = scanner.read();
- } while (Character.isWhitespace((char) c));
-
- fBuffer.setLength(0);
-
- do {
- fBuffer.append((char) c);
- c = scanner.read();
- } while (Character.isJavaIdentifierPart((char) c));
-
- scanner.unread();
-
- IToken token = (IToken) fWords.get("#" + fBuffer.toString());
- if (token != null)
- return token;
-
- return fDefaultToken;
-
- } else { // Doesn't start with '#', roll back scanner
-
- for (int i = 0; i < nCharsToRollback; i++) {
- scanner.unread();
- }
- }
-
- return Token.UNDEFINED;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
deleted file mode 100644
index 4979ce16232..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-public abstract class SingleCharReader extends Reader {
-
- /**
- * @see Reader#read(char)
- */
- public abstract int read() throws IOException;
-
-
- /**
- * @see Reader#read(char[],int,int)
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- int end= off + len;
- for (int i= off; i < end; i++) {
- int ch= read();
- if (ch == -1) {
- if (i == off) {
- return -1;
- } else {
- return i - off;
- }
- }
- cbuf[i]= (char)ch;
- }
- return len;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return true;
- }
-
- /**
- * Gets the content as a String
- */
- public String getString() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch;
- while ((ch= read()) != -1) {
- buf.append((char)ch);
- }
- return buf.toString();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
deleted file mode 100644
index b5144a30e88..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.List;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-
-/**
- *
- */
-public final class SingleTokenCScanner extends AbstractCScanner{
-
- protected IToken fDefaultReturnToken;
- private String[] fProperty;
-
- public SingleTokenCScanner(IColorManager manager, IPreferenceStore store, String property) {
- super(manager, store, 20);
- fProperty= new String[] { property };
- initialize();
- }
-
- /*
- * @see AbstractCScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fProperty;
- }
-
- /*
- * @see AbstractCScanner#createRules()
- */
- protected List createRules() {
- fDefaultReturnToken= getToken(fProperty[0]);
- setDefaultReturnToken(fDefaultReturnToken);
- return null;
- }
-
- /**
- * setRange -- sets the range to be scanned
- */
-
- private int position, end;
- private int size;
- public void setRange(IDocument document, int offset, int length) {
-
- super.setRange(document, offset, length);
- position = offset;
- size = length;
- end = offset + length;
- }
- /**
- * Returns the next token in the document.
- *
- * @return the next token in the document
- */
- public IToken nextToken() {
-
- fTokenOffset = position;
-
- if(position < end) {
- size = end - position;
- position = end;
- return fDefaultReturnToken;
- } else {
- return Token.EOF;
- }
- }
-
- public int getTokenLength() {
- return size;
- }
-
- //public int getTokenOffset() {
- // return position;
- //}
- /* while (true) {
-
- fTokenOffset= fOffset;
- fColumn= UNDEFINED;
-
- if (fRules != null) {
- for (int i= 0; i < fRules.length; i++) {
- token= (fRules[i].evaluate(this));
- if (!token.isUndefined())
- return token;
- }
- }
-
- if (read() == EOF)
- return Token.EOF;
- else
- return fDefaultReturnToken;
- }
- } */
-
-}
-
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
deleted file mode 100644
index 178482a458f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.eclipse.cdt.internal.ui.text;
-
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
- */
-public abstract class SubstitutionTextReader extends SingleCharReader {
-
- protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private Reader fReader;
- private boolean fWasWhiteSpace;
- private int fCharAfterWhiteSpace;
-
- private boolean fReadFromBuffer;
- private StringBuffer fBuffer;
- private int fIndex;
-
-
- protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuffer();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
- }
-
- /**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
- */
- protected abstract String computeSubstitution(int c) throws IOException;
-
- /**
- * Returns the internal reader.
- */
- protected Reader getReader() {
- return fReader;
- }
-
- /**
- * Returns the next character.
- */
- protected int nextChar() throws IOException {
- fReadFromBuffer= (fBuffer.length() > 0);
- if (fReadFromBuffer) {
- char ch= fBuffer.charAt(fIndex++);
- if (fIndex >= fBuffer.length()) {
- fBuffer.setLength(0);
- fIndex= 0;
- }
- return ch;
- } else {
- int ch= fCharAfterWhiteSpace;
- if (ch == -1) {
- ch= fReader.read();
- }
- if (Character.isWhitespace((char)ch)) {
- do {
- ch= fReader.read();
- } while (Character.isWhitespace((char)ch));
- if (ch != -1) {
- fCharAfterWhiteSpace= ch;
- return ' ';
- }
- } else {
- fCharAfterWhiteSpace= -1;
- }
- return ch;
- }
- }
-
- /**
- * @see Reader#read()
- */
- public int read() throws IOException {
- int c;
- do {
-
- c= nextChar();
- while (!fReadFromBuffer) {
- String s= computeSubstitution(c);
- if (s == null)
- break;
- if (s.length() > 0)
- fBuffer.insert(0, s);
- c= nextChar();
- }
-
- } while (fWasWhiteSpace && (c == ' '));
-
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
- return c;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return fReader.ready();
- }
-
- /**
- * @see Reader#close()
- */
- public void close() throws IOException {
- fReader.close();
- }
-
- /**
- * @see Reader#reset()
- */
- public void reset() throws IOException {
- fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
- fBuffer.setLength(0);
- fIndex= 0;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java
deleted file mode 100644
index 6741f5f636d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java
+++ /dev/null
@@ -1,673 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.core.search.matching.OrPattern;
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
-import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
-import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.FunctionPrototypeSummary;
-import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.text.ICCompletionProposal;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ContextInformation;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationExtension;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * C completion processor.
- */
-public class CCompletionProcessor implements IContentAssistProcessor {
-
- private static class ContextInformationWrapper implements IContextInformation, IContextInformationExtension {
-
- private final IContextInformation fContextInformation;
- private int fPosition;
-
- public ContextInformationWrapper(IContextInformation contextInformation) {
- fContextInformation= contextInformation;
- }
-
- /*
- * @see IContextInformation#getContextDisplayString()
- */
- public String getContextDisplayString() {
- return fContextInformation.getContextDisplayString();
- }
-
- /*
- * @see IContextInformation#getImage()
- */
- public Image getImage() {
- return fContextInformation.getImage();
- }
-
- /*
- * @see IContextInformation#getInformationDisplayString()
- */
- public String getInformationDisplayString() {
- return fContextInformation.getInformationDisplayString();
- }
-
- /*
- * @see IContextInformationExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return fPosition;
- }
-
- public void setContextInformationPosition(int position) {
- fPosition= position;
- }
- }
-
-
- private CEditor fEditor;
- private char[] fProposalAutoActivationSet;
- private CCompletionProposalComparator fComparator;
- private IContextInformationValidator fValidator;
-
- private TemplateEngine[] fGlobalContextTemplateEngine;
- private TemplateEngine[] fFunctionContextTemplateEngine;
- private TemplateEngine[] fStructureContextTemplateEngine;
-
- private boolean fRestrictToMatchingCase;
- private boolean fAllowAddIncludes;
-
- private BasicSearchResultCollector searchResultCollector = null;
- private ResultCollector resultCollector = null;
- private CompletionEngine completionEngine = null;
-
- private SearchEngine searchEngine = null;
- private CSearchResultLabelProvider labelProvider = null;
-
- private int fCurrentOffset = 0;
- private IWorkingCopy fCurrentSourceUnit = null;
- private int fNumberOfComputedResults= 0;
- private ITextViewer fTextViewer;
-
- public CCompletionProcessor(IEditorPart editor) {
- fEditor = (CEditor) editor;
-
- // Needed for search
- labelProvider = new CSearchResultLabelProvider();
- searchResultCollector = new BasicSearchResultCollector ();
- resultCollector = new ResultCollector();
- completionEngine = new CompletionEngine(resultCollector);
- searchEngine = new SearchEngine();
- setupTemplateEngine();
-
- fRestrictToMatchingCase = false;
- fAllowAddIncludes = true;
-
- fComparator = new CCompletionProposalComparator();
- }
-
- private boolean isCppContext(){
- String filename = null;
- if (fEditor != null && fEditor.getEditorInput() != null) {
- filename = fEditor.getEditorInput().getName();
- }
- if (filename == null) {
- return true;
- } else if (filename.endsWith(".c")) {
- //Straight C files are always C
- return false;
- } else if (
- filename.endsWith(".cpp")
- || filename.endsWith(".cc")
- || filename.endsWith(".cxx")
- || filename.endsWith(".C")
- || filename.endsWith(".hxx")) {
- return true;
- } else {
- //Defer to the nature of the project
- IFile file = fEditor.getInputFile();
- if (file != null && CoreModel.getDefault().hasCCNature(file.getProject())) {
- return true;
- } else {
- return false;
- }
- }
- }
-
- private void setupTemplateEngine(){
- //Determine if this is a C or a C++ file for the context completion + //This is _totally_ ugly and likely belongs in the main editor class.
- String globalContextNames[] = new String[2];
- String functionContextNames[] = new String[2];
- String structureContextNames[] = new String[2];
- ArrayList globalTemplateList = new ArrayList(2);
- ArrayList functionTemplateList = new ArrayList(2);
- ArrayList structureTemplateList = new ArrayList(2);
- if(isCppContext()){
- // CPP context
- globalContextNames[0] = ITemplateEditor.TemplateContextKind.CPP_GLOBAL_CONTEXT_TYPE; //$NON-NLS-1$
- globalContextNames[1] = ITemplateEditor.TemplateContextKind.C_GLOBAL_CONTEXT_TYPE; //$NON-NLS-1$
- functionContextNames[0] = ITemplateEditor.TemplateContextKind.CPP_FUNCTION_CONTEXT_TYPE; //$NON-NLS-1$
- functionContextNames[1] = ITemplateEditor.TemplateContextKind.C_FUNCTION_CONTEXT_TYPE; //$NON-NLS-1$
- structureContextNames[0] = ITemplateEditor.TemplateContextKind.CPP_STRUCTURE_CONTEXT_TYPE; //$NON-NLS-1$
- structureContextNames[1] = ITemplateEditor.TemplateContextKind.C_STRUCTURE_CONTEXT_TYPE; //$NON-NLS-1$
- }else {
- // C context
- globalContextNames[0] = ITemplateEditor.TemplateContextKind.C_GLOBAL_CONTEXT_TYPE; //$NON-NLS-1$
- structureContextNames[0] = ITemplateEditor.TemplateContextKind.C_STRUCTURE_CONTEXT_TYPE; //$NON-NLS-1$
- functionContextNames[0] = ITemplateEditor.TemplateContextKind.C_FUNCTION_CONTEXT_TYPE; //$NON-NLS-1$
- }
- ContextType contextType;
- for (int i = 0; i < globalContextNames.length; i++) {
- contextType = ContextTypeRegistry.getInstance().getContextType(globalContextNames[i]);
- if (contextType != null) {
- globalTemplateList.add(new TemplateEngine(contextType));
- }
- }
- for (int i = 0; i < functionContextNames.length; i++) {
- contextType = ContextTypeRegistry.getInstance().getContextType(functionContextNames[i]);
- if (contextType != null) {
- functionTemplateList.add(new TemplateEngine(contextType));
- }
- }
- for (int i = 0; i < structureContextNames.length; i++) {
- contextType = ContextTypeRegistry.getInstance().getContextType(structureContextNames[i]);
- if (contextType != null) {
- structureTemplateList.add(new TemplateEngine(contextType));
- }
- }
- fGlobalContextTemplateEngine = (TemplateEngine[]) globalTemplateList.toArray(new TemplateEngine[globalTemplateList.size()]);
- fFunctionContextTemplateEngine = (TemplateEngine[]) functionTemplateList.toArray(new TemplateEngine[functionTemplateList.size()]);
- fStructureContextTemplateEngine = (TemplateEngine[]) structureTemplateList.toArray(new TemplateEngine[structureTemplateList.size()]);
- }
- /**
- * Tells this processor to order the proposals alphabetically.
- *
- * @param order <code>true</code> if proposals should be ordered.
- */
- public void orderProposalsAlphabetically(boolean order) {
- fComparator.setOrderAlphabetically(order);
- }
-
- /**
- * @see IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- if (fNumberOfComputedResults == 0) {
- String errorMsg= resultCollector.getErrorMessage();
- if (errorMsg == null || errorMsg.trim().length() == 0)
- errorMsg= CUIMessages.getString("CEditor.contentassist.noCompletions"); //$NON-NLS-1$
- return errorMsg;
- }
-
- return resultCollector.getErrorMessage();
- }
-
- /**
- * @see IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- if(fValidator == null) {
- fValidator = new CParameterListValidator();
- }
- return fValidator;
- }
-
- /**
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /**
- * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
- List result= addContextInformations(viewer, offset);
- return (IContextInformation[]) result.toArray(new IContextInformation[result.size()]);
- }
-
- private List addContextInformations(ITextViewer viewer, int offset) {
- ICompletionProposal[] proposals= internalComputeCompletionProposals(viewer, offset);
-
- List result= new ArrayList();
- for (int i= 0; i < proposals.length; i++) {
- IContextInformation contextInformation= proposals[i].getContextInformation();
- if (contextInformation != null) {
- ContextInformationWrapper wrapper= new ContextInformationWrapper(contextInformation);
- wrapper.setContextInformationPosition(offset);
- result.add(wrapper);
- }
- }
- return result;
- }
-
- /**
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- /**
- * Sets this processor's set of characters triggering the activation of the
- * completion proposal computation.
- *
- * @param activationSet the activation set
- */
- public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
- fProposalAutoActivationSet = activationSet;
- }
-
- /**
- * Tells this processor to restrict is proposals to those
- * starting with matching cases.
- *
- * @param restrict <code>true</code> if proposals should be restricted
- */
- public void restrictProposalsToMatchingCases(boolean restrict) {
- // not yet supported
- }
-
- /**
- * Tells this processor to add include statement for proposals that have
- * a fully qualified type name
- *
- * @param restrict <code>true</code> if import can be added
- */
- public void allowAddingIncludes(boolean allowAddingIncludes) {
- fAllowAddIncludes = allowAddingIncludes;
- }
-
- /**
- * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- return internalComputeCompletionProposals(viewer, offset);
- }
-
- private ICompletionProposal[] internalComputeCompletionProposals(ITextViewer viewer, int offset) {
- IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
- IWorkingCopy unit = fManager.getWorkingCopy(fEditor.getEditorInput());
-
- IDocument document = viewer.getDocument();
-
- ICCompletionProposal[] results = null;
-
- try {
-// if (document != null) {
-//
-// int offset = documentOffset;
-// int length = 0;
-//
-// Point selection = viewer.getSelectedRange();
-// if (selection.y > 0) {
-// offset = selection.x;
-// length = selection.y;
-// }
-
- results = evalProposals(document, offset, unit, viewer);
-// }
- } catch (Exception e) {
- CUIPlugin.getDefault().log(e);
- }
-
- fNumberOfComputedResults= (results == null ? 0 : results.length);
-
- if (results == null)
- results = new ICCompletionProposal[0];
-
- /*
- * Order here and not in result collector to make sure that the order
- * applies to all proposals and not just those of the compilation unit.
- */
- order(results);
- return results;
- }
- /**
- * Order the given proposals.
- */
- private ICCompletionProposal[] order(ICCompletionProposal[] proposals) {
- if(proposals != null)
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- /**
- * Evaluate the actual proposals for C
- */
- public ICCompletionProposal[] evalProposals(IDocument document, int documentOffset, IWorkingCopy unit, ITextViewer viewer) {
- // setup the global variables
- fCurrentOffset = documentOffset;
- fCurrentSourceUnit = unit;
- fTextViewer = viewer;
-
- ArrayList completions = new ArrayList();
-
- if (fCurrentSourceUnit == null)
- return null;
-
- // clear the completion list at the result collector
- resultCollector.reset(viewer);
-
- IASTCompletionNode completionNode = addProposalsFromModel(completions);
- addProposalsFromSearch(completionNode, completions);
- addProposalsFromCompletionContributors(completionNode, completions);
- addProposalsFromTemplates(viewer, completionNode, completions);
-
- return order ( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]) );
- }
-
- private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){
- if(completionNode == null)
- return;
-
- if(viewer == null)
- return;
-
- IASTCompletionNode.CompletionKind kind = completionNode.getCompletionKind();
-
- if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
- addProposalsFromTemplateEngine(viewer, fGlobalContextTemplateEngine, completions);
- if(kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- addProposalsFromTemplateEngine(viewer, fFunctionContextTemplateEngine, completions);
- if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
- addProposalsFromTemplateEngine(viewer, fStructureContextTemplateEngine, completions);
- }
-
- private void addProposalsFromTemplateEngine(ITextViewer viewer, TemplateEngine[] fTemplateEngine, List completions){
- for (int i = 0; i < fTemplateEngine.length; i++) {
- if (fTemplateEngine[i] == null) {
- continue;
- }
- try {
- fTemplateEngine[i].reset();
- fTemplateEngine[i].complete(viewer, fCurrentOffset, null);
- } catch (Exception x) {
- CUIPlugin.getDefault().log(x);
- }
-
- completions.addAll(fTemplateEngine[i].getResults());
- }
-
- }
- private void addProposalsFromCompletionContributors(IASTCompletionNode completionNode, List completions) {
- if(completionNode == null)
- return;
- String prefix = completionNode.getCompletionPrefix();
- int offset = fCurrentOffset - prefix.length();
- int length = prefix.length();
-
- // calling functions should happen only within the context of a code body
- if(completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- return;
-
- IFunctionSummary[] summary;
-
- summary = CCompletionContributorManager.getDefault().getMatchingFunctions(prefix);
- if(summary == null) {
- return;
- }
-
- for (int i = 0; i < summary.length; i++) {
- String fname = summary[i].getName() + "()";
- String fdesc = summary[i].getDescription();
- IFunctionSummary.IFunctionPrototypeSummary fproto = summary[i].getPrototype();
- String fargs = fproto.getArguments();
-
- CCompletionProposal proposal;
- proposal = new CCompletionProposal(fname,
- offset,
- length,
- CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION),
- fproto.getPrototypeString(true),
- 2,
- fTextViewer);
-
- if(fdesc != null) {
- proposal.setAdditionalProposalInfo(fdesc);
- }
-
- if(fargs != null && fargs.length() > 0) {
- proposal.setContextInformation(new ContextInformation(fname, fargs));
- }
-
- completions.add(proposal);
- }
- }
-
- private FunctionPrototypeSummary getPrototype (BasicSearchMatch match) {
- switch(match.getElementType()){
- case ICElement.C_FUNCTION:
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- {
- return (new FunctionPrototypeSummary ( match.getReturnType() + " " + match.getName() ));
- }
- default:
- return null;
- }
- }
-
-
- private IASTCompletionNode addProposalsFromModel(List completions){
- //invoke the completion engine
- IASTCompletionNode completionNode = completionEngine.complete(fCurrentSourceUnit, fCurrentOffset);
- return completionNode;
- }
-
- private void addProposalsFromSearch (IASTCompletionNode completionNode, List completions) {
- if(completionNode == null)
- return;
- String prefix = completionNode.getCompletionPrefix();
- int offset = fCurrentOffset - prefix.length();
- int length = prefix.length();
-
- String searchPrefix = prefix + "*";
-
- // figure out the search scope
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
- boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SEARCH_SCOPE);
- boolean projectScopeAndDependency = store.getBoolean(ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE);
- ICSearchScope scope = null;
-
- if (((projectScope) || (projectScopeAndDependency))
- && ( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE) )
- && (prefix.length() > 0)){
- List elementsFound = new LinkedList();
-
- ICElement[] projectScopeElement = new ICElement[1];
- projectScopeElement[0] = (ICElement)fCurrentSourceUnit.getCProject();
- scope = SearchEngine.createCSearchScope(projectScopeElement, projectScopeAndDependency);
-
- // search for global variables, functions, classes, structs, unions, enums, macros, and namespaces
- OrPattern orPattern = new OrPattern();
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false ));
-
- if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)){
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DEFINITIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false ));
- }
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true);
- elementsFound.addAll(searchResultCollector.getSearchResults());
-
- sendResultsToCollector(elementsFound.iterator(), offset, length, prefix );
- }
-
- completions.addAll(resultCollector.getCompletions());
-
- }
-
- private void sendResultsToCollector(Iterator results , int completionStart, int completionLength, String prefix){
- while (results.hasNext()){
- ASTAccessVisibility visibility;
-
- BasicSearchMatch match = (BasicSearchMatch)results.next();
- int type = match.getElementType();
- int relevance = completionEngine.computeRelevance(type, prefix, match.getName());
- switch (type){
- case ICElement.C_FIELD:
- switch (match.getVisibility()){
- case ICElement.CPP_PUBLIC:
- visibility = ASTAccessVisibility.PUBLIC;
- break;
- case ICElement.CPP_PROTECTED:
- visibility = ASTAccessVisibility.PROTECTED;
- break;
- default:
- visibility = ASTAccessVisibility.PRIVATE;
- break;
- };
- resultCollector.acceptField(
- match.getName(),
- match.getReturnType(),
- visibility,
- completionStart,
- completionLength,
- relevance);
- break;
-
- case ICElement.C_VARIABLE:
- case ICElement.C_VARIABLE_DECLARATION:
- resultCollector.acceptVariable(
- match.getName(),
- match.getReturnType(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- switch (match.getVisibility()){
- case ICElement.CPP_PUBLIC:
- visibility = ASTAccessVisibility.PUBLIC;
- break;
- case ICElement.CPP_PROTECTED:
- visibility = ASTAccessVisibility.PROTECTED;
- break;
- default:
- visibility = ASTAccessVisibility.PRIVATE;
- break;
- };
- resultCollector.acceptMethod(
- match.getName(),
- null,
- match.getReturnType(),
- visibility,
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_FUNCTION:
- case ICElement.C_FUNCTION_DECLARATION:
- resultCollector.acceptFunction(
- match.getName(),
- null,
- match.getReturnType(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_CLASS:
- resultCollector.acceptClass(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_STRUCT:
- resultCollector.acceptStruct(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_UNION:
- resultCollector.acceptUnion(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_NAMESPACE:
- resultCollector.acceptNamespace(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_MACRO:
- resultCollector.acceptMacro(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_ENUMERATION:
- resultCollector.acceptEnumeration(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_ENUMERATOR:
- resultCollector.acceptEnumerator(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- default :
- break;
- } // end switch
- } // end while
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
deleted file mode 100644
index 77e3d466a71..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionManager;
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionUI;
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionUI.ExitFlags;
-import org.eclipse.cdt.ui.text.ICCompletionProposal;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension {
- private String fDisplayString;
- private String fReplacementString;
- private String fAdditionalInfoString;
- private int fReplacementOffset;
- private int fReplacementLength;
- private int fCursorPosition;
- private Image fImage;
- private IContextInformation fContextInformation;
- private int fContextInformationPosition;
- //private IImportDeclaration fImportDeclaration;
- private char[] fTriggerCharacters;
- protected ITextViewer fTextViewer;
-
- private int fRelevance;
-
- /**
- * Creates a new completion proposal. All fields are initialized based on the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * If set to <code>null</code>, the replacement string will be taken as display string.
- */
- public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance, ITextViewer viewer) {
- Assert.isNotNull(replacementString);
- Assert.isTrue(replacementOffset >= 0);
- Assert.isTrue(replacementLength >= 0);
-
- fReplacementString= replacementString;
- fReplacementOffset= replacementOffset;
- fReplacementLength= replacementLength;
- fImage= image;
- fDisplayString= displayString != null ? displayString : replacementString;
- fRelevance= relevance;
- fTextViewer= viewer;
-
- //@@@ Is this the best way to do this, likely it isn't
- if(replacementString.indexOf("()") == -1) { //Not replacing with a function
- fCursorPosition = replacementString.length();
- } else if(displayString.indexOf("()") == -1) { //Assume that there are arguments between ()
- fCursorPosition = replacementString.length() - 1;
- } else {
- fCursorPosition = replacementString.length();
- }
-
- fAdditionalInfoString = null;
- fContextInformation= null;
- fContextInformationPosition= -1;
- //fIncludeDeclaration= null;
- fTriggerCharacters= null;
- }
-
- /**
- * Sets the context information.
- * @param contentInformation The context information associated with this proposal
- */
- public void setContextInformation(IContextInformation contextInformation) {
- fContextInformation= contextInformation;
- fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
- }
-
- /**
- * Sets the import declaration to import when applied.
- * @param importDeclaration Optional import declaration to be added. Can be <code>null</code>. The underlying compilation unit
- * is assumed to be compatible with the document passed in <code>apply</code>.
- *
- public void setIncludeDeclaration(IImportDeclaration importDeclaration) {
- fIncludeDeclaration= importDeclaration;
- } */
-
- /**
- * Sets the trigger characters.
- * @param triggerCharacters The set of characters which can trigger the application of this completion proposal
- */
- public void setTriggerCharacters(char[] triggerCharacters) {
- fTriggerCharacters= triggerCharacters;
- }
-
- /**
- * Sets the cursor position relative to the insertion offset. By default this is the length of the completion string
- * (Cursor positioned after the completion)
- * @param cursorPosition The cursorPosition to set
- */
- public void setCursorPosition(int cursorPosition) {
- Assert.isTrue(cursorPosition >= 0);
- fCursorPosition= cursorPosition;
- fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
- }
-
-/* protected void addInclude(IRequiredInclude[] inc, CFileElementWorkingCopy tu) {
- AddIncludeOperation op= new AddIncludeOperation(fEditor, tu, inc, false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(false, true, op);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- MessageDialog.openError(getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message1"), e.getTargetException().getMessage()); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- }
- } */
-
- protected void applyIncludes(IDocument document) {
- //AddIncludeOperation(ITextEditor ed, CFileElementWorkingCopy tu, IRequiredInclude[] includes, boolean save) {
-
- //if (fIncludeDeclaration == null) {
- return;
- //}
-
- /* ICompilationUnit cu= (ICompilationUnit) JavaModelUtil.findElementOfKind(fImportDeclaration, IJavaElement.COMPILATION_UNIT);
- if (cu != null) {
- try {
- IType[] types= cu.getTypes();
- if (types.length == 0 || types[0].getSourceRange().getOffset() > fReplacementOffset) {
- // do not add import for code assist on import statements
- return;
- }
-
- String[] prefOrder= ImportOrganizePreferencePage.getImportOrderPreference();
- int threshold= ImportOrganizePreferencePage.getImportNumberThreshold();
- ImportsStructure impStructure= new ImportsStructure(cu, prefOrder, threshold, true);
-
- impStructure.addImport(fImportDeclaration.getElementName());
- // will modify the document as the CU works on the document
- impStructure.create(false, null);
-
- } catch (CoreException e) {
- JavaPlugin.log(e);
- }
- } */
- }
-
- /*
- * @see ICompletionProposal#apply
- */
- public void apply(IDocument document) {
- apply(document, (char) 0, fReplacementOffset + fReplacementLength);
- }
-
- /*
- * In this case we need to apply the completion proposal intelligently.
- * This means that if we are applying it to a function, we don't wipe
- * out the internal arguments, and if the proposal is a function, and it
- * already is bracketed, then don't put those brackets in.
- *
- * @see ICompletionProposalExtension#apply(IDocument, char, int)
- */
- public void apply(IDocument document, char trigger, int offset) {
- int functionBracketIndex;
- boolean isBeforeBracket;
- String replacementStringCopy = fReplacementString;
- fReplacementLength = offset - fReplacementOffset;
- //If just providing context information, then don't move the cursor
-// if(offset != (fReplacementOffset + fReplacementLength)) {
-// fCursorPosition = offset - fReplacementOffset;
-// }
-
- try {
- functionBracketIndex = fReplacementString.indexOf("()");
- isBeforeBracket = document.getChar(fReplacementOffset + fReplacementLength) == '(';
-
- //Strip the brackets off the function if inserting right before brackets
- if(functionBracketIndex != -1 && isBeforeBracket) {
- replacementStringCopy = fReplacementString.substring(0, functionBracketIndex);
- }
- } catch(Exception ex) {
- /* Ignore */
- }
-
- try {
- String string;
- if (trigger == (char) 0) {
- string= fReplacementString;
- replace(document, fReplacementOffset, fReplacementLength, replacementStringCopy);
- } else {
- StringBuffer buffer= new StringBuffer(replacementStringCopy);
-
- // fix for PR #5533. Assumes that no eating takes place.
- if ((fCursorPosition > 0 && fCursorPosition <= buffer.length() && buffer.charAt(fCursorPosition - 1) != trigger)) {
- buffer.insert(fCursorPosition, trigger);
- ++fCursorPosition;
- }
-
- string= buffer.toString();
- replace(document, fReplacementOffset, fReplacementLength, string);
- }
-
- if (fTextViewer != null && string != null) {
- int index= string.indexOf("()"); //$NON-NLS-1$
- if (index != -1 && index + 1 == fCursorPosition) {
- //IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
- //if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS)) {
- int newOffset= fReplacementOffset + fCursorPosition;
-
- LinkedPositionManager manager= new LinkedPositionManager(document);
- manager.addPosition(newOffset, 0);
-
- LinkedPositionUI editor= new LinkedPositionUI(fTextViewer, manager);
- editor.setExitPolicy(new ExitPolicy(')'));
- editor.setFinalCaretOffset(newOffset + 1);
- editor.enter();
- //}
- }
- }
-
- /*
- * The replacement length is used to calculate the new cursor position,
- * so after we update the includes adjust the replacement offset.
- * NOTE: This won't work if the include is added after the offset,
- * such as might be the case with #include completions.
- */
- int oldLen= document.getLength();
- applyIncludes(document);
- fReplacementOffset += document.getLength() - oldLen;
-
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- // #6410 - File unchanged but dirtied by code assist
- private void replace(IDocument document, int offset, int length, String string) throws BadLocationException {
- if (!document.get(offset, length).equals(string))
- document.replace(offset, length, string);
- }
-
- /*
- * @see ICompletionProposal#getSelection
- */
- public Point getSelection(IDocument document) {
- return new Point(fReplacementOffset + fCursorPosition, 0);
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return fContextInformation;
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return fDisplayString;
- }
-
- /**
- * Set the additional information which will be shown when this
- * proposal is selected in the popup list.
- * @param infoString
- */
- public void setAdditionalProposalInfo(String infoString) {
- fAdditionalInfoString = infoString;
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return fAdditionalInfoString;
- }
-
- /*
- * @see ICompletionProposalExtension#getTriggerCharacters()
- */
- public char[] getTriggerCharacters() {
- return fTriggerCharacters;
- }
-
- /*
- * @see ICompletionProposalExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return fReplacementOffset + fContextInformationPosition;
- }
-
- /*
- * @see ICompletionProposalExtension#isValidFor(IDocument, int)
- */
- public boolean isValidFor(IDocument document, int offset) {
- if (offset < fReplacementOffset)
- return false;
-
- int replacementLength= fReplacementString == null ? 0 : fReplacementString.length();
- if (offset > fReplacementOffset + replacementLength)
- return false;
-
- try {
- int length= offset - fReplacementOffset;
- String start= document.get(fReplacementOffset, length);
- return fReplacementString.substring(0, length).equalsIgnoreCase(start);
- } catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /**
- * Gets the replacement offset.
- * @return Returns a int
- */
- public int getReplacementOffset() {
- return fReplacementOffset;
- }
-
- /**
- * Sets the replacement offset.
- * @param replacementOffset The replacement offset to set
- */
- public void setReplacementOffset(int replacementOffset) {
- Assert.isTrue(replacementOffset >= 0);
- fReplacementOffset= replacementOffset;
- }
-
- /**
- * Gets the replacement length.
- * @return Returns a int
- */
- public int getReplacementLength() {
- return fReplacementLength;
- }
-
- /**
- * Sets the replacement length.
- * @param replacementLength The replacementLength to set
- */
- public void setReplacementLength(int replacementLength) {
- Assert.isTrue(replacementLength >= 0);
- fReplacementLength= replacementLength;
- }
-
- /**
- * Gets the replacement string.
- * @return Returns a String
- */
- public String getReplacementString() {
- return fReplacementString;
- }
-
- /**
- * Sets the replacement string.
- * @param replacementString The replacement string to set
- */
- public void setReplacementString(String replacementString) {
- fReplacementString= replacementString;
- }
-
- /**
- * Sets the image.
- * @param image The image to set
- */
- public void setImage(Image image) {
- fImage= image;
- }
-
- /**
- * Gets the proposal's relevance.
- * @return Returns a int
- */
- public int getRelevance() {
- return fRelevance;
- }
-
- /**
- * Sets the proposal's relevance.
- * @param relevance The relevance to set
- */
- public void setRelevance(int relevance) {
- fRelevance= relevance;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fDisplayString.hashCode()
- + fReplacementString.hashCode()
- + ((fAdditionalInfoString == null) ? 0 : fAdditionalInfoString.hashCode());
- }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object other) {
- if(!(other instanceof CCompletionProposal))
- return false;
- if(!(fDisplayString.equals(((CCompletionProposal)other).fDisplayString)))
- return false;
- if(!(fReplacementString.equals(((CCompletionProposal)other).fReplacementString)))
- return false;
- if((fAdditionalInfoString != null) && (((CCompletionProposal)other).fAdditionalInfoString != null) && (!(fAdditionalInfoString.equals(((CCompletionProposal)other).fAdditionalInfoString))))
- return false;
-
- return true;
- }
-
- private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
-
- final char fExitCharacter;
-
- public ExitPolicy(char exitCharacter) {
- fExitCharacter= exitCharacter;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
- */
- public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) {
-
- if (event.character == fExitCharacter) {
- if (manager.anyPositionIncludes(offset, length))
- return new ExitFlags(LinkedPositionUI.COMMIT| LinkedPositionUI.UPDATE_CARET, false);
- else
- return new ExitFlags(LinkedPositionUI.COMMIT, true);
- }
-
- switch (event.character) {
- case '\b':
- if (manager.getFirstPosition().length == 0)
- return new ExitFlags(0, true);
- else
- return null;
-
- case '\n':
- case '\r':
- case ';':
- return new ExitFlags(LinkedPositionUI.COMMIT, true);
-
- default:
- return null;
- }
- }
-
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
deleted file mode 100644
index fc316b47308..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.Comparator;
-
-import org.eclipse.cdt.ui.text.*;
-
-public class CCompletionProposalComparator implements Comparator {
-
- private boolean fOrderAlphabetically;
-
- /**
- * Constructor for CompletionProposalComparator.
- */
- public CCompletionProposalComparator() {
- fOrderAlphabetically= false;
- }
-
- public void setOrderAlphabetically(boolean orderAlphabetically) {
- fOrderAlphabetically= orderAlphabetically;
- }
-
- /* (non-Javadoc)
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- ICCompletionProposal c1= (ICCompletionProposal) o1;
- ICCompletionProposal c2= (ICCompletionProposal) o2;
- if (!fOrderAlphabetically) {
- int relevanceDif= c2.getRelevance() - c1.getRelevance();
- if (relevanceDif != 0) {
- return relevanceDif;
- }
- }
- return c1.getDisplayString().compareToIgnoreCase(c2.getDisplayString());
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java
deleted file mode 100644
index 329af0dadeb..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java
+++ /dev/null
@@ -1,844 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-import java.io.CharArrayReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.IParser;
-import org.eclipse.cdt.core.parser.IScanner;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.parser.ParserFactory;
-import org.eclipse.cdt.core.parser.ParserFactoryException;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.core.parser.ParserNotImplementedException;
-import org.eclipse.cdt.core.parser.ParserUtil;
-import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.core.parser.ast.ASTClassKind;
-import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
-import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
-import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
-import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTMacro;
-import org.eclipse.cdt.core.parser.ast.IASTMethod;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTNode;
-import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
-import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
-import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
-import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.core.model.Util;
-import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * @author hamer
- *
- * This class is the entry point for code completions.
- * It contains a public API used to call ContentAssist on a given working copy
- * and a given completion offset.
- *
- */
-public class CompletionEngine implements RelevanceConstants{
- ICompletionRequestor requestor;
- int completionStart = 0;
- int completionLength = 0;
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- // keywords types
- public static final int BASIC_TYPES_KEYWORDS = 0;
- private static final String basicTypesKeywords[] = {
- "namespace",
- "class",
- "struct",
- "union",
- "enum",
- "bool",
- "char",
- "wchar_t",
- "int",
- "float",
- "double",
- "void",
- "template",
- };
- private static final String exceptionKeyword = "...";
- // scope relevance element counters
- private int numFields = 0;
- private int numVariables = 0;
- private int numLocalVariables = 0;
- private int numMethods = 0;
- private int numFunctions = 0;
- private int numClasses = 0;
- private int numStructs = 0;
- private int numUnions = 0;
- private int numEnumerations = 0;
- private int numEnumerators = 0;
- private int numNamespaces = 0;
- private int numMacros = 0;
-
- public CompletionEngine(ICompletionRequestor completionRequestor){
- requestor = completionRequestor;
- }
-
- private int computeCaseMatchingRelevance(String prefix, String proposalName){
- if (CharOperation.prefixEquals(prefix.toCharArray(), proposalName.toCharArray(), true /* do not ignore case */)) {
- if(CharOperation.equals(prefix.toCharArray(), proposalName.toCharArray(), true /* do not ignore case */)) {
- return CASE_MATCH_RELEVANCE + EXACT_NAME_MATCH_RELEVANCE;
- } else {
- return CASE_MATCH_RELEVANCE;
- }
- }
- else {
- return 0;
- }
- }
- private int computeTypeRelevance(int type){
- switch (type){
- case ICElement.C_VARIABLE_LOCAL:
- return LOCAL_VARIABLE_TYPE_RELEVANCE;
- case ICElement.C_FIELD:
- return FIELD_TYPE_RELEVANCE;
- case ICElement.C_VARIABLE:
- case ICElement.C_VARIABLE_DECLARATION:
- return VARIABLE_TYPE_RELEVANCE;
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- return METHOD_TYPE_RELEVANCE;
- case ICElement.C_FUNCTION:
- case ICElement.C_FUNCTION_DECLARATION:
- return FUNCTION_TYPE_RELEVANCE;
- case ICElement.C_CLASS:
- return CLASS_TYPE_RELEVANCE;
- case ICElement.C_STRUCT:
- return STRUCT_TYPE_RELEVANCE;
- case ICElement.C_UNION:
- return UNION_TYPE_RELEVANCE;
- case ICElement.C_NAMESPACE:
- return NAMESPACE_TYPE_RELEVANCE;
- case ICElement.C_MACRO:
- return MACRO_TYPE_RELEVANCE;
- case ICElement.C_ENUMERATION:
- return ENUMERATION_TYPE_RELEVANCE;
- case ICElement.C_ENUMERATOR:
- return ENUMERATOR_TYPE_RELEVANCE;
- default :
- return DEFAULT_TYPE_RELEVANCE;
- }
- }
- public int computeRelevance(int elementType, String prefix, String proposalName){
- // compute the relevance according to the elemnent type
- int relevance = computeTypeRelevance(elementType);
- // compute the relevance according to the case sensitivity
- relevance += computeCaseMatchingRelevance(prefix, proposalName);
- return relevance;
- }
- private IASTCompletionNode parse(IWorkingCopy sourceUnit, int completionOffset){
- ContentAssistElementRequestor requestor = new ContentAssistElementRequestor();
- // Get resource info
- IResource currentResource = sourceUnit.getResource();
- IPath realPath = currentResource.getLocation();
- IProject project = currentResource.getProject();
- Reader reader = new CharArrayReader( sourceUnit.getContents() );
-
- //Get the scanner info
- IScannerInfo scanInfo = new ScannerInfo();
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null){
- IScannerInfo buildScanInfo = provider.getScannerInformation(project);
- if( buildScanInfo != null )
- scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
- }
-
- //C or CPP?
- ParserLanguage language = CoreModel.getDefault().hasCCNature(project) ? ParserLanguage.CPP : ParserLanguage.C;
-
- IParser parser = null;
- try
- {
- IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.CONTEXTUAL_PARSE, language, requestor, ParserUtil.getParserLogService() );
- parser = ParserFactory.createParser( scanner, requestor, ParserMode.CONTEXTUAL_PARSE, language, ParserUtil.getParserLogService() );
- }
- catch( ParserFactoryException pfe )
- {
-
- }
- if(parser != null){
- IASTCompletionNode result = null;
- try {
- result = parser.parse(completionOffset);
- } catch (ParserNotImplementedException e) {
- }
- return result;
- } else {
- return null;
- }
- }
-
- private void addNodeToCompletions(IASTNode node, String prefix, int totalNumberOfResults){
- if(node instanceof IASTField){
- numFields++;
- IASTField field = (IASTField)node;
- int relevance = computeRelevance(ICElement.C_FIELD, prefix, field.getName());
- relevance += totalNumberOfResults - numFields;
-
- requestor.acceptField(field.getName(),
- ASTUtil.getType(field.getAbstractDeclaration()),
- field.getVisiblity(), completionStart, completionLength, relevance);
- }
- else if (node instanceof IASTParameterDeclaration){
- numLocalVariables++;
- IASTParameterDeclaration param = (IASTParameterDeclaration) node;
- int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, param.getName());
- relevance += totalNumberOfResults - numLocalVariables;
-
- requestor.acceptLocalVariable(param.getName(),
- ASTUtil.getType(param),
- completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTVariable){
- IASTVariable variable = (IASTVariable)node;
- // get the container to check if it is a local variable
- IASTNode container = variable.getOwnerScope();
- if(container instanceof IASTCodeScope){
- numLocalVariables++;
- int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, variable.getName());
- relevance += totalNumberOfResults - numLocalVariables;
-
- requestor.acceptLocalVariable(variable.getName(),
- ASTUtil.getType(variable.getAbstractDeclaration()),
- completionStart, completionLength, relevance);
- }else {
- numVariables++;
- int relevance = computeRelevance(ICElement.C_VARIABLE, prefix, variable.getName());
- relevance += totalNumberOfResults - numVariables;
-
- requestor.acceptVariable(variable.getName(),
- ASTUtil.getType(variable.getAbstractDeclaration()),
- completionStart, completionLength, relevance);
- }
- }
- else if(node instanceof IASTMethod) {
- numMethods++;
- IASTMethod method = (IASTMethod)node;
- int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName());
- relevance += totalNumberOfResults - numMethods;
-
- String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method));
- requestor.acceptMethod(method.getName(),
- parameterString,
- ASTUtil.getType(method.getReturnType()),
- method.getVisiblity(), completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTFunction){
- numFunctions++;
- IASTFunction function = (IASTFunction)node;
- int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName());
- relevance += totalNumberOfResults - numFunctions;
-
- String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function));
- requestor.acceptFunction(function.getName(),
- parameterString,
- ASTUtil.getType(function.getReturnType()),
- completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTClassSpecifier){
- IASTClassSpecifier classSpecifier = (IASTClassSpecifier)node;
- ASTClassKind classkind = classSpecifier.getClassKind();
- if(classkind == ASTClassKind.CLASS){
- numClasses++;
- int relevance = computeRelevance(ICElement.C_CLASS, prefix, classSpecifier.getName());
- relevance += totalNumberOfResults - numClasses;
-
- requestor.acceptClass(classSpecifier.getName(),
- completionStart, completionLength, relevance);
- }
- if(classkind == ASTClassKind.STRUCT){
- numStructs++;
- int relevance = computeRelevance(ICElement.C_STRUCT, prefix, classSpecifier.getName());
- relevance += totalNumberOfResults - numStructs;
-
- requestor.acceptStruct(classSpecifier.getName(),
- completionStart, completionLength, relevance);
- }
- if(classkind == ASTClassKind.UNION){
- numUnions++;
- int relevance = computeRelevance(ICElement.C_UNION, prefix, classSpecifier.getName());
- relevance += totalNumberOfResults - numUnions;
-
- requestor.acceptUnion(classSpecifier.getName(),
- completionStart, completionLength, relevance);
- }
- }
- else if(node instanceof IASTMacro){
- numMacros++;
- IASTMacro macro = (IASTMacro)node;
- int relevance = computeRelevance(ICElement.C_MACRO, prefix, macro.getName());
- relevance += totalNumberOfResults - numMacros;
-
- requestor.acceptMacro(macro.getName(), completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTNamespaceDefinition){
- numNamespaces++;
- IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
- int relevance = computeRelevance(ICElement.C_NAMESPACE, prefix, namespace.getName());
- relevance += totalNumberOfResults - numNamespaces;
-
- requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTEnumerationSpecifier){
- numEnumerations++;
- IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier)node;
- int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, enumeration.getName());
- relevance += totalNumberOfResults - numEnumerations;
-
- requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance);
- }
- else if(node instanceof IASTEnumerator){
- numEnumerators++;
- IASTEnumerator enumerator = (IASTEnumerator)node;
- int relevance = computeRelevance(ICElement.C_ENUMERATOR, prefix, enumerator.getName());
- relevance += totalNumberOfResults - numEnumerators;
-
- requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance);
- }
- }
-
- private void addKeywordToCompletions (String keyword){
- int relevance = KEYWORD_TYPE_RELEVANCE;
- requestor.acceptKeyword(keyword, completionStart, completionLength, relevance);
- }
-
- private void addKeywordsToCompletions(Iterator keywords){
- while (keywords.hasNext()){
- String keyword = (String) keywords.next();
- addKeywordToCompletions(keyword);
- }
- }
-
- private void resetElementNumbers(){
- numFields = 0;
- numVariables = 0;
- numLocalVariables = 0;
- numMethods = 0;
- numFunctions = 0;
- numClasses = 0;
- numStructs = 0;
- numUnions = 0;
- numEnumerations = 0;
- numEnumerators = 0;
- numNamespaces = 0;
- numMacros = 0;
- }
- private void addToCompletions (LookupResult result){
- if(result == null)
- return;
- Iterator nodes = result.getNodes();
- int numberOfElements = result.getResultsSize();
- resetElementNumbers();
- while (nodes.hasNext()){
- IASTNode node = (IASTNode) nodes.next();
- addNodeToCompletions(node, result.getPrefix(), numberOfElements);
- }
- return ;
- }
-
- private List lookupKeyword(String prefix, int lookupType){
- List result = new ArrayList();
- switch (lookupType){
- case BASIC_TYPES_KEYWORDS:
- for(int i = 0; i <basicTypesKeywords.length; i++){
- String kw =basicTypesKeywords[i];
- if(kw.startsWith(prefix))
- result.add(kw);
- }
- break;
- }
- return result;
- }
-
- private LookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){
- try {
- logLookups (kinds);
- LookupResult result = searchNode.lookup (prefix, kinds, context);
- return result ;
- } catch (IASTNode.LookupException ilk ){
- // do we want to do something here?
- ilk.printStackTrace();
- return null;
- }
- }
- private void completionOnMemberReference(IASTCompletionNode completionNode){
- // Completing after a dot
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
-
- LookupResult result = null;
- // lookup fields and methods with the right visibility
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
- kinds[0] = IASTNode.LookupKind.FIELDS;
- kinds[1] = IASTNode.LookupKind.METHODS;
- result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions (result);
-
- }
-
- private void completionOnStatementStart( IASTCompletionNode completionNode )
- {
- IASTScope searchNode = completionNode.getCompletionScope();
-
- LookupResult result = null;
- // lookup fields and methods with the right visibility
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
- kinds[0] = IASTNode.LookupKind.FIELDS;
- kinds[1] = IASTNode.LookupKind.METHODS;
- kinds[2] = IASTNode.LookupKind.VARIABLES;
- kinds[3] = IASTNode.LookupKind.STRUCTURES;
- kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
- kinds[5] = IASTNode.LookupKind.NAMESPACES;
- kinds[6] = IASTNode.LookupKind.FUNCTIONS;
- result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions (result);
- }
- private void completionOnScopedReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- // the search node is the name before the qualification
- IASTScope searchNode = completionNode.getCompletionScope();
- // here we have to look for anything that could be referenced within this scope
- // 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
- kinds[0] = IASTNode.LookupKind.VARIABLES;
- kinds[1] = IASTNode.LookupKind.STRUCTURES;
- kinds[2] = IASTNode.LookupKind.ENUMERATIONS;
- kinds[3] = IASTNode.LookupKind.NAMESPACES;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- // TODO
- // lookup static members (field / methods) in type
-}
- private void completionOnTypeReference(IASTCompletionNode completionNode){
- // completing on a type
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // if the prefix is not empty
- if(completionNode.getCompletionPrefix().length() > 0 ) {
- // 2. Lookup all types that could be used here
- LookupResult result;
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
- kinds[0] = IASTNode.LookupKind.STRUCTURES;
- kinds[1] = IASTNode.LookupKind.ENUMERATIONS;
- result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- } else // prefix is empty, we can not look for everything
- {
-
- }
- }
-
- private void completionOnFieldType(IASTCompletionNode completionNode){
- // 1. basic completion on all types
- completionOnTypeReference(completionNode);
- // 2. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // TODO
- // 3. provide a template for constructor/ destructor
- // 4. lookup methods
- // we are at a field declaration place, the user could be trying to override a function.
- // We have to lookup functions that could be overridden here.
-// LookupResult result;
-// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
-// kinds[0] = IASTNode.LookupKind.METHODS;
-// result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
-// addToCompletions(result);
-
- }
- private void completionOnVariableType(IASTCompletionNode completionNode){
- // 1. basic completion on all types
- completionOnTypeReference(completionNode);
- }
- private void completionOnSingleNameReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- // the search node is the code scope inwhich completion is requested
- IASTScope searchNode = completionNode.getCompletionScope();
- // if prefix is not empty
- if (completionNode.getCompletionPrefix().length() > 0){
- // here we have to look for anything that could be referenced within this scope
- // 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
- kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
- kinds[1] = IASTNode.LookupKind.FIELDS;
- kinds[2] = IASTNode.LookupKind.VARIABLES;
- kinds[3] = IASTNode.LookupKind.STRUCTURES;
- kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
- kinds[5] = IASTNode.LookupKind.METHODS;
- kinds[6] = IASTNode.LookupKind.FUNCTIONS;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- } else // prefix is empty
- {
- // instead of only fields and methods
- // kinds[0] = IASTNode.LookupKind.THIS
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[3];
- kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
- kinds[1] = IASTNode.LookupKind.FIELDS;
- kinds[2] = IASTNode.LookupKind.METHODS;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- }
- }
-
- private void completionOnClassReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // only look for classes
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
- kinds[0] = IASTNode.LookupKind.CLASSES;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- }
- private void completionOnNamespaceReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // only look for namespaces
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
- kinds[0] = IASTNode.LookupKind.NAMESPACES;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- }
- private void completionOnExceptionReference(IASTCompletionNode completionNode){
- // here we have to look for all types
- completionOnTypeReference(completionNode);
- // plus if the prefix is empty, add "..." to the proposals
- if(completionNode.getCompletionPrefix().length() == 0){
- addKeywordToCompletions(exceptionKeyword);
- }
- }
- private void completionOnMacroReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // only look for macros
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
- kinds[0] = IASTNode.LookupKind.MACROS;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- }
- private void completionOnFunctionReference(IASTCompletionNode completionNode){
- // TODO: complete the lookups
- }
- private void completionOnConstructorReference(IASTCompletionNode completionNode){
- // 1. Get the search scope node
- IASTScope searchNode = completionNode.getCompletionScope();
- // only lookup constructors
- IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
- kinds[0] = IASTNode.LookupKind.CONSTRUCTORS;
- LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
- addToCompletions(result);
- }
- private void completionOnKeyword(IASTCompletionNode completionNode){
- // lookup every type of keywords
- // 1. basic types keword list
- List result = lookupKeyword(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
- addKeywordsToCompletions(result.iterator());
- }
-
- public IASTCompletionNode complete(IWorkingCopy sourceUnit, int completionOffset) {
-
- // 1- Parse the translation unit
- IASTCompletionNode completionNode = parse(sourceUnit, completionOffset);
-
- log("");
-
- if (completionNode == null){
- log("Null Completion Node Error");
- return null;
- }
-
- logNode("Scope = " , completionNode.getCompletionScope());
- logNode("Context = " , completionNode.getCompletionContext());
- logKind("Kind = ", completionNode.getCompletionKind().getEnumValue());
-
- // set the completionStart and the completionLength
- completionStart = completionOffset - completionNode.getCompletionPrefix().length();
- completionLength = completionNode.getCompletionPrefix().length();
- CompletionKind kind = completionNode.getCompletionKind();
-
- // 2- Check the return value
- if(kind == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE){
- // completionOnMemberReference
- completionOnMemberReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE){
- // completionOnMemberReference
- completionOnScopedReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE){
- // CompletionOnFieldType
- completionOnFieldType(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) {
- // CompletionOnVariableType
- completionOnVariableType(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.ARGUMENT_TYPE){
- // CompletionOnArgumentType
- completionOnTypeReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE){
- // CompletionOnSingleNameReference
- completionOnSingleNameReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.TYPE_REFERENCE){
- // CompletionOnStructureReference
- completionOnTypeReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.CLASS_REFERENCE){
- // CompletionOnClassReference
- completionOnClassReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.NAMESPACE_REFERENCE){
- // completionOnNamespaceReference
- completionOnNamespaceReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.EXCEPTION_REFERENCE){
- // CompletionOnExceptionReference
- completionOnExceptionReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.MACRO_REFERENCE){
- // CompletionOnMacroReference
- completionOnMacroReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.FUNCTION_REFERENCE){
- // completionOnFunctionReference
- completionOnFunctionReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.CONSTRUCTOR_REFERENCE){
- // completionOnConstructorReference
- completionOnConstructorReference(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.KEYWORD){
- // CompletionOnKeyword
- completionOnKeyword(completionNode);
- }
- else if(kind == IASTCompletionNode.CompletionKind.STATEMENT_START )
- {
- completionOnStatementStart(completionNode);
- }
-
- addKeywordsToCompletions( completionNode.getKeywords());
- return completionNode;
-
- }
- private void logKind(String message, int kindEnum){
- if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST) )
- return;
-
- String kindStr = "";
- switch (kindEnum){
- case 0:
- kindStr = "MEMBER_REFERENCE";
- break;
-
- case 1:
- kindStr = "SCOPED_REFERENCE";
- break;
-
- case 2:
- kindStr = "FIELD_TYPE";
- break;
-
- case 3:
- kindStr = "VARIABLE_TYPE";
- break;
-
- case 4:
- kindStr = "ARGUMENT_TYPE";
- break;
-
- case 5:
- kindStr = "SINGLE_NAME_REFERENCE";
- break;
-
- case 6:
- kindStr = "TYPE_REFERENCE";
- break;
-
- case 7:
- kindStr = "CLASS_REFERENCE";
- break;
-
- case 8:
- kindStr = "NAMESPACE_REFERENCE";
- break;
-
- case 9:
- kindStr = "EXCEPTION_REFERENCE";
- break;
-
- case 10:
- kindStr = "MACRO_REFERENCE";
- break;
-
- case 11:
- kindStr = "FUNCTION_REFERENCE";
- break;
-
- case 12:
- kindStr = "CONSTRUCTOR_REFERENCE";
- break;
-
- case 13:
- kindStr = "KEYWORD";
- break;
-
- case 14:
- kindStr = "PREPROCESSOR_DIRECTIVE";
- break;
-
- case 15:
- kindStr = "USER_SPECIFIED_NAME";
- break;
-
- case 16:
- kindStr = "STATEMENT_START";
- break;
-
- case 200:
- kindStr = "NO_SUCH_KIND";
- break;
- }
- log (message + kindStr);
- }
- private void logNode(String message, IASTNode node){
- if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
- return;
-
- if(node == null){
- log(message + "null");
- return;
- }
- if(node instanceof IASTMethod){
- String name = "Method: ";
- name += ((IASTMethod)node).getName();
- log(message + name);
- return;
- }
- if(node instanceof IASTFunction){
- String name = "Function: ";
- name += ((IASTFunction)node).getName();
- log(message + name);
- return;
- }
- if(node instanceof IASTClassSpecifier){
- String name = "Class: ";
- name += ((IASTClassSpecifier)node).getName();
- log(message + name);
- return;
- }
- if(node instanceof IASTCompilationUnit){
- String name = "Global";
- log(message + name);
- return;
- }
-
- log(message + node.toString());
- return;
-
- }
- private void logLookups(LookupKind[] kinds){
- if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
- return;
-
- StringBuffer kindName = new StringBuffer("Looking For ");
- for(int i = 0; i<kinds.length; i++){
- LookupKind kind = (LookupKind) kinds[i];
- switch (kind.getEnumValue()){
- case 0:
- kindName.append("ALL");
- break;
- case 1:
- kindName.append("STRUCTURES");
- break;
- case 2:
- kindName.append("STRUCS");
- break;
- case 3:
- kindName.append("UNIONS");
- break;
- case 4:
- kindName.append("CLASSES");
- break;
- case 5:
- kindName.append("FUNCTIONS");
- break;
- case 6:
- kindName.append("VARIABLES");
- break;
- case 7:
- kindName.append("LOCAL_VARIABLES");
- break;
- case 8:
- kindName.append("MEMBERS");
- break;
- case 9:
- kindName.append("METHODS");
- break;
- case 10:
- kindName.append("FIELDS");
- break;
- case 11:
- kindName.append("CONSTRUCTORS");
- break;
- case 12:
- kindName.append("NAMESPACES");
- break;
- case 13:
- kindName.append("MACROS");
- break;
- case 14:
- kindName.append("ENUMERATIONS");
- break;
- case 15:
- kindName.append("ENUMERATORS");
- break;
- case 16:
- kindName.append("THIS");
- break;
- }
- kindName.append(", ");
- }
- log (kindName.toString());
- }
- private void log(String message){
- if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
- return;
- Util.debugLog(message, IDebugLogConstants.CONTENTASSIST, false);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java
deleted file mode 100644
index 61c8f94be8d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CompletionRequestorAdaptor implements ICompletionRequestor {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptField(java.lang.String, java.lang.String)
- */
- public void acceptField(String name, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptClass(java.lang.String)
- */
- public void acceptClass(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumeration(java.lang.String)
- */
- public void acceptEnumeration(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptFunction(java.lang.String, java.lang.String, java.lang.String)
- */
- public void acceptFunction(
- String name,
- String parameterString,
- String returnType, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptMacro(java.lang.String)
- */
- public void acceptMacro(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptMethod(java.lang.String, java.lang.String, java.lang.String)
- */
- public void acceptMethod(
- String name,
- String parameterString,
- String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptStruct(java.lang.String)
- */
- public void acceptStruct(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptUnion(java.lang.String)
- */
- public void acceptUnion(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptVariable(java.lang.String, java.lang.String)
- */
- public void acceptVariable(String name, String returnType, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptLocalVariable(java.lang.String, java.lang.String)
- */
- public void acceptLocalVariable(String name, String returnType, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptNamespace(java.lang.String)
- */
- public void acceptNamespace(String name, int completionStart, int completionLength, int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumerator(java.lang.String, int, int, int)
- */
- public void acceptEnumerator(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptKeyword(java.lang.String, int, int, int)
- */
- public void acceptKeyword(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptError(org.eclipse.cdt.core.parser.IProblem)
- */
- public void acceptError(IProblem error) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java
deleted file mode 100644
index 6196bbb6220..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Created on Nov 19, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
-
-/**
- * @author hamer
- *
- * This class is the source element requestor used by the completion engine.
- */
-public class ContentAssistElementRequestor extends NullSourceElementRequestor {
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
deleted file mode 100644
index a7fcaab501a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.IColorManager;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-
-public class ContentAssistPreference {
-
- /** Preference key for content assist auto activation */
- //public final static String AUTOACTIVATION= "content_assist_autoactivation";
- /** Preference key for content assist auto activation delay */
- public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay";
- /** Preference key for content assist proposal color */
- public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground";
- /** Preference key for content assist proposal color */
- public final static String PROPOSALS_BACKGROUND= "content_assist_proposals_background";
- /** Preference key for content assist parameters color */
- public final static String PARAMETERS_FOREGROUND= "content_assist_parameters_foreground";
- /** Preference key for content assist parameters color */
- public final static String PARAMETERS_BACKGROUND= "content_assist_parameters_background";
- /** Preference key for content assist auto insert */
- public final static String AUTOINSERT= "content_assist_autoinsert";
-
- /** Preference key for C/CPP content assist auto activation triggers */
- public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot";
- public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow";
- public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon";
-
- /** Preference key for visibility of proposals */
- public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals";
- /** Preference key for alphabetic ordering of proposals */
- public final static String ORDER_PROPOSALS= "content_assist_order_proposals";
- /** Preference key for case sensitivity of propsals */
- //public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
- /** Preference key for adding imports on code assist */
- public final static String ADD_INCLUDE= "content_assist_add_import";
- /** Preference key for completion search scope */
- public final static String CURRENT_FILE_SEARCH_SCOPE= "content_assist_current_file_search_scope";
- /** Preference key for completion search scope */
- public final static String PROJECT_SEARCH_SCOPE= "content_assist_project_search_scope";
- /** Preference key for completion search scope */
- public final static String PROJECT_AND_DEPENDENCY_SEARCH_SCOPE= "content_assist_project_and_dependency_search_scope";
-
- private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
- RGB rgb= PreferenceConverter.getColor(store, key);
- return manager.getColor(rgb);
- }
-
- private static Color getColor(IPreferenceStore store, String key) {
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- return getColor(store, key, textTools.getColorManager());
- }
-
- private static CCompletionProcessor getCProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
- if (p instanceof CCompletionProcessor)
- return (CCompletionProcessor) p;
- return null;
- }
-
- private static void configureCProcessor(ContentAssistant assistant, IPreferenceStore store) {
- CCompletionProcessor jcp= getCProcessor(assistant);
- if (jcp == null)
- return;
-
- String triggers = "";
- boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- if(useDotAsTrigger)
- triggers = ".";
- boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- if(useArrowAsTrigger)
- triggers += ">";
- boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- if(useDoubleColonAsTrigger)
- triggers += ":";
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
-
- boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
- //jcp.restrictProposalsToVisibility(enabled);
-
- //enabled= store.getBoolean(CASE_SENSITIVITY);
- //jcp.restrictProposalsToMatchingCases(enabled);
-
- enabled= store.getBoolean(ORDER_PROPOSALS);
- jcp.orderProposalsAlphabetically(enabled);
-
- enabled= store.getBoolean(ADD_INCLUDE);
- jcp.allowAddingIncludes(enabled);
- }
-
-
- /**
- * Configure the given content assistant from the given store.
- */
- public static void configure(ContentAssistant assistant, IPreferenceStore store) {
-
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- IColorManager manager= textTools.getColorManager();
-
- boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
- assistant.enableAutoActivation(enabled);
-
- int delay= store.getInt(AUTOACTIVATION_DELAY);
- assistant.setAutoActivationDelay(delay);
-
- Color c1= getColor(store, PROPOSALS_FOREGROUND, manager);
- assistant.setProposalSelectorForeground(c1);
-
- Color c2= getColor(store, PROPOSALS_BACKGROUND, manager);
- assistant.setProposalSelectorBackground(c2);
-
- Color c3= getColor(store, PARAMETERS_FOREGROUND, manager);
- assistant.setContextInformationPopupForeground(c3);
- assistant.setContextSelectorForeground(c3);
-
- Color c4= getColor(store, PARAMETERS_BACKGROUND, manager);
- assistant.setContextInformationPopupBackground(c4);
- assistant.setContextSelectorBackground(c4);
-
- enabled= store.getBoolean(AUTOINSERT);
- assistant.enableAutoInsert(enabled);
-
- configureCProcessor(assistant, store);
- }
-
-
- private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
- CCompletionProcessor jcp= getCProcessor(assistant);
- if (jcp == null)
- return;
-
- if (AUTOACTIVATION_TRIGGERS_DOT.equals(key)) {
- boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- if (useDotAsTrigger){
- String triggers= ".";
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- }
- } else if (AUTOACTIVATION_TRIGGERS_ARROW.equals(key)) {
- boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- if (useArrowAsTrigger){
- String triggers= ">";
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- }
- } else if (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) {
- boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- if (useDoubleColonAsTrigger){
- String triggers= ":";
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- }
- } else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
- //boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
- //jcp.restrictProposalsToVisibility(enabled);
- }
- //else if (CASE_SENSITIVITY.equals(key)) {
- // boolean enabled= store.getBoolean(CASE_SENSITIVITY);
- // jcp.restrictProposalsToMatchingCases(enabled);
- // }
- else if (ORDER_PROPOSALS.equals(key)) {
- boolean enable= store.getBoolean(ORDER_PROPOSALS);
- jcp.orderProposalsAlphabetically(enable);
- } else if (ADD_INCLUDE.equals(key)) {
- boolean enabled= store.getBoolean(ADD_INCLUDE);
- jcp.allowAddingIncludes(enabled);
- }
- }
-
- /**
- * Changes the configuration of the given content assistant according to the given property
- * change event and the given preference store.
- */
- public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store, PropertyChangeEvent event) {
-
- String p= event.getProperty();
-
- if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
- || (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
- || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))){
- boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
- assistant.enableAutoActivation(enabled);
- } else if (AUTOACTIVATION_DELAY.equals(p)) {
- int delay= store.getInt(AUTOACTIVATION_DELAY);
- assistant.setAutoActivationDelay(delay);
- } else if (PROPOSALS_FOREGROUND.equals(p)) {
- Color c= getColor(store, PROPOSALS_FOREGROUND);
- assistant.setProposalSelectorForeground(c);
- } else if (PROPOSALS_BACKGROUND.equals(p)) {
- Color c= getColor(store, PROPOSALS_BACKGROUND);
- assistant.setProposalSelectorBackground(c);
- } else if (PARAMETERS_FOREGROUND.equals(p)) {
- Color c= getColor(store, PARAMETERS_FOREGROUND);
- assistant.setContextInformationPopupForeground(c);
- assistant.setContextSelectorForeground(c);
- } else if (PARAMETERS_BACKGROUND.equals(p)) {
- Color c= getColor(store, PARAMETERS_BACKGROUND);
- assistant.setContextInformationPopupBackground(c);
- assistant.setContextSelectorBackground(c);
- } else if (AUTOINSERT.equals(p)) {
- boolean enabled= store.getBoolean(AUTOINSERT);
- assistant.enableAutoInsert(enabled);
- }
-
- changeCProcessor(assistant, store, p);
- }
-}
-
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java
deleted file mode 100644
index 7d71ed94f4e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
-/**
- * @author hamer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public interface ICompletionRequestor {
- void acceptField(String name, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance);
- void acceptVariable(String name, String returnType, int completionStart, int completionLength, int relevance);
- void acceptLocalVariable(String name, String returnType, int completionStart, int completionLength, int relevance);
- void acceptMethod(String name, String parameterString, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance);
- void acceptFunction(String name, String parameterString, String returnType, int completionStart, int completionLength, int relevance);
- void acceptClass(String name, int completionStart, int completionLength, int relevance);
- void acceptStruct(String name, int completionStart, int completionLength, int relevance);
- void acceptUnion(String name, int completionStart, int completionLength, int relevance);
- void acceptNamespace(String name, int completionStart, int completionLength, int relevance);
- void acceptMacro(String name, int completionStart, int completionLength, int relevance);
- void acceptEnumeration(String name, int completionStart, int completionLength, int relevance);
- void acceptEnumerator(String name, int completionStart, int completionLength, int relevance);
- void acceptKeyword(String name, int completionStart, int completionLength, int relevance);
- void acceptError(IProblem error);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
deleted file mode 100644
index 48058d3e089..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-/**
- * @author hamer
- *
- */
-public interface RelevanceConstants {
- final int CASE_MATCH_RELEVANCE = 150;
- final int EXACT_NAME_MATCH_RELEVANCE = 40;
-
- final int LOCAL_VARIABLE_TYPE_RELEVANCE = 130;
- final int FIELD_TYPE_RELEVANCE = 120;
- final int VARIABLE_TYPE_RELEVANCE = 110;
- final int METHOD_TYPE_RELEVANCE = 100;
- final int FUNCTION_TYPE_RELEVANCE = 90;
- final int CLASS_TYPE_RELEVANCE = 80;
- final int STRUCT_TYPE_RELEVANCE = 70;
- final int UNION_TYPE_RELEVANCE = 60;
- final int NAMESPACE_TYPE_RELEVANCE = 50;
- final int MACRO_TYPE_RELEVANCE = 40;
- final int ENUMERATION_TYPE_RELEVANCE = 30;
- final int ENUMERATOR_TYPE_RELEVANCE = 20;
- final int KEYWORD_TYPE_RELEVANCE = 10;
- final int DEFAULT_TYPE_RELEVANCE = 0;
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java
deleted file mode 100644
index 5641cf8de0a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.text.contentassist;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.ui.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.FunctionPrototypeSummary;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ContextInformation;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author hamer
- *
- * The Result Collector class receives information from the completion engine
- * as a completion requestor. It might also receive information from others
- * such as the results of a search operation to generate completion proposals.
- *
- */
-public class ResultCollector extends CompletionRequestorAdaptor {
- private Set completions = new HashSet();
- private ImageDescriptorRegistry registry = CUIPlugin.getImageDescriptorRegistry();
- private IProblem fLastProblem;
- private ITextViewer fTextViewer;
-
- public ResultCollector(){
- completions.clear();
- fTextViewer = null;
- }
-
- /**
- * @return the completion list
- */
- public Set getCompletions() {
- return completions;
- }
- public void reset(ITextViewer viewer) {
- completions.clear();
- fTextViewer = viewer;
- fLastProblem = null;
- }
- /*
- * Create a proposal
- */
- public ICompletionProposal createProposal(String replaceString, String displayString, String infoString, String arguments, Image image, int offset, int length, int relevance){
- CCompletionProposal proposal;
-
- proposal = new CCompletionProposal(
- replaceString, // Replacement string
- offset,
- length,
- image,
- displayString, // Display string
- relevance,
- fTextViewer);
-
- if(arguments != null && arguments.length() > 0) {
- proposal.setContextInformation(new ContextInformation(replaceString, arguments));
- }
-
- // The info string could be populated with documentation info.
- // For now, it has the name and the parent's name if available.
- if((infoString != null)&& (!displayString.equals(infoString)))
- proposal.setAdditionalProposalInfo(infoString);
-
- return proposal;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptField(java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, int, int)
- */
- public void acceptField(String name, String returnType, ASTAccessVisibility visibility,
- int completionStart, int completionLength, int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
- if(returnType != null)
- displayString+= " : " + returnType;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getFieldImageDescriptor(visibility);
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptClass(java.lang.String, int, int, int)
- */
- public void acceptClass(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getClassImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptFunction(java.lang.String, java.lang.String, java.lang.String, int, int, int)
- */
- public void acceptFunction(
- String name,
- String parameterString,
- String returnType,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- String arguments = "";
-
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
- String functionPrototype = returnType + " " + name;
- if(parameterString != null){
- if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1))
- {
- functionPrototype += "(" + parameterString + ")";
- }
- else {
- functionPrototype += parameterString;
- }
- }
-
- FunctionPrototypeSummary fproto = new FunctionPrototypeSummary(functionPrototype);
- if(fproto != null) {
- replaceString = fproto.getName() + "()";
- displayString = fproto.getPrototypeString(true);
- infoString.append(displayString);
- arguments = fproto.getArguments();
- }
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- arguments, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptLocalVariable(java.lang.String, java.lang.String, int, int, int)
- */
- public void acceptLocalVariable(
- String name,
- String returnType,
- int completionStart,
- int completionLength,
- int relevance) {
-
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
- if(returnType != null)
- displayString+= " : " + returnType;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getLocalVariableImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptMacro(java.lang.String, int, int, int)
- */
- public void acceptMacro(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
-
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getMacroImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptMethod(java.lang.String, java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, int, int)
- */
- public void acceptMethod(
- String name,
- String parameterString,
- String returnType,
- ASTAccessVisibility visibility,
- int completionStart,
- int completionLength,
- int relevance) {
-
- String replaceString = "";
- String displayString = "";
- String arguments = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
- String functionPrototype = returnType + " " + name;
- if(parameterString != null){
- if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1))
- {
- functionPrototype += "(" + parameterString + ")";
- }
- else {
- functionPrototype += parameterString;
- }
- }
-
- FunctionPrototypeSummary fproto = new FunctionPrototypeSummary(functionPrototype);
- if(fproto != null) {
- replaceString = fproto.getName() + "()";
- displayString = fproto.getPrototypeString(true);
- infoString.append(displayString);
- arguments = fproto.getArguments();
- }
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getMethodImageDescriptor(visibility);
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- arguments, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptNamespace(java.lang.String, int, int, int)
- */
- public void acceptNamespace(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptStruct(java.lang.String, int, int, int)
- */
- public void acceptStruct(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getStructImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptUnion(java.lang.String, int, int, int)
- */
- public void acceptUnion(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptVariable(java.lang.String, java.lang.String, int, int, int)
- */
- public void acceptVariable(
- String name,
- String returnType,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
- if(returnType != null)
- displayString+= " : " + returnType;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumeration(java.lang.String, int, int, int)
- */
- public void acceptEnumeration(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumerator(java.lang.String, int, int, int)
- */
- public void acceptEnumerator(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // get the image
- ImageDescriptor imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
- image = registry.get( imageDescriptor );
-
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptKeyword(java.lang.String, int, int, int)
- */
- public void acceptKeyword(
- String name,
- int completionStart,
- int completionLength,
- int relevance) {
- String replaceString = "";
- String displayString = "";
- Image image = null;
- StringBuffer infoString = new StringBuffer();
-
- // fill the replace, display and info strings
- replaceString = name;
- displayString = name;
-
- // no image for keywords
- // create proposal and add it to completions list
- ICompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
- null, image, completionStart, completionLength, relevance);
- completions.add(proposal);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICompletionRequestor#acceptError(org.eclipse.cdt.core.parser.IProblem)
- */
- public void acceptError(IProblem error) {
- fLastProblem = error;
- }
-
- public String getErrorMessage() {
- if (fLastProblem != null)
- return fLastProblem.getMessage();
- return ""; //$NON-NLS-1$
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionListener.java
deleted file mode 100644
index 12e3bb8de5b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.link;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.Position;
-
-/**
- * A listener for highlight change notification and exititing linked mode.
- */
-public interface LinkedPositionListener {
-
- /**
- * Notifies that the linked mode has been left. On success, all changes
- * are kept, otherwise all changes made to the linked positions are restored
- * to the state before entering linked mode.
- */
- void exit(boolean success);
-
- /**
- * Notifies the changed linked position. The listener is asked
- * to reposition the caret at the given offset.
- *
- * @param position the linked position which initiated the change.
- * @param caretOffset the caret offset relative to the position.
- */
- void setCurrentPosition(Position position, int caretOffset);
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionManager.java
deleted file mode 100644
index 21666b6199a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionManager.java
+++ /dev/null
@@ -1,449 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.link;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * This class manages linked positions in a document. Positions are linked
- * by type names. If positions have the same type name, they are considered
- * as <em>linked</em>.
- *
- * The manager remains active on a document until any of the following actions
- * occurs:
- *
- * <ul>
- * <li>A document change is performed which would invalidate any of the
- * above constraints.</li>
- *
- * <li>The method <code>uninstall()</code> is called.</li>
- *
- * <li>Another instance of <code>LinkedPositionManager</code> tries to
- * gain control of the same document.
- * </ul>
- */
-public class LinkedPositionManager implements IDocumentListener, IPositionUpdater {
-
- private static class PositionComparator implements Comparator {
- /*
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object object0, Object object1) {
- Position position0= (Position) object0;
- Position position1= (Position) object1;
-
- return position0.getOffset() - position1.getOffset();
- }
- }
-
- private class Replace implements IDocumentExtension.IReplace {
-
- private Position fReplacePosition;
- private int fReplaceDeltaOffset;
- private int fReplaceLength;
- private String fReplaceText;
-
- public Replace(Position position, int deltaOffset, int length, String text) {
- fReplacePosition= position;
- fReplaceDeltaOffset= deltaOffset;
- fReplaceLength= length;
- fReplaceText= text;
- }
-
- public void perform(IDocument document, IDocumentListener owner) {
- document.removeDocumentListener(owner);
- try {
- document.replace(fReplacePosition.getOffset() + fReplaceDeltaOffset, fReplaceLength, fReplaceText);
- } catch (BadLocationException e) {
- CUIPlugin.getDefault().log(e);
- // TBD
- }
- document.addDocumentListener(owner);
- }
- }
-
- private static final String LINKED_POSITION= "LinkedPositionManager.linked.position"; //$NON-NLS-1$
- private static final Comparator fgPositionComparator= new PositionComparator();
- private static final Map fgActiveManagers= new HashMap();
-
- private IDocument fDocument;
-
- private LinkedPositionListener fListener;
-
- /**
- * Creates a <code>LinkedPositionManager</code> for a <code>IDocument</code>.
- *
- * @param document the document to use with linked positions.
- */
- public LinkedPositionManager(IDocument document) {
- Assert.isNotNull(document);
-
- fDocument= document;
- install();
- }
-
- /**
- * Sets a listener to notify changes of current linked position.
- */
- public void setLinkedPositionListener(LinkedPositionListener listener) {
- fListener= listener;
- }
-
- /**
- * Adds a linked position to the manager.
- * There are the following constraints for linked positions:
- *
- * <ul>
- * <li>Any two positions have spacing of at least one character.
- * This implies that two positions must not overlap.</li>
- *
- * <li>The string at any position must not contain line delimiters.</li>
- * </ul>
- *
- * @param offset the offset of the position.
- * @param length the length of the position.
- */
- public void addPosition(int offset, int length) throws BadLocationException {
- Position[] positions= getPositions(fDocument);
-
- if (positions != null) {
- for (int i = 0; i < positions.length; i++)
- if (collides(positions[i], offset, length))
- throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.position.collision"))); //$NON-NLS-1$
- }
-
- String type= fDocument.get(offset, length);
-
- if (containsLineDelimiters(type))
- throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.contains.line.delimiters"))); //$NON-NLS-1$
-
- try {
- fDocument.addPosition(LINKED_POSITION, new TypedPosition(offset, length, type));
- } catch (BadPositionCategoryException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
- }
- }
-
- /**
- * Tests if a manager is already active for a document.
- */
- public static boolean hasActiveManager(IDocument document) {
- return fgActiveManagers.get(document) != null;
- }
-
- private void install() {
- LinkedPositionManager manager= (LinkedPositionManager) fgActiveManagers.get(fDocument);
- if (manager != null)
- manager.leave(true);
-
- fgActiveManagers.put(fDocument, this);
-
- fDocument.addPositionCategory(LINKED_POSITION);
- fDocument.addPositionUpdater(this);
- fDocument.addDocumentListener(this);
- }
-
- /**
- * Leaves the linked mode. If unsuccessful, the linked positions
- * are restored to the values at the time they were added.
- */
- public void uninstall(boolean success) {
- fDocument.removeDocumentListener(this);
-
- try {
- Position[] positions= getPositions(fDocument);
- if ((!success) && (positions != null)) {
- // restore
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- fDocument.replace(position.getOffset(), position.getLength(), position.getType());
- }
- }
-
- fDocument.removePositionCategory(LINKED_POSITION);
-
- } catch (BadLocationException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
-
- } catch (BadPositionCategoryException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
-
- } finally {
- fDocument.removePositionUpdater(this);
- fgActiveManagers.remove(fDocument);
- }
- }
-
- /**
- * Returns the first linked position.
- *
- * @return returns <code>null</code> if no linked position exist.
- */
- public Position getFirstPosition() {
- return getNextPosition(-1);
- }
-
- /**
- * Returns the next linked position with an offset greater than <code>offset</code>.
- * If another position with the same type and offset lower than <code>offset</code>
- * exists, the position is skipped.
- *
- * @return returns <code>null</code> if no linked position exist.
- */
- public Position getNextPosition(int offset) {
- Position[] positions= getPositions(fDocument);
- return findNextPosition(positions, offset);
- }
-
- private static Position findNextPosition(Position[] positions, int offset) {
- // skip already visited types
- for (int i= 0; i != positions.length; i++) {
- if (positions[i].getOffset() > offset) {
- String type= ((TypedPosition) positions[i]).getType();
- int j;
- for (j = 0; j != i; j++)
- if (((TypedPosition) positions[j]).getType().equals(type))
- break;
-
- if (j == i)
- return positions[i];
- }
- }
-
- return null;
- }
-
- /**
- * Returns the position with the greatest offset smaller than <code>offset</code>.
- *
- * @return returns <code>null</code> if no linked position exist.
- */
- public Position getPreviousPosition(int offset) {
- Position[] positions= getPositions(fDocument);
- if (positions == null)
- return null;
-
- Position lastPosition= null;
- Position position= getFirstPosition();
-
- while ((position != null) && (position.getOffset() < offset)) {
- lastPosition= position;
- position= findNextPosition(positions, position.getOffset());
- }
-
- return lastPosition;
- }
-
- private static Position[] getPositions(IDocument document) {
- try {
- Position[] positions= document.getPositions(LINKED_POSITION);
- Arrays.sort(positions, fgPositionComparator);
- return positions;
-
- } catch (BadPositionCategoryException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
- }
-
- return null;
- }
-
- public static boolean includes(Position position, int offset, int length) {
- return
- (offset >= position.getOffset()) &&
- (offset + length <= position.getOffset() + position.getLength());
- }
-
- public static boolean excludes(Position position, int offset, int length) {
- return
- (offset + length <= position.getOffset()) ||
- (position.getOffset() + position.getLength() <= offset);
- }
-
- /*
- * Collides if spacing if positions intersect each other or are adjacent.
- */
- private static boolean collides(Position position, int offset, int length) {
- return
- (offset <= position.getOffset() + position.getLength()) &&
- (position.getOffset() <= offset + length);
- }
-
- private void leave(boolean success) {
- uninstall(success);
-
- if (fListener != null)
- fListener.exit(success);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- IDocument document= event.getDocument();
-
- Position[] positions= getPositions(document);
- Position position= findCurrentEditablePosition(positions, event.getOffset());
-
- // modification outside editable position
- if (position == null) {
- position= findCurrentPosition(positions, event.getOffset());
-
- // modification outside any position
- if (position == null) {
- // check for destruction of constraints (spacing of at least 1)
- if ((event.getText().length() == 0) &&
- (findCurrentPosition(positions, event.getOffset()) != null) &&
- (findCurrentPosition(positions, event.getOffset() + event.getLength()) != null))
- {
- leave(true);
- }
-
- // modification intersects non-editable position
- } else {
- leave(true);
- }
-
- // modification intersects editable position
- } else {
- // modificaction inside editable position
- if (includes(position, event.getOffset(), event.getLength())) {
- if (containsLineDelimiters(event.getText()))
- leave(true);
-
- // modificaction exceeds editable position
- } else {
- leave(true);
- }
- }
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- IDocument document= event.getDocument();
-
- Position[] positions= getPositions(document);
- TypedPosition currentPosition= (TypedPosition) findCurrentEditablePosition(positions, event.getOffset());
-
- // ignore document changes (assume it won't invalidate constraints)
- if (currentPosition == null)
- return;
-
- int deltaOffset= event.getOffset() - currentPosition.getOffset();
-
- if (fListener != null)
- fListener.setCurrentPosition(currentPosition, deltaOffset + event.getText().length());
-
- for (int i= 0; i != positions.length; i++) {
- TypedPosition p= (TypedPosition) positions[i];
-
- if (p.getType().equals(currentPosition.getType()) && !p.equals(currentPosition)) {
- Replace replace= new Replace(p, deltaOffset, event.getLength(), event.getText());
- ((IDocumentExtension) document).registerPostNotificationReplace(this, replace);
- }
- }
- }
-
- /*
- * @see IPositionUpdater#update(DocumentEvent)
- */
- public void update(DocumentEvent event) {
- int deltaLength= event.getText().length() - event.getLength();
-
- Position[] positions= getPositions(event.getDocument());
- TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());
-
- // document change outside positions
- if (currentPosition == null) {
-
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- int offset= position.getOffset();
-
- if (offset >= event.getOffset())
- position.setOffset(offset + deltaLength);
- }
-
- // document change within a position
- } else {
- int length= currentPosition.getLength();
-
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- int offset= position.getOffset();
-
- if (position.equals(currentPosition)) {
- position.setLength(length + deltaLength);
- } else if (offset > currentPosition.getOffset()) {
- position.setOffset(offset + deltaLength);
- }
- }
- }
- }
-
- private static Position findCurrentPosition(Position[] positions, int offset) {
- for (int i= 0; i != positions.length; i++)
- if (includes(positions[i], offset, 0))
- return positions[i];
-
- return null;
- }
-
- private static Position findCurrentEditablePosition(Position[] positions, int offset) {
- Position position= positions[0];
-
- while ((position != null) && !includes(position, offset, 0))
- position= findNextPosition(positions, position.getOffset());
-
- return position;
- }
-
- private boolean containsLineDelimiters(String string) {
- String[] delimiters= fDocument.getLegalLineDelimiters();
-
- for (int i= 0; i != delimiters.length; i++)
- if (string.indexOf(delimiters[i]) != -1)
- return true;
-
- return false;
- }
-
- /**
- * Test if ok to modify through UI.
- */
- public boolean anyPositionIncludes(int offset, int length) {
- Position[] positions= getPositions(fDocument);
-
- Position position= findCurrentEditablePosition(positions, offset);
- if (position == null)
- return false;
-
- return includes(position, offset, length);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.java
deleted file mode 100644
index 67439db4171..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.link;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class LinkedPositionMessages {
-
- private static final String RESOURCE_BUNDLE= LinkedPositionMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private LinkedPositionMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * 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
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.properties
deleted file mode 100644
index 267939d0cfc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionMessages.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-LinkedPositionUI.error.title=Error in LinkedPositionError
-
-LinkedPositionManager.error.contains.line.delimiters=String contains line delimiters.
-LinkedPositionManager.error.position.collision=Linked position collides with another linked position.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionUI.java
deleted file mode 100644
index a3a64c68f8e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/link/LinkedPositionUI.java
+++ /dev/null
@@ -1,547 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.link;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * A user interface for <code>LinkedPositionManager</code>, using <code>ITextViewer</code>.
- */
-public class LinkedPositionUI implements LinkedPositionListener,
- ITextInputListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener, IPropertyChangeListener {
-
- /**
- * A listener for notification when the user cancelled the edit operation.
- */
- public interface ExitListener {
- void exit(boolean accept);
- }
-
- // leave flags
- private static final int UNINSTALL= 1; // uninstall linked position manager
- public static final int COMMIT= 2; // commit changes
- private static final int DOCUMENT_CHANGED= 4; // document has changed
- public static final int UPDATE_CARET= 8; // update caret
-
- private static final String CARET_POSITION= "LinkedPositionUI.caret.position";
- private static final IPositionUpdater fgUpdater= new DefaultPositionUpdater(CARET_POSITION);
- private static final IPreferenceStore fgStore= CUIPlugin.getDefault().getPreferenceStore();
-
- private final ITextViewer fViewer;
- private final LinkedPositionManager fManager;
- private Color fFrameColor;
-
- private int fFinalCaretOffset= -1; // no final caret offset
-
- private Position fFramePosition;
- private int fCaretOffset;
-
- private ExitPolicy fExitPolicy;
- private ExitListener fExitListener;
-
- /**
- * Creates a user interface for <code>LinkedPositionManager</code>.
- *
- * @param viewer the text viewer.
- * @param manager the <code>LinkedPositionManager</code> managing a <code>IDocument</code> of the <code>ITextViewer</code>.
- */
- public LinkedPositionUI(ITextViewer viewer, LinkedPositionManager manager) {
- Assert.isNotNull(viewer);
- Assert.isNotNull(manager);
-
- fViewer= viewer;
- fManager= manager;
-
- fManager.setLinkedPositionListener(this);
-
- initializeHighlightColor(viewer);
- }
-
- /**
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(CEditor.LINKED_POSITION_COLOR)) {
- initializeHighlightColor(fViewer);
- redrawRegion();
- }
- }
-
- private void initializeHighlightColor(ITextViewer viewer) {
-
- if (fFrameColor != null)
- fFrameColor.dispose();
-
- StyledText text= viewer.getTextWidget();
- if (text != null) {
- Display display= text.getDisplay();
- fFrameColor= createColor(fgStore, CEditor.LINKED_POSITION_COLOR, display);
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
-
- RGB rgb= null;
-
- if (store.contains(key)) {
-
- if (store.isDefault(key))
- rgb= PreferenceConverter.getDefaultColor(store, key);
- else
- rgb= PreferenceConverter.getColor(store, key);
-
- if (rgb != null)
- return new Color(display, rgb);
- }
-
- return null;
- }
-
- /**
- * Sets the final position of the caret when the linked mode is exited
- * successfully by leaving the last linked position using TAB.
- */
- public void setFinalCaretOffset(int offset) {
- fFinalCaretOffset= offset;
- }
-
- /**
- * Sets a <code>CancelListener</code> which is notified if the linked mode
- * is exited unsuccessfully by hitting ESC.
- */
- public void setCancelListener(ExitListener listener) {
- fExitListener= listener;
- }
-
- /*
- * @see LinkedPositionManager.LinkedPositionListener#setCurrentPositions(Position, int)
- */
- public void setCurrentPosition(Position position, int caretOffset) {
- if (!fFramePosition.equals(position)) {
- redrawRegion();
- fFramePosition= position;
- }
-
- fCaretOffset= caretOffset;
- }
- /**
- * Sets an <code>ExitPolicy</code> which decides when and how
- * the linked mode is exited.
- */
- public void setExitPolicy(ExitPolicy policy) {
- fExitPolicy= policy;
- }
- /**
- * Enters the linked mode. The linked mode can be left by calling
- * <code>exit</code>.
- *
- * @see exit(boolean)
- */
- public void enter() {
- // track final caret
- IDocument document= fViewer.getDocument();
- document.addPositionCategory(CARET_POSITION);
- document.addPositionUpdater(fgUpdater);
- try {
- if (fFinalCaretOffset != -1)
- document.addPosition(CARET_POSITION, new Position(fFinalCaretOffset));
- } catch (BadLocationException e) {
- openErrorDialog(fViewer.getTextWidget().getShell(), e);
-
- } catch (BadPositionCategoryException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
- }
-
- fViewer.addTextInputListener(this);
-
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.prependVerifyKeyListener(this);
-
- StyledText text= fViewer.getTextWidget();
- text.addVerifyListener(this);
- text.addModifyListener(this);
- text.addPaintListener(this);
- text.showSelection();
-
- fFramePosition= fManager.getFirstPosition();
- if (fFramePosition == null)
- leave(UNINSTALL | COMMIT | UPDATE_CARET);
-
- fgStore.addPropertyChangeListener(this);
- }
-
- /**
- * @see LinkedPositionManager.LinkedPositionListener#exit(boolean)
- */
- public void exit(boolean success) {
- // no UNINSTALL since manager has already uninstalled itself
- leave((success ? COMMIT : 0) | UPDATE_CARET);
- }
-
- /**
- * Returns the cursor selection, after having entered the linked mode.
- * <code>enter()</code> must be called prior to a call to this method.
- */
- public IRegion getSelectedRegion() {
- if (fFramePosition == null)
- return new Region(fFinalCaretOffset, 0);
- else
- return new Region(fFramePosition.getOffset(), fFramePosition.getLength());
- }
-
- private void leave(int flags) {
- if ((flags & UNINSTALL) != 0)
- fManager.uninstall((flags & COMMIT) != 0);
-
- fgStore.removePropertyChangeListener(this);
-
- if (fFrameColor != null) {
- fFrameColor.dispose();
- fFrameColor= null;
- }
-
- StyledText text= fViewer.getTextWidget();
- text.removePaintListener(this);
- text.removeModifyListener(this);
- text.removeVerifyListener(this);
-
- ITextViewerExtension extension= (ITextViewerExtension) fViewer;
- extension.removeVerifyKeyListener(this);
-
- fViewer.removeTextInputListener(this);
-
- try {
- IRegion region= fViewer.getVisibleRegion();
- IDocument document= fViewer.getDocument();
-
- if (((flags & COMMIT) != 0) &&
- ((flags & DOCUMENT_CHANGED) == 0) &&
- ((flags & UPDATE_CARET) != 0))
- {
- Position[] positions= document.getPositions(CARET_POSITION);
-
- if ((positions != null) && (positions.length != 0)) {
- int offset= positions[0].getOffset() - region.getOffset();
- if ((offset >= 0) && (offset <= region.getLength()))
- text.setSelection(offset, offset);
- }
- }
-
- document.removePositionUpdater(fgUpdater);
- document.removePositionCategory(CARET_POSITION);
-
- if (fExitListener != null)
- fExitListener.exit(
- ((flags & COMMIT) != 0) ||
- ((flags & DOCUMENT_CHANGED) != 0));
-
- } catch (BadPositionCategoryException e) {
- CUIPlugin.getDefault().log(e);
- Assert.isTrue(false);
- }
-
- if ((flags & DOCUMENT_CHANGED) == 0)
- text.redraw();
- }
-
- private void next() {
- redrawRegion();
-
- fFramePosition= fManager.getNextPosition(fFramePosition.getOffset());
- if (fFramePosition == null) {
- leave(UNINSTALL | COMMIT | UPDATE_CARET);
- } else {
- selectRegion();
- redrawRegion();
- }
- }
-
- private void previous() {
- redrawRegion();
-
- Position position= fManager.getPreviousPosition(fFramePosition.getOffset());
- if (position == null) {
- fViewer.getTextWidget().getDisplay().beep();
- } else {
- fFramePosition= position;
- selectRegion();
- redrawRegion();
- }
- }
-
- /*
- * @see VerifyKeyListener#verifyKey(VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- if (!event.doit )
- return;
-
- Point selection= fViewer.getSelectedRange();
- int offset= selection.x;
- int length= selection.y;
-
- ExitFlags exitFlags= fExitPolicy == null ? null : fExitPolicy.doExit(fManager, event, offset, length);
- if (exitFlags != null) {
- leave(UNINSTALL | exitFlags.flags);
- event.doit= exitFlags.doit;
- return;
- }
-
- switch (event.character) {
- // [SHIFT-]TAB = hop between edit boxes
- case 0x09:
- {
- selection= fViewer.getTextWidget().getSelection();
- IRegion region= fViewer.getVisibleRegion();
- offset= selection.x + region.getOffset();
- length= selection.y - selection.x;
-
- // if tab was treated as a document change, would it exceed variable range?
- if (!LinkedPositionManager.includes(fFramePosition, offset, length)) {
- leave(UNINSTALL | COMMIT | UPDATE_CARET);
- return;
- }
- }
-
- if (event.stateMask == SWT.SHIFT)
- previous();
- else
- next();
-
- event.doit= false;
- break;
-
- // ENTER
- case 0x0D:
- leave(UNINSTALL | COMMIT | UPDATE_CARET);
- event.doit= false;
- break;
-
- // ESC
- case 0x1B:
- leave(UNINSTALL | COMMIT);
- event.doit= false;
- break;
-
- case ';':
- leave(UNINSTALL | COMMIT);
- event.doit= true;
- break;
-
- }
- }
-
- /*
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- public void verifyText(VerifyEvent event) {
- if (!event.doit)
- return;
-
- IRegion region= fViewer.getVisibleRegion();
-
- int offset= event.start + region.getOffset();
- int length= event.end - event.start;
-
- // allow changes only within linked positions when coming through UI
- if (!fManager.anyPositionIncludes(offset, length))
- leave(UNINSTALL | COMMIT);
- }
-
- /*
- * @see PaintListener#paintControl(PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fFramePosition == null)
- return;
-
- IRegion region= fViewer.getVisibleRegion();
-
- // #6824
- if (!includes(region, fFramePosition)) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
- }
-
- int offset= fFramePosition.getOffset() - region.getOffset();
- int length= fFramePosition.getLength();
-
- StyledText text= fViewer.getTextWidget();
-
- // support for bidi
- Point minLocation= getMinimumLocation(text, offset, length);
- Point maxLocation= getMaximumLocation(text, offset, length);
-
- int x1= minLocation.x;
- int x2= minLocation.x + maxLocation.x - minLocation.x - 1;
- int y= minLocation.y + text.getLineHeight() - 1;
-
- GC gc= event.gc;
- gc.setForeground(fFrameColor);
- gc.drawLine(x1, y, x2, y);
- }
-
- private static Point getMinimumLocation(StyledText text, int offset, int length) {
- Point minLocation= new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
-
- for (int i= 0; i <= length; i++) {
- Point location= text.getLocationAtOffset(offset + i);
-
- if (location.x < minLocation.x)
- minLocation.x= location.x;
- if (location.y < minLocation.y)
- minLocation.y= location.y;
- }
-
- return minLocation;
- }
-
- private static Point getMaximumLocation(StyledText text, int offset, int length) {
- Point maxLocation= new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
-
- for (int i= 0; i <= length; i++) {
- Point location= text.getLocationAtOffset(offset + i);
-
- if (location.x > maxLocation.x)
- maxLocation.x= location.x;
- if (location.y > maxLocation.y)
- maxLocation.y= location.y;
- }
-
- return maxLocation;
- }
-
- private void redrawRegion() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
- }
-
- int offset= fFramePosition.getOffset() - region.getOffset();
- int length= fFramePosition.getLength();
-
- fViewer.getTextWidget().redrawRange(offset, length, true);
- }
-
- private void selectRegion() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
- }
-
- int start= fFramePosition.getOffset() - region.getOffset();
- int end= fFramePosition.getLength() + start;
-
- fViewer.getTextWidget().setSelection(start, end);
- }
-
- private void updateCaret() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
- }
-
- int offset= fFramePosition.getOffset() + fCaretOffset - region.getOffset();
-
- if ((offset >= 0) && (offset <= region.getLength()))
- fViewer.getTextWidget().setCaretOffset(offset);
- }
-
- /*
- * @see ModifyListener#modifyText(ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- // reposition caret after StyledText
- redrawRegion();
- updateCaret();
- }
-
- private static void openErrorDialog(Shell shell, Exception e) {
- MessageDialog.openError(shell, LinkedPositionMessages.getString("LinkedPositionUI.error.title"), e.getMessage()); //$NON-NLS-1$
- }
-
- /*
- * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- // 5326: leave linked mode on document change
- int flags= UNINSTALL | COMMIT | (oldInput.equals(newInput) ? 0 : DOCUMENT_CHANGED);
- leave(flags);
- }
-
- /*
- * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- }
-
- private static boolean includes(IRegion region, Position position) {
- return
- position.getOffset() >= region.getOffset() &&
- position.getOffset() + position.getLength() <= region.getOffset() + region.getLength();
- }
-
-
- public static class ExitFlags {
- public int flags;
- public boolean doit;
- public ExitFlags(int flags, boolean doit) {
- this.flags= flags;
- this.doit= doit;
- }
- }
-
- public interface ExitPolicy {
- ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length);
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateContentProvider.java
deleted file mode 100644
index 0440dce8286..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateContentProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.TemplateSet;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-
-public class TemplateContentProvider implements IStructuredContentProvider {
-
- private TemplateSet fTemplateSet;
-
- /**
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object input) {
- return fTemplateSet.getTemplates();
- }
-
- /**
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fTemplateSet= (TemplateSet) newInput;
- }
-
- /**
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- fTemplateSet= null;
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
deleted file mode 100644
index b447c42929b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.corext.template.Templates;
-import org.eclipse.cdt.internal.corext.template.c.CompilationUnitContext;
-import org.eclipse.cdt.internal.corext.template.c.CompilationUnitContextType;
-import org.eclipse.cdt.internal.corext.template.c.ICompilationUnit;
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionManager;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-
-public class TemplateEngine {
-
- private ContextType fContextType;
- private ITableLabelProvider fLabelProvider= new TemplateLabelProvider();
-
- private ArrayList fProposals= new ArrayList();
-
- /**
- * Creates the template engine for a particular context type.
- * See <code>TemplateContext</code> for supported context types.
- */
- public TemplateEngine(ContextType contextType) {
- Assert.isNotNull(contextType);
- fContextType= contextType;
- }
-
- /**
- * Empties the collector.
- *
- * @param viewer the text viewer
- * @param unit the compilation unit (may be <code>null</code>)
- */
- public void reset() {
- fProposals.clear();
- }
-
- /**
- * Returns the array of matching templates.
- */
- public List getResults() {
- // return (ICCompletionProposal[]) fProposals.toArray(new ICCompletionProposal[fProposals.size()]);
- return fProposals;
- }
-
- /**
- * Inspects the context of the compilation unit around <code>completionPosition</code>
- * and feeds the collector with proposals.
- * @param viewer the text viewer
- * @param completionPosition the context position in the document of the text viewer
- * @param compilationUnit the compilation unit (may be <code>null</code>)
- */
- public void complete(ITextViewer viewer, int completionPosition, ICompilationUnit compilationUnit)
- //throws JavaModelException
- {
- IDocument document= viewer.getDocument();
-
- // prohibit recursion
- if (LinkedPositionManager.hasActiveManager(document))
- return;
-
- if (!(fContextType instanceof CompilationUnitContextType))
- return;
-
- ((CompilationUnitContextType) fContextType).setContextParameters(document.get(), completionPosition, compilationUnit);
- CompilationUnitContext context= (CompilationUnitContext) fContextType.createContext();
- int start= context.getStart();
- int end= context.getEnd();
- IRegion region= new Region(start, end - start);
-
- Template[] templates= Templates.getInstance().getTemplates();
- for (int i= 0; i != templates.length; i++)
- if (context.canEvaluate(templates[i]))
- fProposals.add(new TemplateProposal(templates[i], context, region, viewer, fLabelProvider.getColumnImage(templates[i], 0)));
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateLabelProvider.java
deleted file mode 100644
index a6860e7f59a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateLabelProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-
-
-public class TemplateLabelProvider implements ITableLabelProvider {
-
- /*
- * @see ITableLabelProvider#getColumnImage(Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex != 0)
- return null;
-
- return CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE);
- }
-
- /*
- * @see ITableLabelProvider#getColumnText(Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- Template template = (Template) element;
-
- switch (columnIndex) {
- case 0:
- return template.getName();
- case 1:
- return template.getContextTypeName();
- case 2:
- return template.getDescription();
- default:
- return null;
- }
- }
-
- /*
- * @see IBaseLabelProvider#addListener(ILabelProviderListener)
- */
- public void addListener(ILabelProviderListener listener) {
- }
-
- /*
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IBaseLabelProvider#isLabelProperty(Object, String)
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /*
- * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
- */
- public void removeListener(ILabelProviderListener listener) {
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateProposal.java
deleted file mode 100644
index a1174b132cd..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateProposal.java
+++ /dev/null
@@ -1,225 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.corext.template.Template;
-import org.eclipse.cdt.internal.corext.template.TemplateBuffer;
-import org.eclipse.cdt.internal.corext.template.TemplateContext;
-import org.eclipse.cdt.internal.corext.template.TemplateMessages;
-import org.eclipse.cdt.internal.corext.template.TemplatePosition;
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionManager;
-import org.eclipse.cdt.internal.ui.text.link.LinkedPositionUI;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.ICCompletionProposal;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.util.Assert;
-
-/**
- * A template proposal.
- */
-public class TemplateProposal implements ICCompletionProposal {
-
- private final Template fTemplate;
- private final TemplateContext fContext;
- private final ITextViewer fViewer;
- private final Image fImage;
- private final IRegion fRegion;
-
- private TemplateBuffer fTemplateBuffer;
- private String fOldText;
- private IRegion fSelectedRegion; // initialized by apply()
-
- /**
- * Creates a template proposal with a template and its context.
- * @param template the template
- * @param context the context in which the template was requested.
- * @param image the icon of the proposal.
- */
- public TemplateProposal(Template template, TemplateContext context, IRegion region, ITextViewer viewer, Image image) {
- Assert.isNotNull(template);
- Assert.isNotNull(context);
- Assert.isNotNull(region);
- Assert.isNotNull(viewer);
-
- fTemplate= template;
- fContext= context;
- fViewer= viewer;
- fImage= image;
- fRegion= region;
- }
-
- /**
- * @see ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
- try {
- if (fTemplateBuffer == null)
- fTemplateBuffer= fContext.evaluate(fTemplate);
-
- int start= fRegion.getOffset();
- int end= fRegion.getOffset() + fRegion.getLength();
-
- // insert template string
- String templateString= fTemplateBuffer.getString();
- document.replace(start, end - start, templateString);
-
- // translate positions
- LinkedPositionManager manager= new LinkedPositionManager(document);
- TemplatePosition[] variables= fTemplateBuffer.getVariables();
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- if (variable.isResolved())
- continue;
-
- int[] offsets= variable.getOffsets();
- int length= variable.getLength();
-
- for (int j= 0; j != offsets.length; j++)
- manager.addPosition(offsets[j] + start, length);
- }
-
- LinkedPositionUI editor= new LinkedPositionUI(fViewer, manager);
- editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) + start);
- editor.enter();
-
- fSelectedRegion= editor.getSelectedRegion();
-
- } catch (BadLocationException e) {
- CUIPlugin.getDefault().log(e);
- openErrorDialog(e);
-
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openErrorDialog(e);
- }
- }
-
- private static int getCaretOffset(TemplateBuffer buffer) {
- TemplatePosition[] variables= buffer.getVariables();
- for (int i= 0; i != variables.length; i++) {
- TemplatePosition variable= variables[i];
-
- if (variable.getName().equals("cursor"))
- return variable.getOffsets()[0];
- }
-
- return buffer.getString().length();
- }
-
- /**
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
- }
-
- /**
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- try {
- if (fTemplateBuffer == null)
- fTemplateBuffer= fContext.evaluate(fTemplate);
-
- return textToHTML(fTemplateBuffer.getString());
-
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- openErrorDialog(e);
-
- return null;
- }
- }
-
- /**
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
- }
-
- /**
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /**
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- private static String textToHTML(String string) {
- StringBuffer buffer= new StringBuffer(string.length());
- buffer.append("<pre>"); //$NON-NLS-1$
-
- for (int i= 0; i != string.length(); i++) {
- char ch= string.charAt(i);
-
- switch (ch) {
- case '&':
- buffer.append("&amp;"); //$NON-NLS-1$
- break;
-
- case '<':
- buffer.append("&lt;"); //$NON-NLS-1$
- break;
-
- case '>':
- buffer.append("&gt;"); //$NON-NLS-1$
- break;
-
- case '\t':
- buffer.append(" "); //$NON-NLS-1$
- break;
-
- case '\n':
- buffer.append("<br>"); //$NON-NLS-1$
- break;
-
- default:
- buffer.append(ch);
- break;
- }
- }
-
- buffer.append("</pre>"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- private void openErrorDialog(BadLocationException e) {
- Shell shell= fViewer.getTextWidget().getShell();
- MessageDialog.openError(shell, TemplateMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
- }
-
- private void openErrorDialog(CoreException e) {
- Shell shell= fViewer.getTextWidget().getShell();
- MessageDialog.openError(shell, TemplateMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see IJavaCompletionProposal#getRelevance()
- */
- public int getRelevance() {
- return 9;
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
deleted file mode 100644
index e583dcd8fd8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-
-import org.eclipse.cdt.internal.corext.template.ContextType;
-import org.eclipse.cdt.internal.corext.template.TemplateVariable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-
-public class TemplateVariableProcessor implements IContentAssistProcessor {
-
- private static Comparator fgTemplateVariableProposalComparator= new Comparator() {
- public int compare(Object arg0, Object arg1) {
- TemplateVariableProposal proposal0= (TemplateVariableProposal) arg0;
- TemplateVariableProposal proposal1= (TemplateVariableProposal) arg1;
-
- return proposal0.getDisplayString().compareTo(proposal1.getDisplayString());
- }
-
- public boolean equals(Object arg0) {
- return false;
- }
- };
-
-
- /** the context type */
- private ContextType fContextType;
-
- /**
- * Sets the context type.
- */
- public void setContextType(ContextType contextType) {
- fContextType= contextType;
- }
-
- /*
- * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
-
- if (fContextType == null)
- return null;
-
- List proposals= new ArrayList();
-
- String text= viewer.getDocument().get();
- int start= getStart(text, documentOffset);
- int end= documentOffset;
-
- String string= text.substring(start, end);
- String prefix= (string.length() >= 2)
- ? string.substring(2)
- : null;
-
- int offset= start;
- int length= end - start;
-
- for (Iterator iterator= fContextType.variableIterator(); iterator.hasNext(); ) {
- TemplateVariable variable= (TemplateVariable) iterator.next();
-
- if (prefix == null || variable.getName().startsWith(prefix))
- proposals.add(new TemplateVariableProposal(variable, offset, length, viewer));
- }
-
- Collections.sort(proposals, fgTemplateVariableProposalComparator);
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- /* Guesses the start position of the completion */
- private int getStart(String string, int end) {
- int start= end;
-
- if (start >= 1 && string.charAt(start - 1) == '$')
- return start - 1;
-
- while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
- start--;
-
- if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$')
- return start - 2;
-
- return end;
- }
-
- /*
- * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- return null;
- }
-
- /*
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return new char[] {'$'};
- }
-
- /*
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return null;
- }
-
- /*
- * @see IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
deleted file mode 100644
index 6cde736a8d4..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.template;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.internal.corext.template.TemplateMessages;
-import org.eclipse.cdt.internal.corext.template.TemplateVariable;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-
-
-/**
- * A proposal for insertion of template variables.
- */
-public class TemplateVariableProposal implements ICompletionProposal {
-
- private TemplateVariable fVariable;
- private int fOffset;
- private int fLength;
- private ITextViewer fViewer;
-
- private Point fSelection;
-
- /**
- * Creates a template variable proposal.
- *
- * @param variable the template variable
- * @param offset the offset to replace
- * @param length the length to replace
- * @param viewer the viewer
- */
- public TemplateVariableProposal(TemplateVariable variable, int offset, int length, ITextViewer viewer) {
- fVariable= variable;
- fOffset= offset;
- fLength= length;
- fViewer= viewer;
- }
-
- /*
- * @see ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
-
- try {
- String variable= fVariable.getName().equals("dollar") ? "$$" : "${" + fVariable.getName() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- document.replace(fOffset, fLength, variable);
- fSelection= new Point(fOffset + variable.length(), 0);
-
- } catch (BadLocationException e) {
- CUIPlugin.getDefault().log(e);
-
- Shell shell= fViewer.getTextWidget().getShell();
- MessageDialog.openError(shell, TemplateMessages.getString("TemplateVariableProposal.error.title"), e.getMessage()); //$NON-NLS-1$
- }
- }
-
- /*
- * @see ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return fSelection;
- }
-
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return null;
- }
-
- /*
- * @see ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return fVariable.getName() + " - " + fVariable.getDescription(); //$NON-NLS-1$
- }
-
- /*
- * @see ICompletionProposal#getImage()
- */
- public Image getImage() {
- return null;
- }
-
- /*
- * @see ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
deleted file mode 100644
index eef5f1f03b9..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.internal.ui.text.IColorManager;
-import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Java color manager.
- */
-public class CColorManager implements IColorManager, IColorManagerExtension {
-
- protected Map fKeyTable= new HashMap(10);
- protected Map fDisplayTable= new HashMap(2);
-
-
- public CColorManager() {
- }
-
- protected void dispose(Display display) {
- Map colorTable= (Map) fDisplayTable.get(display);
- if (colorTable != null) {
- Iterator e= colorTable.values().iterator();
- while (e.hasNext())
- ((Color) e.next()).dispose();
- }
- }
-
- /*
- * @see IColorManager#getColor(RGB)
- */
- public Color getColor(RGB rgb) {
-
- if (rgb == null)
- return null;
-
- final Display display= Display.getCurrent();
- Map colorTable= (Map) fDisplayTable.get(display);
- if (colorTable == null) {
- colorTable= new HashMap(10);
- fDisplayTable.put(display, colorTable);
- display.disposeExec(new Runnable() {
- public void run() {
- dispose(display);
- }
- });
- }
-
- Color color= (Color) colorTable.get(rgb);
- if (color == null) {
- color= new Color(Display.getCurrent(), rgb);
- colorTable.put(rgb, color);
- }
-
- return color;
- }
-
- /*
- * @see IColorManager#dispose
- */
- public void dispose() {
- // nothing to dispose
- }
-
- /*
- * @see IColorManager#getColor(String)
- */
- public Color getColor(String key) {
-
- if (key == null)
- return null;
-
- RGB rgb= (RGB) fKeyTable.get(key);
- return getColor(rgb);
- }
-
- /*
- * @see IColorManagerExtension#bindColor(String, RGB)
- */
- public void bindColor(String key, RGB rgb) {
- Object value= fKeyTable.get(key);
- if (value != null)
- throw new UnsupportedOperationException();
-
- fKeyTable.put(key, rgb);
- }
-
- /*
- * @see IColorManagerExtension#unbindColor(String)
- */
- public void unbindColor(String key) {
- fKeyTable.remove(key);
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java
deleted file mode 100644
index 99aff354b02..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.rules.IWhitespaceDetector;
-
-
-/**
- * A C aware white space detector.
- */
-public class CWhitespaceDetector implements IWhitespaceDetector {
-
- /**
- * @see IWhitespaceDetector#isWhitespace
- */
- public boolean isWhitespace(char c) {
- return Character.isWhitespace(c);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java
deleted file mode 100644
index ee79266e6ea..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.text.rules.IWordDetector;
-
-
-/**
- * A C aware word detector.
- */
-public class CWordDetector implements IWordDetector {
-
- /**
- * @see IWordDetector#isWordIdentifierStart
- */
- public boolean isWordStart(char c) {
- return Character.isJavaIdentifierStart(c);
- }
-
- /**
- * @see IWordDetector#isWordIdentifierPart
- */
- public boolean isWordPart(char c) {
- return Character.isJavaIdentifierPart(c);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
deleted file mode 100644
index 558e5c3a2ba..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionDelegate;
-
-import org.eclipse.cdt.core.model.ICModelMarker;
-
-public class DeleteTaskAction extends ActionDelegate implements IObjectActionDelegate
-{
- private IStructuredSelection selection;
-
- /**
- * @see ActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- // Add your code here to perform the action
- if (selection != null) {
- if (selection.isEmpty()) {
- return;
- }
- try {
- List list = ((IStructuredSelection) selection).toList();
- List listMarkers = new ArrayList();
- Iterator iterator = list.iterator();
- while (iterator.hasNext()) {
- IMarker marker = (IMarker)iterator.next();
- if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
- || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
- listMarkers.add(marker);
- }
- }
- // Bail out early
- if (listMarkers.isEmpty()) {
- return;
- }
- IMarker[] markers = new IMarker[listMarkers.size()];
- listMarkers.toArray(markers);
- // be sure to only invoke one workspace operation
- ResourcesPlugin.getWorkspace().deleteMarkers(markers);
- selection = null;
- } catch (CoreException e) {
- }
- }
- }
-
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- boolean enable = false;
- if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection) selection).getFirstElement();
- if (object instanceof IMarker) {
- try {
- IMarker marker = (IMarker) object;
- if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
- || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
- enable = true;
- }
- this.selection = (IStructuredSelection)selection;
- action.setEnabled(enable);
- } catch (CoreException e) {
- }
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
deleted file mode 100644
index 7110fb5ffa3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
+++ /dev/null
@@ -1,330 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.spawner.ProcessFactory;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class EditorUtility {
-
- private EditorUtility () {
- }
-
- /**
- * Tests if a cu is currently shown in an editor
- * @return the IEditorPart if shown, null if element is not open in an editor
- */
- public static IEditorPart isOpenInEditor(Object inputElement) {
- IEditorInput input = null;
-
- try {
- input = getEditorInput(inputElement);
- } catch (CModelException x) {
- //CUIPlugin.log(x.getStatus());
- }
-
- if (input != null) {
- IWorkbenchPage p= CUIPlugin.getActivePage();
- if (p != null) {
- return p.findEditor(input);
- }
- }
-
- return null;
- }
-
-
- /**
- * Opens a Java editor for an element such as <code>IJavaElement</code>, <code>IFile</code>, or <code>IStorage</code>.
- * The editor is activated by default.
- * @return the IEditorPart or null if wrong element type or opening failed
- */
- public static IEditorPart openInEditor(Object inputElement) throws CModelException, PartInitException {
- return openInEditor(inputElement, true);
- }
-
- /**
- * Opens a Java editor for an element (IJavaElement, IFile, IStorage...)
- * @return the IEditorPart or null if wrong element type or opening failed
- */
- public static IEditorPart openInEditor(Object inputElement, boolean activate) throws CModelException, PartInitException {
-
- if (inputElement instanceof IFile) {
- return openInEditor((IFile) inputElement, activate);
- }
-
- IEditorInput input = getEditorInput(inputElement);
- if (input instanceof IFileEditorInput) {
- IFileEditorInput fileInput= (IFileEditorInput) input;
- return openInEditor(fileInput.getFile(), activate);
- }
-
- if (input != null) {
- return openInEditor(input, getEditorID(input, inputElement), activate);
- }
-
- return null;
- }
-
- /**
- * Selects a C Element in an editor
- */
- public static void revealInEditor(IEditorPart part, ICElement element) {
- if (element != null && part instanceof CEditor) {
- ((CEditor) part).setSelection(element);
- }
- }
-
- private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
- if (file != null) {
- IWorkbenchPage p= CUIPlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart = IDE.openEditor(p, file, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
- }
- return null;
- }
-
- private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
- if (input != null) {
- IWorkbenchPage p= CUIPlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart= p.openEditor(input, editorID, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
- }
- return null;
- }
-
- private static void initializeHighlightRange(IEditorPart editorPart) {
- if (editorPart instanceof ITextEditor) {
- //TogglePresentationAction toggleAction= new TogglePresentationAction();
- // Initialize editor
- //toggleAction.setEditor((ITextEditor)editorPart);
- // Reset action
- //toggleAction.setEditor(null);
- }
- }
-
- private static IEditorInput getEditorInput(ICElement element) throws CModelException {
- while (element != null) {
- if (element instanceof IWorkingCopy && ((IWorkingCopy) element).isWorkingCopy())
- element= ((IWorkingCopy) element).getOriginalElement();
-
- if (element instanceof ISourceReference) {
- ITranslationUnit tu = ((ISourceReference)element).getTranslationUnit();
- if (tu != null) {
- element = tu;
- }
- }
-
- if (element instanceof ITranslationUnit) {
- ITranslationUnit unit= (ITranslationUnit) element;
- IResource resource= unit.getResource();
- if (resource instanceof IFile)
- return new FileEditorInput((IFile) resource);
- }
-
- if (element instanceof IBinary) {
- //return new InternalClassFileEditorInput((IBinary) element);
- return new ExternalEditorInput(getStorage((IBinary)element));
- }
-
- element= element.getParent();
- }
-
- return null;
- }
-
- public static IEditorInput getEditorInput(Object input) throws CModelException {
- if (input instanceof ICElement) {
- return getEditorInput((ICElement) input);
- }
-
- if (input instanceof IFile) {
- return new FileEditorInput((IFile) input);
- }
-
- if (input instanceof IStorage) {
- //return new JarEntryEditorInput((IStorage)input);
- return new ExternalEditorInput((IStorage)input);
- }
- return null;
- }
-
-
- /**
- * If the current active editor edits a c element return it, else
- * return null
- */
- public static ICElement getActiveEditorCInput() {
- IWorkbenchPage page= CUIPlugin.getActivePage();
- if (page != null) {
- IEditorPart part= page.getActiveEditor();
- if (part != null) {
- IEditorInput editorInput= part.getEditorInput();
- if (editorInput != null) {
- return (ICElement)editorInput.getAdapter(ICElement.class);
- }
- }
- }
- return null;
- }
-
- /**
- * Gets the working copy of an compilation unit opened in an editor
- * @param part the editor part
- * @param cu the original compilation unit (or another working copy)
- * @return the working copy of the compilation unit, or null if not found
- */
-// public static ITranslationUnit getWorkingCopy(ITranslationUnit cu) {
-// if (cu == null)
-// return null;
-// if (cu.isWorkingCopy())
-// return cu;
-//
-// return (ITranslationUnit)cu.findSharedWorkingCopy(CUIPlugin.getBufferFactory());
-// }
-
-
- /**
- * Returns the translation unit for the given c element.
- * @param element the c element whose compilation unit is searched for
- * @return the compilation unit of the given java element
- */
- private static ITranslationUnit getTranslationUnit(ICElement element) {
-
- if (element == null)
- return null;
-
- int type= element.getElementType();
- if (ICElement.C_UNIT == type) {
- return (ITranslationUnit) element;
- }
- if (ICElement.C_BINARY == type) {
- return null;
- }
- if (element instanceof ISourceReference) {
- return ((ISourceReference) element).getTranslationUnit();
- }
- return getTranslationUnit(element.getParent());
- }
-
-
-// public static IEditorPart openInEditor (IFile file) throws PartInitException {
-// IWorkbenchWindow window= CUIPlugin.getDefault().getActiveWorkbenchWindow();
-// if (window != null) {
-// IWorkbenchPage p= window.getActivePage();
-// if (p != null) {
-// return p.openEditor(file);
-// }
-// }
-// return null;
-// }
-//
-//
-// public static IEditorPart openInEditor (IPath path) throws PartInitException {
-// IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
-// if (f == null) {
-// IStorage s = new FileStorage(path);
-// return openInEditor(s, path.lastSegment());
-// }
-// return openInEditor(f);
-// }
-//
-// public static IEditorPart openInEditor (IStorage store, String name) throws PartInitException {
-// IEditorInput ei = new ExternalEditorInput(store);
-// IWorkbenchWindow window= CUIPlugin.getDefault().getActiveWorkbenchWindow();
-// if (window != null) {
-// IWorkbenchPage p = window.getActivePage();
-// if (p != null) {
-// return p.openEditor(ei, getEditorID(name));
-// }
-// }
-// return null;
-// }
-//
-
- public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
- if (descriptor != null) {
- return descriptor.getId();
- } else {
- return registry.getDefaultEditor().getId();
- }
- }
- return null;
- }
-
- public static String getEditorID(IEditorInput input, Object inputObject) {
- return getEditorID(input.getName());
- }
-
- public static IStorage getStorage(IBinary bin) {
- IStorage store = null;
- Process objdump = null;
- IPath path;
- IResource file = null;
- file = bin.getResource();
- if (file == null)
- return store;
- path = file.getLocation();
- try {
- String[] args = new String[] {"objdump", "-CxS", path.toOSString()};
- objdump = ProcessFactory.getFactory().exec(args);
- StringBuffer buffer = new StringBuffer();
- BufferedReader stdout =
- new BufferedReader(new InputStreamReader(objdump.getInputStream()));
- char[] buf = new char[128];
- while (stdout.read(buf, 0, buf.length) != -1) {
- buffer.append(buf);
- }
- store = new FileStorage(new ByteArrayInputStream(buffer.toString().getBytes()), path);
- } catch (SecurityException e) {
- } catch (IndexOutOfBoundsException e) {
- } catch (NullPointerException e) {
- } catch (IOException e) {
- } finally {
- if (objdump != null) {
- objdump.destroy();
- }
- }
- return store;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
deleted file mode 100644
index 11dfbd084e4..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.util;
-
-
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.CStatusConstants;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-/**
- * The default exception handler shows an error dialog when one of its handle methods
- * is called. If the passed exception is a <code>CoreException</code> an error dialog
- * pops up showing the exception's status information. For a <code>InvocationTargetException</code>
- * a normal message dialog pops up showing the exception's message. Additionally the exception
- * is written to the platform log.
- */
-public class ExceptionHandler {
-
- private static ExceptionHandler fgInstance= new ExceptionHandler();
-
- /**
- * Logs the given exception using the platform's logging mechanism. The exception is
- * logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>.
- */
- public static void log(Throwable t, String message) {
- CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- CStatusConstants.INTERNAL_ERROR, message, t));
- }
-
- /**
- * Handles the given <code>CoreException</code>. The workbench shell is used as a parent
- * for the dialog window.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, String title, String message) {
- handle(e, CUIPlugin.getDefault().getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>CoreException</code>.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>. The workbench shell is used
- * as a parent for the dialog window.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, String title, String message) {
- handle(e, CUIPlugin.getDefault().getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- //---- Hooks for subclasses to control exception handling ------------------------------------
-
- protected void perform(CoreException e, Shell shell, String title, String message) {
- CUIPlugin.getDefault().log(e);
- IStatus status= e.getStatus();
- if (status != null) {
- ErrorDialog.openError(shell, title, message, status);
- } else {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- }
- }
-
- protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
- Throwable target= e.getTargetException();
- if (target instanceof CoreException) {
- perform((CoreException)target, shell, title, message);
- } else {
- CUIPlugin.getDefault().log(e);
- if (e.getMessage() != null && e.getMessage().length() > 0) {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- } else {
- displayMessageDialog(e, target.getMessage(), shell, title, message);
- }
- }
- }
-
- //---- Helper methods -----------------------------------------------------------------------
-
- private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
- StringWriter msg= new StringWriter();
- if (message != null) {
- msg.write(message);
- msg.write("\n\n"); //$NON-NLS-1$
- }
- if (exceptionMessage == null || exceptionMessage.length() == 0)
- msg.write(CUIMessages.getString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$
- else
- msg.write(exceptionMessage);
- MessageDialog.openError(shell, title, msg.toString());
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
deleted file mode 100644
index 34ba1e29312..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.core.resources.IStorage;
-
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * An EditorInput for a JarEntryFile.
- */
-public class ExternalEditorInput implements IStorageEditorInput {
-
- IStorage externalFile;
-
- /*
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof ExternalEditorInput))
- return false;
- ExternalEditorInput other = (ExternalEditorInput)obj;
- return externalFile.equals(other.externalFile);
- }
-
- /*
- * @see IEditorInput#exists()
- */
- public boolean exists() {
- // External file ca not be deleted
- return true;
- }
-
- /*
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- /*
- * @see IEditorInput#getContentType()
- */
- public String getContentType() {
- return externalFile.getFullPath().getFileExtension();
- }
-
- /*
- * @see IEditorInput#getFullPath()
- */
- public String getFullPath() {
- return externalFile.getFullPath().toString();
- }
-
- /*
- * @see IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
- return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension());
- }
-
- /*
- * @see IEditorInput#getName()
- */
- public String getName() {
- return externalFile.getName();
- }
-
- /*
- * @see IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /*
- * see IStorageEditorInput#getStorage()
- */
- public IStorage getStorage() {
- return externalFile;
- }
-
- /*
- * @see IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return externalFile.getFullPath().toString();
- }
-
- public ExternalEditorInput(IStorage exFile) {
- externalFile = exFile;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
deleted file mode 100644
index 354e19e9c19..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Set;
-
-/**
- * Can be added to a ProblemMarkerManager to get notified about error
- * marker changes. Used to update error ticks.
- */
-public interface IProblemChangedListener {
-
- /**
- * @param changedElements A set of type <code>IPath</code> that
- * describe the resources that had an error marker change.
- */
- void problemsChanged(Set changedElements);
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
deleted file mode 100644
index 5d65893821d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-
-/**
- * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>.
- */
-public class ImageDescriptorRegistry {
-
- private HashMap fRegistry= new HashMap(10);
- private Display fDisplay;
-
- /**
- * Creates a new image descriptor registry for the current or default display,
- * respectively.
- */
- public ImageDescriptorRegistry() {
- this(SWTUtil.getStandardDisplay());
- }
-
- /**
- * Creates a new image descriptor registry for the given display. All images
- * managed by this registry will be disposed when the display gets disposed.
- *
- * @param diaplay the display the images managed by this registry are allocated for
- */
- public ImageDescriptorRegistry(Display display) {
- fDisplay= display;
- Assert.isNotNull(fDisplay);
- hookDisplay();
- }
-
- /**
- * Returns the image assiciated with the given image descriptor.
- *
- * @param descriptor the image descriptor for which the registry manages an image
- * @return the image associated with the image descriptor or <code>null</code>
- * if the image descriptor can't create the requested image.
- */
- public Image get(ImageDescriptor descriptor) {
- if (descriptor == null)
- descriptor= ImageDescriptor.getMissingImageDescriptor();
-
- Image result= (Image)fRegistry.get(descriptor);
- if (result != null)
- return result;
-
- Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$
- result= descriptor.createImage();
- if (result != null)
- fRegistry.put(descriptor, result);
- return result;
- }
-
- /**
- * Disposes all images managed by this registry.
- */
- public void dispose() {
- for (Iterator iter= fRegistry.values().iterator(); iter.hasNext(); ) {
- Image image= (Image)iter.next();
- image.dispose();
- }
- fRegistry.clear();
- }
-
- private void hookDisplay() {
- fDisplay.disposeExec(new Runnable() {
- public void run() {
- dispose();
- }
- });
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java
deleted file mode 100644
index 194ea8ff918..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.util;
-
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.Dialog;
-
-public class PixelConverter {
-
- private FontMetrics fFontMetrics;
-
- public PixelConverter(Control control) {
- GC gc = new GC(control);
- gc.setFont(control.getFont());
- fFontMetrics= gc.getFontMetrics();
- gc.dispose();
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
- */
- public int convertHeightInCharsToPixels(int chars) {
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
- */
- public int convertHorizontalDLUsToPixels(int dlus) {
- return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
- */
- public int convertVerticalDLUsToPixels(int dlus) {
- return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
- */
- public int convertWidthInCharsToPixels(int chars) {
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemItemMapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemItemMapper.java
deleted file mode 100644
index 94e70d7c92f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemItemMapper.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.ICElement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Item;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-
-
-/**
- * Helper class for updating error markers.
- * Items are mapped to paths of their underlying resources.
- * Method <code>problemsChanged</code> updates all items that are affected from the changed
- * elements.
- */
-public class ProblemItemMapper {
-
- private static final int NUMBER_LIST_REUSE= 10;
-
- // map from path to item
- private HashMap fPathToItem;
- private Stack fReuseLists;
-
- public ProblemItemMapper() {
- fPathToItem= new HashMap();
- fReuseLists= new Stack();
- }
-
- /**
- * Updates the icons of all mapped elements containing to the changed elements.
- * Must be called from the UI thread.
- */
- public void problemsChanged(Collection changedPaths, ILabelProvider lprovider) {
- // iterate over the smaller set/map
- if (changedPaths.size() <= fPathToItem.size()) {
- iterateChanges(changedPaths, lprovider);
- } else {
- iterateItems(changedPaths, lprovider);
- }
- }
-
- private void iterateChanges(Collection changedPaths, ILabelProvider lprovider) {
- Iterator elements= changedPaths.iterator();
- while (elements.hasNext()) {
- IPath curr= (IPath) elements.next();
- Object obj= fPathToItem.get(curr);
- if (obj == null) {
- // not mapped
- } else if (obj instanceof Item) {
- refreshIcon(lprovider, (Item)obj);
- } else { // List of Items
- List list= (List) obj;
- for (int i= 0; i < list.size(); i++) {
- refreshIcon(lprovider, (Item) list.get(i));
- }
- }
- }
- }
-
- private void iterateItems(Collection changedPaths, ILabelProvider lprovider) {
- Iterator keys= fPathToItem.keySet().iterator();
- while (keys.hasNext()) {
- IPath curr= (IPath) keys.next();
- if (changedPaths.contains(curr)) {
- Object obj= fPathToItem.get(curr);
- if (obj instanceof Item) {
- refreshIcon(lprovider, (Item)obj);
- } else { // List of Items
- List list= (List) obj;
- for (int i= 0; i < list.size(); i++) {
- refreshIcon(lprovider, (Item) list.get(i));
- }
- }
- }
- }
- }
-
- private void refreshIcon(ILabelProvider lprovider, Item item) {
- if (!item.isDisposed()) { // defensive code
- Object data= item.getData();
- if (data instanceof ICElement && !((ICElement)data).exists()) {
- // @@@ not yet return;
- }
- Image old= item.getImage();
- Image image= lprovider.getImage(data);
- if (image != null && image != old) {
- item.setImage(image);
- }
- }
- }
-
- /**
- * Adds a new item to the map.
- * @param element Element to map
- * @param item The item used for the element
- */
- public void addToMap(Object element, Item item) {
- IPath path= getCorrespondingPath(element);
- if (path != null) {
- Object existingMapping= fPathToItem.get(path);
- if (existingMapping == null) {
- fPathToItem.put(path, item);
- } else if (existingMapping instanceof Item) {
- if (existingMapping != item) {
- List list= newList();
- list.add(existingMapping);
- list.add(item);
- fPathToItem.put(path, list);
- }
- } else { // List
- List list= (List)existingMapping;
- if (!list.contains(item)) {
- list.add(item);
- }
- }
- }
- }
-
- /**
- * Removes an element from the map.
- */
- public void removeFromMap(Object element, Item item) {
- IPath path= getCorrespondingPath(element);
- if (path != null) {
- Object existingMapping= fPathToItem.get(path);
- if (existingMapping == null) {
- return;
- } else if (existingMapping instanceof Item) {
- fPathToItem.remove(path);
- } else { // List
- List list= (List) existingMapping;
- list.remove(item);
- if (list.isEmpty()) {
- fPathToItem.remove(list);
- releaseList(list);
- }
- }
- }
- }
-
- private List newList() {
- if (!fReuseLists.isEmpty()) {
- return (List) fReuseLists.pop();
- }
- return new ArrayList(2);
- }
-
- private void releaseList(List list) {
- if (fReuseLists.size() < NUMBER_LIST_REUSE) {
- fReuseLists.push(list);
- }
- }
-
- /**
- * Clears the map.
- */
- public void clearMap() {
- fPathToItem.clear();
- }
-
- /**
- * Method that decides which elements can have error markers
- * Returns null if an element can not have error markers.
- */
- private static IPath getCorrespondingPath(Object element) {
- if (element instanceof ICElement) {
- ICElement elem= (ICElement) element;
- //if (!elem.isReadOnly()) { // only modifieable elements can get error ticks
- return elem.getPath();
- //}
- //return null;
- } else if (element instanceof IResource) {
- return ((IResource)element).getFullPath();
- }
- return null;
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
deleted file mode 100644
index 2f94b8a662c..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.util.ListenerList;
-
-
-/**
- * Listens to resource deltas and filters for marker changes of type IMarker.PROBLEM
- * Viewers showing error ticks should register as listener to
- * this type.
- */
-public class ProblemMarkerManager implements IResourceChangeListener {
-
- /**
- * Visitors used to filter the element delta changes
- */
- private static class ProjectErrorVisitor implements IResourceDeltaVisitor {
-
- private HashSet fChangedElements;
-
- public ProjectErrorVisitor(HashSet changedElements) {
- fChangedElements= changedElements;
- }
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource res= delta.getResource();
- if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
- try {
- IProject project= (IProject) res;
- if (!project.isAccessible() || !project.hasNature(CProjectNature.C_NATURE_ID)) {
- // only track open C projects
- return false;
- }
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- return false;
- }
- }
- checkInvalidate(delta, res.getFullPath());
- return true;
- }
-
- private void checkInvalidate(IResourceDelta delta, IPath path) {
- int kind= delta.getKind();
- if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) {
- // invalidate the path and all parent paths
- while (!path.isEmpty() && !path.isRoot() && !fChangedElements.contains(path)) {
- fChangedElements.add(path);
- path= path.removeLastSegments(1);
- }
- }
- }
-
- private boolean isErrorDelta(IResourceDelta delta) {
- if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) {
- IMarkerDelta[] markerDeltas= delta.getMarkerDeltas();
- for (int i= 0; i < markerDeltas.length; i++) {
- if (markerDeltas[i].isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
- int kind= markerDeltas[i].getKind();
- if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED)
- return true;
- int severity= markerDeltas[i].getAttribute(IMarker.SEVERITY, -1);
- int newSeverity= markerDeltas[i].getMarker().getAttribute(IMarker.SEVERITY, -1);
- if (newSeverity != severity)
- return true;
- }
- }
- }
- return false;
- }
- }
-
- private ListenerList fListeners;
-
-
- public ProblemMarkerManager() {
- fListeners= new ListenerList(5);
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged
- */
- public void resourceChanged(IResourceChangeEvent event) {
- HashSet changedElements= new HashSet();
-
- try {
- IResourceDelta delta= event.getDelta();
- if (delta != null)
- delta.accept(new ProjectErrorVisitor(changedElements));
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- }
-
- if (changedElements.size() > 0) {
- fireChanges(changedElements);
- }
- }
-
- /**
- * Adds a listener for problem marker changes.
- */
- public void addListener(IProblemChangedListener listener) {
- if (fListeners.isEmpty()) {
- CUIPlugin.getWorkspace().addResourceChangeListener(this);
- }
- fListeners.add(listener);
- }
-
- /**
- * Removes a <code>IProblemChangedListener</code>.
- */
- public void removeListener(IProblemChangedListener listener) {
- fListeners.remove(listener);
- if (fListeners.isEmpty()) {
- CUIPlugin.getWorkspace().removeResourceChangeListener(this);
- }
- }
-
- private void fireChanges(Set changes) {
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- IProblemChangedListener curr= (IProblemChangedListener) listeners[i];
- curr.problemsChanged(changes);
- }
- }
- }
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
deleted file mode 100644
index 6dec74276b1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.Set;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-
-
-/**
- * Extends a TreeViewer to allow more performance when showing error ticks.
- * A <code>ProblemItemMapper</code> is contained that maps all items in
- * the tree to underlying resource
- */
-public class ProblemTreeViewer extends TreeViewer implements IProblemChangedListener {
-
- protected ProblemItemMapper fProblemItemMapper;
-
- /*
- * @see TreeViewer#TreeViewer(Composite)
- */
- public ProblemTreeViewer(Composite parent) {
- super(parent);
- initMapper();
- }
-
- /*
- * @see TreeViewer#TreeViewer(Composite, int)
- */
- public ProblemTreeViewer(Composite parent, int style) {
- super(parent, style);
- initMapper();
- }
-
- /*
- * @see TreeViewer#TreeViewer(Tree)
- */
- public ProblemTreeViewer(Tree tree) {
- super(tree);
- initMapper();
- }
-
- private void initMapper() {
- fProblemItemMapper= new ProblemItemMapper();
- }
-
-
- /*
- * @see IProblemChangedListener#problemsChanged
- */
- public void problemsChanged(final Set changed) {
- Control control= getControl();
- if (control != null && !control.isDisposed()) {
- control.getDisplay().asyncExec(new Runnable() {
- public void run() {
- fProblemItemMapper.problemsChanged(changed, (ILabelProvider)getLabelProvider());
- }
- });
- }
- }
-
- /*
- * @see StructuredViewer#mapElement(Object, Widget)
- */
- protected void mapElement(Object element, Widget item) {
- super.mapElement(element, item);
- if (item instanceof Item) {
- fProblemItemMapper.addToMap(element, (Item) item);
- }
- }
-
- /*
- * @see StructuredViewer#unmapElement(Object, Widget)
- */
- protected void unmapElement(Object element, Widget item) {
- if (item instanceof Item) {
- fProblemItemMapper.removeFromMap(element, (Item) item);
- }
- super.unmapElement(element);
- }
-
- /*
- * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
- */
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object source= event.getElement();
- if (source == null) {
- super.handleLabelProviderChanged(event);
- return;
- }
-
- /*
- // map the event to the Java elements if possible
- // this does not handle the ambiguity of default packages
- Object[] mapped= new Object[source.length];
- for (int i= 0; i < source.length; i++) {
- Object o= source[i];
- // needs to handle the case of:
- // default package
- // package fragment root on project
- if (o instanceof IResource) {
- IResource r= (IResource)o;
- IJavaElement element= JavaCore.create(r);
- if (element != null)
- mapped[i]= element;
- else
- mapped[i]= o;
- } else {
- mapped[i]= o;
- }
- }
- super.handleLabelProviderChanged(new LabelProviderChangedEvent((IBaseLabelProvider)event.getSource(), mapped)); */
- super.handleLabelProviderChanged(event);
- return;
- }
-
- /**
- * @see StructuredViewer#handleInvalidSelection(ISelection, ISelection)
- */
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- super.handleInvalidSelection(invalidSelection, newSelection);
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
deleted file mode 100644
index 7de94146a04..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.util;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Caret;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.Assert;
-
-/**
- * Utility class to simplify access to some SWT resources.
- */
-public class SWTUtil {
-
- /**
- * Returns the standard display to be used. The method first checks, if
- * the thread calling this method has an associated disaply. If so, this
- * display is returned. Otherwise the method returns the default display.
- */
- public static Display getStandardDisplay() {
- Display display;
- display= Display.getCurrent();
- if (display == null)
- display= Display.getDefault();
- return display;
- }
-
- /**
- * Returns the shell for the given widget. If the widget doesn't represent
- * a SWT object that manage a shell, <code>null</code> is returned.
- *
- * @return the shell for the given widget
- */
- public static Shell getShell(Widget widget) {
- if (widget instanceof Control)
- return ((Control)widget).getShell();
- if (widget instanceof Caret)
- return ((Caret)widget).getParent().getShell();
- if (widget instanceof DragSource)
- return ((DragSource)widget).getControl().getShell();
- if (widget instanceof DropTarget)
- return ((DropTarget)widget).getControl().getShell();
- if (widget instanceof Menu)
- return ((Menu)widget).getParent().getShell();
- if (widget instanceof ScrollBar)
- return ((ScrollBar)widget).getParent().getShell();
-
- return null;
- }
-
-
- /**
- * Returns a width hint for a button control.
- */
- public static int getButtonWidthHint(Button button) {
- if (button.getFont().equals(JFaceResources.getDefaultFont()))
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- }
-
- /**
- * Returns a height hint for a button control.
- */
- public static int getButtonHeigthHint(Button button) {
- if (button.getFont().equals(JFaceResources.getDefaultFont()))
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- }
-
-
- /**
- * Sets width and height hint for the button control.
- * <b>Note:</b> This is a NOP if the button's layout data is not
- * an instance of <code>GridData</code>.
- *
- * @param the button for which to set the dimension hint
- */
- public static void setButtonDimensionHint(Button button) {
- Assert.isNotNull(button);
- Object gd= button.getLayoutData();
- if (gd instanceof GridData) {
- ((GridData)gd).heightHint= getButtonHeigthHint(button);
- ((GridData)gd).widthHint= getButtonWidthHint(button);
- }
- }
-
- public static int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
- table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows + table.getHeaderHeight();
- if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
- return result;
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
deleted file mode 100644
index e788f300278..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-/**
- * Provides utilities for checking the validity of selections.
- * <p>
- * This class provides static methods only; it is not intended to be instantiated
- * or subclassed.
- * </p>
- */
-
-public class SelectionUtil {
-
- /**
- * Returns the first element of the given selection.
- * Returns null if the selection is empty or if
- * the given selection is not of type <code>IStructuredSelection</code>.
- *
- * @param selection the selection
- * @return the selected elements
- *
- */
- public static Object getFirstElement (ISelection selection) {
- if (!(selection instanceof IStructuredSelection)) {
- return null;
- }
- return ((IStructuredSelection)selection).getFirstElement ();
- }
-
- public static Object getSingleElement (ISelection s) {
- if (!(s instanceof IStructuredSelection))
- return null;
- IStructuredSelection selection= (IStructuredSelection)s;
- if (selection.size () != 1)
- return null;
- return selection.getFirstElement ();
- }
-
- /**
- * Returns the elements of the given selection.
- * Returns an empty array if the selection is empty or if
- * the given selection is not of type <code>IStructuredSelection</code>.
- *
- * @param selection the selection
- * @return the selected elements
- *
- */
-
- public static Object[] toArray(ISelection selection) {
- if (!(selection instanceof IStructuredSelection)) {
- return new Object[0];
- }
- return ((IStructuredSelection)selection).toArray();
- }
-
- public static List toList(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- return ((IStructuredSelection)selection).toList();
- }
- return null;
- }
-
- /**
- * Returns whether the types of the resources in the given selection are among
- * the specified resource types.
- *
- * @param selection the selection
- * @param resourceMask resource mask formed by bitwise OR of resource type
- * constants (defined on <code>IResource</code>)
- * @return <code>true</code> if all selected elements are resources of the right
- * type, and <code>false</code> if at least one element is either a resource
- * of some other type or a non-resource
- * @see IResource#getType
- */
- public static boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) {
- Iterator resources = selection.iterator();
- while (resources.hasNext()) {
- Object next = resources.next();
- if (!(next instanceof IResource))
- return false;
- if (!resourceIsType((IResource)next, resourceMask))
- return false;
- }
- return true;
- }
-
- /**
- * Returns whether the type of the given resource is among the specified
- * resource types.
- *
- * @param resource the resource
- * @param resourceMask resource mask formed by bitwise OR of resource type
- * constants (defined on <code>IResource</code>)
- * @return <code>true</code> if the resources has a matching type, and
- * <code>false</code> otherwise
- * @see IResource#getType
- */
- public static boolean resourceIsType(IResource resource, int resourceMask) {
- return ((resource != null) && ((resource.getType() & resourceMask) != 0));
- }
-
- /* (non-Javadoc)
- * Private constructor to block instantiation.
- */
- private SelectionUtil(){
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
deleted file mode 100644
index 6dfa5c748e8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
+++ /dev/null
@@ -1,390 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Vector;
-
-public class StringMatcher {
- protected String fPattern;
- protected int fLength; // pattern length
- protected boolean fIgnoreWildCards;
- protected boolean fIgnoreCase;
- protected boolean fHasLeadingStar;
- protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound= 0;
-
- protected static final char fSingleWildCard= '\u0000';
-
- public static class Position {
- int start; //inclusive
- int end; //exclusive
- public Position(int start, int end) {
- this.start= start;
- this.end= end;
- }
- public int getStart() {
- return start;
- }
- public int getEnd() {
- return end;
- }
- }
-
- /**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param <code>text</code>, the String object to search in
- * @param <code>start</code>, the starting index of the search range, inclusive
- * @param <code>end</code>, the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
-
- public StringMatcher.Position find(String text, int start, int end) {
- if (fPattern == null || text == null)
- throw new IllegalArgumentException();
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
- if (end < 0 || start >= end)
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x= posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x + fLength);
- }
-
- int segCount= fSegments.length;
- if (segCount == 0) //pattern contains only '*'(s)
- return new Position(start, end);
-
- int curPos= start;
- int matchStart= -1;
- for (int i= 0; i < segCount && curPos < end; ++i) {
- String current= fSegments[i];
- int nextMatch= regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0)
- return null;
- if (i == 0)
- matchStart= nextMatch;
- curPos= nextMatch + current.length();
- }
- return new Position(matchStart, curPos);
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain *  for 0 and many characters and
- * ?  for exactly one character. Also takes as parameter a boolean object
- * specifying if case should be ignored
- * @deprecated Use StringMatcher(pattern, ignoreCase, ignoreWildCards).
- */
- public StringMatcher(String aPattern, boolean ignoreCase) {
- this(aPattern, ignoreCase, false);
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain *  for 0 and many characters and
- * ?  for exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param aPattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
- fIgnoreCase= ignoreCase;
- fIgnoreWildCards= ignoreWildCards;
- fLength= aPattern.length();
-
- /* convert case */
- if (fIgnoreCase) {
- fPattern= aPattern.toUpperCase();
- } else {
- fPattern= aPattern;
- }
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
- /**
- * Given the starting (inclusive) and the ending (exclusive) poisitions in the
- * <code>text</code>, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param String <code>text</code>, a String object that contains the substring to match
- * @param int <code>start<code> marks the starting position (inclusive) of the substring
- * @param int <code>end<code> marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == fPattern || null == text)
- throw new IllegalArgumentException();
-
- if (start > end)
- return false;
-
- if (fIgnoreWildCards)
- return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0) //pattern contains only '*'(s) or empty pattern
- return true;
- if (start == end)
- return fLength == 0;
- if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if (bound < 0)
- return false;
- int i= 0;
- String current= fSegments[i];
- int segLength= current.length();
-
- /* process first segment */
- if (!fHasLeadingStar) {
- if (!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
- }
- }
-
- /* process middle segments */
- for (; i < segCount && tCurPos <= bound; ++i) {
- current= fSegments[i];
- int currentMatch;
- int k= current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- }
- tCurPos= currentMatch + current.length();
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount;
- }
- /**
- * match the given <code>text</code> with the pattern
- * @return true if matched eitherwise false
- * @param <code>text</code>, a String object
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments= new String[1];
- fSegments[0]= fPattern;
- fBound= fLength;
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * @param p, a String object that is a simple regular expression with *  and/or ? 
- */
- private void parseWildCards() {
- if (fPattern.startsWith("*")) //$NON-NLS-1$
- fHasLeadingStar= true;
- if (fPattern.endsWith("*")) { //$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar= true;
- }
- }
-
- Vector temp= new Vector();
-
- int pos= 0;
- StringBuffer buf= new StringBuffer();
- while (pos < fLength) {
- char c= fPattern.charAt(pos++);
- switch (c) {
- case '\\' :
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next= fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*' :
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?' :
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default :
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- fBound += buf.length();
- }
-
- fSegments= new String[temp.size()];
- temp.copyInto(fSegments);
- }
- /**
- * @param <code>text</code>, a string which contains no wildcard
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) { //no wild card in pattern
- int max= end - fLength;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(fPattern, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength))
- return i;
- }
-
- return -1;
- }
- /**
- * @param <code>text</code>, a simple regular expression that may only contain '?'(s)
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param <code>p</code>, a simple regular expression that may contains '?'
- * @param <code>caseIgnored</code>, wether the pattern is not casesensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen= p.length();
-
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen))
- return i;
- }
- return -1;
- }
- /**
- *
- * @return boolean
- * @param <code>text</code>, a String to match
- * @param <code>start</code>, int that indicates the starting index of match, inclusive
- * @param <code>end</code> int that indicates the ending index of match, exclusive
- * @param <code>p</code>, String, String, a simple regular expression that may contain '?'
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
- while (plen-- > 0) {
- char tchar= text.charAt(tStart++);
- char pchar= p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar)
- continue;
- if (fIgnoreCase) {
- char tc= Character.toUpperCase(tchar);
- if (tc == pchar)
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * @param <code>text</code>, the string to match
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param code>p</code>, a string that has no wildcard
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen= p.length();
- int max= end - plen;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(p, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= 0; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen))
- return i;
- }
-
- return -1;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java
deleted file mode 100644
index eccf9c8865f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.util;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Helper class to provide String manipulation functions not available in standard JDK.
- */
-public class Strings {
-
- /**
- * Indent char is a space char but not a line delimiters.
- * <code>== Character.isWhitespace(ch) && ch != '\n' && ch != '\r'</code>
- */
- public static boolean isIndentChar(char ch) {
- return Character.isWhitespace(ch) && !isLineDelimiterChar(ch);
- }
-
- /**
- * tests if a char is lower case. Fix for 26529
- */
- public static boolean isLowerCase(char ch) {
- return Character.toLowerCase(ch) == ch;
- }
-
- /**
- * Line delimiter chars are '\n' and '\r'.
- */
- public static boolean isLineDelimiterChar(char ch) {
- return ch == '\n' || ch == '\r';
- }
-
- public static String removeNewLine(String message) {
- StringBuffer result= new StringBuffer();
- int current= 0;
- int index= message.indexOf('\n', 0);
- while (index != -1) {
- result.append(message.substring(current, index));
- if (current < index && index != 0)
- result.append(' ');
- current= index + 1;
- index= message.indexOf('\n', current);
- }
- result.append(message.substring(current));
- return result.toString();
- }
-
- /**
- * Converts the given string into an array of lines. The lines
- * don't contain any line delimiter characters.
- *
- * @return the string converted into an array of strings. Returns <code>
- * null</code> if the input string can't be converted in an array of lines.
- */
- public static String[] convertIntoLines(String input) {
- try {
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(input);
- int size= tracker.getNumberOfLines();
- String result[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- int offset= region.getOffset();
- result[i]= input.substring(offset, offset + region.getLength());
- }
- return result;
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns <code>true</code> if the given string only consists of
- * white spaces according to Java. If the string is empty, <code>true
- * </code> is returned.
- *
- * @return <code>true</code> if the string only consists of white
- * spaces; otherwise <code>false</code> is returned
- *
- * @see java.lang.Character#isWhitespace(char)
- */
- public static boolean containsOnlyWhitespaces(String s) {
- int size= s.length();
- for (int i= 0; i < size; i++) {
- if (!Character.isWhitespace(s.charAt(i)))
- return false;
- }
- return true;
- }
-
- /**
- * Removes leading tabs and spaces from the given string. If the string
- * doesn't contain any leading tabs or spaces then the string itself is
- * returned.
- */
- public static String trimLeadingTabsAndSpaces(String line) {
- int size= line.length();
- int start= size;
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (!isIndentChar(c)) {
- start= i;
- break;
- }
- }
- if (start == 0)
- return line;
- else if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
-
- public static String trimTrailingTabsAndSpaces(String line) {
- int size= line.length();
- int end= size;
- for (int i= size - 1; i >= 0; i--) {
- char c= line.charAt(i);
- if (isIndentChar(c)) {
- end= i;
- } else {
- break;
- }
- }
- if (end == size)
- return line;
- else if (end == 0)
- return ""; //$NON-NLS-1$
- else
- return line.substring(0, end);
- }
-
- /**
- * Returns the indent of the given string.
- *
- * @param line the text line
- * @param tabWidth the width of the '\t' character.
- */
- public static int computeIndent(String line, int tabWidth) {
- int result= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (c == '\t') {
- result++;
- blanks= 0;
- } else if (isIndentChar(c)) {
- blanks++;
- if (blanks == tabWidth) {
- result++;
- blanks= 0;
- }
- } else {
- return result;
- }
- }
- return result;
- }
-
- /**
- * Removes the given number of idents from the line. Asserts that the given line
- * has the requested number of indents. If <code>indentsToRemove <= 0</code>
- * the line is returned.
- */
- public static String trimIndent(String line, int indentsToRemove, int tabWidth) {
- if (line == null || indentsToRemove <= 0)
- return line;
-
- int start= 0;
- int indents= 0;
- int blanks= 0;
- int size= line.length();
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (c == '\t') {
- indents++;
- blanks= 0;
- } else if (isIndentChar(c)) {
- blanks++;
- if (blanks == tabWidth) {
- indents++;
- blanks= 0;
- }
- } else {
- // Assert.isTrue(false, "Line does not have requested number of indents"); //$NON-NLS-1$
- start= i + 1;
- break;
- }
- if (indents == indentsToRemove) {
- start= i + 1;
- break;
- }
- }
- if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
-
- /**
- * Removes all leading indents from the given line. If the line doesn't contain
- * any indents the line itself is returned.
- */
- public static String trimIndents(String s, int tabWidth) {
- int indent= computeIndent(s, tabWidth);
- if (indent == 0)
- return s;
- return trimIndent(s, indent, tabWidth);
- }
-
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored.
- */
- public static void trimIndentation(String[] lines, int tabWidth) {
- trimIndentation(lines, tabWidth, true);
- }
-
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored. If <code>
- * considerFirstLine</code> is false the first line will be ignored.
- */
- public static void trimIndentation(String[] lines, int tabWidth, boolean considerFirstLine) {
- String[] toDo= new String[lines.length];
- // find indentation common to all lines
- int minIndent= Integer.MAX_VALUE; // very large
- for (int i= considerFirstLine ? 0 : 1; i < lines.length; i++) {
- String line= lines[i];
- if (containsOnlyWhitespaces(line))
- continue;
- toDo[i]= line;
- int indent= computeIndent(line, tabWidth);
- if (indent < minIndent) {
- minIndent= indent;
- }
- }
-
- if (minIndent > 0) {
- // remove this indent from all lines
- for (int i= considerFirstLine ? 0 : 1; i < toDo.length; i++) {
- String s= toDo[i];
- if (s != null)
- lines[i]= trimIndent(s, minIndent, tabWidth);
- else {
- String line= lines[i];
- int indent= computeIndent(line, tabWidth);
- if (indent > minIndent)
- lines[i]= trimIndent(line, minIndent, tabWidth);
- else
- lines[i]= trimLeadingTabsAndSpaces(line);
- }
- }
- }
- }
-
- public static String getIndentString(String line, int tabWidth) {
- int size= line.length();
- int end= 0;
- int blanks= 0;
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (c == '\t') {
- end= i + 1;
- blanks= 0;
- } else if (isIndentChar(c)) {
- blanks++;
- if (blanks == tabWidth) {
- end= i + 1;
- blanks= 0;
- }
- } else {
- break;
- }
- }
- if (end == 0)
- return ""; //$NON-NLS-1$
- else if (end == size)
- return line;
- else
- return line.substring(0, end);
- }
-
- public static String[] removeTrailingEmptyLines(String[] sourceLines) {
- int lastNonEmpty= findLastNonEmptyLineIndex(sourceLines);
- String[] result= new String[lastNonEmpty + 1];
- for (int i= 0; i < result.length; i++) {
- result[i]= sourceLines[i];
- }
- return result;
- }
-
- private static int findLastNonEmptyLineIndex(String[] sourceLines) {
- for (int i= sourceLines.length - 1; i >= 0; i--) {
- if (! sourceLines[i].trim().equals(""))//$NON-NLS-1$
- return i;
- }
- return -1;
- }
-
- /**
- * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
- * The first line of the code will not be changed. (It is considered to have no indent as it might start in
- * the middle of a line)
- */
- public static String changeIndent(String code, int codeIndentLevel, int tabWidth, String newIndent, String lineDelim) {
- try {
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(code);
- int nLines= tracker.getNumberOfLines();
- if (nLines == 1) {
- return code;
- }
-
- StringBuffer buf= new StringBuffer();
-
- for (int i= 0; i < nLines; i++) {
- IRegion region= tracker.getLineInformation(i);
- int start= region.getOffset();
- int end= start + region.getLength();
- String line= code.substring(start, end);
-
- if (i == 0) { // no indent for first line (contained in the formatted string)
- buf.append(line);
- } else { // no new line after last line
- buf.append(lineDelim);
- buf.append(newIndent);
- buf.append(trimIndent(line, codeIndentLevel, tabWidth));
- }
- }
- return buf.toString();
- } catch (BadLocationException e) {
- // can not happen
- return code;
- }
- }
-
- /**
- * Concatenate the given strings into one strings using the passed line delimiter as a
- * delimiter. No delimiter is added to the last line.
- */
- public static String concatenate(String[] lines, String delimiter) {
- StringBuffer buffer= new StringBuffer();
- for (int i= 0; i < lines.length; i++) {
- if (i > 0)
- buffer.append(delimiter);
- buffer.append(lines[i]);
- }
- return buffer.toString();
- }
-
- public static boolean equals(String s, char[] c) {
- if (s.length() != c.length)
- return false;
-
- for (int i = c.length; --i >= 0;)
- if (s.charAt(i) != c[i])
- return false;
- return true;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
deleted file mode 100644
index 7d5cad85ae4..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-
-/**
- * A special composite to layout columns inside a table. The composite is needed since we have
- * to layout the columns "before" the actual table gets layouted. Hence we can't use a normal
- * layout manager.
- */
-public class TableLayoutComposite extends Composite {
-
- private List columns= new ArrayList();
-
- /**
- * Creates a new <code>TableLayoutComposite</code>.
- */
- public TableLayoutComposite(Composite parent, int style) {
- super(parent, style);
- addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Rectangle area= getClientArea();
- Table table= (Table)getChildren()[0];
- Point preferredSize= computeTableSize(table);
- int width= area.width - 2 * table.getBorderWidth();
- if (preferredSize.y > area.height) {
- // Subtract the scrollbar width from the total column width
- // if a vertical scrollbar will be required
- Point vBarSize = table.getVerticalBar().getSize();
- width -= vBarSize.x;
- }
- layoutTable(table, width, area, table.getSize().x < area.width);
- }
- });
- }
-
- /**
- * Adds a new column of data to this table layout.
- *
- * @param data the column layout data
- */
- public void addColumnData(ColumnLayoutData data) {
- columns.add(data);
- }
-
- //---- Helpers -------------------------------------------------------------------------------------
-
- private Point computeTableSize(Table table) {
- Point result= table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- int width= 0;
- int size= columns.size();
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData layoutData= (ColumnLayoutData) columns.get(i);
- if (layoutData instanceof ColumnPixelData) {
- ColumnPixelData col= (ColumnPixelData) layoutData;
- width += col.width;
- } else if (layoutData instanceof ColumnWeightData) {
- ColumnWeightData col= (ColumnWeightData) layoutData;
- width += col.minimumWidth;
- } else {
- Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
- }
- }
- if (width > result.x)
- result.x= width;
- return result;
- }
-
- private void layoutTable(Table table, int width, Rectangle area, boolean increase) {
- // XXX: Layout is being called with an invalid value the first time
- // it is being called on Linux. This method resets the
- // Layout to null so we make sure we run it only when
- // the value is OK.
- if (width <= 1)
- return;
-
- TableColumn[] tableColumns= table.getColumns();
- int size= Math.min(columns.size(), tableColumns.length);
- int[] widths= new int[size];
- int fixedWidth= 0;
- int numberOfWeightColumns= 0;
- int totalWeight= 0;
-
- // First calc space occupied by fixed columns
- for (int i= 0; i < size; i++) {
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnPixelData) {
- int pixels= ((ColumnPixelData) col).width;
- widths[i]= pixels;
- fixedWidth += pixels;
- } else if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
- numberOfWeightColumns++;
- // first time, use the weight specified by the column data, otherwise use the actual width as the weight
- // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
- totalWeight += weight;
- } else {
- Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
- }
- }
-
- // Do we have columns that have a weight
- if (numberOfWeightColumns > 0) {
- // Now distribute the rest to the columns with weight.
- int rest= width - fixedWidth;
- int totalDistributed= 0;
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
- // calculate weight as above
- // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
- int pixels= totalWeight == 0 ? 0 : weight * rest / totalWeight;
- if (pixels < cw.minimumWidth)
- pixels= cw.minimumWidth;
- totalDistributed += pixels;
- widths[i]= pixels;
- }
- }
-
- // Distribute any remaining pixels to columns with weight.
- int diff= rest - totalDistributed;
- for (int i= 0; diff > 0; ++i) {
- if (i == size)
- i= 0;
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnWeightData) {
- ++widths[i];
- --diff;
- }
- }
- }
-
- if (increase) {
- table.setSize(area.width, area.height);
- }
- for (int i= 0; i < size; i++) {
- tableColumns[i].setWidth(widths[i]);
- }
- if (!increase) {
- table.setSize(area.width, area.height);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
deleted file mode 100644
index 5ae29f2f8a1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.cdt.internal.ui.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * Quick sort to sort two arrays in parallel.
- */
-public class TwoArrayQuickSort {
-
- private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) {
-
- int original_left= left;
- int original_right= right;
-
- String mid= keys[(left + right) / 2];
- do {
- while (smaller(keys[left], mid, ignoreCase)) {
- left++;
- }
- while (smaller(mid, keys[right], ignoreCase)) {
- right--;
- }
- if (left <= right) {
- String tmp= keys[left];
- keys[left]= keys[right];
- keys[right]= tmp;
-
- Object tmp2= values[left];
- values[left]= values[right];
- values[right]= tmp2;
-
- left++;
- right--;
- }
- } while (left <= right);
-
- if (original_left < right) {
- internalSort(keys , values, original_left, right, ignoreCase);
- }
- if (left < original_right) {
- internalSort(keys, values, left, original_right, ignoreCase);
- }
- }
- private static boolean smaller(String left, String right, boolean ignoreCase) {
- if (ignoreCase)
- return left.compareToIgnoreCase(right) < 0;
- else
- return left.compareTo(right) < 0;
- }
- /**
- * Sorts keys and values in parallel.
- */
- public static void sort(String[] keys, Object[] values, boolean ignoreCase) {
- if (keys != null && values != null) {
- Assert.isTrue(keys.length == values.length);
- if (keys.length > 1)
- internalSort(keys, values, 0, keys.length - 1, ignoreCase);
- } else {
- if (keys != null || values != null)
- Assert.isTrue(false, "Either keys or values in null"); //$NON-NLS-1$
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
deleted file mode 100644
index b92122dbd83..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.viewsupport;
-
-import org.eclipse.cdt.core.model.IDeclaration;
-import org.eclipse.cdt.core.model.IField;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-
-/**
- * Filter for the methods viewer.
- * Changing a filter property does not trigger a refiltering of the viewer
- */
-
-public class MemberFilter extends ViewerFilter{
-
- public static final int FILTER_NONPUBLIC= 1;
- public static final int FILTER_STATIC= 2;
- public static final int FILTER_FIELDS= 4;
-
- private int fFilterProperties;
-
- /**
- * Modifies filter and add a property to filter for
- */
- public final void addFilter(int filter) {
- fFilterProperties |= filter;
- }
- /**
- * Modifies filter and remove a property to filter for
- */
- public final void removeFilter(int filter) {
- fFilterProperties &= (-1 ^ filter);
- }
- /**
- * Tests if a property is filtered
- */
- public final boolean hasFilter(int filter) {
- return (fFilterProperties & filter) != 0;
- }
-
- /*
- * @see ViewerFilter@isFilterProperty
- */
- public boolean isFilterProperty(Object element, Object property) {
- return false;
- }
- /*
- * @see ViewerFilter@select
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof IDeclaration){
- IDeclaration declaration = (IDeclaration) element;
- if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) {
- return false;
- }
- if (element instanceof IMember) {
- IMember member= (IMember)element;
- if (hasFilter(FILTER_NONPUBLIC) && (member.getVisibility() != ASTAccessVisibility.PUBLIC)) {
- return false;
- }
-
- if (hasFilter(FILTER_FIELDS) && element instanceof IField) {
- return false;
- }
- }
- }
- return true;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
deleted file mode 100644
index 5291c560b14..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.viewsupport;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;;
-
-/**
- * Action used to enable / disable method filter properties
- */
-
-public class MemberFilterAction extends Action {
-
- private int fFilterProperty;
- private MemberFilterActionGroup fFilterActionGroup;
-
- public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId, boolean initValue) {
- super(title);
- fFilterActionGroup= actionGroup;
- fFilterProperty= property;
-
- WorkbenchHelp.setHelp(this, contextHelpId);
-
- setChecked(initValue);
- }
-
- /**
- * Returns this action's filter property.
- */
- public int getFilterProperty() {
- return fFilterProperty;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- fFilterActionGroup.setMemberFilter(fFilterProperty, isChecked());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/IStatusChangeListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/IStatusChangeListener.java
deleted file mode 100644
index 8f0f417e5e8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/IStatusChangeListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards;
-
-import org.eclipse.core.runtime.IStatus;
-
-public interface IStatusChangeListener {
-
- /**
- * Notifies this listener that the given status has changed.
- *
- * @param status the new status
- */
- void statusChanged(IStatus status);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java
deleted file mode 100644
index 23916c92190..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards;
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-public class NewWizardMessages {
-
- private static final String RESOURCE_BUNDLE= NewWizardMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private NewWizardMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * 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
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties
deleted file mode 100644
index ad39e78b7a7..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties
+++ /dev/null
@@ -1,595 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# ------- AbstractOpenWizardAction -------
-
-AbstractOpenWizardAction.noproject.title=New
-AbstractOpenWizardAction.noproject.message=A project needs to be created first.\nOpen the 'New Project' wizard'?
-
-AbstractOpenWizardAction.createerror.title=Open Wizard
-AbstractOpenWizardAction.createerror.message=The wizard could not be opened. See log for details.
-
-# ------- NewElementWizard -------
-
-NewElementWizard.op_error.title=New
-NewElementWizard.op_error.message=Creation of element failed.
-
-NewElementWizard.typecomment.deprecated.title=Type Creation
-NewElementWizard.typecomment.deprecated.message=You can configure the default layout of newly created files and types on the 'code generation' preference page. This was previously implemented on the template page in the templates 'filecomment' and 'typecomment'.
-# ------- NewContainerWizardPage -------
-
-NewContainerWizardPage.container.label=Source Fol&der:
-NewContainerWizardPage.container.button=Br&owse...
-
-NewContainerWizardPage.error.EnterContainerName=Folder name is empty.
-NewContainerWizardPage.error.ContainerIsBinary=''{0}'' is a JAR archive.
-NewContainerWizardPage.error.ContainerDoesNotExist=Folder ''{0}'' does not exist.
-NewContainerWizardPage.error.NotAFolder=''{0}'' must be a project or folder.
-NewContainerWizardPage.error.ProjectClosed=Project ''{0}'' must be accessible.
-
-NewContainerWizardPage.warning.NotAJavaProject=Folder is not a Java project.
-NewContainerWizardPage.warning.NotInAJavaProject=Folder is not in a Java project.
-NewContainerWizardPage.warning.NotOnClassPath=Folder is not on the Java build class path.
-
-NewContainerWizardPage.ChooseSourceContainerDialog.title=Folder Selection
-NewContainerWizardPage.ChooseSourceContainerDialog.description=&Choose a folder:
-
-# ------- NewPackageWizardPage -------
-
-NewPackageCreationWizard.title=New Java Package
-
-NewPackageWizardPage.package.label=&Name:
-
-
-NewPackageWizardPage.error.InvalidPackageName=Invalid package name. {0}
-NewPackageWizardPage.error.IsOutputFolder=Name conflict with output folder.
-
-NewPackageWizardPage.error.PackageExists=Package already exists.
-NewPackageWizardPage.error.EnterName=Enter a package name.
-NewPackageWizardPage.warning.PackageNotShown=Package already exists. Note: Views might filter empty parent packages.
-NewPackageWizardPage.warning.DiscouragedPackageName=Discouraged package name. {0}
-
-NewPackageWizardPage.title=Java Package
-NewPackageWizardPage.description=Create a Java package.
-NewPackageWizardPage.info=Creates folders corresponding to packages.
-# ------- NewTypeWizardPage -------
-
-NewTypeWizardPage.package.label=Pac&kage:
-NewTypeWizardPage.package.button=Bro&wse...
-
-NewTypeWizardPage.enclosing.selection.label=Enclosing t&ype:
-NewTypeWizardPage.enclosing.button=Bro&wse...
-
-NewTypeWizardPage.error.InvalidPackageName=Package name is not valid. {0}
-NewTypeWizardPage.error.ClashOutputLocation=Package clashes with project output folder.
-NewTypeWizardPage.warning.DiscouragedPackageName=This package name is discouraged. {0}
-
-NewTypeWizardPage.default=(default)
-
-NewTypeWizardPage.ChoosePackageDialog.title=Package Selection
-NewTypeWizardPage.ChoosePackageDialog.description=&Choose a folder:
-NewTypeWizardPage.ChoosePackageDialog.empty=Cannot find packages to select.
-
-NewTypeWizardPage.ChooseEnclosingTypeDialog.title=Enclosing Type Selection
-NewTypeWizardPage.ChooseEnclosingTypeDialog.description=&Choose a type to which the new class will be added:
-
-NewTypeWizardPage.error.EnclosingTypeEnterName=Name of enclosing type must be entered.
-NewTypeWizardPage.error.EnclosingTypeNotExists=Enclosing type does not exist.
-NewTypeWizardPage.error.EnclosingNotInCU=Enclosing type is binary.
-NewTypeWizardPage.error.EnclosingNotEditable=Enclosing type is not editable.
-NewTypeWizardPage.warning.EnclosingNotInSourceFolder=Enclosing type is not in specified source folder.
-
-NewTypeWizardPage.typename.label=Na&me:
-
-NewTypeWizardPage.superclass.label=&Superclass:
-NewTypeWizardPage.superclass.button=Brows&e...
-
-NewTypeWizardPage.interfaces.class.label=&Interfaces:
-NewTypeWizardPage.interfaces.ifc.label=Extended &interfaces:
-NewTypeWizardPage.interfaces.add=&Add...
-NewTypeWizardPage.interfaces.remove=&Remove
-
-NewTypeWizardPage.modifiers.acc.label=Modifiers:
-NewTypeWizardPage.modifiers.public=&public
-NewTypeWizardPage.modifiers.private=pri&vate
-NewTypeWizardPage.modifiers.protected=pro&tected
-NewTypeWizardPage.modifiers.default=defa&ult
-NewTypeWizardPage.modifiers.abstract=abs&tract
-NewTypeWizardPage.modifiers.final=fina&l
-NewTypeWizardPage.modifiers.static=stati&c
-
-NewTypeWizardPage.error.EnterTypeName=Type name is empty.
-NewTypeWizardPage.error.TypeNameExists=Type already exists.
-NewTypeWizardPage.error.InvalidTypeName=Type name is not valid. {0}
-NewTypeWizardPage.error.QualifiedName=Type name must not be qualified.
-NewTypeWizardPage.warning.TypeNameDiscouraged=Type name is discouraged. {0}
-
-NewTypeWizardPage.error.InvalidSuperClassName=Superclass name is not valid.
-NewTypeWizardPage.warning.SuperClassNotExists=Warning: Superclass does not exist in current project.
-NewTypeWizardPage.warning.SuperClassIsFinal=Warning: Superclass ''{0}'' is final.
-NewTypeWizardPage.warning.SuperClassIsNotVisible=Warning: Superclass ''{0}'' is not visible.
-NewTypeWizardPage.warning.SuperClassIsNotClass=Warning: Superclass ''{0}'' is an interface.
-
-NewTypeWizardPage.warning.InterfaceIsNotVisible=Extended interface ''{0}'' is not visible.
-NewTypeWizardPage.warning.InterfaceNotExists=Extended interface ''{0}'' does not exist in current project.
-NewTypeWizardPage.warning.InterfaceIsNotInterface=Extended interface ''{0}'' is not an interface.
-
-NewTypeWizardPage.error.ModifiersFinalAndAbstract=Class cannot be both final and abstract
-
-NewTypeWizardPage.SuperClassDialog.title=Superclass Selection
-NewTypeWizardPage.SuperClassDialog.message=&Choose a type:
-
-NewTypeWizardPage.InterfacesDialog.class.title= Implemented Interfaces Selection
-NewTypeWizardPage.InterfacesDialog.interface.title= Extended Interfaces Selection
-NewTypeWizardPage.InterfacesDialog.message=&Choose interfaces:
-
-NewTypeWizardPage.operationdesc=Creating type....
-
-# -----------NewClassWizardPage -------------
-NewClassWizardPage.classname.label=&Name:
-
-NewClassWizardPage.baseclass.label=&Base class:
-NewClassWizardPage.baseclass.button=Brows&e...
-NewClassWizardPage.baseclass.access.public=&public
-NewClassWizardPage.baseclass.access.protected=pro&tected
-NewClassWizardPage.baseclass.access.private=pri&vate
-NewClassWizardPage.baseclass.access.access=&default
-NewClassWizardPage.baseclass.access.label=Access:
-
-NewClassWizardPage.constdest.virtualdestructor=&Virtual Destructor
-NewClassWizardPage.constdest.inline=&Inline
-NewClassWizardPage.constdest.includeguard=Include &Guard
-
-NewClassWizardPage.files.header=Header File:
-NewClassWizardPage.files.body=Body File:
-NewClassWizardPage.files.linkFileButton=Link to file
-
-NewClassWizardPage.error.EnterClassName=Class name is empty.
-NewClassWizardPage.error.ClassNameExists=Class already exists.
-NewClassWizardPage.error.InvalidClassName=Class name is not valid. {0}
-NewClassWizardPage.error.QualifiedName=Class name must not be qualified.
-NewClassWizardPage.warning.ClassNameDiscouraged=Class name is discouraged. {0}
-
-NewClassWizardPage.error.InvalidBaseClassName=Base class name is not valid.
-NewClassWizardPage.warning.BaseClassNotExists=Warning: Base class does not exist in current project.
-
-NewClassWizardPage.operations.getProjectClasses=Looking for classes in project
-
-NewClassWizardPage.error.NotAvailableForNonCppProjects= The wizard is not available for non C++ projects.
-# ------- BaseClassSelectionDialog -----
-
-BaseClassSelectionDialog.title=Classes in this project
-BaseClassSelectionDialog.message=Select a base class:
-
-# ------- NewClassWizardPage -------
-
-NewClassCreationWizard.title=New Java Class
-
-NewClassWizardPage.title=Java Class
-NewClassWizardPage.description=Create a new Java class.
-
-NewClassWizardPage.methods.label=Which method stubs would you like to create?
-NewClassWizardPage.methods.main=public static void main(Strin&g[] args)
-NewClassWizardPage.methods.constructors=&Constructors from superclass
-NewClassWizardPage.methods.inherited=In&herited abstract methods
-
-
-# ------- NewInterfaceWizardPage -------
-
-NewInterfaceCreationWizard.title=New Java Interface
-
-NewInterfaceWizardPage.title=Java Interface
-NewInterfaceWizardPage.description=Create a new Java interface.
-
-# ------- JavaCapabilityWizard -------
-
-JavaCapabilityWizard.title=Configure Java Capability
-JavaCapabilityWizard.op_error.title=Error Configure Java Capability
-JavaCapabilityWizard.op_error.message=An error occurred while configuring the Java project
-
-# ------- JavaCapabilityConfigurationPage -------
-
-JavaCapabilityConfigurationPage.title=Java Settings
-JavaCapabilityConfigurationPage.description=Define the Java build settings.
-JavaCapabilityConfigurationPage.op_desc_java=Configuring Java project...
-
-
-# ------- NewProjectCreationWizard -------
-
-NewProjectCreationWizard.title=New Java Project
-NewProjectCreationWizard.op_error.title=Error Creating Java Project
-NewProjectCreationWizard.op_error_create.message=An error occurred while creating the Java project
-NewProjectCreationWizard.MainPage.title=Java Project
-NewProjectCreationWizard.MainPage.description=Create a new Java project.
-
-NewProjectCreationWizardPage.op_error.title=Error Creating Java Project
-NewProjectCreationWizardPage.op_error_remove.message=An error occurred while removing a temporary project
-NewProjectCreationWizardPage.EarlyCreationOperation.desc=Creating project and examining existing resources...
-NewProjectCreationWizardPage.EarlyCreationOperation.error.title=New Java Project
-NewProjectCreationWizardPage.EarlyCreationOperation.error.desc=An error occurred while creating project. Check log for details.
-NewProjectCreationWizardPage.createproject.desc=Creating project...
-NewProjectCreationWizardPage.removeproject.desc=Removing project...
-
-# ------- NewJavaProjectWizardPage-------
-
-NewJavaProjectWizardPage.title=Java Settings
-NewJavaProjectWizardPage.description=Define the Java build settings.
-
-NewJavaProjectWizardPage.op_desc=Creating Java project...
-
-
-# ------- NewSourceFolderWizardPage-------
-
-NewSourceFolderCreationWizard.title=New Source Folder
-
-NewSourceFolderWizardPage.title=Source folder
-NewSourceFolderWizardPage.description=Add a new source folder
-
-NewSourceFolderWizardPage.root.label=Fol&der name:
-NewSourceFolderWizardPage.root.button=Br&owse...
-
-NewSourceFolderWizardPage.project.label=Project &name:
-NewSourceFolderWizardPage.project.button=Bro&wse...
-
-NewSourceFolderWizardPage.exclude.label=&Update exclusion filters in other source folders to solve nesting.
-
-NewSourceFolderWizardPage.ChooseExistingRootDialog.title=Existing Folder Selection
-NewSourceFolderWizardPage.ChooseExistingRootDialog.description=&Choose folder as source folder:
-
-NewSourceFolderWizardPage.ChooseProjectDialog.title=Project Selection
-NewSourceFolderWizardPage.ChooseProjectDialog.description=&Choose project for the new source folder:
-
-NewSourceFolderWizardPage.error.EnterRootName=Root name must be entered.
-NewSourceFolderWizardPage.error.InvalidRootName=Invalid folder name. {0}
-NewSourceFolderWizardPage.error.NotAFolder=Not a folder.
-NewSourceFolderWizardPage.error.AlreadyExisting=Already a source folder.
-
-NewSourceFolderWizardPage.error.EnterProjectName=Project name must be entered.
-NewSourceFolderWizardPage.error.InvalidProjectPath=Invalid project path.
-NewSourceFolderWizardPage.error.NotAJavaProject=Project is not a Java project.
-NewSourceFolderWizardPage.error.ProjectNotExists=Project does not exist.
-
-NewSourceFolderWizardPage.warning.ReplaceSFandOL=To avoid overlapping, the existing project source folder entry will be replaced and the output folder set to ''{0}''.
-NewSourceFolderWizardPage.warning.ReplaceOL=An exclusion pattern will be added to the project source folder entry and the output folder will be set to ''{0}''.
-NewSourceFolderWizardPage.warning.ReplaceSF=To avoid overlapping, the existing project source folder entry will be replaced.
-NewSourceFolderWizardPage.warning.AddedExclusions=Exclusion patterns of {0} source folder(s) updated to solve nesting.
-
-# ------- NewSnippetFileWizardPage-------
-
-NewSnippetFileCreationWizard.title=New Scrapbook Page
-
-NewSnippetFileWizardPage.title=Create Java Scrapbook Page
-
-NewSnippetFileWizardPage.error.AlreadyExists=A resource with the specified path already exists.
-NewSnippetFileWizardPage.error.OnlyInJavaProject=The scrapbook page can only be created in a Java project.
-
-NewSnippetFileWizardPage.open_error.message=Error in NewScrapbookPage
-
-# ------- BuildPathsBlock -------
-
-BuildPathsBlock.tab.source=&Source
-BuildPathsBlock.tab.projects=&Projects
-BuildPathsBlock.tab.libraries=&Libraries
-BuildPathsBlock.tab.order=&Order and Export
-
-BuildPathsBlock.classpath.label=Build &class path order and exported entries:\n(Exported entries are contributed to dependent projects)
-
-BuildPathsBlock.classpath.up.button=&Up
-BuildPathsBlock.classpath.down.button=&Down
-BuildPathsBlock.classpath.checkall.button=Select &All
-BuildPathsBlock.classpath.uncheckall.button=D&eselect All
-
-BuildPathsBlock.buildpath.label=Defaul&t output folder:
-BuildPathsBlock.buildpath.button=Bro&wse...
-
-BuildPathsBlock.error.InvalidBuildPath=Invalid build output folder: ''{0}''
-BuildPathsBlock.error.EnterBuildPath=Build output folder must be entered.
-
-BuildPathsBlock.warning.EntryMissing=Build path entry is missing: {0}
-BuildPathsBlock.warning.EntriesMissing={0} build path entries are missing.
-
-BuildPathsBlock.operationdesc_project=Creating project...
-BuildPathsBlock.operationdesc_java=Setting build paths...
-
-BuildPathsBlock.ChooseOutputFolderDialog.title=Folder Selection
-BuildPathsBlock.ChooseOutputFolderDialog.description=&Choose the folder for the build output:
-
-BuildPathsBlock.RemoveBinariesDialog.title=Setting Build Paths
-BuildPathsBlock.RemoveBinariesDialog.description=The output folder has changed. OK to remove all generated resources from the old location ''{0}''?
-
-# ------- CPListLabelProvider -------
-
-CPListLabelProvider.new=(new)
-CPListLabelProvider.classcontainer=(class folder)
-CPListLabelProvider.twopart={0} - {1}
-CPListLabelProvider.willbecreated=(will be created)
-
-
-# ------- SourceContainerWorkbookPage-------
-
-SourceContainerWorkbookPage.folders.label=Source folders on build pat&h:
-SourceContainerWorkbookPage.folders.remove.button=&Remove
-SourceContainerWorkbookPage.folders.add.button=&Add Folder...
-SourceContainerWorkbookPage.folders.edit.button=&Edit...
-
-SourceContainerWorkbookPage.folders.check=Allow output folders for sour&ce folders.
-
-SourceContainerWorkbookPage.ExistingSourceFolderDialog.new.title=Source Folder Selection
-SourceContainerWorkbookPage.ExistingSourceFolderDialog.new.description=&Choose source folders to be added to the build path:
-
-SourceContainerWorkbookPage.ExistingSourceFolderDialog.edit.title=Source Folder Selection
-SourceContainerWorkbookPage.ExistingSourceFolderDialog.edit.description=&Select the source folder:
-
-SourceContainerWorkbookPage.NewSourceFolderDialog.new.title=New Source Folder
-SourceContainerWorkbookPage.NewSourceFolderDialog.edit.title=Edit Source Folder
-
-SourceContainerWorkbookPage.NewSourceFolderDialog.description=&Enter a path relative to ''{0}'':
-
-SourceContainerWorkbookPage.ChangeOutputLocationDialog.title=Source Folder Added
-SourceContainerWorkbookPage.ChangeOutputLocationDialog.project_and_output.message=Do you want to remove the project as source folder and update build output folder to ''{0}''?
-SourceContainerWorkbookPage.ChangeOutputLocationDialog.project.message=Do you want to remove the project as source folder?
-
-SourceContainerWorkbookPage.exclusion_added.title=Source Folder Added
-SourceContainerWorkbookPage.exclusion_added.message=Exclusion filters have been added to nesting folders.
-
-# ------- ProjectsWorkbookPage-------
-
-ProjectsWorkbookPage.projects.label=&Required projects on the build path:
-ProjectsWorkbookPage.projects.checkall.button=Select &All
-ProjectsWorkbookPage.projects.uncheckall.button=&Deselect All
-
-# ------- LibrariesWorkbookPage-------
-
-LibrariesWorkbookPage.libraries.label=JARs &and class folders on the build path:
-LibrariesWorkbookPage.libraries.remove.button=&Remove
-
-LibrariesWorkbookPage.libraries.addjar.button=Add &JARs...
-LibrariesWorkbookPage.libraries.addextjar.button=Add E&xternal JARs...
-LibrariesWorkbookPage.libraries.addvariable.button=Add &Variable...
-LibrariesWorkbookPage.libraries.addlibrary.button=Add Li&brary...
-LibrariesWorkbookPage.libraries.addclassfolder.button=Add Class &Folder...
-
-
-LibrariesWorkbookPage.libraries.edit.button=&Edit...
-
-LibrariesWorkbookPage.ExistingClassFolderDialog.new.title=Class Folder Selection
-LibrariesWorkbookPage.ExistingClassFolderDialog.new.description=&Choose class folders to be added to the build path:
-
-LibrariesWorkbookPage.ExistingClassFolderDialog.edit.title=Edit Class Folder
-LibrariesWorkbookPage.ExistingClassFolderDialog.edit.description=&Select the class folder:
-
-LibrariesWorkbookPage.NewClassFolderDialog.new.title=New Class Folder
-LibrariesWorkbookPage.NewClassFolderDialog.edit.title=Edit Class Folder
-
-LibrariesWorkbookPage.NewClassFolderDialog.description=&Enter a path relative to ''{0}'':
-
-LibrariesWorkbookPage.JARArchiveDialog.new.title=JAR Selection
-LibrariesWorkbookPage.JARArchiveDialog.new.description=&Choose jar archives to be added to the build path:
-
-LibrariesWorkbookPage.JARArchiveDialog.edit.title=Edit JAR
-LibrariesWorkbookPage.JARArchiveDialog.edit.description=&Select the jar archive:
-
-LibrariesWorkbookPage.ContainerDialog.new.title=Add Library
-LibrariesWorkbookPage.ContainerDialog.edit.title=Edit Library
-
-LibrariesWorkbookPage.VariableSelectionDialog.new.title=New Variable Classpath Entry
-LibrariesWorkbookPage.VariableSelectionDialog.edit.title=Edit Variable Entry
-
-LibrariesWorkbookPage.ExtJARArchiveDialog.new.title=JAR Selection
-
-LibrariesWorkbookPage.ExtJARArchiveDialog.edit.title=Edit JAR
-
-LibrariesWorkbookPage.SourceAttachmentDialog.title=Source For ''{0}''
-LibrariesWorkbookPage.JavadocPropertyDialog.title=Javadoc For ''{0}''
-
-LibrariesWorkbookPage.AdvancedDialog.title=Add Classpath Entry
-LibrariesWorkbookPage.AdvancedDialog.description=Select the entry to add to the classpath:
-LibrariesWorkbookPage.AdvancedDialog.createfolder=Create &New Class Folder
-LibrariesWorkbookPage.AdvancedDialog.addfolder=Add &Existing Class Folder
-LibrariesWorkbookPage.AdvancedDialog.addcontainer=Add &Container:
-
-# ------- NewContainerDialog-------
-
-NewContainerDialog.error.invalidpath=Invalid folder path: ''{0}''
-NewContainerDialog.error.enterpath=Folder name must be entered
-NewContainerDialog.error.pathexists=This folder is already in the list or it is an output folder.
-# ------- NewSourceFolderDialog-------
-
-NewSourceFolderDialog.error.invalidpath=Invalid folder path: ''{0}''
-NewSourceFolderDialog.error.enterpath=Folder name must be entered.
-NewSourceFolderDialog.error.pathexists=The folder is already in the list.
-
-# ------- SourceAttachmentBlock-------
-
-SourceAttachmentBlock.message=Select the location (folder, JAR or zip) containing the source for ''{0}'':
-SourceAttachmentBlock.filename.description=Source attachments for variable entries are defined by variable paths. The first segment of such a path describes a variable name, the rest is an optional path extension.
-
-SourceAttachmentBlock.filename.label=Lo&cation path:
-SourceAttachmentBlock.filename.externalfile.button=External &File...
-SourceAttachmentBlock.filename.externalfolder.button=External F&older...
-SourceAttachmentBlock.filename.internal.button=&Workspace...
-
-SourceAttachmentBlock.filename.varlabel=Lo&cation variable path:
-SourceAttachmentBlock.filename.variable.button=&Variable...
-SourceAttachmentBlock.filename.external.varbutton=&Extension....
-
-SourceAttachmentBlock.filename.error.notvalid=The archive path is not a valid path.
-SourceAttachmentBlock.filename.error.filenotexists=The path ''{0}'' does not exist.
-SourceAttachmentBlock.filename.error.varnotexists=Variable in the location path does not exist.
-SourceAttachmentBlock.filename.error.deviceinpath=Location must be described a variable path.
-SourceAttachmentBlock.filename.warning.varempty=Location variable path is empty.
-
-SourceAttachmentBlock.intjardialog.title=Source Location Selection
-SourceAttachmentBlock.intjardialog.message=&Select folder or JAR/zip archive containing the source:
-
-SourceAttachmentBlock.extvardialog.title=Variable Extension Selection
-SourceAttachmentBlock.extvardialog.description=Select source location:
-
-SourceAttachmentBlock.extjardialog.text=JAR/ZIP File Selection
-SourceAttachmentBlock.extfolderdialog.text=Folder Selection
-
-SourceAttachmentBlock.putoncpdialog.title=Setting Source Attachment
-SourceAttachmentBlock.putoncpdialog.message=Source can only be attached to libraries on the build path.\nDo you want to add the library to the build path?
-
-SourceAttachmentDialog.title=Source Attachment Configuration
-SourceAttachmentDialog.error.title=Error Attaching Source
-SourceAttachmentDialog.error.message=An error occurred while associating the source.
-
-# ------- EditVariableEntryDialog -------
-
-EditVariableEntryDialog.filename.varlabel=Edit classpath variable entry:
-EditVariableEntryDialog.filename.variable.button=&Variable...
-EditVariableEntryDialog.filename.external.varbutton=&Extension....
-
-EditVariableEntryDialog.extvardialog.title=Variable Extension Selection
-EditVariableEntryDialog.extvardialog.description=Select JAR archive:
-
-EditVariableEntryDialog.filename.error.notvalid=The archive path is not a valid path.
-EditVariableEntryDialog.filename.error.filenotexists=The path ''{0}'' does not point to an existing archive.
-EditVariableEntryDialog.filename.error.varnotexists=Variable in the archive path does not exist.
-EditVariableEntryDialog.filename.error.deviceinpath=The archive has to be described by a variable path.
-EditVariableEntryDialog.filename.warning.varempty=Archive variable path is empty.
-EditVariableEntryDialog.filename.error.alreadyexists=Classpath entry already exists.
-
-
-# ------- VariableBlock-------
-
-VariableBlock.vars.label=Defined &classpath variables:
-VariableBlock.vars.add.button=Ne&w...
-VariableBlock.vars.edit.button=&Edit...
-VariableBlock.vars.remove.button=&Remove
-VariableBlock.operation_desc=Setting classpath variables...
-
-VariableBlock.operation_errror.title=Classpath Variables
-VariableBlock.operation_errror.message=Problem while setting classpath variable. See log for details.
-
-VariableBlock.needsbuild.title=Classpath Variables Changed
-VariableBlock.needsbuild.message=The classpath variables have changed. A full rebuild is recommended to make changes effective. Do the full build now?
-
-VariablePathDialogField.variabledialog.title=Variable Selection
-
-CPVariableElementLabelProvider.reserved=(reserved)
-CPVariableElementLabelProvider.empty=(empty)
-
-# ------- VariableCreationDialog-------
-
-VariableCreationDialog.titlenew=New Variable Entry
-VariableCreationDialog.titleedit=Edit Variable Entry
-
-VariableCreationDialog.name.label=&Name:
-VariableCreationDialog.path.label=&Path:
-VariableCreationDialog.path.file.button=&File...
-VariableCreationDialog.path.dir.button=F&older...
-
-VariableCreationDialog.error.entername=Variable name must be entered.
-VariableCreationDialog.error.invalidname=Invalid name: ''{0}''.
-VariableCreationDialog.error.nameexists=Variable name already exists.
-VariableCreationDialog.error.invalidpath=The path is invalid.
-
-VariableCreationDialog.warning.pathnotexists=Path does not exist.
-
-
-VariableCreationDialog.extjardialog.text=JAR Selection
-VariableCreationDialog.extdirdialog.text=Folder Selection
-VariableCreationDialog.extdirdialog.message=&Specify folder to be represented by the variable:
-
-# ------- NewVariableEntryDialog -------
-NewVariableEntryDialog.vars.extend=E&xtend...
-NewVariableEntryDialog.vars.config=&Edit...
-
-NewVariableEntryDialog.vars.label=Select &variables to add to build path:
-
-NewVariableEntryDialog.ExtensionDialog.title=Variable Extension
-NewVariableEntryDialog.ExtensionDialog.description=Choose extensions to ''{0}''.
-
-NewVariableEntryDialog.info.isfolder=Variable points to a folder: Click 'extend' to choose an archive inside the folder.
-NewVariableEntryDialog.info.noselection=Select variable(s) to add to the classpath.
-NewVariableEntryDialog.info.selected={0} variables selected.
-
-# ------- OutputLocationDialog -------
-
-OutputLocationDialog.title=Source Folder Output Location
-
-OutputLocationDialog.usedefault.label=Project's default output folder.
-OutputLocationDialog.usespecific.label=Specific output folder (path relative to ''{0}'').
-OutputLocationDialog.location.button=Bro&wse...
-
-OutputLocationDialog.error.existingisfile=Location is an existing file
-OutputLocationDialog.error.invalidpath=Invalid path: {0}
-
-OutputLocationDialog.ChooseOutputFolder.title=Folder Selection
-OutputLocationDialog.ChooseOutputFolder.description=&Choose the folder for the build output:
-
-# ------- ExclusionPatternDialog -------
-
-ExclusionPatternDialog.title=Source Folder Exclusion Patterns
-
-ExclusionPatternDialog.pattern.label=E&xclusion patterns for ''{0}'':
-ExclusionPatternDialog.pattern.add=A&dd...
-ExclusionPatternDialog.pattern.add.multiple=Add &Multiple...
-ExclusionPatternDialog.pattern.remove=&Remove
-ExclusionPatternDialog.pattern.edit=&Edit...
-
-ExclusionPatternDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection
-ExclusionPatternDialog.ChooseExclusionPattern.description=&Choose folders or files to exclude:
-
-# ------- ExclusionPatternEntryDialog -------
-
-ExclusionPatternEntryDialog.add.title=Add Exclusion Pattern
-ExclusionPatternEntryDialog.edit.title=Edit Exclusion Pattern
-ExclusionPatternEntryDialog.description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'java/util/A*.java', 'java/util/', '**/Test*'.
-
-ExclusionPatternEntryDialog.pattern.label=E&xclusion pattern (Path relative to ''{0}''):
-ExclusionPatternEntryDialog.pattern.button=Bro&wse...
-
-ExclusionPatternEntryDialog.error.empty=Enter a pattern.
-ExclusionPatternEntryDialog.error.notrelative=Pattern must be a relative path.
-ExclusionPatternEntryDialog.error.exists=Pattern already exists.
-
-ExclusionPatternEntryDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection
-ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude:
-
-# ------- ClasspathContainerDefaultPage-------
-
-ClasspathContainerDefaultPage.title=Classpath Container
-ClasspathContainerDefaultPage.description=Select classpath container path. First segment is the container type.
-
-ClasspathContainerDefaultPage.path.label=&Classpath container path:
-
-ClasspathContainerDefaultPage.path.error.enterpath=Enter path.
-ClasspathContainerDefaultPage.path.error.invalidpath=Invalid path.
-ClasspathContainerDefaultPage.path.error.needssegment=Path needs at least one segment.
-ClasspathContainerDefaultPage.path.error.alreadyexists=Entry already exists.
-
-# ------- ClasspathContainerSelectionPage-------
-
-ClasspathContainerSelectionPage.title=Add Library
-ClasspathContainerSelectionPage.description=Select the library type to add.
-
-# ------- ClasspathContainerWizard-------
-
-ClasspathContainerWizard.pagecreationerror.title= Library Wizard
-ClasspathContainerWizard.pagecreationerror.message=Wizard page creation failed. Check log for details.
-
-
-FolderSelectionDialog.button=Create New Folder...
-CPListLabelProvider.none=(None)
-CPListLabelProvider.source_attachment.label=Source attachment:
-CPListLabelProvider.source_attachment_root.label=Source attachment root:
-CPListLabelProvider.javadoc_location.label=Javadoc location:
-CPListLabelProvider.output_folder.label=Output folder:
-CPListLabelProvider.default_output_folder.label=(Default output folder)
-CPListLabelProvider.exclusion_filter.label=Exclusion filter:
-CPListLabelProvider.exclusion_filter_separator=;
-CPListLabelProvider.unknown_element.label=unknown element
-NewSourceFolderDialog.useproject.button=&Project as source folder
-NewSourceFolderDialog.usefolder.button=&Folder as source folder
-NewSourceFolderDialog.sourcefolder.label=&Source folder name:
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java
deleted file mode 100644
index 5b80966105a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class OpenNewFileWizardAction extends Action implements IWorkbenchWindowActionDelegate {
-
-
- public void run() {
- BasicNewFileResourceWizard wizard= new BasicNewFileResourceWizard();
- wizard.init(CUIPlugin.getDefault().getWorkbench(), getCurrentSelection());
- wizard.setNeedsProgressMonitor(true);
- WizardDialog dialog=
- new WizardDialog(CUIPlugin.getDefault().getActiveWorkbenchShell(), wizard);
- dialog.create();
- dialog.getShell().setText(
- CUIPlugin.getResourceString("OpenNewFileWizardAction.title")); //$NON-NLS-1$
- dialog.open();
- }
-
-
- protected IStructuredSelection getCurrentSelection() {
- IWorkbenchWindow window= CUIPlugin.getDefault().getActiveWorkbenchWindow();
- if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection) selection;
- }
- }
- return StructuredSelection.EMPTY;
- }
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- run();
- }
- /**
- * @see IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- }
- /**
- * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- }
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java
deleted file mode 100644
index 8cb6dcbaa60..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class OpenNewFolderWizardAction extends Action implements IWorkbenchWindowActionDelegate {
-
- public void run() {
- BasicNewFolderResourceWizard wizard= new BasicNewFolderResourceWizard();
- wizard.init(CUIPlugin.getDefault().getWorkbench(), getCurrentSelection());
- wizard.setNeedsProgressMonitor(true);
- WizardDialog dialog=
- new WizardDialog(CUIPlugin.getDefault().getActiveWorkbenchShell(), wizard);
- dialog.create();
- dialog.getShell().setText(
- CUIPlugin.getResourceString("OpenNewFolderWizardAction.title")); //$NON-NLS-1$
- dialog.open();
- }
-
- protected IStructuredSelection getCurrentSelection() {
- IWorkbenchWindow window= CUIPlugin.getDefault().getActiveWorkbenchWindow();
- if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection) selection;
- }
- }
- return StructuredSelection.EMPTY;
- }
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- run();
- }
- /**
- * @see IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- }
- /**
- * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- }
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
deleted file mode 100644
index f87c6135539..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TableViewer;
-
-/**
- * A list with checkboxes and a button bar. Typical buttons are 'Check All' and 'Uncheck All'.
- * List model is independend of widget creation.
- * DialogFields controls are: Label, List and Composite containing buttons.
- */
-public class CheckedListDialogField extends ListDialogField {
-
- private int fCheckAllButtonIndex;
- private int fUncheckAllButtonIndex;
-
- private List fCheckElements;
-
- public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, ILabelProvider lprovider) {
- super(adapter, customButtonLabels, lprovider);
- fCheckElements= new ArrayList();
-
- fCheckAllButtonIndex= -1;
- fUncheckAllButtonIndex= -1;
- }
-
- /**
- * Sets the index of the 'check' button in the button label array passed in the constructor.
- * The behaviour of the button marked as the check button will then be handled internally.
- * (enable state, button invocation behaviour)
- */
- public void setCheckAllButtonIndex(int checkButtonIndex) {
- Assert.isTrue(checkButtonIndex < fButtonLabels.length);
- fCheckAllButtonIndex= checkButtonIndex;
- }
-
- /**
- * Sets the index of the 'uncheck' button in the button label array passed in the constructor.
- * The behaviour of the button marked as the uncheck button will then be handled internally.
- * (enable state, button invocation behaviour)
- */
- public void setUncheckAllButtonIndex(int uncheckButtonIndex) {
- Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
- fUncheckAllButtonIndex= uncheckButtonIndex;
- }
-
-
- /*
- * @see ListDialogField#createTableViewer
- */
- protected TableViewer createTableViewer(Composite parent) {
- Table table= new Table(parent, SWT.CHECK + getListStyle());
- CheckboxTableViewer tableViewer= new CheckboxTableViewer(table);
- tableViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent e) {
- doCheckStateChanged(e);
- }
- });
- return tableViewer;
- }
-
-
- /*
- * @see ListDialogField#getListControl
- */
- public Control getListControl(Composite parent) {
- Control control= super.getListControl(parent);
- if (parent != null) {
- ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray());
- }
- return control;
- }
-
- /*
- * @see DialogField#dialogFieldChanged
- * Hooks in to get element changes to update check model.
- */
- public void dialogFieldChanged() {
- for (int i= fCheckElements.size() -1; i >= 0; i--) {
- if (!fElements.contains(fCheckElements.get(i))) {
- fCheckElements.remove(i);
- }
- }
- super.dialogFieldChanged();
- }
-
- private void checkStateChanged() {
- //call super and do not update check model
- super.dialogFieldChanged();
- }
-
- /**
- * Gets the checked elements.
- */
- public List getCheckedElements() {
- return new ArrayList(fCheckElements);
- }
-
- /**
- * Returns true if the element is checked.
- */
- public boolean isChecked(Object obj) {
- return fCheckElements.contains(obj);
- }
-
- /**
- * Sets the checked elements.
- */
- public void setCheckedElements(List list) {
- fCheckElements= new ArrayList(list);
- if (fTable != null) {
- ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
- }
- checkStateChanged();
- }
-
- /**
- * Sets the checked state of an element.
- */
- public void setChecked(Object object, boolean state) {
- setCheckedWithoutUpdate(object, state);
- checkStateChanged();
- }
-
- /**
- * Sets the checked state of an element. No dialog changed listener is informed.
- */
- public void setCheckedWithoutUpdate(Object object, boolean state) {
- if (!fCheckElements.contains(object)) {
- fCheckElements.add(object);
- }
- if (fTable != null) {
- ((CheckboxTableViewer)fTable).setChecked(object, state);
- }
- }
-
- /**
- * Sets the check state of all elements
- */
- public void checkAll(boolean state) {
- if (state) {
- fCheckElements= getElements();
- } else {
- fCheckElements.clear();
- }
- if (fTable != null) {
- ((CheckboxTableViewer)fTable).setAllChecked(state);
- }
- checkStateChanged();
- }
-
-
- protected void doCheckStateChanged(CheckStateChangedEvent e) {
- if (e.getChecked()) {
- fCheckElements.add(e.getElement());
- } else {
- fCheckElements.remove(e.getElement());
- }
- checkStateChanged();
- }
-
- // ------ enable / disable management
-
- /*
- * @see ListDialogField#getManagedButtonState
- */
- protected boolean getManagedButtonState(ISelection sel, int index) {
- if (index == fCheckAllButtonIndex) {
- return !fElements.isEmpty();
- } else if (index == fUncheckAllButtonIndex) {
- return !fElements.isEmpty();
- }
- return super.getManagedButtonState(sel, index);
- }
-
- /*
- * @see ListDialogField#extraButtonPressed
- */
- protected boolean managedButtonPressed(int index) {
- if (index == fCheckAllButtonIndex) {
- checkAll(true);
- } else if (index == fUncheckAllButtonIndex) {
- checkAll(false);
- } else {
- return super.managedButtonPressed(index);
- }
- return true;
- }
-
-
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
deleted file mode 100644
index 6b2d6333f1a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * Dialog field containing a label and a combo control.
- */
-public class ComboDialogField extends DialogField {
-
- private String fText;
- private int fSelectionIndex;
- private String[] fItems;
- private Combo fComboControl;
- private ModifyListener fModifyListener;
- private int fFlags;
-
- public ComboDialogField(int flags) {
- super();
- fText= ""; //$NON-NLS-1$
- fItems= new String[0];
- fFlags= flags;
- fSelectionIndex= -1;
- }
-
- // ------- layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(1));
- Combo combo= getComboControl(parent);
- combo.setLayoutData(gridDataForCombo(nColumns - 1));
-
- return new Control[] { label, combo };
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 2;
- }
-
- protected static GridData gridDataForCombo(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- return gd;
- }
-
- // ------- focus methods
-
- /*
- * @see DialogField#setFocus
- */
- public boolean setFocus() {
- if (isOkToUse(fComboControl)) {
- fComboControl.setFocus();
- }
- return true;
- }
-
- // ------- ui creation
-
- /**
- * Creates or returns the created combo control.
- * @param parent The parent composite or <code>null</code> when the widget has
- * already been created.
- */
- public Combo getComboControl(Composite parent) {
- if (fComboControl == null) {
- assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doModifyText(e);
- }
- };
- SelectionListener selectionListener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- doSelectionChanged(e);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) { };
- };
-
- fComboControl= new Combo(parent, fFlags);
- // moved up due to 1GEUNW2
- fComboControl.setItems(fItems);
- if (fSelectionIndex != -1) {
- fComboControl.select(fSelectionIndex);
- } else {
- fComboControl.setText(fText);
- }
- fComboControl.setFont(parent.getFont());
- fComboControl.addModifyListener(fModifyListener);
- fComboControl.addSelectionListener(selectionListener);
- fComboControl.setEnabled(isEnabled());
- }
- return fComboControl;
- }
-
- protected void doModifyText(ModifyEvent e) {
- if (isOkToUse(fComboControl)) {
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
- }
- dialogFieldChanged();
- }
-
- protected void doSelectionChanged(SelectionEvent e) {
- if (isOkToUse(fComboControl)) {
- fItems= fComboControl.getItems();
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
- }
- dialogFieldChanged();
- }
-
- // ------ enable / disable management
-
- /*
- * @see DialogField#updateEnableState
- */
- protected void updateEnableState() {
- super.updateEnableState();
- if (isOkToUse(fComboControl)) {
- fComboControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
- /**
- * Gets the combo items.
- */
- public String[] getItems() {
- return fItems;
- }
-
- /**
- * Sets the combo items. Triggers a dialog-changed event.
- */
- public void setItems(String[] items) {
- fItems= items;
- if (isOkToUse(fComboControl)) {
- fComboControl.setItems(items);
- }
- dialogFieldChanged();
- }
-
- /**
- * Gets the text.
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Sets the text. Triggers a dialog-changed event.
- */
- public void setText(String text) {
- fText= text;
- if (isOkToUse(fComboControl)) {
- fComboControl.setText(text);
- } else {
- dialogFieldChanged();
- }
- }
-
- /**
- * Selects an item.
- */
- public void selectItem(int index) {
- if (isOkToUse(fComboControl)) {
- fComboControl.select(index);
- } else {
- if (index >= 0 && index < fItems.length) {
- fText= fItems[index];
- fSelectionIndex= index;
- }
- }
- dialogFieldChanged();
- }
-
- public int getSelectionIndex() {
- return fSelectionIndex;
- }
-
-
- /**
- * Sets the text without triggering a dialog-changed event.
- */
- public void setTextWithoutUpdate(String text) {
- fText= text;
- if (isOkToUse(fComboControl)) {
- fComboControl.removeModifyListener(fModifyListener);
- fComboControl.setText(text);
- fComboControl.addModifyListener(fModifyListener);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
deleted file mode 100644
index 02b0a9dc978..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-
-public class DialogField {
-
- private Label fLabel;
- protected String fLabelText;
-
- private IDialogFieldListener fDialogFieldListener;
-
- private boolean fEnabled;
-
- public DialogField() {
- fEnabled= true;
- fLabel= null;
- fLabelText= ""; //$NON-NLS-1$
- }
-
- /**
- * Sets the label of the dialog field.
- */
- public void setLabelText(String labeltext) {
- fLabelText= labeltext;
- }
-
- // ------ change listener
-
- /**
- * Defines the listener for this dialog field.
- */
- public final void setDialogFieldListener(IDialogFieldListener listener) {
- fDialogFieldListener= listener;
- }
-
- /**
- * Programatical invocation of a dialog field change.
- */
- public void dialogFieldChanged() {
- if (fDialogFieldListener != null) {
- fDialogFieldListener.dialogFieldChanged(this);
- }
- }
-
- // ------- focus management
-
- /**
- * Tries to set the focus to the dialog field.
- * Returns <code>true</code> if the dialog field can take focus.
- * To be reimplemented by dialog field implementors.
- */
- public boolean setFocus() {
- return false;
- }
-
- /**
- * Posts <code>setFocus</code> to the display event queue.
- */
- public void postSetFocusOnDialogField(Display display) {
- if (display != null) {
- display.asyncExec(
- new Runnable() {
- public void run() {
- setFocus();
- }
- }
- );
- }
- }
-
- // ------- layout helpers
-
- /**
- * Creates all controls of the dialog field and fills it to a composite.
- * The composite is assumed to have <code>MGridLayout</code> as
- * layout.
- * The dialog field will adjust its controls' spans to the number of columns given.
- * To be reimplemented by dialog field implementors.
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(nColumns));
-
- return new Control[] { label };
- }
-
- /**
- * Returns the number of columns of the dialog field.
- * To be reimplemented by dialog field implementors.
- */
- public int getNumberOfControls() {
- return 1;
- }
-
- protected static GridData gridDataForLabel(int span) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= span;
- return gd;
- }
-
- // ------- ui creation
-
- /**
- * Creates or returns the created label widget.
- * @param parent The parent composite or <code>null</code> if the widget has
- * already been created.
- */
- public Label getLabelControl(Composite parent) {
- if (fLabel == null) {
- assertCompositeNotNull(parent);
-
- fLabel= new Label(parent, SWT.LEFT | SWT.WRAP);
- fLabel.setFont(parent.getFont());
- fLabel.setEnabled(fEnabled);
- if (fLabelText != null && !"".equals(fLabelText)) { //$NON-NLS-1$
- fLabel.setText(fLabelText);
- } else {
- // XXX: to avoid a 16 pixel wide empty label - revisit
- fLabel.setText("."); //$NON-NLS-1$
- fLabel.setVisible(false);
- }
- }
- return fLabel;
- }
-
- /**
- * Creates a spacer control.
- * @param parent The parent composite
- */
- public static Control createEmptySpace(Composite parent) {
- return createEmptySpace(parent, 1);
- }
-
- /**
- * Creates a spacer control with the given span.
- * The composite is assumed to have <code>MGridLayout</code> as
- * layout.
- * @param parent The parent composite
- */
- public static Control createEmptySpace(Composite parent, int span) {
- Label label= new Label(parent, SWT.LEFT);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.horizontalIndent= 0;
- gd.widthHint= 0;
- gd.heightHint= 0;
- label.setLayoutData(gd);
- return label;
- }
-
- /**
- * Tests is the control is not <code>null</code> and not disposed.
- */
- protected final boolean isOkToUse(Control control) {
- return (control != null) && !(control.isDisposed());
- }
-
- // --------- enable / disable management
-
- /**
- * Sets the enable state of the dialog field.
- */
- public final void setEnabled(boolean enabled) {
- if (enabled != fEnabled) {
- fEnabled= enabled;
- updateEnableState();
- }
- }
-
- /**
- * Called when the enable state changed.
- * To be extended by dialog field implementors.
- */
- protected void updateEnableState() {
- if (fLabel != null) {
- fLabel.setEnabled(fEnabled);
- }
- }
-
- /**
- * Gets the enable state of the dialog field.
- */
- public final boolean isEnabled() {
- return fEnabled;
- }
-
- protected final void assertCompositeNotNull(Composite comp) {
- Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
- }
-
- protected final void assertEnoughColumns(int nColumns) {
- Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$
- }
-
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
deleted file mode 100644
index 65ef15bc79f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-public interface IDialogFieldListener {
-
- void dialogFieldChanged(DialogField field);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
deleted file mode 100644
index 50c50d8ea53..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/**
- * Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
- */
-public interface IListAdapter {
-
- /**
- * A button from the button bar has been pressed.
- */
- void customButtonPressed(ListDialogField field, int index);
-
- /**
- * The selection of the list has changed.
- */
- void selectionChanged(ListDialogField field);
-
- /**
- * En entry in the list has been double clicked
- */
- void doubleClicked(ListDialogField field);
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
deleted file mode 100644
index 0f59e6736e1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-public interface IStringButtonAdapter {
-
- void changeControlPressed(DialogField field);
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
deleted file mode 100644
index cfb7cd8c9a9..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-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.Control;
-
-public class LayoutUtil {
-
- /**
- * Calculates the number of columns needed by field editors
- */
- public static int getNumberOfColumns(DialogField[] editors) {
- int nCulumns= 0;
- for (int i= 0; i < editors.length; i++) {
- nCulumns= Math.max(editors[i].getNumberOfControls(), nCulumns);
- }
- return nCulumns;
- }
-
- /**
- * Creates a composite and fills in the given editors.
- * @param labelOnTop Defines if the label of all fields should be on top of the fields
- */
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) {
- doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0);
- }
-
- /**
- * Creates a composite and fills in the given editors.
- * @param labelOnTop Defines if the label of all fields should be on top of the fields
- * @param minWidth The minimal width of the composite
- * @param minHeight The minimal height of the composite
- */
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight) {
- doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
- }
-
- /**
- * Creates a composite and fills in the given editors.
- * @param labelOnTop Defines if the label of all fields should be on top of the fields
- * @param minWidth The minimal width of the composite
- * @param minHeight The minimal height of the composite
- * @param marginWidth The margin width to be used by the composite
- * @param marginHeight The margin height to be used by the composite
- * @deprecated
- */
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight, int marginWidth, int marginHeight) {
- int nCulumns= getNumberOfColumns(editors);
- Control[][] controls= new Control[editors.length][];
- for (int i= 0; i < editors.length; i++) {
- controls[i]= editors[i].doFillIntoGrid(parent, nCulumns);
- }
- if (labelOnTop) {
- nCulumns--;
- modifyLabelSpans(controls, nCulumns);
- }
- GridLayout layout= new GridLayout();
- if (marginWidth != SWT.DEFAULT) {
- layout.marginWidth= marginWidth;
- }
- if (marginHeight != SWT.DEFAULT) {
- layout.marginHeight= marginHeight;
- }
- layout.numColumns= nCulumns;
- parent.setLayout(layout);
- }
-
- private static void modifyLabelSpans(Control[][] controls, int nCulumns) {
- for (int i= 0; i < controls.length; i++) {
- setHorizontalSpan(controls[i][0], nCulumns);
- }
- }
-
- /**
- * Sets the span of a control. Assumes that GridData is used.
- */
- public static void setHorizontalSpan(Control control, int span) {
- Object ld= control.getLayoutData();
- if (ld instanceof GridData) {
- ((GridData)ld).horizontalSpan= span;
- } else if (span != 1) {
- GridData gd= new GridData();
- gd.horizontalSpan= span;
- control.setLayoutData(gd);
- }
- }
-
- /**
- * Sets the width hint of a control. Assumes that GridData is used.
- */
- public static void setWidthHint(Control control, int widthHint) {
- Object ld= control.getLayoutData();
- if (ld instanceof GridData) {
- ((GridData)ld).widthHint= widthHint;
- }
- }
-
- /**
- * Sets the heigthHint hint of a control. Assumes that GridData is used.
- */
- public static void setHeigthHint(Control control, int heigthHint) {
- Object ld= control.getLayoutData();
- if (ld instanceof GridData) {
- ((GridData)ld).heightHint= heigthHint;
- }
- }
-
- /**
- * Sets the horizontal indent of a control. Assumes that GridData is used.
- */
- public static void setHorizontalIndent(Control control, int horizontalIndent) {
- Object ld= control.getLayoutData();
- if (ld instanceof GridData) {
- ((GridData)ld).horizontalIndent= horizontalIndent;
- }
- }
-
- /**
- * Sets the horizontal indent of a control. Assumes that GridData is used.
- */
- public static void setHorizontalGrabbing(Control control) {
- Object ld= control.getLayoutData();
- if (ld instanceof GridData) {
- ((GridData)ld).grabExcessHorizontalSpace= true;
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
deleted file mode 100644
index 15146e86cef..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-import java.io.File;
-
-import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
-import org.eclipse.core.resources.IPathVariableManager;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.dialogs.IDialogConstants;
-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.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.ide.dialogs.PathVariableSelectionDialog;
-
-/**
- */
-public class LinkToFileGroup extends StringButtonDialogField {
- private String fText;
- protected Listener listener;
- private String initialLinkTarget;
- private int type;
- protected boolean createLink = false;
-
- // used to compute layout sizes
- //private FontMetrics fontMetrics;
-
- // widgets
- //private Composite groupComposite;
- protected Text linkTargetField;
- protected Button linkButton;
- protected Button browseButton;
- protected Button variablesButton;
- private Label resolvedPathLabelText;
- private Label resolvedPathLabelData;
-
- public LinkToFileGroup(IStringButtonAdapter adapter, Listener listener) {
- super(adapter);
- this.listener = listener;
- this.type = IResource.FILE;
- }
-
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
- //initializeDialogUnits(parent);
-
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(1));
-
- getLinkCheckButtonControl(parent);
-
- Text text= getTextControl(parent);
- text.setLayoutData(gridDataForText(1));
-
- Button browseButton = getBrowseButtonControl(parent);
- browseButton.setLayoutData(gridDataForButton(browseButton, 1));
-
- Button variablesButton = getVariablesButtonControl(parent);
- variablesButton.setLayoutData(gridDataForButton(variablesButton, 1));
-
- DialogField.createEmptySpace(parent);
-
- resolvedPathLabelText = new Label(parent, SWT.SINGLE);
- resolvedPathLabelText.setText(WorkbenchMessages.getString("CreateLinkedResourceGroup.resolvedPathLabel")); //$NON-NLS-1$
- resolvedPathLabelText.setVisible(true);
-
- resolvedPathLabelData = new Label(parent, SWT.SINGLE);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 3;
- resolvedPathLabelData.setLayoutData(data);
- resolvedPathLabelData.setVisible(true);
-
- return null;
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 5;
- }
-
- public Button getLinkCheckButtonControl(Composite parent){
- if(linkButton == null){
- linkButton = new Button(parent, SWT.CHECK);
- linkButton.setText(NewWizardMessages.getString("NewClassWizardPage.files.linkFileButton")); //$NON-NLS-1$
- linkButton.setSelection(createLink);
- linkButton.setFont(parent.getFont());
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- createLink = linkButton.getSelection();
- browseButton.setEnabled(createLink);
- variablesButton.setEnabled(createLink);
- linkTargetField.setEnabled(createLink);
- if (listener != null)
- listener.handleEvent(new Event());
- }
- };
- linkButton.addSelectionListener(selectionListener);
- }
- return linkButton;
- }
-
- public String getText() {
- return linkTargetField.getText();
- }
-
- public void setText(String text) {
- fText= text;
- if (isOkToUse(linkTargetField)) {
- linkTargetField.setText(text);
- } else {
- dialogFieldChanged();
- }
- }
-
- public Text getTextControl(Composite parent){
- if(linkTargetField == null){
- assertCompositeNotNull(parent);
- linkTargetField = new Text(parent, SWT.BORDER);
- linkTargetField.setFont(parent.getFont());
- linkTargetField.setEnabled(createLink);
- linkTargetField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- resolveVariable();
- if (listener != null)
- listener.handleEvent(new Event());
- }
- });
- if (initialLinkTarget != null)
- linkTargetField.setText(initialLinkTarget);
- }
- return linkTargetField;
- }
-
- public static GridData gridDataForText(int span){
- GridData data = new GridData();
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- data.horizontalAlignment= GridData.FILL;
- data.grabExcessHorizontalSpace= false;
- data.horizontalSpan= span;
- return data;
- }
-
- public Button getBrowseButtonControl(Composite parent){
- // browse button
- if(browseButton == null){
- assertCompositeNotNull(parent);
- browseButton = new Button(parent, SWT.PUSH);
- //setButtonLayoutData(browseButton);
- browseButton.setFont(parent.getFont());
- browseButton.setText(WorkbenchMessages.getString("CreateLinkedResourceGroup.browseButton")); //$NON-NLS-1$
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleLinkTargetBrowseButtonPressed();
- }
- });
- browseButton.setEnabled(createLink);
- }
- return browseButton;
- }
-
- public Button getVariablesButtonControl(Composite parent){
- // variables button
- if(variablesButton == null){
- assertCompositeNotNull(parent);
- variablesButton = new Button(parent, SWT.PUSH);
- //setButtonLayoutData(variablesButton);
- variablesButton.setFont(parent.getFont());
- variablesButton.setText(WorkbenchMessages.getString("CreateLinkedResourceGroup.variablesButton")); //$NON-NLS-1$
- variablesButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleVariablesButtonPressed();
- }
- });
- variablesButton.setEnabled(createLink);
- }
- return variablesButton;
- }
- /**
- * Returns a new status object with the given severity and message.
- *
- * @return a new status object with the given severity and message.
- */
- private IStatus createStatus(int severity, String message) {
- return new Status(
- severity,
- WorkbenchPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- severity,
- message,
- null);
- }
- /**
- * Returns the link target location entered by the user.
- *
- * @return the link target location entered by the user. null if the user
- * chose not to create a link.
- */
- public String getLinkTarget() {
- if (createLink && linkTargetField != null && linkTargetField.isDisposed() == false)
- return linkTargetField.getText();
-
- return null;
- }
-
- public String getResolvedPath() {
- if (createLink && resolvedPathLabelData != null && resolvedPathLabelData.isDisposed() == false)
- return resolvedPathLabelData.getText();
-
- return null;
- }
-
- /**
- * Opens a file or directory browser depending on the link type.
- */
- protected void handleLinkTargetBrowseButtonPressed() {
- String linkTargetName = linkTargetField.getText();
- File file = null;
- String selection = null;
-
- if ("".equals(linkTargetName) == false) { //$NON-NLS-1$
- file = new File(linkTargetName);
- if (file.exists() == false)
- file = null;
- }
- if (type == IResource.FILE) {
- FileDialog dialog = new FileDialog(linkTargetField.getShell());
- if (file != null) {
- if (file.isFile())
- dialog.setFileName(linkTargetName);
- else
- dialog.setFilterPath(linkTargetName);
- }
- selection = dialog.open();
- }
- else {
- DirectoryDialog dialog = new DirectoryDialog(linkTargetField.getShell());
- if (file != null) {
- if (file.isFile())
- linkTargetName = file.getParent();
- if (linkTargetName != null)
- dialog.setFilterPath(linkTargetName);
- }
- dialog.setMessage(WorkbenchMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$
- selection = dialog.open();
- }
- if (selection != null)
- linkTargetField.setText(selection);
- }
- /**
- * Opens a path variable selection dialog
- */
- protected void handleVariablesButtonPressed() {
- int variableTypes = IResource.FOLDER;
-
- // allow selecting file and folder variables when creating a
- // linked file
- if (type == IResource.FILE)
- variableTypes |= IResource.FILE;
-
- PathVariableSelectionDialog dialog =
- new PathVariableSelectionDialog(linkTargetField.getShell(), variableTypes);
- if (dialog.open() == IDialogConstants.OK_ID) {
- String[] variableNames = (String[]) dialog.getResult();
- if (variableNames != null && variableNames.length == 1)
- linkTargetField.setText(variableNames[0]);
- }
- }
- /**
- * Tries to resolve the value entered in the link target field as
- * a variable, if the value is a relative path.
- * Displays the resolved value if the entered value is a variable.
- */
- protected void resolveVariable() {
- if(!linkTargetField.isEnabled())
- return;
-
- IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
- IPath path = new Path(linkTargetField.getText());
- IPath resolvedPath = pathVariableManager.resolvePath(path);
-
- /* (path.equals(resolvedPath)) {
- resolvedPathLabelText.setVisible(false);
- resolvedPathLabelData.setVisible(false);
- } else {
- resolvedPathLabelText.setVisible(true);
- resolvedPathLabelData.setVisible(true);
- }
- */
- resolvedPathLabelData.setText(resolvedPath.toOSString());
- }
- /**
- * Sets the value of the link target field
- *
- * @param target the value of the link target field
- */
- public void setLinkTarget(String target) {
- initialLinkTarget = target;
- if (linkTargetField != null && linkTargetField.isDisposed() == false)
- linkTargetField.setText(target);
- }
- /**
- * Validates the type of the given file against the link type specified
- * in the constructor.
- *
- * @param linkTargetFile file to validate
- * @return IStatus indicating the validation result. IStatus.OK if the
- * given file is valid.
- */
- private IStatus validateFileType(File linkTargetFile) {
- if (type == IResource.FILE && linkTargetFile.isFile() == false) {
- return createStatus(
- IStatus.ERROR,
- WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNotFile")); //$NON-NLS-1$
- } else if (type == IResource.FOLDER && linkTargetFile.isDirectory() == false) {
- return createStatus(
- IStatus.ERROR,
- WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNotFolder")); //$NON-NLS-1$
- }
- return createStatus(IStatus.OK, ""); //$NON-NLS-1$
- }
- /**
- * Validates this page's controls.
- *
- * @return IStatus indicating the validation result. IStatus.OK if the
- * specified link target is valid given the linkHandle.
- */
- public IStatus validateLinkLocation(IResource linkHandle) {
- if (linkTargetField == null || linkTargetField.isDisposed())
- return createStatus(IStatus.OK, ""); //$NON-NLS-1$
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- String linkTargetName = linkTargetField.getText();
- IPath path = new Path(linkTargetName);
-
- if (createLink == false)
- return createStatus(IStatus.OK, ""); //$NON-NLS-1$
-
- IStatus locationStatus = workspace.validateLinkLocation(linkHandle, path);
- if (locationStatus.getSeverity() == IStatus.ERROR)
- return locationStatus;
-
- // use the resolved link target name
- linkTargetName = resolvedPathLabelData.getText();
- path = new Path(linkTargetName);
- File linkTargetFile = new Path(linkTargetName).toFile();
- if (linkTargetFile.exists()) {
- IStatus fileTypeStatus = validateFileType(linkTargetFile);
- if (fileTypeStatus.isOK() == false)
- return fileTypeStatus;
- } else if (locationStatus.getSeverity() == IStatus.OK) {
- // locationStatus takes precedence over missing location warning.
- return createStatus(
- IStatus.WARNING,
- WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNonExistent")); //$NON-NLS-1$
- }
- return locationStatus;
- }
-
- public boolean linkCreated (){
- return createLink;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
deleted file mode 100644
index db326ad9ff3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
+++ /dev/null
@@ -1,894 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.cdt.internal.ui.util.PixelConverter;
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
-
-/**
- * A list with a button bar.
- * Typical buttons are 'Add', 'Remove', 'Up' and 'Down'.
- * List model is independend of widget creation.
- * DialogFields controls are: Label, List and Composite containing buttons.
- */
-public class ListDialogField extends DialogField {
-
- public static class ColumnsDescription {
- protected ColumnLayoutData[] columns;
- protected String[] headers;
- protected boolean drawLines;
-
- public ColumnsDescription(ColumnLayoutData[] columns, String[] headers, boolean drawLines) {
- this.columns= columns;
- this.headers= headers;
- this.drawLines= drawLines;
- }
-
- public ColumnsDescription(String[] headers, boolean drawLines) {
- this(createColumnWeightData(headers.length), headers, drawLines);
- }
-
- public ColumnsDescription(int nColumns, boolean drawLines) {
- this(createColumnWeightData(nColumns), null, drawLines);
- }
-
- private static ColumnLayoutData[] createColumnWeightData(int nColumns) {
- ColumnLayoutData[] data= new ColumnLayoutData[nColumns];
- for (int i= 0; i < nColumns; i++) {
- data[i]= new ColumnWeightData(1);
- }
- return data;
- }
- }
-
- protected TableViewer fTable;
- protected ILabelProvider fLabelProvider;
- protected ListViewerAdapter fListViewerAdapter;
- protected List fElements;
- protected ViewerSorter fViewerSorter;
-
- protected String[] fButtonLabels;
- private Button[] fButtonControls;
-
- private boolean[] fButtonsEnabled;
-
- private int fRemoveButtonIndex;
- private int fUpButtonIndex;
- private int fDownButtonIndex;
-
- private Label fLastSeparator;
-
- protected Control fTableControl;
- private Composite fButtonsControl;
- private ISelection fSelectionWhenEnabled;
-
- private IListAdapter fListAdapter;
-
- private Object fParentElement;
-
- protected ColumnsDescription fTableColumns;
-
-
- /**
- * Creates the <code>ListDialogField</code>.
- * @param adapter A listener for button invocation, selection changes. Can
- * be <code>null</code>.
- * @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and
- * marks a separator.
- * @param lprovider The label provider to render the table entries
- */
- public ListDialogField(IListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider) {
- super();
- fListAdapter= adapter;
-
- fLabelProvider= lprovider;
- fListViewerAdapter= new ListViewerAdapter();
- fParentElement= this;
-
- fElements= new ArrayList(10);
-
- fButtonLabels= buttonLabels;
- if (fButtonLabels != null) {
- int nButtons= fButtonLabels.length;
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsEnabled[i]= true;
- }
- }
-
- fTable= null;
- fTableControl= null;
- fButtonsControl= null;
- fTableColumns= null;
-
- fRemoveButtonIndex= -1;
- fUpButtonIndex= -1;
- fDownButtonIndex= -1;
- }
-
- /**
- * Sets the index of the 'remove' button in the button label array passed in the constructor.
- * The behaviour of the button marked as the 'remove' button will then be handled internally.
- * (enable state, button invocation behaviour)
- */
- public void setRemoveButtonIndex(int removeButtonIndex) {
- Assert.isTrue(removeButtonIndex < fButtonLabels.length);
- fRemoveButtonIndex= removeButtonIndex;
- }
-
- /**
- * Sets the index of the 'up' button in the button label array passed in the constructor.
- * The behaviour of the button marked as the 'up' button will then be handled internally.
- * (enable state, button invocation behaviour)
- */
- public void setUpButtonIndex(int upButtonIndex) {
- Assert.isTrue(upButtonIndex < fButtonLabels.length);
- fUpButtonIndex= upButtonIndex;
- }
-
- /**
- * Sets the index of the 'down' button in the button label array passed in the constructor.
- * The behaviour of the button marked as the 'down' button will then be handled internally.
- * (enable state, button invocation behaviour)
- */
- public void setDownButtonIndex(int downButtonIndex) {
- Assert.isTrue(downButtonIndex < fButtonLabels.length);
- fDownButtonIndex= downButtonIndex;
- }
-
- /**
- * Sets the viewerSorter.
- * @param viewerSorter The viewerSorter to set
- */
- public void setViewerSorter(ViewerSorter viewerSorter) {
- fViewerSorter= viewerSorter;
- }
-
- public void setTableColumns(ColumnsDescription column) {
- fTableColumns= column;
- }
-
-
-
- // ------ adapter communication
-
- private void buttonPressed(int index) {
- if (!managedButtonPressed(index) && fListAdapter != null) {
- fListAdapter.customButtonPressed(this, index);
- }
- }
-
- /**
- * Checks if the button pressed is handled internally
- * @return Returns true if button has been handled.
- */
- protected boolean managedButtonPressed(int index) {
- if (index == fRemoveButtonIndex) {
- remove();
- } else if (index == fUpButtonIndex) {
- up();
- } else if (index == fDownButtonIndex) {
- down();
- } else {
- return false;
- }
- return true;
- }
-
-
- // ------ layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- PixelConverter converter= new PixelConverter(parent);
-
- assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- GridData gd= gridDataForLabel(1);
- gd.verticalAlignment= GridData.BEGINNING;
- label.setLayoutData(gd);
-
- Control list= getListControl(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= nColumns - 2;
- gd.widthHint= converter.convertWidthInCharsToPixels(50);
- gd.heightHint= converter.convertHeightInCharsToPixels(6);
-
- list.setLayoutData(gd);
-
- Composite buttons= getButtonBox(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= 1;
- buttons.setLayoutData(gd);
-
- return new Control[] { label, list, buttons };
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 3;
- }
-
- /**
- * Sets the minimal width of the buttons. Must be called after widget creation.
- */
- public void setButtonsMinWidth(int minWidth) {
- if (fLastSeparator != null) {
- ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth;
- }
- }
-
-
- // ------ ui creation
-
- /**
- * Returns the list control. When called the first time, the control will be created.
- * @param The parent composite when called the first time, or <code>null</code>
- * after.
- */
- public Control getListControl(Composite parent) {
- if (fTableControl == null) {
- assertCompositeNotNull(parent);
-
- if (fTableColumns == null) {
- fTable= createTableViewer(parent);
- Table tableControl= fTable.getTable();
-
- fTableControl= tableControl;
- tableControl.setLayout(new TableLayout());
- } else {
- TableLayoutComposite composite= new TableLayoutComposite(parent, SWT.NONE);
- fTableControl= composite;
-
- fTable= createTableViewer(composite);
- Table tableControl= fTable.getTable();
-
- tableControl.setHeaderVisible(fTableColumns.headers != null);
- tableControl.setLinesVisible(fTableColumns.drawLines);
- ColumnLayoutData[] columns= fTableColumns.columns;
- for (int i= 0; i < columns.length; i++) {
- composite.addColumnData(columns[i]);
- TableColumn column= new TableColumn(tableControl, SWT.NONE);
- //tableLayout.addColumnData(columns[i]);
- if (fTableColumns.headers != null) {
- column.setText(fTableColumns.headers[i]);
- }
- }
- }
-
- fTable.getTable().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
- });
-
- //fTableControl.setLayout(tableLayout);
-
- fTable.setContentProvider(fListViewerAdapter);
- fTable.setLabelProvider(fLabelProvider);
- fTable.addSelectionChangedListener(fListViewerAdapter);
- fTable.addDoubleClickListener(fListViewerAdapter);
-
- fTable.setInput(fParentElement);
-
- if (fViewerSorter != null) {
- fTable.setSorter(fViewerSorter);
- }
-
- fTableControl.setEnabled(isEnabled());
- if (fSelectionWhenEnabled != null) {
- postSetSelection(fSelectionWhenEnabled);
- }
- }
- return fTableControl;
- }
-
- /**
- * Returns the internally used table viewer.
- */
- public TableViewer getTableViewer() {
- return fTable;
- }
-
- /*
- * Subclasses may override to specify a different style.
- */
- protected int getListStyle(){
- int style= SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ;
- if (fTableColumns != null) {
- style |= SWT.FULL_SELECTION;
- }
- return style;
- }
-
- protected TableViewer createTableViewer(Composite parent) {
- Table table= new Table(parent, getListStyle());
- return new TableViewer(table);
- }
-
- protected Button createButton(Composite parent, String label, SelectionListener listener) {
- Button button= new Button(parent, SWT.PUSH);
- button.setText(label);
- button.addSelectionListener(listener);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint = SWTUtil.getButtonHeigthHint(button);
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
-
- button.setLayoutData(gd);
- return button;
- }
-
- private Label createSeparator(Composite parent) {
- Label separator= new Label(parent, SWT.NONE);
- separator.setVisible(false);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= 4;
- separator.setLayoutData(gd);
- return separator;
- }
-
- /**
- * Returns the composite containing the buttons. When called the first time, the control
- * will be created.
- * @param The parent composite when called the first time, or <code>null</code>
- * after.
- */
- public Composite getButtonBox(Composite parent) {
- if (fButtonsControl == null) {
- assertCompositeNotNull(parent);
-
- SelectionListener listener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- doButtonSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- doButtonSelected(e);
- }
- };
-
- Composite contents= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- contents.setLayout(layout);
-
- if (fButtonLabels != null) {
- fButtonControls= new Button[fButtonLabels.length];
- for (int i= 0; i < fButtonLabels.length; i++) {
- String currLabel= fButtonLabels[i];
- if (currLabel != null) {
- fButtonControls[i]= createButton(contents, currLabel, listener);
- fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
- } else {
- fButtonControls[i]= null;
- createSeparator(contents);
- }
- }
- }
-
- fLastSeparator= createSeparator(contents);
-
- updateButtonState();
- fButtonsControl= contents;
- }
-
- return fButtonsControl;
- }
-
- protected void doButtonSelected(SelectionEvent e) {
- if (fButtonControls != null) {
- for (int i= 0; i < fButtonControls.length; i++) {
- if (e.widget == fButtonControls[i]) {
- buttonPressed(i);
- return;
- }
- }
- }
- }
-
- /**
- * Handles key events in the table viewer. Specifically
- * when the delete key is pressed.
- */
- protected void handleKeyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- if (fRemoveButtonIndex != -1 && isButtonEnabled(fTable.getSelection(), fRemoveButtonIndex)) {
- managedButtonPressed(fRemoveButtonIndex);
- }
- }
- }
-
- // ------ enable / disable management
-
- /*
- * @see DialogField#dialogFieldChanged
- */
- public void dialogFieldChanged() {
- super.dialogFieldChanged();
- updateButtonState();
- }
-
- /*
- * Updates the enable state of the all buttons
- */
- protected void updateButtonState() {
- if (fButtonControls != null) {
- ISelection sel= fTable.getSelection();
- for (int i= 0; i < fButtonControls.length; i++) {
- Button button= fButtonControls[i];
- if (isOkToUse(button)) {
- button.setEnabled(isButtonEnabled(sel, i));
- }
- }
- }
- }
-
- protected boolean getManagedButtonState(ISelection sel, int index) {
- if (index == fRemoveButtonIndex) {
- return !sel.isEmpty();
- } else if (index == fUpButtonIndex) {
- return !sel.isEmpty() && canMoveUp();
- } else if (index == fDownButtonIndex) {
- return !sel.isEmpty() && canMoveDown();
- }
- return true;
- }
-
- /*
- * @see DialogField#updateEnableState
- */
- protected void updateEnableState() {
- super.updateEnableState();
-
- boolean enabled= isEnabled();
- if (isOkToUse(fTableControl)) {
- if (!enabled) {
- fSelectionWhenEnabled= fTable.getSelection();
- selectElements(null);
- } else {
- selectElements(fSelectionWhenEnabled);
- fSelectionWhenEnabled= null;
- }
- fTableControl.setEnabled(enabled);
- }
- updateButtonState();
- }
-
- /**
- * Sets a button enabled or disabled.
- */
- public void enableButton(int index, boolean enable) {
- if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
- updateButtonState();
- }
- }
-
- private boolean isButtonEnabled(ISelection sel, int index) {
- boolean extraState= getManagedButtonState(sel, index);
- return isEnabled() && extraState && fButtonsEnabled[index];
- }
-
-
- // ------ model access
-
- /**
- * Sets the elements shown in the list.
- */
- public void setElements(List elements) {
- fElements= new ArrayList(elements);
- if (fTable != null) {
- fTable.refresh();
- }
- dialogFieldChanged();
- }
-
- /**
- * Gets the elements shown in the list.
- * The list returned is a copy, so it can be modified by the user.
- */
- public List getElements() {
- return new ArrayList(fElements);
- }
-
- /**
- * Gets the elements shown at the given index.
- */
- public Object getElement(int index) {
- return fElements.get(index);
- }
-
- /**
- * Gets the index of an element in the list or -1 if element is not in list.
- */
- public int getIndexOfElement(Object elem) {
- return fElements.indexOf(elem);
- }
-
- /**
- * Replace an element.
- */
- public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException {
- int idx= fElements.indexOf(oldElement);
- if (idx != -1) {
- fElements.set(idx, newElement);
- if (fTable != null) {
- List selected= getSelectedElements();
- if (selected.remove(oldElement)) {
- selected.add(newElement);
- }
- fTable.refresh();
- selectElements(new StructuredSelection(selected));
- }
- dialogFieldChanged();
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Adds an element at the end of the list.
- */
- public void addElement(Object element) {
- if (fElements.contains(element)) {
- return;
- }
- fElements.add(element);
- if (fTable != null) {
- fTable.add(element);
- }
- dialogFieldChanged();
- }
-
- /**
- * Adds elements at the end of the list.
- */
- public void addElements(List elements) {
- int nElements= elements.size();
-
- if (nElements > 0) {
- // filter duplicated
- ArrayList elementsToAdd= new ArrayList(nElements);
-
- for (int i= 0; i < nElements; i++) {
- Object elem= elements.get(i);
- if (!fElements.contains(elem)) {
- elementsToAdd.add(elem);
- }
- }
- fElements.addAll(elementsToAdd);
- if (fTable != null) {
- fTable.add(elementsToAdd.toArray());
- }
- dialogFieldChanged();
- }
- }
-
- /**
- * Adds an element at a position.
- */
- public void insertElementAt(Object element, int index) {
- if (fElements.contains(element)) {
- return;
- }
- fElements.add(index, element);
- if (fTable != null) {
- fTable.add(element);
- }
-
- dialogFieldChanged();
- }
-
-
- /**
- * Adds an element at a position.
- */
- public void removeAllElements() {
- if (fElements.size() > 0) {
- fElements.clear();
- if (fTable != null) {
- fTable.refresh();
- }
- dialogFieldChanged();
- }
- }
-
- /**
- * Removes an element from the list.
- */
- public void removeElement(Object element) throws IllegalArgumentException {
- if (fElements.remove(element)) {
- if (fTable != null) {
- fTable.remove(element);
- }
- dialogFieldChanged();
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Removes elements from the list.
- */
- public void removeElements(List elements) {
- if (elements.size() > 0) {
- fElements.removeAll(elements);
- if (fTable != null) {
- fTable.remove(elements.toArray());
- }
- dialogFieldChanged();
- }
- }
-
- /**
- * Gets the number of elements
- */
- public int getSize() {
- return fElements.size();
- }
-
-
- public void selectElements(ISelection selection) {
- fSelectionWhenEnabled= selection;
- if (fTable != null) {
- fTable.setSelection(selection, true);
- }
- }
-
- public void selectFirstElement() {
- Object element= null;
- if (fViewerSorter != null) {
- Object[] arr= fElements.toArray();
- fViewerSorter.sort(fTable, arr);
- if (arr.length > 0) {
- element= arr[0];
- }
- } else {
- if (fElements.size() > 0) {
- element= fElements.get(0);
- }
- }
- if (element != null) {
- selectElements(new StructuredSelection(element));
- }
- }
-
-
- public void postSetSelection(final ISelection selection) {
- if (isOkToUse(fTableControl)) {
- Display d= fTableControl.getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- if (isOkToUse(fTableControl)) {
- selectElements(selection);
- }
- }
- });
- }
- }
-
- /**
- * Refreshes the table.
- */
- public void refresh() {
- if (fTable != null) {
- fTable.refresh();
- }
- }
-
- // ------- list maintenance
-
- private List moveUp(List elements, List move) {
- int nElements= elements.size();
- List res= new ArrayList(nElements);
- Object floating= null;
- for (int i= 0; i < nElements; i++) {
- Object curr= elements.get(i);
- if (move.contains(curr)) {
- res.add(curr);
- } else {
- if (floating != null) {
- res.add(floating);
- }
- floating= curr;
- }
- }
- if (floating != null) {
- res.add(floating);
- }
- return res;
- }
-
- private void moveUp(List toMoveUp) {
- if (toMoveUp.size() > 0) {
- setElements(moveUp(fElements, toMoveUp));
- fTable.reveal(toMoveUp.get(0));
- }
- }
-
- private void moveDown(List toMoveDown) {
- if (toMoveDown.size() > 0) {
- setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
- fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
- }
- }
-
- private List reverse(List p) {
- List reverse= new ArrayList(p.size());
- for (int i= p.size()-1; i >= 0; i--) {
- reverse.add(p.get(i));
- }
- return reverse;
- }
-
-
- private void remove() {
- removeElements(getSelectedElements());
- }
-
- private void up() {
- moveUp(getSelectedElements());
- }
-
- private void down() {
- moveDown(getSelectedElements());
- }
-
- private boolean canMoveUp() {
- if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- for (int i= 0; i < indc.length; i++) {
- if (indc[i] != i) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean canMoveDown() {
- if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- int k= fElements.size() - 1;
- for (int i= indc.length - 1; i >= 0 ; i--, k--) {
- if (indc[i] != k) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Returns the selected elements.
- */
- public List getSelectedElements() {
- List result= new ArrayList();
- if (fTable != null) {
- ISelection selection= fTable.getSelection();
- if (selection instanceof IStructuredSelection) {
- Iterator iter= ((IStructuredSelection)selection).iterator();
- while (iter.hasNext()) {
- result.add(iter.next());
- }
- }
- }
- return result;
- }
-
- // ------- ListViewerAdapter
-
- private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
-
- // ------- ITableContentProvider Interface ------------
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // will never happen
- }
-
- public boolean isDeleted(Object element) {
- return false;
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object obj) {
- return fElements.toArray();
- }
-
- // ------- ISelectionChangedListener Interface ------------
-
- public void selectionChanged(SelectionChangedEvent event) {
- doListSelected(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- public void doubleClick(DoubleClickEvent event) {
- doDoubleClick(event);
- }
-
- }
-
-
- protected void doListSelected(SelectionChangedEvent event) {
- updateButtonState();
- if (fListAdapter != null) {
- fListAdapter.selectionChanged(this);
- }
- }
-
- protected void doDoubleClick(DoubleClickEvent event) {
- if (fListAdapter != null) {
- fListAdapter.doubleClicked(this);
- }
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
deleted file mode 100644
index a69f1fb3330..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-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.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-
-/**
- * Dialog Field containing a single button such as a radio or checkbox button.
- */
-public class SelectionButtonDialogField extends DialogField {
-
- private Button fButton;
- private boolean fIsSelected;
- private DialogField[] fAttachedDialogFields;
- private int fButtonStyle;
-
- /**
- * Creates a selection button.
- * Allowed button styles: SWT.RADIO, SWT.CHECK, SWT.TOGGLE, SWT.PUSH
- */
- public SelectionButtonDialogField(int buttonStyle) {
- super();
- fIsSelected= false;
- fAttachedDialogFields= null;
- fButtonStyle= buttonStyle;
- }
-
- /**
- * Attaches a field to the selection state of the selection button.
- * The attached field will be disabled if the selection button is not selected.
- */
- public void attachDialogField(DialogField dialogField) {
- attachDialogFields(new DialogField[] { dialogField });
- }
-
- /**
- * Attaches fields to the selection state of the selection button.
- * The attached fields will be disabled if the selection button is not selected.
- */
- public void attachDialogFields(DialogField[] dialogFields) {
- fAttachedDialogFields= dialogFields;
- for (int i= 0; i < dialogFields.length; i++) {
- dialogFields[i].setEnabled(fIsSelected);
- }
- }
-
- /**
- * Returns <code>true</code> is teh gived field is attached to the selection button.
- */
- public boolean isAttached(DialogField editor) {
- if (fAttachedDialogFields != null) {
- for (int i=0; i < fAttachedDialogFields.length; i++) {
- if (fAttachedDialogFields[i] == editor) {
- return true;
- }
- }
- }
- return false;
- }
-
- // ------- layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- Button button= getSelectionButton(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- gd.horizontalAlignment= GridData.FILL;
- if (fButtonStyle == SWT.PUSH) {
- gd.heightHint = SWTUtil.getButtonHeigthHint(button);
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
- }
-
- button.setLayoutData(gd);
-
- return new Control[] { button };
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 1;
- }
-
- // ------- ui creation
-
- /**
- * Returns the selection button widget. When called the first time, the widget will be created.
- * @param The parent composite when called the first time, or <code>null</code>
- * after.
- */
- public Button getSelectionButton(Composite group) {
- if (fButton == null) {
- assertCompositeNotNull(group);
-
- fButton= new Button(group, fButtonStyle);
- fButton.setFont(group.getFont());
- fButton.setText(fLabelText);
- fButton.setEnabled(isEnabled());
- fButton.setSelection(fIsSelected);
- fButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- doWidgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- doWidgetSelected(e);
- }
- });
- }
- return fButton;
- }
-
- protected void doWidgetSelected(SelectionEvent e) {
- if (isOkToUse(fButton)) {
- changeValue(fButton.getSelection());
- }
- }
-
- private void changeValue(boolean newState) {
- if (fIsSelected != newState) {
- fIsSelected= newState;
- if (fAttachedDialogFields != null) {
- boolean focusSet= false;
- for (int i= 0; i < fAttachedDialogFields.length; i++) {
- fAttachedDialogFields[i].setEnabled(fIsSelected);
- if (fIsSelected && !focusSet) {
- focusSet= fAttachedDialogFields[i].setFocus();
- }
- }
- }
- dialogFieldChanged();
- } else if (fButtonStyle == SWT.PUSH) {
- dialogFieldChanged();
- }
- }
-
- // ------ model access
-
- /**
- * Returns the selection state of the button.
- */
- public boolean isSelected() {
- return fIsSelected;
- }
-
- /**
- * Sets the selection state of the button.
- */
- public void setSelection(boolean selected) {
- changeValue(selected);
- if (isOkToUse(fButton)) {
- fButton.setSelection(selected);
- }
- }
-
- // ------ enable / disable management
-
- /*
- * @see DialogField#updateEnableState
- */
- protected void updateEnableState() {
- super.updateEnableState();
- if (isOkToUse(fButton)) {
- fButton.setEnabled(isEnabled());
- }
- }
-
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
deleted file mode 100644
index 396c52d589e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-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.Group;
-import org.eclipse.swt.widgets.Label;
-
-import org.eclipse.jface.util.Assert;
-
-/**
- * Dialog field describing a group with buttons (Checkboxes, radio buttons..)
- */
-public class SelectionButtonDialogFieldGroup extends DialogField {
-
- private Composite fButtonComposite;
-
- private Button[] fButtons;
- private String[] fButtonNames;
- private boolean[] fButtonsSelected;
- private boolean[] fButtonsEnabled;
-
- private int fGroupBorderStyle;
- private int fGroupNumberOfColumns;
- private int fButtonsStyle;
-
- /**
- * Creates a group without border.
- */
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
- this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
- }
-
-
- /**
- * Creates a group with border (label in border).
- * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
- * For border styles see <code>Group</code>
- */
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
- super();
-
- Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
-
- int nButtons= buttonNames.length;
- fButtonsSelected= new boolean[nButtons];
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsSelected[i]= false;
- fButtonsEnabled[i]= true;
- }
- if (fButtonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
- }
-
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
- fButtonsStyle= buttonsStyle;
-
- }
-
- // ------- layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- if (fGroupBorderStyle == SWT.NONE) {
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(1));
-
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns - 1;
- buttonsgroup.setLayoutData(gd);
-
- return new Control[] { label, buttonsgroup };
- } else {
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- buttonsgroup.setLayoutData(gd);
-
- return new Control[] { buttonsgroup };
- }
- }
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public int getNumberOfControls() {
- return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
- }
-
- // ------- ui creation
-
- private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
- button.setFont(group.getFont());
- button.setText(fButtonNames[index]);
- button.setEnabled(isEnabled() && fButtonsEnabled[index]);
- button.setSelection(fButtonsSelected[index]);
- button.addSelectionListener(listener);
- button.setLayoutData(new GridData());
- return button;
- }
-
- /**
- * Returns the group widget. When called the first time, the widget will be created.
- * @param The parent composite when called the first time, or <code>null</code>
- * after.
- */
- public Composite getSelectionButtonsGroup(Composite parent) {
- if (fButtonComposite == null) {
- assertCompositeNotNull(parent);
-
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= fGroupNumberOfColumns;
-
- if (fGroupBorderStyle != SWT.NONE) {
- Group group= new Group(parent, fGroupBorderStyle);
- if (fLabelText != null && fLabelText.length() > 0) {
- group.setText(fLabelText);
- }
- fButtonComposite= group;
- } else {
- fButtonComposite= new Composite(parent, SWT.NULL);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- }
-
- fButtonComposite.setLayout(layout);
-
- SelectionListener listener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- doWidgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- doWidgetSelected(e);
- }
- };
- int nButtons= fButtonNames.length;
- fButtons= new Button[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
- }
- int nRows= nButtons / fGroupNumberOfColumns;
- int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
- for (int i= 0; i < nFillElements; i++) {
- createEmptySpace(fButtonComposite);
- }
- }
- return fButtonComposite;
- }
-
- /**
- * Returns a button from the group or <code>null</code> if not yet created.
- */
- public Button getSelectionButton(int index) {
- if (index >= 0 && index < fButtons.length) {
- return fButtons[index];
- }
- return null;
- }
-
- protected void doWidgetSelected(SelectionEvent e) {
- Button button= (Button)e.widget;
- for (int i= 0; i < fButtons.length; i++) {
- if (fButtons[i] == button) {
- fButtonsSelected[i]= button.getSelection();
- dialogFieldChanged();
- return;
- }
- }
- }
-
- // ------ model access
-
- /**
- * Returns the selection state of a button contained in the group.
- * @param The index of the button
- */
- public boolean isSelected(int index) {
- if (index >= 0 && index < fButtonsSelected.length) {
- return fButtonsSelected[index];
- }
- return false;
- }
-
- /**
- * Sets the selection state of a button contained in the group.
- */
- public void setSelection(int index, boolean selected) {
- if (index >= 0 && index < fButtonsSelected.length) {
- if (fButtonsSelected[index] != selected) {
- fButtonsSelected[index]= selected;
- if (fButtons != null) {
- Button button= fButtons[index];
- if (isOkToUse(button)) {
- button.setSelection(selected);
- }
- }
- }
- }
- }
-
- // ------ enable / disable management
-
- protected void updateEnableState() {
- super.updateEnableState();
- if (fButtons != null) {
- boolean enabled= isEnabled();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
- if (isOkToUse(button)) {
- button.setEnabled(enabled && fButtonsEnabled[i]);
- }
- }
- }
- }
-
- /**
- * Sets the enable state of a button contained in the group.
- */
- public void enableSelectionButton(int index, boolean enable) {
- if (index >= 0 && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
- if (fButtons != null) {
- Button button= fButtons[index];
- if (isOkToUse(button)) {
- button.setEnabled(isEnabled() && enable);
- }
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
deleted file mode 100644
index 462e2f9fcf3..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001 Rational Software Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - initial implementation
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-
-import org.eclipse.swt.layout.GridData;
-
-/**
- * Dialog field describing a separator.
- */
-public class Separator extends DialogField {
-
- private Label fSeparator;
- private int fStyle;
-
- public Separator() {
- this(SWT.NONE);
- }
-
- /**
- * @param style of the separator. See <code>Label</code> for possible
- * styles.
- */
- public Separator(int style) {
- super();
- fStyle= style;
- }
-
- // ------- layout helpers
-
- /**
- * Creates the separator and fills it in a MGridLayout.
- * @param height The heigth of the separator
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
- assertEnoughColumns(nColumns);
-
- Control separator= getSeparator(parent);
- separator.setLayoutData(gridDataForSeperator(nColumns, height));
-
- return new Control[] { separator };
- }
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- return doFillIntoGrid(parent, nColumns, 4);
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 1;
- }
-
- protected static GridData gridDataForSeperator(int span, int height) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= height;
- gd.horizontalSpan= span;
- return gd;
- }
-
- // ------- ui creation
-
- /**
- * Creates or returns the created separator.
- * @param parent The parent composite or <code>null</code> if the widget has
- * already been created.
- */
- public Control getSeparator(Composite parent) {
- if (fSeparator == null) {
- assertCompositeNotNull(parent);
- fSeparator= new Label(parent, fStyle);
- }
- return fSeparator;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
deleted file mode 100644
index ce9d78e02dc..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-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.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-
-/**
- * Dialog field containing a label, text control and a button control.
- */
-public class StringButtonDialogField extends StringDialogField {
-
- private Button fBrowseButton;
- private String fBrowseButtonLabel;
- private IStringButtonAdapter fStringButtonAdapter;
-
- private boolean fButtonEnabled;
-
- public StringButtonDialogField(IStringButtonAdapter adapter) {
- super();
- fStringButtonAdapter= adapter;
- fBrowseButtonLabel= "!Browse...!"; //$NON-NLS-1$
- fButtonEnabled= true;
- }
-
- /**
- * Sets the label of the button.
- */
- public void setButtonLabel(String label) {
- fBrowseButtonLabel= label;
- }
-
- // ------ adapter communication
-
- /**
- * Programmatical pressing of the button
- */
- public void changeControlPressed() {
- fStringButtonAdapter.changeControlPressed(this);
- }
-
- // ------- layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
- text.setLayoutData(gridDataForText(nColumns - 2));
- Button button= getChangeControl(parent);
- button.setLayoutData(gridDataForButton(button, 1));
-
- return new Control[] { label, text, button };
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 3;
- }
-
- protected static GridData gridDataForButton(Button button, int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.heightHint = SWTUtil.getButtonHeigthHint(button);
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
- return gd;
- }
-
- // ------- ui creation
-
- /**
- * Creates or returns the created buttom widget.
- * @param parent The parent composite or <code>null</code> if the widget has
- * already been created.
- */
- public Button getChangeControl(Composite parent) {
- if (fBrowseButton == null) {
- assertCompositeNotNull(parent);
-
- fBrowseButton= new Button(parent, SWT.PUSH);
- fBrowseButton.setText(fBrowseButtonLabel);
- fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
- fBrowseButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- changeControlPressed();
- }
- public void widgetSelected(SelectionEvent e) {
- changeControlPressed();
- }
- });
-
- }
- return fBrowseButton;
- }
-
- // ------ enable / disable management
-
- /**
- * Sets the enable state of the button.
- */
- public void enableButton(boolean enable) {
- if (isOkToUse(fBrowseButton)) {
- fBrowseButton.setEnabled(isEnabled() && enable);
- }
- fButtonEnabled= enable;
- }
-
- /*
- * @see DialogField#updateEnableState
- */
- protected void updateEnableState() {
- super.updateEnableState();
- if (isOkToUse(fBrowseButton)) {
- fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
deleted file mode 100644
index 2bc15ba7a4d..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-
-public class StringDialogField extends DialogField {
-
- private String fText;
- private Text fTextControl;
- private ModifyListener fModifyListener;
-
- public StringDialogField() {
- super();
- fText= ""; //$NON-NLS-1$
- }
-
- // ------- layout helpers
-
- /*
- * @see DialogField#doFillIntoGrid
- */
- public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
- text.setLayoutData(gridDataForText(nColumns - 1));
-
- return new Control[] { label, text };
- }
-
- /*
- * @see DialogField#getNumberOfControls
- */
- public int getNumberOfControls() {
- return 2;
- }
-
- protected static GridData gridDataForText(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- return gd;
- }
-
- // ------- focus methods
-
- /*
- * @see DialogField#setFocus
- */
- public boolean setFocus() {
- if (isOkToUse(fTextControl)) {
- fTextControl.setFocus();
- fTextControl.setSelection(0, fTextControl.getText().length());
- }
- return true;
- }
-
- // ------- ui creation
-
- /**
- * Creates or returns the created text control.
- * @param parent The parent composite or <code>null</code> when the widget has
- * already been created.
- */
- public Text getTextControl(Composite parent) {
- if (fTextControl == null) {
- assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doModifyText(e);
- }
- };
-
- fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER);
- // moved up due to 1GEUNW2
- fTextControl.setText(fText);
- fTextControl.setFont(parent.getFont());
- fTextControl.addModifyListener(fModifyListener);
-
- fTextControl.setEnabled(isEnabled());
- }
- return fTextControl;
- }
-
- protected void doModifyText(ModifyEvent e) {
- if (isOkToUse(fTextControl)) {
- fText= fTextControl.getText();
- }
- dialogFieldChanged();
- }
-
- // ------ enable / disable management
-
- /*
- * @see DialogField#updateEnableState
- */
- protected void updateEnableState() {
- super.updateEnableState();
- if (isOkToUse(fTextControl)) {
- fTextControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
- /**
- * Gets the text. Can not be <code>null</code>
- */
- public String getText() {
- return fText;
- }
-
- /**
- * Sets the text. Triggers a dialog-changed event.
- */
- public void setText(String text) {
- fText= text;
- if (isOkToUse(fTextControl)) {
- fTextControl.setText(text);
- } else {
- dialogFieldChanged();
- }
- }
-
- /**
- * Sets the text without triggering a dialog-changed event.
- */
- public void setTextWithoutUpdate(String text) {
- fText= text;
- if (isOkToUse(fTextControl)) {
- fTextControl.removeModifyListener(fModifyListener);
- fTextControl.setText(text);
- fTextControl.addModifyListener(fModifyListener);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridData.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridData.java
deleted file mode 100644
index 7d8254c884f..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridData.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.swt;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.SWT;
-
-public final class MGridData {
- /**
- * verticalAlignment specifies how controls will be positioned
- * vertically within a cell.
- *
- * The default value is CENTER.
- *
- * Possible values are:
- *
- * BEGINNING: Position the control at the top of the cell
- * CENTER: Position the control in the vertical center of the cell
- * END: Position the control at the bottom of the cell
- * FILL: Resize the control to fill the cell vertically
- */
- public int verticalAlignment= CENTER;
- /**
- * horizontalAlignment specifies how controls will be positioned
- * horizontally within a cell.
- *
- * The default value is BEGINNING.
- *
- * Possible values are:
- *
- * BEGINNING: Position the control at the left of the cell
- * CENTER: Position the control in the horizontal center of the cell
- * END: Position the control at the right of the cell
- * FILL: Resize the control to fill the cell horizontally
- */
- public int horizontalAlignment= BEGINNING;
- /**
- * widthHint specifies a minimum width for the column. A value of
- * SWT.DEFAULT indicates that no minimum width is specified.
- *
- * The default value is SWT.DEFAULT.
- */
- public int widthHint= SWT.DEFAULT;
- /**
- * heightHint specifies a minimum height for the row. A value of
- * SWT.DEFAULT indicates that no minimum height is specified.
- *
- * The default value is SWT.DEFAULT.
- */
- public int heightHint= SWT.DEFAULT;
- /**
- * horizontalIndent specifies the number of pixels of indentation
- * that will be placed along the left side of the cell.
- *
- * The default value is 0.
- */
- public int horizontalIndent= 0;
- /**
- * horizontalSpan specifies the number of column cells that the control
- * will take up.
- *
- * The default value is 1.
- */
- public int horizontalSpan= 1;
- /**
- * verticalSpan specifies the number of row cells that the control
- * will take up.
- *
- * The default value is 1.
- */
- public int verticalSpan= 1;
- /**
- * grabExcessHorizontalSpace specifies whether the cell will be made
- * wide enough to fit the remaining horizontal space.
- *
- * The default value is false.
- */
- public boolean grabExcessHorizontalSpace= false;
- /**
- * grabExcessVerticalSpace specifies whether the cell will be made
- * tall enough to fit the remaining vertical space.
- *
- * The default value is false.
- */
- public boolean grabExcessVerticalSpace= false;
-
-
- // --------- added to original GridData --------
-
- /**
- * if a span is defined that is also grabing, this defines the column that
- * will grab the space
- *
- * The default value is -1, which will result in the default behavior
- * (=last culumn)
- */
- public int grabColumn= -1;
-
- /**
- * If a span is defined that is also grabing, this defines the row that
- * will grab
- *
- * The default value is -1, which will result in the default behavior
- * (=last row)
- */
- public int grabRow= -1;
-
- // Alignment constants.
- public static final int BEGINNING= 1;
- public static final int CENTER= 2;
- public static final int END= 3;
- public static final int FILL= 4;
-
- // Style constants
- public static final int VERTICAL_ALIGN_BEGINNING= 1 << 1;
- public static final int VERTICAL_ALIGN_CENTER= 1 << 2;
- public static final int VERTICAL_ALIGN_END= 1 << 3;
- public static final int VERTICAL_ALIGN_FILL= 1 << 4;
- public static final int HORIZONTAL_ALIGN_BEGINNING= 1 << 5;
- public static final int HORIZONTAL_ALIGN_CENTER= 1 << 6;
- public static final int HORIZONTAL_ALIGN_END= 1 << 7;
- public static final int HORIZONTAL_ALIGN_FILL= 1 << 8;
- public static final int GRAB_HORIZONTAL= 1 << 9;
- public static final int GRAB_VERTICAL= 1 << 10;
-
- // Private
- int childIndex;
- boolean isItemData= true;
- boolean isItemData() {
- return isItemData;
- }
- boolean isSpacerData() {
- return !isItemData;
- }
- public MGridData(int style) {
- super();
-
- if ((style & VERTICAL_ALIGN_BEGINNING) != 0)
- verticalAlignment= BEGINNING;
- if ((style & VERTICAL_ALIGN_CENTER) != 0)
- verticalAlignment= CENTER;
- if ((style & VERTICAL_ALIGN_FILL) != 0)
- verticalAlignment= FILL;
- if ((style & VERTICAL_ALIGN_END) != 0)
- verticalAlignment= END;
-
- if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0)
- horizontalAlignment= BEGINNING;
- if ((style & HORIZONTAL_ALIGN_CENTER) != 0)
- horizontalAlignment= CENTER;
- if ((style & HORIZONTAL_ALIGN_FILL) != 0)
- horizontalAlignment= FILL;
- if ((style & HORIZONTAL_ALIGN_END) != 0)
- horizontalAlignment= END;
-
- if ((style & GRAB_HORIZONTAL) != 0)
- grabExcessHorizontalSpace= true;
- else
- grabExcessHorizontalSpace= false;
- if ((style & GRAB_VERTICAL) != 0)
- grabExcessVerticalSpace= true;
- else
- grabExcessVerticalSpace= false;
-
- }
- public MGridData() {
- super();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridLayout.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridLayout.java
deleted file mode 100644
index 190cf77a5f0..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/swt/MGridLayout.java
+++ /dev/null
@@ -1,682 +0,0 @@
-package org.eclipse.cdt.internal.ui.wizards.swt;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-public final class MGridLayout extends Layout {
- /**
- * marginWidth specifies the number of pixels of horizontal margin
- * that will be placed along the left and right edges of the layout.
- *
- * The default value is 5.
- */
- public int marginWidth= 5;
- /**
- * marginHeight specifies the number of pixels of vertical margin
- * that will be placed along the top and bottom edges of the layout.
- *
- * The default value is 5.
- */
- public int marginHeight= 5;
- /**
- * numColumns specifies the number of cell columns in the layout.
- *
- * The default value is 1.
- */
- public int numColumns= 1;
- /**
- * makeColumnsEqualWidth specifies whether all columns in the layout
- * will be forced to have the same width.
- *
- * The default value is false.
- */
- public boolean makeColumnsEqualWidth= false;
- /**
- * horizontalSpacing specifies the number of pixels between the right
- * edge of one cell and the left edge of its neighbouring cell to
- * the right.
- *
- * The default value is 5.
- */
- public int horizontalSpacing= 5;
- /**
- * verticalSpacing specifies the number of pixels between the bottom
- * edge of one cell and the top edge of its neighbouring cell underneath.
- *
- * The default value is 5.
- */
- public int verticalSpacing= 5;
-
-
- // --------- added to original GridLayout --------
-
- /**
- * minimumWidth specifies a minimum width of this layout
- * If SWT.DEFAULT is set, no minimum width is forced
- *
- * The default value is SWT.DEFAULT.
- */
- public int minimumWidth= SWT.DEFAULT;
- /**
- * minimumHeight specifies a minimum height of this layout
- * If SWT.DEFAULT is set, no minimum height is forced
- *
- * The default value is SWT.DEFAULT.
- */
- public int minimumHeight= SWT.DEFAULT;
-
- /**
- * id specifies an identifier string for this layout.
- */
- public String id;
-
- // Private variables. Cached values used to cut down on grid calculations.
- boolean initialLayout= true;
- Vector grid= new Vector();
- int[] pixelColumnWidths;
- int[] pixelRowHeights;
- int[] expandableColumns;
- int[] expandableRows;
- void adjustGridDimensions(Composite composite, boolean flushCache) {
- // Ensure that widgets that span more than one row or column have enough space.
- for (int row= 0; row < grid.size(); row++) {
- for (int column= 0; column < numColumns; column++) {
- MGridData spec= ((MGridData[]) grid.elementAt(row))[column];
- if (spec.isItemData()) {
- // Widgets spanning columns.
- if (spec.horizontalSpan > 1) {
- Control child= composite.getChildren()[spec.childIndex];
- Point extent= child.computeSize(spec.widthHint, spec.heightHint, flushCache);
-
- // Calculate the size of the widget's spanned columns.
- int lastSpanIndex= column + spec.horizontalSpan;
- int spannedSize= 0;
- for (int c= column; c < lastSpanIndex; c++) {
- spannedSize= spannedSize + pixelColumnWidths[c] + horizontalSpacing;
- }
- spannedSize= spannedSize - horizontalSpacing;
-
- // If the spanned columns are not large enough to display the widget, adjust the column
- // sizes to account for the extra space that is needed.
- if (extent.x + spec.horizontalIndent > spannedSize) {
- int extraSpaceNeeded= extent.x + spec.horizontalIndent - spannedSize;
- int lastColumn= column + spec.horizontalSpan - 1;
- int colWidth;
- if (makeColumnsEqualWidth) {
- // Evenly distribute the extra space amongst all of the columns.
- int columnExtra= extraSpaceNeeded / numColumns;
- int columnRemainder= extraSpaceNeeded % numColumns;
- for (int i= 0; i < pixelColumnWidths.length; i++) {
- colWidth= pixelColumnWidths[i] + columnExtra;
- pixelColumnWidths[i]= colWidth;
- }
- colWidth= pixelColumnWidths[lastColumn] + columnRemainder;
- pixelColumnWidths[lastColumn]= colWidth;
- } else {
- Vector localExpandableColumns= new Vector();
- for (int i= column; i < lastColumn; i++) {
- for (int j= 0; j < expandableColumns.length; j++) {
- if (expandableColumns[j] == i) {
- localExpandableColumns.addElement(new Integer(i));
- }
- }
- }
- if (localExpandableColumns.size() > 0) {
- // If any of the widget's columns grab excess space, allocate the space amongst those columns.
- int columnExtra= extraSpaceNeeded / localExpandableColumns.size();
- int columnRemainder= extraSpaceNeeded % localExpandableColumns.size();
- for (int i= 0; i < localExpandableColumns.size(); i++) {
- int expandableCol= ((Integer) localExpandableColumns.elementAt(i)).intValue();
- colWidth= pixelColumnWidths[expandableCol] + columnExtra;
- pixelColumnWidths[expandableCol]= colWidth;
- }
- colWidth= pixelColumnWidths[lastColumn] + columnRemainder;
- pixelColumnWidths[lastColumn]= colWidth;
- } else {
- // Add the extra space to the widget's last column if none of its columns grab excess space.
- colWidth= pixelColumnWidths[lastColumn] + extraSpaceNeeded;
- pixelColumnWidths[lastColumn]= colWidth;
- }
- }
- }
- }
-
- // Widgets spanning rows.
- if (spec.verticalSpan > 1) {
- Control child= composite.getChildren()[spec.childIndex];
- Point extent= child.computeSize(spec.widthHint, spec.heightHint, flushCache);
-
- // Calculate the size of the widget's spanned rows.
- int lastSpanIndex= row + spec.verticalSpan;
- int spannedSize= 0;
- for (int r= row; r < lastSpanIndex; r++) {
- spannedSize= spannedSize + pixelRowHeights[r] + verticalSpacing;
- }
- spannedSize= spannedSize - verticalSpacing;
- // If the spanned rows are not large enough to display the widget, adjust the row
- // sizes to account for the extra space that is needed.
- if (extent.y > spannedSize) {
- int extraSpaceNeeded= extent.y - spannedSize;
- int lastRow= row + spec.verticalSpan - 1;
- int rowHeight;
- Vector localExpandableRows= new Vector();
- for (int i= row; i < lastRow; i++) {
- for (int j= 0; j < expandableRows.length; j++) {
- if (expandableRows[j] == i) {
- localExpandableRows.addElement(new Integer(i));
- }
- }
- }
- if (localExpandableRows.size() > 0) {
- // If any of the widget's rows grab excess space, allocate the space amongst those rows.
- int rowExtra= extraSpaceNeeded / localExpandableRows.size();
- int rowRemainder= extraSpaceNeeded % localExpandableRows.size();
- for (int i= 0; i < localExpandableRows.size(); i++) {
- int expandableRow= ((Integer) localExpandableRows.elementAt(i)).intValue();
- rowHeight= pixelRowHeights[expandableRow] + rowExtra;
- pixelRowHeights[expandableRow]= rowHeight;
- }
- rowHeight= pixelRowHeights[lastRow] + rowRemainder;
- pixelRowHeights[lastRow]= rowHeight;
- } else {
- // Add the extra space to the widget's last row if no rows grab excess space.
- rowHeight= pixelRowHeights[lastRow] + extraSpaceNeeded;
- pixelRowHeights[lastRow]= rowHeight;
- }
- }
- }
- }
- }
- }
- }
- void calculateGridDimensions(Composite composite, boolean flushCache) {
- int maxWidth, childWidth, maxHeight, childHeight;
-
- //
- Control[] children= composite.getChildren();
- Point[] childSizes= new Point[children.length];
- pixelColumnWidths= new int[numColumns];
- pixelRowHeights= new int[grid.size()];
-
- // Loop through the grid by column to get the width that each column needs to be.
- // Each column will be as wide as its widest widget.
- for (int column= 0; column < numColumns; column++) {
- maxWidth= 0;
- for (int row= 0; row < grid.size(); row++) {
- MGridData spec= ((MGridData[]) grid.elementAt(row))[column];
- if (spec.isItemData()) {
- Control child= children[spec.childIndex];
- childSizes[spec.childIndex]= child.computeSize(spec.widthHint, spec.heightHint, flushCache);
- childWidth= childSizes[spec.childIndex].x + spec.horizontalIndent;
- if (spec.horizontalSpan == 1) {
- maxWidth= Math.max(maxWidth, childWidth);
- }
- }
- }
- // Cache the values for later use.
- pixelColumnWidths[column]= maxWidth;
- }
-
- //
- if (makeColumnsEqualWidth) {
- maxWidth= 0;
- // Find the largest column size that is necessary and make each column that size.
- for (int i= 0; i < numColumns; i++) {
- maxWidth= Math.max(maxWidth, pixelColumnWidths[i]);
- }
- for (int i= 0; i < numColumns; i++) {
- pixelColumnWidths[i]= maxWidth;
- }
- }
-
- // Loop through the grid by row to get the height that each row needs to be.
- // Each row will be as high as its tallest widget.
- for (int row= 0; row < grid.size(); row++) {
- maxHeight= 0;
- for (int column= 0; column < numColumns; column++) {
- MGridData spec= ((MGridData[]) grid.elementAt(row))[column];
- if (spec.isItemData()) {
- childHeight= childSizes[spec.childIndex].y;
- if (spec.verticalSpan == 1) {
- maxHeight= Math.max(maxHeight, childHeight);
- }
- }
- }
- // Cache the values for later use.
- pixelRowHeights[row]= maxHeight;
- }
- }
- void computeExpandableCells() {
- // If a widget grabs excess horizontal space, the last column that the widget spans
- // will be expandable. Similarly, if a widget grabs excess vertical space, the
- // last row that the widget spans will be expandable.
- Hashtable growColumns= new Hashtable();
- Hashtable growRows= new Hashtable();
- for (int col= 0; col < numColumns; col++) {
- for (int row= 0; row < grid.size(); row++) {
- MGridData spec= ((MGridData[]) grid.elementAt(row))[col];
- if (spec.grabExcessHorizontalSpace) {
- if (spec.grabColumn >= 0 && spec.grabColumn < spec.horizontalSpan) {
- growColumns.put(new Integer(col + spec.grabColumn), new Object());
- } else {
- growColumns.put(new Integer(col + spec.horizontalSpan - 1), new Object());
- }
- }
- if (spec.grabExcessVerticalSpace) {
- if (spec.grabRow >= 0 && spec.grabRow < spec.verticalSpan) {
- growRows.put(new Integer(row + spec.grabRow), new Object());
- } else {
- growRows.put(new Integer(row + spec.verticalSpan - 1), new Object());
- }
- }
- }
- }
-
- // Cache the values. These values are used later during children layout.
- int i= 0;
- Enumeration enum= growColumns.keys();
- expandableColumns= new int[growColumns.size()];
- while (enum.hasMoreElements()) {
- expandableColumns[i]= ((Integer) enum.nextElement()).intValue();
- i= i + 1;
- }
- i= 0;
- enum= growRows.keys();
- expandableRows= new int[growRows.size()];
- while (enum.hasMoreElements()) {
- expandableRows[i]= ((Integer) enum.nextElement()).intValue();
- i= i + 1;
- }
- }
- Point computeLayoutSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- int totalMarginHeight, totalMarginWidth;
- int totalWidth, totalHeight;
- int cols, rows;
-
- // Initialize the grid and other cached information that help with the grid layout.
- if (grid.size() == 0) {
- createGrid(composite);
- calculateGridDimensions(composite, flushCache);
- computeExpandableCells();
- adjustGridDimensions(composite, flushCache);
- }
-
- //
- cols= numColumns;
- rows= grid.size();
- totalMarginHeight= marginHeight + composite.getBorderWidth();
- totalMarginWidth= marginWidth + composite.getBorderWidth();
-
- // The total width is the margin plus border width plus space between each column,
- // plus the width of each column.
- totalWidth= (totalMarginWidth * 2) + ((cols - 1) * horizontalSpacing);
-
- //Add up the width of each column.
- for (int i= 0; i < pixelColumnWidths.length; i++) {
- totalWidth= totalWidth + pixelColumnWidths[i];
- }
-
- // The total height is the margin plus border height, plus space between each row,
- // plus the height of the tallest child in each row.
- totalHeight= (totalMarginHeight * 2) + ((rows - 1) * verticalSpacing);
-
- //Add up the height of each row.
- for (int i= 0; i < pixelRowHeights.length; i++) {
- totalHeight= totalHeight + pixelRowHeights[i];
- }
-
- if (wHint != SWT.DEFAULT) {
- totalWidth= wHint;
- };
- if (hHint != SWT.DEFAULT) {
- totalHeight= hHint;
- };
- // The preferred extent is the width and height that will accomodate the grid's widgets.
- return new Point(totalWidth, totalHeight);
- }
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
-
- if (composite.getChildren().length == 0)
- return new Point(0, 0);
-
- // Make sure that all of the composite children have a layout spec. Do this by
- // using the initialLayout flag.
- if (flushCache)
- initialLayout= true;
- if (initialLayout) {
- initializeLayoutData(composite);
- initialLayout= false;
- }
-
- if (flushCache) {
- // Cause the grid and its related information to be calculated
- // again.
- grid.removeAllElements();
- }
-
- Point size= computeLayoutSize(composite, wHint, hHint, flushCache);
- if (minimumWidth != SWT.DEFAULT && size.x < minimumWidth) {
- size.x= minimumWidth;
- }
- if (minimumHeight != SWT.DEFAULT && size.y < minimumHeight) {
- size.y= minimumHeight;
- }
- return size;
- }
- void createGrid(Composite composite) {
- int row, column, rowFill, columnFill;
- Control[] children;
- MGridData spacerSpec;
-
- //
- children= composite.getChildren();
-
- //
- grid.addElement(emptyRow());
- row= 0;
- column= 0;
-
- // Loop through the children and place their associated layout specs in the
- // grid. Placement occurs left to right, top to bottom (i.e., by row).
- for (int i= 0; i < children.length; i++) {
- // Find the first available spot in the grid.
- Control child= children[i];
- MGridData spec= (MGridData) child.getLayoutData();
- while (((MGridData[]) grid.elementAt(row))[column] != null) {
- column= column + 1;
- if (column >= numColumns) {
- row= row + 1;
- column= 0;
- if (row >= grid.size()) {
- grid.addElement(emptyRow());
- }
- }
- }
- // See if the place will support the widget's horizontal span. If not, go to the
- // next row.
- if (column + spec.horizontalSpan - 1 >= numColumns) {
- grid.addElement(emptyRow());
- row= row + 1;
- column= 0;
- }
-
- // The vertical span for the item will be at least 1. If it is > 1,
- // add other rows to the grid.
- for (int j= 2; j <= spec.verticalSpan; j++) {
- if (row + j > grid.size()) {
- grid.addElement(emptyRow());
- }
- }
-
- // Store the layout spec. Also cache the childIndex. NOTE: That we assume the children of a
- // composite are maintained in the order in which they are created and added to the composite.
- ((MGridData[]) grid.elementAt(row))[column]= spec;
- spec.childIndex= i;
-
- // Put spacers in the grid to account for the item's vertical and horizontal
- // span.
- rowFill= spec.verticalSpan - 1;
- columnFill= spec.horizontalSpan - 1;
- for (int r= 1; r <= rowFill; r++) {
- for (int c= 0; c < spec.horizontalSpan; c++) {
- spacerSpec= new MGridData();
- spacerSpec.isItemData= false;
- ((MGridData[]) grid.elementAt(row + r))[column + c]= spacerSpec;
- }
- }
- for (int c= 1; c <= columnFill; c++) {
- for (int r= 0; r < spec.verticalSpan; r++) {
- spacerSpec= new MGridData();
- spacerSpec.isItemData= false;
- ((MGridData[]) grid.elementAt(row + r))[column + c]= spacerSpec;
- }
- }
- column= column + spec.horizontalSpan - 1;
- }
-
- // Fill out empty grid cells with spacers.
- for (int k= column + 1; k < numColumns; k++) {
- spacerSpec= new MGridData();
- spacerSpec.isItemData= false;
- ((MGridData[]) grid.elementAt(row))[k]= spacerSpec;
- }
- for (int k= row + 1; k < grid.size(); k++) {
- spacerSpec= new MGridData();
- spacerSpec.isItemData= false;
- ((MGridData[]) grid.elementAt(k))[column]= spacerSpec;
- }
- }
- MGridData[] emptyRow() {
- MGridData[] row= new MGridData[numColumns];
- for (int i= 0; i < numColumns; i++) {
- row[i]= null;
- }
- return row;
- }
- void initializeLayoutData(Composite composite) {
- Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- Control child= children[i];
- if (child.getLayoutData() == null) {
- child.setLayoutData(new MGridData());
- }
- }
- }
- protected void layout(Composite composite, boolean flushCache) {
- //System.out.println("start layout " + id);
- //new Error (). printStackTrace();
- int[] columnWidths;
- int[] rowHeights;
- int rowSize, rowY, columnX;
- int compositeWidth, compositeHeight;
- int excessHorizontal, excessVertical;
- Control[] children;
- if (flushCache) {
- // Cause the grid and its related information to be calculated
- // again.
- grid.removeAllElements();
- }
- children= composite.getChildren();
- if (children.length == 0)
- return;
-
- //
- Point extent= computeLayoutSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache);
- columnWidths= new int[numColumns];
- for (int i= 0; i < pixelColumnWidths.length; i++) {
- columnWidths[i]= pixelColumnWidths[i];
- }
- rowHeights= new int[grid.size()];
- for (int i= 0; i < pixelRowHeights.length; i++) {
- rowHeights[i]= pixelRowHeights[i];
- }
- int columnWidth= 0;
- rowSize= Math.max(1, grid.size());
-
- //
- compositeWidth= extent.x;
- compositeHeight= extent.y;
-
- // Calculate whether or not there is any extra space or not enough space due to a resize
- // operation. Then allocate/deallocate the space to columns and rows that are expandable.
- // If a widget grabs excess space, its last column or row will be expandable.
- excessHorizontal= composite.getClientArea().width - compositeWidth;
- excessVertical= composite.getClientArea().height - compositeHeight;
-
- // Allocate/deallocate horizontal space.
- if (expandableColumns.length != 0) {
- int excess, remainder, last;
- int colWidth;
- excess= excessHorizontal / expandableColumns.length;
- remainder= excessHorizontal % expandableColumns.length;
- last= 0;
- for (int i= 0; i < expandableColumns.length; i++) {
- int expandableCol= expandableColumns[i];
- colWidth= columnWidths[expandableCol];
- colWidth= colWidth + excess;
- columnWidths[expandableCol]= colWidth;
- last= Math.max(last, expandableCol);
- }
- colWidth= columnWidths[last];
- colWidth= colWidth + remainder;
- columnWidths[last]= colWidth;
- }
-
- // Go through all specs in each expandable column and get the maximum specified
- // widthHint. Use this as the minimumWidth for the column.
- for (int i= 0; i < expandableColumns.length; i++) {
- int expandableCol= expandableColumns[i];
- int colWidth= columnWidths[expandableCol];
- int minWidth= 0;
- for (int j= 0; j < grid.size(); j++) {
- MGridData[] row= (MGridData[]) grid.elementAt(j);
- MGridData spec= row[expandableCol];
- minWidth= Math.max(minWidth, spec.widthHint);
- }
- columnWidths[expandableCol]= Math.max(colWidth, minWidth);
- }
- // Allocate/deallocate vertical space.
- if (expandableRows.length != 0) {
- int excess, remainder, last;
- int rowHeight;
- excess= excessVertical / expandableRows.length;
- remainder= excessVertical % expandableRows.length;
- last= 0;
- for (int i= 0; i < expandableRows.length; i++) {
- int expandableRow= expandableRows[i];
- rowHeight= rowHeights[expandableRow];
- rowHeight= rowHeight + excess;
- rowHeights[expandableRow]= rowHeight;
- last= Math.max(last, expandableRow);
- }
- rowHeight= rowHeights[last];
- rowHeight= rowHeight + remainder;
- rowHeights[last]= rowHeight;
- }
- // Go through all specs in each expandable row and get the maximum specified
- // heightHint. Use this as the minimumHeight for the row.
- for (int i= 0; i < expandableRows.length; i++) {
- int expandableRow= expandableRows[i];
- int rowHeight= rowHeights[expandableRow];
- int minHeight= 0;
- MGridData[] row= (MGridData[]) grid.elementAt(expandableRow);
- for (int j= 0; j < numColumns; j++) {
- MGridData spec= row[j];
- minHeight= Math.max(minHeight, spec.heightHint);
- }
- rowHeights[expandableRow]= Math.max(rowHeight, minHeight);
- }
-
- // Get the starting x and y.
- columnX= marginWidth + composite.getBorderWidth() + composite.getClientArea().x;
- rowY= marginHeight + composite.getBorderWidth() + composite.getClientArea().y;
-
- // Layout the widget left to right, top to bottom.
- for (int r= 0; r < rowSize; r++) {
- int rowHeight= rowHeights[r];
- MGridData[] row= (MGridData[]) grid.elementAt(r);
-
- //
- for (int c= 0; c < row.length; c++) {
- int spannedWidth= 0, spannedHeight= 0;
- int hAlign= 0, vAlign= 0;
- int widgetX= 0, widgetY= 0;
- int widgetW= 0, widgetH= 0;
-
- //
- MGridData spec= (MGridData) row[c];
- if (makeColumnsEqualWidth) {
- columnWidth= composite.getBounds().width - ((marginWidth + composite.getBorderWidth()) * 2) - ((numColumns - 1) * horizontalSpacing);
- columnWidth= columnWidth / numColumns;
- for (int i= 0; i < columnWidths.length; i++) {
- columnWidths[i]= columnWidth;
- }
- } else {
- columnWidth= columnWidths[c];
- }
-
- //
- spannedWidth= columnWidth;
- for (int k= 1; k < spec.horizontalSpan; k++) {
- if ((c + k) <= numColumns) {
- if (!makeColumnsEqualWidth) {
- columnWidth= columnWidths[c + k];
- }
- spannedWidth= spannedWidth + columnWidth + horizontalSpacing;
- }
- }
-
- //
- spannedHeight= rowHeight;
- for (int k= 1; k < spec.verticalSpan; k++) {
- if ((r + k) <= grid.size()) {
- spannedHeight= spannedHeight + rowHeights[r + k] + verticalSpacing;
- }
- }
-
- //
- if (spec.isItemData()) {
- Control child= children[spec.childIndex];
- Point childExtent= child.computeSize(spec.widthHint, spec.heightHint, flushCache);
- hAlign= spec.horizontalAlignment;
- widgetX= columnX;
-
- // Calculate the x and width values for the widget.
- if (hAlign == MGridData.CENTER) {
- widgetX= widgetX + (spannedWidth / 2) - (childExtent.x / 2);
- } else if (hAlign == MGridData.END) {
- widgetX= widgetX + spannedWidth - childExtent.x - spec.horizontalIndent;
- } else {
- widgetX= widgetX + spec.horizontalIndent;
- }
- if (hAlign == MGridData.FILL) {
- widgetW= spannedWidth - spec.horizontalIndent;
- widgetX= columnX + spec.horizontalIndent;
- } else {
- widgetW= childExtent.x;
- }
-
- // Calculate the y and height values for the widget.
- vAlign= spec.verticalAlignment;
- widgetY= rowY;
- if (vAlign == MGridData.CENTER) {
- widgetY= widgetY + (spannedHeight / 2) - (childExtent.y / 2);
- } else if (vAlign == MGridData.END) {
- widgetY= widgetY + spannedHeight - childExtent.y;
- } else {
- //widgetY= widgetY;
- }
- if (vAlign == MGridData.FILL) {
- widgetH= spannedHeight;
- widgetY= rowY;
- } else {
- widgetH= childExtent.y;
- }
- // Place the widget.
- child.setBounds(widgetX, widgetY, widgetW, widgetH);
- }
- // Update the starting x value.
- columnX= columnX + columnWidths[c] + horizontalSpacing;
- }
- // Update the starting y value and since we're starting a new row, reset the starting x value.
- rowY= rowY + rowHeights[r] + verticalSpacing;
- columnX= marginWidth + composite.getBorderWidth() + composite.getClientArea().x;
- }
- //System.out.println("end layout " + id);
- }
- public MGridLayout() {
- super();
- }
-}

Back to the top