Skip to main content
summaryrefslogtreecommitdiffstats

Back to the top

ss='graph'>
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementProperties.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaHierarchyPerspectiveFactory.java83
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPerspectiveFactory.java88
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java598
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaProjectAdapterFactory.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaScriptPlugin.java930
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaTaskListAdapter.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIException.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java171
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties179
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIPreferenceInitializer.java33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIStatus.java45
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaWorkbenchAdapter.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/LogicalPackageAdapterFactory.java63
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/MarkerAdapterFactory.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/PersistableJavaElementFactory.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceAdapterFactory.java45
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceLocator.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SetupProjectsWizzard.java70
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SharedImages.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AbstractToggleLinkingAction.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.java376
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.properties412
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionUtil.java178
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddBlockCommentAction.java215
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddTaskAction.java53
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AllCleanUpsAction.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/BlockCommentAction.java327
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CategoryFilterActionGroup.java530
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java287
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CompositeActionGroup.java97
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ConfigureContainerAction.java120
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CopyQualifiedNameAction.java276
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ExtractSuperClassAction.java191
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java358
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingActionGroup.java246
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.properties49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsContentProvider.java201
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java364
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsValidator.java87
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateJavadocAction.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/IndentAction.java571
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/JDTQuickMenuAction.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/LexicalSortingAction.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiActionGroup.java126
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiOrganizeImportAction.java60
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiSortMembersAction.java108
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/NewWizardsActionGroup.java84
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OccurrencesSearchMenuAction.java182
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenBrowserUtil.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeAction.java119
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeInHierarchyAction.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/QuickMenuAction.java300
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/RemoveBlockCommentAction.java87
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectAllAction.java84
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectionConverter.java310
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithActionGroup.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithTemplateMenuAction.java412
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/WorkbenchRunnableAdapter.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/IPackagesViewViewer.java40
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java539
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.properties24
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPart.java1319
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPerspectiveFactory.java180
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java86
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackage.java141
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackagesProvider.java214
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java338
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackageViewerWrapper.java343
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesView.java653
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewFlatContentProvider.java300
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java646
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewLabelProvider.java162
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTableViewer.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTreeViewer.java121
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PatchedOpenInNewWindowAction.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectAndSourceFolderContentProvider.java99
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectsView.java211
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ToggleLinkingAction.java41
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TopLevelTypeProblemsLabelDecorator.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java220
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java204
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java86
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyImageDescriptor.java154
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelDecorator.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelProvider.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.java116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.properties116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java76
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyUI.java276
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewPart.java948
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewer.java138
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CancelSearchAction.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CopyCallHierarchyAction.java128
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/DeferredMethodWrapper.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FiltersDialog.java226
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FocusOnSelectionAction.java86
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryAction.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryDropDownAction.java108
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryListAction.java181
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java19
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationCopyAction.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationLabelProvider.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationViewer.java127
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/MethodWrapperWorkbenchAdapter.java75
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java239
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenDeclarationAction.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenLocationAction.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/RefreshAction.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeAction.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeActionGroup.java355
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeProjectAction.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchUtil.java137
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SelectWorkingSetAction.java55
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleCallModeAction.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleOrientationAction.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeRoot.java28
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeTermination.java17
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/JavaElementReferenceConverter.java233
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/OpenElementInEditorHandler.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInPackageViewHandler.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/AddFromHistoryAction.properties35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareAction.properties20
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareDialog.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareWithEditionAction.properties33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/EclipsePreferencesAdapter.java317
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistory.java22
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistoryImpl.java304
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareAction.java183
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java459
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionAction.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaContentViewerCreator.java28
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryAction.java80
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryActionImpl.java334
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaMergeViewer.java423
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java174
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaParseTreeBuilder.java205
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionAction.java24
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionActionImpl.java212
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithPreviousEditionAction.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureCreator.java501
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewer.java215
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewerCreator.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextBufferNode.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewer.java97
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewerCreator.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTokenComparator.java225
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/LocalHistoryActionGroup.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ReplaceWithEditionAction.properties33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ResizableDialog.java148
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/TextMergeViewerCreator.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.java33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.properties18
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java1663
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/ListDialog.java107
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/MultiElementListSelectionDialog.java323
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog2.java136
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OptionalMessageDialog.java121
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OverrideMethodDialog.java397
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/PackageSelectionDialog.java321
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SortMembersMessageDialog.java186
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SourceActionDialog.java655
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusInfo.java196
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusUtil.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TableTextCellEditor.java437
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TextFieldNavigationHandler.java505
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeInfoViewer.java1583
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionComponent.java437
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionDialog2.java332
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDragAdapter.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDropAdapter.java268
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDragAdapter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDropAdapter.java295
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/ResourceTransferDragAdapter.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClassFilter.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClosedProjectFilter.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ContainedLibraryFilter.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/CustomFiltersDialog.java417
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyInnerPackageFilter.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyPackageFilter.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FieldsFilter.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterDescriptor.java277
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.properties23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ImportDeclarationFilter.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InnerClassFilesFilter.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InterfaceFilter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/JavaFileFilter.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LibraryFilter.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LocalTypesFilter.java24
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NamePatternFilter.java105
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NoPackageContainingFoldersFilter.java54
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaElementFilter.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaProjectsFilter.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicFilter.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicTypeFilter.java40
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonSharedProjectFilter.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/OutputFolderFilter.java75
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/PackageDeclarationFilter.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/StaticsFilter.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/SyntheticMembersFilter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/AbstractCleanUp.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpRefactoringWizard.java494
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantConfigurationModifyDialog.java285
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantPreferenceConfiguration.java345
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatCleanUp.java118
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatFix.java171
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeStyleCleanUp.java237
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatCleanUp.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatFix.java204
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ControlStatementsCleanUp.java157
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ConvertLoopCleanUp.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ExpressionsCleanUp.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ICleanUp.java175
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ImportsCleanUp.java145
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/Java50CleanUp.java179
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.java92
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.properties73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.java43
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.properties25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SortMembersCleanUp.java175
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/StringCleanUp.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnnecessaryCodeCleanUp.java133
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnusedCodeCleanUp.java219
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/VariableDeclarationCleanUp.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/AbstractInfoView.java553
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/CopyToClipboardAction.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/GotoInputAction.java41
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.properties35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/JavadocView.java703
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/SourceView.java518
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/TextSelectionConverter.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CheckboxTreeAndListGroup.java804
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CreateJavadocActionDelegate.java54
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocConsoleLineTracker.java158
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.java125
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.properties119
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkDialogLabelProvider.java62
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkRef.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocMemberContentProvider.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocOptionsManager.java1158
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocProjectContentProvider.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocReader.java92
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java302
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocStandardWizardPage.java573
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocTreeWizardPage.java714
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizard.java456
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizardPage.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWriter.java310
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/RecentSettingsStore.java277
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ASTProvider.java672
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddClassFileMarkerAction.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddImportOnSelectionAction.java245
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicCompilationUnitEditorActionContributor.java191
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicJavaEditorActionContributor.java230
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileDocumentProvider.java389
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditor.java871
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorActionContributor.java20
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorInputFactory.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerAnnotationModel.java157
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerRulerAction.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClipboardOperationAction.java510
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitAnnotationModelEvent.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java1561
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditor.java1711
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java80
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompoundEditExitStrategy.java242
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ConstructedJavaEditorMessages.properties218
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/DocumentAdapter.java524
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorHighlightingSynchronizer.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorUtility.java636
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ExternalClassFileEditorInput.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/GotoMatchingBracketAction.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IClassFileEditorInput.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompilationUnitDocumentProvider.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompoundEditListener.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaAnnotation.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaEditorActionConstants.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ISavePolicy.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IndentUtil.java476
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/InternalClassFileEditorInput.java126
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JarEntryEditorInput.java120
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationImageProvider.java165
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationIterator.java98
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaDocumentSetupParticipant.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditor.java3612
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java99
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.java127
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.properties115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlink.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMarkerAnnotation.java159
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMoveLinesAction.java474
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaOutlinePage.java1387
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java179
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectMarkerRulerAction2.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectRulerAction.java26
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSourceViewer.java630
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaTextSelection.java211
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlink.java184
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorImageProvider.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorManager.java248
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/RemoveOccurrenceAnnotations.java41
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlighting.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingManager.java627
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java772
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java469
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightings.java1666
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticToken.java116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistAction.java148
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java75
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/StorageMarkerAnnotationModel.java102
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleCommentAction.java318
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleMarkOccurrencesAction.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/TogglePresentationAction.java149
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleTextHoverAction.java97
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/WorkingCopyManager.java129
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/AbstractSaveParticipantPreferenceConfiguration.java177
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java102
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantDescriptor.java90
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.java33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.properties12
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantRegistry.java160
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/GoToNextPreviousMemberAction.java241
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.properties32
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionHistory.java84
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectEnclosingAction.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectHistoryAction.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectNextAction.java98
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectPreviousAction.java102
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java170
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelAdapterFactory.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelContentProvider.java83
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelLabelProvider.java124
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelMerger.java85
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelProvider.java80
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringDescriptorResourceMapping.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringHistoryResourceMapping.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaResourceMapping.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationCompareAdapter.java171
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationContentProvider.java808
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationLabelProvider.java173
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.properties12
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/CommonLayoutActionGroup.java146
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/ContainerFolder.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/IExtensionStateConstants.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaDropAdapterAssistant.java252
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaFileLinkHelper.java53
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorActionProvider.java108
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorContentProvider.java334
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorLabelProvider.java182
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorRefactorActionProvider.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorViewActionProvider.java154
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialElementsFilter.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyInnerPackageFilter.java21
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyPackageFilter.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/OpenAndExpand.java264
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CollapseAllAction.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CustomHashtable.java403
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/DefaultElementComparer.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDragAdapter.java240
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDropAdapter.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoPackageAction.java83
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoRequiredProjectAction.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoResourceAction.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoTypeAction.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/HierarchicalDecorationContext.java94
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/IMultiElementTreeContentProvider.java18
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/JsGlobalScopeContainer.java182
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LayoutActionGroup.java112
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LibraryContainer.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerActionGroup.java393
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerContentProvider.java1191
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerLabelProvider.java162
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java1607
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerProblemsDecorator.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageFragmentRootContainer.java87
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesFrameSource.java41
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.java72
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.properties71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDragAdapter.java21
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDropAdapter.java244
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/ToggleLinkingAction.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareContentProvider.java246
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareJavaElementSorter.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetDropAdapter.java262
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlock.java469
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferenceAndPropertyPage.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java124
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AppearancePreferencePage.java235
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BuildPathsPropertyPage.java269
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BulletListBlock.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ClasspathVariablesPreferencePage.java144
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CleanUpPreferencePage.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java768
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java86
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistConfigurationBlock.java420
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java464
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesPreferencePage.java97
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistPreferencePage.java98
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreferencePage.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreviewCode.txt44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeStylePreferencePage.java126
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateBlock.java592
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplatePreferencePage.java141
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java159
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ColorSettingPreviewCode.txt31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ComplianceConfigurationBlock.java632
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CompliancePreferencePage.java146
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/EditTemplateDialog.java608
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingConfigurationBlock.java377
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingPreferencePage.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceAndPropertyConfigurationBlock.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceConfigurationBlock.java63
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java508
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeInputDialog.java240
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizePreferencePage.java135
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBasePreferencePage.java263
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildConfigurationBlock.java310
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildPreferencePage.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaCategoryPropertyPage.java113
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorAppearanceConfigurationBlock.java433
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java960
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringPreferencePage.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java580
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverPreferencePage.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPreferencePage.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPropertyPage.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaElementInfoPage.java142
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaPreferencesSettings.java113
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaScriptMainPage.java60
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java78
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaTemplatePreferencePage.java164
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationBlock.java920
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java254
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java266
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsPreferencePage.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java267
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferenceCache.java183
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferencePage.java405
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MockupPreferenceStore.java273
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NameConventionConfigurationBlock.java513
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NewJavaProjectPreferencePage.java529
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OccurrencesPreferencePage.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OptionsConfigurationBlock.java881
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OverlayPreferenceStore.java486
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesAccess.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.java775
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.properties906
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java546
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesPreferencePage.java154
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProfilePreferencePage.java95
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProjectSelectionDialog.java157
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertiesFileEditorColorSettingPreviewCode.txt5
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertyAndPreferencePage.java339
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantConfigurationBlock.java171
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantPreferencePage.java63
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ScrolledPageContent.java53
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingConfigurationBlock.java263
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingPreferencePage.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SourceAttachmentPropertyPage.java212
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingConfigurationBlock.java629
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingPreferenceBlock.java121
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskConfigurationBlock.java369
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskInputDialog.java162
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskPreferencePage.java143
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterInputDialog.java150
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterPreferencePage.java280
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/UserLibraryPreferencePage.java1381
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/WorkInProgressPreferencePage.java165
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java269
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.properties55
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpModifyDialog.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpPreview.java99
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileManager.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpTabPage.java158
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java208
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BlankLinesTabPage.java133
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BracesTabPage.java182
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CommentsTabPage.java242
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CompilationUnitPreview.java75
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java143
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CreateProfileDialog.java215
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.java492
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.properties554
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterModifyDialog.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileManager.java128
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileStore.java144
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterTabPage.java76
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IProfileVersioner.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IndentationTabPage.java191
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/JavaPreview.java216
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/LineWrappingTabPage.java893
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialog.java389
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java817
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/NewLinesTabPage.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java452
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileManager.java795
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileStore.java342
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileVersioner.java687
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/SnippetPreview.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java1273
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java475
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionHandler.java160
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionsControl.java317
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeParametersControl.java732
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeSignatureWizard.java396
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeContentProvider.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeWizard.java371
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ComboSelectionDialog.java92
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CompilationUnitChangeNode.java202
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ConvertAnonymousToNestedWizard.java152
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CreateTextFileChangePreviewViewer.java148
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/DelegateUIHelper.java116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractConstantWizard.java317
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractInterfaceWizard.java420
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMemberPage.java563
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMethodPage.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeWizard.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractTempWizard.java172
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IExceptionListChangeListener.java40
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IParameterListChangeListener.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IScheduledRefactoring.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IVisibilityChangeListener.java15
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InferTypeArgumentsWizard.java136
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineConstantWizard.java143
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineTempWizard.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryInputPage.java223
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryWizard.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionInputPage.java236
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionWizard.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceParameterWizard.java195
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/JavaStatusContextViewer.java133
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MessageWizardPage.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInnerToTopWizard.java184
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInstanceMethodWizard.java339
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveMembersWizard.java293
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ParameterEditDialog.java226
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PromoteTempWizard.java234
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullPushCheckboxTableViewer.java71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMemberPage.java978
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMethodPage.java562
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpWizard.java45
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PushDownWizard.java599
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/QualifiedNameComponent.java70
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringAdapterFactory.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringExecutionHelper.java211
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringMessages.java968
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSaveHelper.java226
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSavePreferences.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/TextInputWizardPage.java195
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UseSupertypeWizard.java339
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceManager.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceStarter.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/VisibilityControlUtil.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ApplyRefactoringScriptAction.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/CreateRefactoringScriptAction.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineConstantAction.java155
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineMethodAction.java149
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ListDialog.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveInstanceMethodAction.java144
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveStaticMembersAction.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringActions.java83
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringStarter.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameJavaElementAction.java222
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameResourceAction.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ShowRefactoringHistoryAction.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/binary/BinaryRefactoringHistoryWizard.java731
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodInputPage.java407
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodWizard.java45
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodInputPage.java116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodWizard.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsInputPage.java152
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CUPositionCompletionProcessor.java260
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CompletionContextRequestor.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/FieldNameProcessor.java121
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageCompletionProcessor.java155
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageFragmentRootCompletionProcessor.java150
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaSourcePackageFragmentRootCompletionProcessor.java137
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java194
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/VariableNamesProcessor.java127
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/AccessorDescription.java146
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizard.java51
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java1332
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/MultiStateCellEditor.java85
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSAccessorConfigurationDialog.java442
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.properties97
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageBrowseAdapter.java144
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageFragmentSelection.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionDialogButtonField.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionStringButtonAdapter.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/RenameKeysDialog.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceChangeListener.java18
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceContainerDialog.java107
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFirstPackageSelectionDialogField.java202
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFolderSelectionDialogButtonField.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/CompilationUnitEntry.java40
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/FileEntry.java45
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/LineReader.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchEditorOpener.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.java43
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.properties25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchQuery.java185
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResult.java234
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultLabelProvider2.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultPage.java108
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultRequestor.java377
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/Properties.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java26
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/refactoringui.properties618
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java357
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CreateTargetQueries.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CutAction.java105
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteAction.java84
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteUserInterfaceManager.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteWizard.java287
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DestinationContentProvider.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/NewNameQueries.java213
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/PasteAction.java1221
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameCuWizard.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameFieldWizard.java221
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInformationPopup.java822
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java313
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameJavaProjectWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLinkedMode.java618
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLocalVariableWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodUserInterfaceStarter.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenamePackageWizard.java84
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameRefactoringWizard.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameResourceWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSelectionState.java140
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSourceFolderWizard.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeParameterWizard.java32
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizard.java75
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardInputPage.java192
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsOptionsDialog.java165
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsPage.java778
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceManager.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceStarter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyAction.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyStarter.java71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyWizard.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.properties176
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveAction.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveStarter.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveWizard.java262
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgQueries.java418
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgUserInputPage.java146
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/TypedSourceTransfer.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldInputPage.java334
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldWizard.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/BreakContinueTargetFinder.java281
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesFinder.java267
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesGroupKey.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/FindOccurrencesEngine.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/GroupAction.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/IOccurrencesFinder.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ImplementOccurrencesFinder.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementLine.java41
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementMatch.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaMatchFilter.java524
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchContentProvider.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchEditorOpener.java151
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPage.java977
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPageScoreComputer.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchQuery.java261
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResult.java214
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResultPage.java547
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchScopeFactory.java436
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchTableContentProvider.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LRUWorkingSetsList.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LevelTreeContentProvider.java251
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/MethodExitsFinder.java258
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchResultCollector.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchViewActionGroup.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesFinder.java299
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesGroupKey.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchLabelProvider.java47
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchQuery.java108
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResult.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResultPage.java95
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OpenJavaSearchPageAction.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PatternStrings.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PostfixLabelProvider.java95
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchLabelProvider.java238
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.java250
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.properties312
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantDescriptor.java87
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantRecord.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantsExtensionPoint.java98
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchResultUpdater.java159
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchUtil.java237
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortAction.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortingLabelProvider.java101
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchLabelProvider.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchTableContentProvider.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetComparator.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetsComparator.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractInformationControl.java775
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractJavaScanner.java356
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/BufferedDocumentScanner.java176
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ChangeHoverInformationControl.java222
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CombinedWordRule.java371
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CompositeReconcilingStrategy.java117
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ContentAssistPreference.java233
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/DocumentCharacterIterator.java222
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java534
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/HTMLAnnotationHover.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ISourceVersionDependent.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ITypingRunListener.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaBreakIterator.java420
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaChangeHover.java148
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCodeReader.java239
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaColorManager.java141
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCommentScanner.java294
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCompositeReconcilingStrategy.java138
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaElementProvider.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaHeuristicScanner.java950
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaIndenter.java1643
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java752
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaPairMatcher.java155
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaPartitionScanner.java124
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaPresentationReconciler.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaReconciler.java416
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaWhitespaceDetector.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaWordDetector.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaWordFinder.java63
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaWordIterator.java223
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/LineBreakingReader.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/PreferencesAdapter.java330
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/SequenceCharacterIterator.java167
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/SimpleJavaSourceViewerConfiguration.java142
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/SingleTokenJavaScanner.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/SmartBackspaceManager.java275
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/Symbols.java55
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/TextMessages.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/TextMessages.properties25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/TypingRun.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/TypingRunDetector.java469
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/comment/CommentFormattingContext.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/comment/CommentFormattingStrategy.java373
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ASTResolving.java1097
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ASTRewriteCorrectionProposal.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AbstractMethodCompletionProposal.java206
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AddArgumentCorrectionProposal.java127
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AddImportCorrectionProposal.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AddTypeParameterProposal.java126
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java2288
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AssignToVariableAssistProposal.java345
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/AssistContext.java102
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CUCorrectionProposal.java584
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CastCompletionProposal.java176
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ChangeCorrectionProposal.java280
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ChangeMethodSignatureProposal.java481
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ConstructorFromSuperclassProposal.java237
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ContributedProcessorDescriptor.java137
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectMainTypeNameProposal.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectPackageDeclarationProposal.java88
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectionCommandHandler.java156
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectionCommandInstaller.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectionMarkerResolutionGenerator.java590
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectionMessages.java315
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/CorrectionMessages.properties353
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/FixCorrectionProposal.java201
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ICommandAccess.java26
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/IStatusLineProposal.java30
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ImplementInterfaceProposal.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/JavaCorrectionAssistant.java329
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/JavaCorrectionProcessor.java495
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/JavadocTagsSubProcessor.java597
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/LinkedCorrectionProposal.java95
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/LinkedNamesAssistProposal.java288
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java1015
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/MarkerResolutionProposal.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/MissingReturnTypeCorrectionProposal.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ModifierChangeCompletionProposal.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java1150
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/NameMatcher.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/NewCUCompletionUsingWizardProposal.java442
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/NewDefiningMethodProposal.java149
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/NewMethodCompletionProposal.java270
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/NewVariableCompletionProposal.java502
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ProblemLocation.java174
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java281
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/QuickAssistProcessor.java1371
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/QuickFixProcessor.java544
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/QuickTemplateProcessor.java195
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/RemoveDeclarationCorrectionProposal.java237
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/RenameNodeCompletionProposal.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java547
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ReplaceCorrectionProposal.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/ReturnTypeSubProcessor.java324
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/SimilarElement.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/SimilarElementsRequestor.java232
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/SurroundWith.java563
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/TaskMarkerProposal.java152
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/TypeChangeCompletionProposal.java161
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/TypeMismatchSubProcessor.java363
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/TypeParameterMismatchSubProcessor.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/UnimplementedMethodsCompletionProposal.java109
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java1603
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/DefaultJavaFoldingPreferenceBlock.java153
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/EmptyJavaFoldingPreferenceBlock.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/FoldingMessages.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/FoldingMessages.properties22
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/JavaFoldingStructureProviderDescriptor.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/folding/JavaFoldingStructureProviderRegistry.java139
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/BrowserInformationControl.java591
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/HTML2TextReader.java330
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/HTMLMessages.java83
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/HTMLMessages.properties16
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/HTMLPrinter.java306
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/HTMLTextPresenter.java315
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/SingleCharReader.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/html/SubstitutionTextReader.java162
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java1035
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AlphabeticSorter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AnonymousTypeCompletionProposal.java285
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AnonymousTypeProposalInfo.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/CompletionProposalCategory.java327
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java547
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/CompletionProposalComputerRegistry.java388
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ContentAssistComputerParameter.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ContentAssistHistory.java481
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ContentAssistProcessor.java559
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/FieldProposalInfo.java63
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/FillArgumentNamesCompletionProposalCollector.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/FilledArgumentNamesMethodProposal.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/GetterSetterCompletionProposal.java147
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/HippieProposalComputer.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/IJavaReconcilingListener.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/IProblemRequestorExtension.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/IReconcilingParticipant.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ImportCompletionProposal.java206
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaAutoIndentStrategy.java1314
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaCodeScanner.java561
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaCompletionProcessor.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaCompletionProposal.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaCompletionProposalComputer.java246
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaContentAssistHandler.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaDoubleClickSelector.java340
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaFormattingStrategy.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaMethodCompletionProposal.java222
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaNoTypeCompletionProposalComputer.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaParameterListValidator.java318
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaReconcilingStrategy.java191
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java199
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaStringDoubleClickSelector.java70
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaTextMessages.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaTextMessages.properties69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaTypeCompletionProposal.java120
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaTypeCompletionProposalComputer.java192
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/JavadocDoubleClickStrategy.java249
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/LazyGenericTypeProposal.java790
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/LazyJavaCompletionProposal.java429
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java387
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/MemberProposalInfo.java70
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/MethodDeclarationCompletionProposal.java189
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/MethodProposalInfo.java225
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/OverrideCompletionProposal.java174
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ParameterGuesser.java669
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ParameterGuessingProposal.java319
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ProposalContextInformation.java105
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ProposalInfo.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ProposalSorterHandle.java280
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/ProposalSorterRegistry.java123
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/RelevanceSorter.java37
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/SmartSemicolonAutoEditStrategy.java1012
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/TemplateCompletionProposalComputer.java208
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/TypeProposalInfo.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/AbstractAnnotationHover.java176
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/AbstractJavaEditorTextHover.java182
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/AnnotationExpandHover.java308
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/AnnotationExpansionControl.java844
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/AnnotationHover.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/BestMatchHover.java130
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java293
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java109
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaExpandHover.java204
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaHoverMessages.java39
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaHoverMessages.properties23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaInformationProvider.java178
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaSourceHover.java142
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavaTypeHover.java54
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/JavadocHover.java233
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/NLSStringHover.java157
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/ProblemHover.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/hover/SourceViewerInformationControl.java458
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/HTMLTagCompletionProposalComputer.java250
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/IHtmlTagConstants.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/IJavaDocTagConstants.java38
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java371
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java437
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavaDocMessages.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavaDocMessages.properties18
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavaDocScanner.java214
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavadocCompletionProcessor.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavadocCompletionProposalComputer.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavadocContentAssistInvocationContext.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavadocInlineTagCompletionProposal.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/JavadocLinkTypeCompletionProposal.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/LegacyJavadocCompletionProposalComputer.java157
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/javadoc/OAADocReader.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/AddWordProposal.java185
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/ChangeCaseProposal.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/CoreSpellingProblem.java192
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/DefaultSpellingEngine.java92
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/HtmlTagDictionary.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/JavaDocTagDictionary.java71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/JavaSpellingEngine.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/JavaSpellingProblem.java228
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/JavaSpellingReconcileStrategy.java229
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/SpellCheckEngine.java441
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/SpellCheckIterator.java417
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/SpellingEngine.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/TaskTagDictionary.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/TextSpellingEngine.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/WordCompletionProposalComputer.java136
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/WordCorrectionProposal.java174
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/WordIgnoreProposal.java124
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/WordQuickFixProcessor.java124
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java615
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java683
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java375
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellChecker.java126
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellDictionary.java77
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellEvent.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/ISpellEventListener.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java59
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java99
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/RankedWordProposal.java102
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/spelling/engine/SpellEvent.java109
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/InclusivePositionUpdater.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/MultiVariable.java133
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/MultiVariableGuess.java283
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/PositionBasedCompletionProposal.java197
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/SurroundWithTemplateProposal.java267
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.java32
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.properties17
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/TemplateEngine.java164
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/TemplateProposal.java537
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/contentassist/VariablePosition.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/preferences/TemplateContentProvider.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.properties12
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/preferences/TemplateVariableProcessor.java167
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/template/preferences/TemplateVariableProposal.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/AbstractHierarchyViewerSorter.java169
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/EnableMemberFilterAction.java51
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/FocusOnSelectionAction.java70
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/FocusOnTypeAction.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HierarchyInformationControl.java372
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HierarchyLabelProvider.java186
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HierarchyViewerSorter.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HistoryAction.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HistoryDropDownAction.java105
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/HistoryListAction.java181
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ITypeHierarchyLifeCycleListener.java27
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/MethodsContentProvider.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/MethodsLabelProvider.java147
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/MethodsViewer.java316
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java54
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java50
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/SortByDefiningTypeAction.java53
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ToggleLinkingAction.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ToggleOrientationAction.java71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/ToggleViewAction.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java176
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java357
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java274
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyMessages.java99
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties109
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyTransferDropAdapter.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java1646
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/typehierarchy/TypeHierarchyViewer.java194
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/BusyIndicatorRunnableContext.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/CoreUtility.java196
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/ElementValidator.java203
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/ExceptionHandler.java134
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/JSDScopeUiUtil.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/JavaUIHelp.java133
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/JavadocHelpContext.java242
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/OpenTypeHierarchyUtil.java183
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/PatternConstructor.java129
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/PixelConverter.java62
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/RowLayouter.java184
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/SWTUtil.java109
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/SelectionUtil.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/StringMatcher.java384
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/TableLayoutComposite.java186
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/TypeNameMatchLabelProvider.java129
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/util/ViewerPane.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java120
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/BindingLabelProvider.java526
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredJavaElementLabels.java996
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredString.java173
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredViewersManager.java218
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/DecoratingJavaLabelProvider.java101
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/FilterUpdater.java78
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/HistoryDropDownAction.java153
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/HistoryListAction.java241
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/IProblemChangedListener.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/IRichLabelProvider.java19
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ISelectionListenerWithAST.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/IViewPartInputProvider.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ImageDescriptorRegistry.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ImageDisposer.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ImageImageDescriptor.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaElementImageProvider.java543
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaUILabelProvider.java278
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaViewerFilter.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/LabelProviderDisposer.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/LibraryFilter.java33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/MemberFilter.java119
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/MemberFilterAction.java49
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/OwnerDrawSupport.java163
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ProblemMarkerManager.java180
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ProblemTableViewer.java141
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ProblemTreeViewer.java328
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ProjectTemplateStore.java172
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ResourceToItemsMapper.java179
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java211
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/SelectionProviderMediator.java206
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/SourcePositionComparator.java113
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/StatusBarUpdater.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/StorageLabelProvider.java136
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/TreeHierarchyLayoutProblemsDecorator.java74
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ViewHistory.java103
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/ClassPathDetector.java383
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/IStatusChangeListener.java23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/JavaProjectWizard.java188
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/JavaProjectWizardFirstPage.java931
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/JavaProjectWizardSecondPage.java494
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewClassCreationWizard.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewElementWizard.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewInterfaceCreationWizard.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java257
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java91
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewPackageCreationWizard.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewSourceFolderCreationWizard.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewSourceFolderWizardPage.java537
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewTypeDropDownAction.java211
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewWizardMessages.java764
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewWizardMessages.properties1020
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/OpenJavaProjectWizardToolbarAction.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/OpenPackageWizardToolbarAction.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/SuperInterfaceSelectionDialog.java202
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/TypedElementSelectionValidator.java100
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/TypedViewerFilter.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/AccessRuleEntryDialog.java173
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java361
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/AccessRulesLabelProvider.java78
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/AddSourceFolderWizard.java119
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/AddSourceFolderWizardPage.java759
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ArchiveFileFilter.java110
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/BuildPathBasePage.java167
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/BuildPathSupport.java303
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/BuildPathWizard.java114
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java1231
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPListElement.java853
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPListElementAttribute.java148
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPListElementSorter.java104
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPListLabelProvider.java415
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPUserLibraryElement.java213
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPVariableElement.java106
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CPVariableElementLabelProvider.java146
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ClasspathAttributeConfigurationDescriptors.java122
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ClasspathOrderingWorkbookPage.java233
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/CreateMultipleSourceFoldersDialog.java298
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/EditFilterWizard.java62
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/EditVariableEntryDialog.java329
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ExclusionInclusionDialog.java314
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ExclusionInclusionEntryDialog.java285
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/FolderSelectionDialog.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JARFileSelectionDialog.java186
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JavadocAttributeConfiguration.java116
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java85
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JsGlobalScopeContainerDefaultPage.java142
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JsGlobalScopeContainerDescriptor.java131
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JsGlobalScopeContainerSelectionPage.java150
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/JsGlobalScopeContainerWizard.java224
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java887
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/MultipleFolderSelectionDialog.java312
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/NewContainerDialog.java158
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/NewSourceFolderDialog.java194
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/NewVariableEntryDialog.java345
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/ProjectsWorkbookPage.java475
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/SetFilterWizardPage.java336
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java594
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/SourceAttachmentDialog.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/SourceContainerWorkbookPage.java996
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/UserLibraryMarkerResolutionGenerator.java254
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/UserLibraryWizardPage.java324
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/VariableBlock.java433
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/VariableCreationDialog.java284
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/VariablePathDialogField.java209
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/AddFolderToBuildpathAction.java292
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/AddSelectedLibraryToBuildpathAction.java175
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/BuildpathModifierAction.java192
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierDropDownAction.java178
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java673
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/CreateLinkedSourceFolderAction.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/CreateLinkedSourceFolderAction2.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/CreateSourceFolderAction.java135
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/CreateSourceFolderAction2.java36
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/DialogPackageExplorer.java537
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/DialogPackageExplorerActionGroup.java330
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/EditFilterAction.java168
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/ExcludeFromBuildpathAction.java175
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/HelpAction.java34
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/HintTextGroup.java321
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/IncludeToBuildpathAction.java171
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/LinkFolderDialog.java515
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/NewSourceContainerWorkbookPage.java415
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveFromBuildpathAction.java263
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveLinkedFolderDialog.java96
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/buildpaths/newsourcepage/ResetAllAction.java184
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java284
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/ComboDialogField.java252
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/DialogField.java239
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/IListAdapter.java33
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java20
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java46
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/LayoutUtil.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/ListDialogField.java942
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/ObjectStringStatusButtonDialogField.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java209
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java274
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/Separator.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java141
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/StringButtonStatusDialogField.java180
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/StringDialogField.java190
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/dialogfields/TreeListDialogField.java909
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/full_rhino_transparent.gifbin2193 -> 0 bytes-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/AbstractWorkingSetWizardPage.java136
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/ClearWorkingSetAction.java42
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/ConfigureWorkingSetAction.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/ConfigureWorkingSetAssignementAction.java573
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/EditWorkingSetAction.java89
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/EditorTracker.java71
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/IWorkingSetActionGroup.java23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/JavaWorkingSetElementAdapter.java73
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/JavaWorkingSetPage.java480
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/JavaWorkingSetPageContentProvider.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/JavaWorkingSetUpdater.java242
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/Mementos.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/OpenPropertiesWorkingSetAction.java55
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/OthersWorkingSetUpdater.java204
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/RemoveWorkingSetElementAction.java82
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/SelectWorkingSetAction.java85
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java335
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/ViewAction.java35
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/ViewActionGroup.java177
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java403
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java609
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetFilter.java222
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java355
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java101
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetMessages.java87
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetMessages.properties79
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetModel.java456
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/workingsets/WorkingSetShowActionGroup.java76
1214 files changed, 0 insertions, 266848 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/CompatibilityTemplateStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/CompatibilityTemplateStore.java
deleted file mode 100644
index 1416c89f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/CompatibilityTemplateStore.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
-
-
-/**
- * for compatibility only - don't use
- */
-public final class CompatibilityTemplateStore extends ContributionTemplateStore {
-
-
- private org.eclipse.wst.jsdt.internal.corext.template.java.TemplateSet fLegacySet;
-
- public CompatibilityTemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key, org.eclipse.wst.jsdt.internal.corext.template.java.TemplateSet legacySet) {
- super(registry, store, key);
- fLegacySet= legacySet;
- }
-
- public void load() throws IOException {
- super.load();
-
- if (fLegacySet != null) {
-
- List legacyTemplates= new ArrayList(Arrays.asList(fLegacySet.getTemplates()));
- fLegacySet.clear();
-
- TemplatePersistenceData[] datas= getTemplateData(true);
- for (Iterator it= legacyTemplates.listIterator(); it.hasNext();) {
- Template t= (Template) it.next();
- TemplatePersistenceData orig= findSimilarTemplate(datas, t, isCodeTemplates());
- if (orig == null) { // no contributed match for the old template found
- if (!isCodeTemplates())
- add(new TemplatePersistenceData(t, true));
- } else { // a contributed template seems to be the descendant of the non-id template t
- if (!orig.getTemplate().getPattern().equals(t.getPattern()))
- // add as modified contributed template if changed compared to the original
- orig.setTemplate(t);
- }
- }
-
- save();
- fLegacySet= null;
- }
- }
-
- private static TemplatePersistenceData findSimilarTemplate(TemplatePersistenceData[] datas, Template template, boolean isCodeTemplates) {
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
- Template orig= data.getTemplate();
- if (isSimilar(template, orig, isCodeTemplates))
- return data;
- }
-
- return null;
- }
-
- private static boolean isSimilar(Template t, Template orig, boolean isCodeTemplates) {
- return orig.getName().equals(t.getName()) && orig.getContextTypeId().equals(t.getContextTypeId())
- && (isCodeTemplates || orig.getDescription().equals(t.getDescription())); // only use description for templates (for, while...)
- }
-
- private boolean isCodeTemplates() {
- return fLegacySet instanceof org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplates;
- }
-
- /**
- * Removes any duplicates from a template store. Duplicate user added templates
- * are copied over their contributed siblings. If isCodeTemplates is true,
- * any user added templates are then removed.
- *
- * @param store
- * @param isCodeTemplates
- */
- public static void pruneDuplicates(TemplateStore store, boolean isCodeTemplates) {
- TemplatePersistenceData[] datas= store.getTemplateData(true);
- for (int i= datas.length - 1; i >= 0; i--) {
- TemplatePersistenceData data= datas[i];
- if (data.isUserAdded()) {
- // find a contributed template that is similar and check it
- TemplatePersistenceData similar= findSimilarTemplate(datas, data.getTemplate(), isCodeTemplates);
- if (similar != data && !similar.isUserAdded()) {
- similar.setTemplate(data.getTemplate());
- store.delete(data);
- }
- }
- }
-
- if (isCodeTemplates) {
- datas= store.getTemplateData(true);
- for (int i= datas.length - 1; i >= 0; i--) {
- if (datas[i].isUserAdded())
- store.delete(datas[i]);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/EditorInputAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/EditorInputAdapterFactory.java
deleted file mode 100644
index 5bf498df..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/EditorInputAdapterFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Adapter factory to support basic UI operations for for editor inputs.
- */
-public class EditorInputAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {IJavaScriptElement.class};
-
- private Object fSearchPageScoreComputer;
-
- public Class[] getAdapterList() {
- updateLazyLoadedAdapters();
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- updateLazyLoadedAdapters();
- if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key))
- return fSearchPageScoreComputer;
-
- if (IJavaScriptElement.class.equals(key) && element instanceof IEditorInput) {
- IJavaScriptElement je= JavaScriptUI.getWorkingCopyManager().getWorkingCopy((IEditorInput)element);
- if (je != null)
- return je;
- if (element instanceof IStorageEditorInput) {
- try {
- return ((IStorageEditorInput)element).getStorage().getAdapter(key);
- } catch (CoreException ex) {
- // Fall through
- }
- }
- }
- return null;
- }
-
- private void updateLazyLoadedAdapters() {
- if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
- createSearchPageScoreComputer();
- }
-
- private void createSearchPageScoreComputer() {
- fSearchPageScoreComputer= new JavaSearchPageScoreComputer();
- PROPERTIES= new Class[] {ISearchPageScoreComputer.class, IJavaScriptElement.class};
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaHelpContextIds.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaHelpContextIds.java
deleted file mode 100644
index 6503d50d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaHelpContextIds.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids <sdavids@gmx.de> bug 38692
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-/**
- * Help context ids for the Java UI.
- * <p>
- * This interface contains constants only; it is not intended to be implemented
- * or extended.
- * </p>
- *
- */
-public interface IJavaHelpContextIds {
- public static final String PREFIX= JavaScriptUI.ID_PLUGIN + '.';
-
- // Actions
- public static final String GETTERSETTER_ACTION= PREFIX + "getter_setter_action_context"; //$NON-NLS-1$
- public static final String ADD_UNIMPLEMENTED_METHODS_ACTION= PREFIX + "add_unimplemented_methods_action_context"; //$NON-NLS-1$
- /* */
- public static final String GENERATE_HASHCODE_EQUALS_ACTION= PREFIX + "add_hashcode_equals_action_context"; //$NON-NLS-1$
- public static final String ADD_UNIMPLEMENTED_CONSTRUCTORS_ACTION= PREFIX + "add_unimplemented_constructors_action_context"; //$NON-NLS-1$
- public static final String CREATE_NEW_CONSTRUCTOR_ACTION= PREFIX + "create_new_constructor_action_context"; //$NON-NLS-1$
- public static final String SHOW_IN_PACKAGEVIEW_ACTION= PREFIX + "show_in_packageview_action_context"; //$NON-NLS-1$
- public static final String SHOW_IN_HIERARCHYVIEW_ACTION= PREFIX + "show_in_hierarchyview_action_context"; //$NON-NLS-1$
- public static final String FOCUS_ON_SELECTION_ACTION= PREFIX + "focus_on_selection_action"; //$NON-NLS-1$
- public static final String FOCUS_ON_TYPE_ACTION= PREFIX + "focus_on_type_action"; //$NON-NLS-1$
-
- public static final String TYPEHIERARCHY_HISTORY_ACTION= PREFIX + "typehierarchy_history_action"; //$NON-NLS-1$
- public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action"; //$NON-NLS-1$
- public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action"; //$NON-NLS-1$
- public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action"; //$NON-NLS-1$
- public static final String FILTER_LOCALTYPES_ACTION= PREFIX + "filter_localtypes_action"; //$NON-NLS-1$
-
- public static final String SHOW_INHERITED_ACTION= PREFIX + "show_inherited_action"; //$NON-NLS-1$
- public static final String SHOW_SUPERTYPES= PREFIX + "show_supertypes_action"; //$NON-NLS-1$
- public static final String SHOW_SUBTYPES= PREFIX + "show_subtypes_action"; //$NON-NLS-1$
- public static final String SHOW_HIERARCHY= PREFIX + "show_hierarchy_action"; //$NON-NLS-1$
- public static final String ENABLE_METHODFILTER_ACTION= PREFIX + "enable_methodfilter_action"; //$NON-NLS-1$
- public static final String ADD_IMPORT_ON_SELECTION_ACTION= PREFIX + "add_imports_on_selection_action_context"; //$NON-NLS-1$
- public static final String ORGANIZE_IMPORTS_ACTION= PREFIX + "organize_imports_action_context"; //$NON-NLS-1$
- public static final String ADD_TO_CLASSPATH_ACTION= PREFIX + "addjtoclasspath_action_context"; //$NON-NLS-1$
- public static final String REMOVE_FROM_CLASSPATH_ACTION= PREFIX + "removefromclasspath_action_context"; //$NON-NLS-1$
-
- public static final String TOGGLE_PRESENTATION_ACTION= PREFIX + "toggle_presentation_action_context"; //$NON-NLS-1$
- public static final String TOGGLE_MARK_OCCURRENCES_ACTION= PREFIX + "toggle_mark_occurrences_action_context"; //$NON-NLS-1$
- public static final String TOGGLE_TEXTHOVER_ACTION= PREFIX + "toggle_texthover_action_context"; //$NON-NLS-1$
-
- public static final String OPEN_CLASS_WIZARD_ACTION= PREFIX + "open_class_wizard_action"; //$NON-NLS-1$
- public static final String OPEN_INTERFACE_WIZARD_ACTION= PREFIX + "open_interface_wizard_action"; //$NON-NLS-1$
- /** */
- public static final String OPEN_ENUM_WIZARD_ACTION= PREFIX + "open_enum_wizard_action"; //$NON-NLS-1$
- /** */
- public static final String OPEN_ANNOTATION_WIZARD_ACTION= PREFIX + "open_annotation_wizard_action"; //$NON-NLS-1$
-
- public static final String SORT_MEMBERS_ACTION= PREFIX + "sort_members_action"; //$NON-NLS-1$
-
- public static final String OPEN_PACKAGE_WIZARD_ACTION= PREFIX + "open_package_wizard_action"; //$NON-NLS-1$
- public static final String OPEN_PROJECT_WIZARD_ACTION= PREFIX + "open_project_wizard_action"; //$NON-NLS-1$
- /** */
- public static final String OPEN_SOURCEFOLDER_WIZARD_ACTION= PREFIX + "open_sourcefolder_wizard_action"; //$NON-NLS-1$
-
- public static final String EDIT_WORKING_SET_ACTION= PREFIX + "edit_working_set_action"; //$NON-NLS-1$
- public static final String CLEAR_WORKING_SET_ACTION= PREFIX + "clear_working_set_action"; //$NON-NLS-1$
- public static final String GOTO_MARKER_ACTION= PREFIX + "goto_marker_action"; //$NON-NLS-1$
- public static final String GOTO_PACKAGE_ACTION= PREFIX + "goto_package_action"; //$NON-NLS-1$
- public static final String GOTO_TYPE_ACTION= PREFIX + "goto_type_action"; //$NON-NLS-1$
- public static final String GOTO_MATCHING_BRACKET_ACTION= PREFIX + "goto_matching_bracket_action"; //$NON-NLS-1$Object[] FORMAT_ALL= null;
-
- /**
- *
- */
- public static final String FORMAT_ALL= PREFIX + "format_all_action"; //$NON-NLS-1$
-
- public static final String GOTO_NEXT_MEMBER_ACTION= PREFIX + "goto_next_member_action"; //$NON-NLS-1$
- public static final String GOTO_PREVIOUS_MEMBER_ACTION= PREFIX + "goto_previous_member_action"; //$NON-NLS-1$
- public static final String HISTORY_ACTION= PREFIX + "history_action"; //$NON-NLS-1$
- public static final String HISTORY_LIST_ACTION= PREFIX + "history_list_action"; //$NON-NLS-1$
- public static final String LEXICAL_SORTING_OUTLINE_ACTION= PREFIX + "lexical_sorting_outline_action"; //$NON-NLS-1$
- public static final String LEXICAL_SORTING_BROWSING_ACTION= PREFIX + "lexical_sorting_browsing_action"; //$NON-NLS-1$
- public static final String OPEN_JAVA_PERSPECTIVE_ACTION= PREFIX + "open_java_perspective_action"; //$NON-NLS-1$
- public static final String ADD_DELEGATE_METHODS_ACTION= PREFIX + "add_delegate_methods_action"; //$NON-NLS-1$
-
- public static final String OPEN_JAVA_BROWSING_PERSPECTIVE_ACTION= PREFIX + "open_java_browsing_perspective_action"; //$NON-NLS-1$
- public static final String OPEN_PROJECT_ACTION= PREFIX + "open_project_action"; //$NON-NLS-1$
-
- public static final String OPEN_TYPE_ACTION= PREFIX + "open_type_action"; //$NON-NLS-1$
- public static final String OPEN_TYPE_IN_HIERARCHY_ACTION= PREFIX + "open_type_in_hierarchy_action"; //$NON-NLS-1$
-
-
- /**
- *
- */
- public static final String CONFIG_CONTAINER_ACTION= PREFIX + "org.eclipse.wst.jsdt.ui.config_container_action"; //$NON-NLS-1$
-
- public static final String ADD_JAVADOC_STUB_ACTION= PREFIX + "add_javadoc_stub_action"; //$NON-NLS-1$
- public static final String ADD_TASK_ACTION= PREFIX + "add_task_action"; //$NON-NLS-1$
- public static final String EXTERNALIZE_STRINGS_ACTION= PREFIX + "externalize_strings_action"; //$NON-NLS-1$
- public static final String EXTRACT_METHOD_ACTION= PREFIX + "extract_method_action"; //$NON-NLS-1$
- public static final String EXTRACT_TEMP_ACTION= PREFIX + "extract_temp_action"; //$NON-NLS-1$
- public static final String PROMOTE_TEMP_TO_FIELD_ACTION= PREFIX + "promote_temp_to_field_action"; //$NON-NLS-1$
- public static final String CONVERT_ANONYMOUS_TO_NESTED_ACTION= PREFIX + "convert_anonymous_to_nested_action"; //$NON-NLS-1$
- public static final String EXTRACT_CONSTANT_ACTION= PREFIX + "extract_constant_action"; //$NON-NLS-1$
- public static final String INTRODUCE_PARAMETER_ACTION= PREFIX + "introduce_parameter_action"; //$NON-NLS-1$
- public static final String INTRODUCE_FACTORY_ACTION= PREFIX + "introduce_factory_action"; //$NON-NLS-1$
- /**
- *
- */
- public static final String INTRODUCE_INDIRECTION_ACTION= PREFIX + "introduce_indirection_action"; //$NON-NLS-1$
-
- public static final String EXTRACT_INTERFACE_ACTION= PREFIX + "extract_interface_action"; //$NON-NLS-1$
- public static final String CHANGE_TYPE_ACTION= PREFIX + "change_type_action"; //$NON-NLS-1$
- public static final String MOVE_INNER_TO_TOP_ACTION= PREFIX + "move_inner_to_top_level_action"; //$NON-NLS-1$
- public static final String USE_SUPERTYPE_ACTION= PREFIX + "use_supertype_action"; //$NON-NLS-1$
- public static final String FIND_DECLARATIONS_IN_WORKSPACE_ACTION= PREFIX + "find_declarations_in_workspace_action"; //$NON-NLS-1$
- public static final String FIND_DECLARATIONS_IN_PROJECT_ACTION= PREFIX + "find_declarations_in_project_action"; //$NON-NLS-1$
- public static final String FIND_DECLARATIONS_IN_HIERARCHY_ACTION= PREFIX + "find_declarations_in_hierarchy_action"; //$NON-NLS-1$
- public static final String FIND_DECLARATIONS_IN_WORKING_SET_ACTION= PREFIX + "find_declarations_in_working_set_action"; //$NON-NLS-1$
- public static final String FIND_IMPLEMENTORS_IN_WORKSPACE_ACTION= PREFIX + "find_implementors_in_workspace_action"; //$NON-NLS-1$
- public static final String FIND_IMPLEMENTORS_IN_PROJECT_ACTION= PREFIX + "find_implementors_in_project_action"; //$NON-NLS-1$
- public static final String FIND_IMPLEMENTORS_IN_WORKING_SET_ACTION= PREFIX + "find_implementors_in_working_set_action"; //$NON-NLS-1$
- public static final String FIND_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_references_in_workspace_action"; //$NON-NLS-1$
- public static final String FIND_REFERENCES_IN_PROJECT_ACTION= PREFIX + "find_references_in_project_action"; //$NON-NLS-1$
- public static final String FIND_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_references_in_hierarchy_action"; //$NON-NLS-1$
- public static final String FIND_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_references_in_working_set_action"; //$NON-NLS-1$
- public static final String FIND_READ_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_read_references_in_workspace_action"; //$NON-NLS-1$
- public static final String FIND_READ_REFERENCES_IN_PROJECT_ACTION= PREFIX + "find_read_references_in_project_action"; //$NON-NLS-1$
- public static final String FIND_READ_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_read_references_in_hierarchy_action"; //$NON-NLS-1$
- public static final String FIND_READ_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_read_references_in_working_set_action"; //$NON-NLS-1$
- public static final String FIND_WRITE_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_write_references_in_hierarchy_action"; //$NON-NLS-1$
- public static final String FIND_WRITE_REFERENCES_IN_PROJECT_ACTION= PREFIX + "find_write_references_in_project_action"; //$NON-NLS-1$
- public static final String FIND_WRITE_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_write_references_in_working_set_action"; //$NON-NLS-1$
- public static final String FIND_WRITE_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_write_references_in_workspace_action"; //$NON-NLS-1$
- public static final String FIND_OCCURRENCES_IN_FILE_ACTION= PREFIX + "find_occurrences_in_file_action"; //$NON-NLS-1$
- public static final String FIND_EXCEPTION_OCCURRENCES= PREFIX + "find_exception_occurrences"; //$NON-NLS-1$
- public static final String FIND_IMPLEMENT_OCCURRENCES= PREFIX + "find_implement_occurrences"; //$NON-NLS-1$
- public static final String WORKING_SET_FIND_ACTION= PREFIX + "working_set_find_action"; //$NON-NLS-1$
- public static final String FIND_STRINGS_TO_EXTERNALIZE_ACTION= PREFIX + "find_strings_to_externalize_action"; //$NON-NLS-1$
- public static final String INLINE_ACTION= PREFIX + "inline_action"; //$NON-NLS-1$
- /**
- *
- */
- public static final String REPLACE_INVOCATIONS_ACTION= PREFIX + "replace_invocations_action"; //$NON-NLS-1$
- public static final String MODIFY_PARAMETERS_ACTION= PREFIX + "modify_parameters_action"; //$NON-NLS-1$
- public static final String MOVE_ACTION= PREFIX + "move_action"; //$NON-NLS-1$
- public static final String OPEN_ACTION= PREFIX + "open_action"; //$NON-NLS-1$
- public static final String OPEN_EXTERNAL_JAVADOC_ACTION= PREFIX + "open_external_javadoc_action"; //$NON-NLS-1$
- public static final String OPEN_INPUT_ACTION= PREFIX + "open_input_action"; //$NON-NLS-1$
- public static final String OPEN_SUPER_IMPLEMENTATION_ACTION= PREFIX + "open_super_implementation_action"; //$NON-NLS-1$
- public static final String PULL_UP_ACTION= PREFIX + "pull_up_action"; //$NON-NLS-1$
- /**
- *
- */
- public static final String EXTRACT_SUPERTYPE_ACTION= PREFIX + "extract_supertype_action"; //$NON-NLS-1$
- public static final String PUSH_DOWN_ACTION= PREFIX + "push_down_action"; //$NON-NLS-1$
- public static final String REFRESH_ACTION= PREFIX + "refresh_action"; //$NON-NLS-1$
- public static final String RENAME_ACTION= PREFIX + "rename_action"; //$NON-NLS-1$
- public static final String SELF_ENCAPSULATE_ACTION= PREFIX + "self_encapsulate_action"; //$NON-NLS-1$
- public static final String SHOW_IN_NAVIGATOR_VIEW_ACTION= PREFIX + "show_in_navigator_action"; //$NON-NLS-1$
- public static final String SURROUND_WITH_TRY_CATCH_ACTION= PREFIX + "surround_with_try_catch_action"; //$NON-NLS-1$
- public static final String OPEN_RESOURCE_ACTION= PREFIX + "open_resource_action"; //$NON-NLS-1$
- public static final String SELECT_WORKING_SET_ACTION= PREFIX + "select_working_set_action"; //$NON-NLS-1$
- public static final String STRUCTURED_SELECTION_HISTORY_ACTION= PREFIX + "structured_selection_history_action"; //$NON-NLS-1$
- public static final String STRUCTURED_SELECT_ENCLOSING_ACTION= PREFIX + "structured_select_enclosing_action"; //$NON-NLS-1$
- public static final String STRUCTURED_SELECT_NEXT_ACTION= PREFIX + "structured_select_next_action"; //$NON-NLS-1$
- public static final String STRUCTURED_SELECT_PREVIOUS_ACTION= PREFIX + "structured_select_previous_action"; //$NON-NLS-1$
- public static final String TOGGLE_ORIENTATION_ACTION= PREFIX + "toggle_orientations_action"; //$NON-NLS-1$
- public static final String CUT_ACTION= PREFIX + "cut_action"; //$NON-NLS-1$
- public static final String COPY_ACTION= PREFIX + "copy_action"; //$NON-NLS-1$
- public static final String PASTE_ACTION= PREFIX + "paste_action"; //$NON-NLS-1$
- public static final String DELETE_ACTION= PREFIX + "delete_action"; //$NON-NLS-1$
- public static final String SELECT_ALL_ACTION= PREFIX + "select_all_action"; //$NON-NLS-1$
- public static final String OPEN_TYPE_HIERARCHY_ACTION= PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$
- public static final String COLLAPSE_ALL_ACTION= PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$
- public static final String GOTO_RESOURCE_ACTION= PREFIX + "goto_resource_action"; //$NON-NLS-1$
- public static final String LINK_EDITOR_ACTION= PREFIX + "link_editor_action"; //$NON-NLS-1$
- public static final String GO_INTO_TOP_LEVEL_TYPE_ACTION= PREFIX + "go_into_top_level_type_action"; //$NON-NLS-1$
- public static final String COMPARE_WITH_HISTORY_ACTION= PREFIX + "compare_with_history_action"; //$NON-NLS-1$
- public static final String REPLACE_WITH_PREVIOUS_FROM_HISTORY_ACTION= PREFIX + "replace_with_previous_from_history_action"; //$NON-NLS-1$
- public static final String REPLACE_WITH_HISTORY_ACTION= PREFIX + "replace_with_history_action"; //$NON-NLS-1$
- public static final String ADD_FROM_HISTORY_ACTION= PREFIX + "add_from_history_action"; //$NON-NLS-1$
- public static final String LAYOUT_FLAT_ACTION= PREFIX + "layout_flat_action"; //$NON-NLS-1$
- public static final String LAYOUT_HIERARCHICAL_ACTION= PREFIX + "layout_hierarchical_action"; //$NON-NLS-1$
- // *** Don't delete this constants and the doc since it is still used in refactoring
- public static final String NEXT_CHANGE_ACTION= PREFIX + "next_change_action"; //$NON-NLS-1$
- public static final String PREVIOUS_CHANGE_ACTION= PREFIX + "previous_change_action"; //$NON-NLS-1$
- public static final String NEXT_PROBLEM_ACTION= PREFIX + "next_problem_action"; //$NON-NLS-1$
- public static final String PREVIOUS_PROBLEM_ACTION= PREFIX + "previous_problem_action"; //$NON-NLS-1$
- // *** end
- public static final String JAVA_SELECT_MARKER_RULER_ACTION= PREFIX + "java_select_marker_ruler_action"; //$NON-NLS-1$
- public static final String SHOW_QUALIFIED_NAMES_ACTION= PREFIX + "show_qualified_names_action"; //$NON-NLS-1$
- public static final String SORT_BY_DEFINING_TYPE_ACTION= PREFIX + "sort_by_defining_type_action"; //$NON-NLS-1$
- public static final String FORMAT_ACTION= PREFIX + "format_action"; //$NON-NLS-1$
- public static final String COMMENT_ACTION= PREFIX + "comment_action"; //$NON-NLS-1$
- public static final String UNCOMMENT_ACTION= PREFIX + "uncomment_action"; //$NON-NLS-1$
- /**
- *
- */
- public static final String TOGGLE_COMMENT_ACTION= PREFIX + "toggle_comment_action"; //$NON-NLS-1$
- public static final String ADD_BLOCK_COMMENT_ACTION= PREFIX + "add_block_comment_action"; //$NON-NLS-1$
- public static final String REMOVE_BLOCK_COMMENT_ACTION= PREFIX + "remove_block_comment_action"; //$NON-NLS-1$
- public static final String QUICK_FIX_ACTION= PREFIX + "quick_fix_action"; //$NON-NLS-1$
- public static final String CONTENT_ASSIST_ACTION= PREFIX + "content_assist_action"; //$NON-NLS-1$
- public static final String PARAMETER_HINTS_ACTION= PREFIX + "parameter_hints_action"; //$NON-NLS-1$
- public static final String SHOW_OUTLINE_ACTION= PREFIX + "show_outline_action"; //$NON-NLS-1$
- public static final String OPEN_STRUCTURE_ACTION= PREFIX + "open_structure_action"; //$NON-NLS-1$
- public static final String OPEN_HIERARCHY_ACTION= PREFIX + "open_hierarchy_action"; //$NON-NLS-1$
- public static final String TOGGLE_SMART_TYPING_ACTION= PREFIX + "toggle_smart_typing_action"; //$NON-NLS-1$
- public static final String INDENT_ACTION= PREFIX + "indent_action"; //$NON-NLS-1$
-
- // Dialogs
- public static final String MAINTYPE_SELECTION_DIALOG= PREFIX + "maintype_selection_dialog_context"; //$NON-NLS-1$
- public static final String OPEN_TYPE_DIALOG= PREFIX + "open_type_dialog_context"; //$NON-NLS-1$
- public static final String TYPE_SELECTION_DIALOG2= PREFIX + "type_selection_dialog2_context"; //$NON-NLS-1$
- public static final String OPEN_PACKAGE_DIALOG= PREFIX + "open_package_dialog_context"; //$NON-NLS-1$
- public static final String SOURCE_ATTACHMENT_DIALOG= PREFIX + "source_attachment_dialog_context"; //$NON-NLS-1$
- public static final String LIBRARIES_WORKBOOK_PAGE_ADVANCED_DIALOG= PREFIX + "advanced_dialog_context"; //$NON-NLS-1$
- public static final String CONFIRM_SAVE_MODIFIED_RESOURCES_DIALOG= PREFIX + "confirm_save_modified_resources_dialog_context"; //$NON-NLS-1$
- public static final String NEW_VARIABLE_ENTRY_DIALOG= PREFIX + "new_variable_dialog_context"; //$NON-NLS-1$
- public static final String NONNLS_DIALOG= PREFIX + "nonnls_dialog_context"; //$NON-NLS-1$
- public static final String MULTI_MAIN_TYPE_SELECTION_DIALOG= PREFIX + "multi_main_type_selection_dialog_context"; //$NON-NLS-1$
- public static final String MULTI_TYPE_SELECTION_DIALOG= PREFIX + "multi_type_selection_dialog_context"; //$NON-NLS-1$
- public static final String SUPER_INTERFACE_SELECTION_DIALOG= PREFIX + "super_interface_selection_dialog_context"; //$NON-NLS-1$
-
- public static final String OVERRIDE_TREE_SELECTION_DIALOG= PREFIX + "override_tree_selection_dialog_context"; //$NON-NLS-1$
- public static final String ADD_GETTER_SETTER_SELECTION_DIALOG= PREFIX + "add_getter_setter_selection_dialog_context"; //$NON-NLS-1$
- public static final String ADD_DELEGATE_METHODS_SELECTION_DIALOG= PREFIX + "add_delegate_methods_selection_dialog_context"; //$NON-NLS-1$
- public static final String GENERATE_HASHCODE_EQUALS_SELECTION_DIALOG= PREFIX + "hash_code_equals_tree_selection_dialog_context"; //$NON-NLS-1$
- public static final String GENERATE_CONSTRUCTOR_USING_FIELDS_SELECTION_DIALOG= PREFIX + "generate_constructor_using_fields_selection_dialog_context"; //$NON-NLS-1$
- public static final String ADD_UNIMPLEMENTED_CONSTRUCTORS_DIALOG= PREFIX + "add_unimplemented_constructors_dialog_context"; //$NON-NLS-1$
-
- public static final String MOVE_DESTINATION_DIALOG= PREFIX + "move_destination_dialog_context"; //$NON-NLS-1$
- public static final String CHOOSE_VARIABLE_DIALOG= PREFIX + "choose_variable_dialog_context"; //$NON-NLS-1$
- public static final String EDIT_TEMPLATE_DIALOG= PREFIX + "edit_template_dialog_context"; //$NON-NLS-1$
- public static final String HISTORY_LIST_DIALOG= PREFIX + "history_list_dialog_context"; //$NON-NLS-1$
- public static final String IMPORT_ORGANIZE_INPUT_DIALOG= PREFIX + "import_organize_input_dialog_context"; //$NON-NLS-1$
- public static final String TODO_TASK_INPUT_DIALOG= PREFIX + "todo_task_input_dialog_context"; //$NON-NLS-1$
- public static final String JAVADOC_PROPERTY_DIALOG= PREFIX + "javadoc_property_dialog_context"; //$NON-NLS-1$
- public static final String NEW_CONTAINER_DIALOG= PREFIX + "new_container_dialog_context"; //$NON-NLS-1$
- public static final String EXCLUSION_PATTERN_DIALOG= PREFIX + "exclusion_pattern_dialog_context"; //$NON-NLS-1$
- public static final String ACCESS_RULES_DIALOG= PREFIX + "access_rules_dialog_context"; //$NON-NLS-1$
- public static final String OUTPUT_LOCATION_DIALOG= PREFIX + "output_location_dialog_context"; //$NON-NLS-1$
- public static final String VARIABLE_CREATION_DIALOG= PREFIX + "variable_creation_dialog_context"; //$NON-NLS-1$
- public static final String JAVA_SEARCH_PAGE= PREFIX + "java_search_page_context"; //$NON-NLS-1$
- public static final String NLS_SEARCH_PAGE= PREFIX + "nls_search_page_context"; //$NON-NLS-1$
- public static final String JAVA_EDITOR= PREFIX + "java_editor_context"; //$NON-NLS-1$
- public static final String GOTO_RESOURCE_DIALOG= PREFIX + "goto_resource_dialog"; //$NON-NLS-1$
-
- public static final String COMPARE_DIALOG= PREFIX + "compare_dialog_context"; //$NON-NLS-1$
- public static final String ADD_ELEMENT_FROM_HISTORY_DIALOG= PREFIX + "add_element_from_history_dialog_context"; //$NON-NLS-1$
- public static final String COMPARE_ELEMENT_WITH_HISTORY_DIALOG= PREFIX + "compare_element_with_history_dialog_context"; //$NON-NLS-1$
- public static final String REPLACE_ELEMENT_WITH_HISTORY_DIALOG= PREFIX + "replace_element_with_history_dialog_context"; //$NON-NLS-1$
-
- public static final String SORT_MEMBERS_DIALOG= PREFIX + "sort_members_dialog_context"; //$NON-NLS-1$
-
- // view parts
- public static final String TYPE_HIERARCHY_VIEW= PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$
- public static final String PACKAGES_VIEW= PREFIX + "package_view_context"; //$NON-NLS-1$
- public static final String PROJECTS_VIEW= PREFIX + "projects_view_context"; //$NON-NLS-1$
- public static final String PACKAGES_BROWSING_VIEW= PREFIX + "packages_browsing_view_context"; //$NON-NLS-1$
- public static final String TYPES_VIEW= PREFIX + "types_view_context"; //$NON-NLS-1$
- public static final String MEMBERS_VIEW= PREFIX + "members_view_context"; //$NON-NLS-1$
- public static final String JAVADOC_VIEW= PREFIX + "javadoc_view_context"; //$NON-NLS-1$
- public static final String SOURCE_VIEW= PREFIX + "source_view_context"; //$NON-NLS-1$
-
- // Preference/Property pages
- public static final String APPEARANCE_PREFERENCE_PAGE= PREFIX + "appearance_preference_page_context"; //$NON-NLS-1$
- public static final String SORT_ORDER_PREFERENCE_PAGE= PREFIX + "sort_order_preference_page_context"; //$NON-NLS-1$
- public static final String TYPE_FILTER_PREFERENCE_PAGE= PREFIX + "type_filter_preference_page_context"; //$NON-NLS-1$
- public static final String BUILD_PATH_PROPERTY_PAGE= PREFIX + "build_path_property_page_context"; //$NON-NLS-1$
- public static final String CP_VARIABLES_PREFERENCE_PAGE= PREFIX + "cp_variables_preference_page_context"; //$NON-NLS-1$
- /**
- *
- */
- public static final String CP_USERLIBRARIES_PREFERENCE_PAGE= PREFIX + "cp_userlibraries_preference_page_context"; //$NON-NLS-1$
-
- public static final String CODEFORMATTER_PREFERENCE_PAGE= PREFIX + "codeformatter_preference_page_context"; //$NON-NLS-1$
- public static final String SOURCE_ATTACHMENT_PROPERTY_PAGE= PREFIX + "source_attachment_property_page_context"; //$NON-NLS-1$
- public static final String COMPILER_PROPERTY_PAGE= PREFIX + "compiler_property_page_context"; //$NON-NLS-1$
- public static final String JAVA_BUILD_PROPERTY_PAGE= PREFIX + "java_build_property_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_PROBLEMS_PROPERTY_PAGE= PREFIX + "javadoc_problems_property_page_context"; //$NON-NLS-1$
- public static final String PROBLEM_SEVERITIES_PROPERTY_PAGE= PREFIX + "problem_severities_property_page_context"; //$NON-NLS-1$
- public static final String TODOTASK_PROPERTY_PAGE= PREFIX + "tasktags_property_page_context"; //$NON-NLS-1$
-
- /**
- *
- */
- public static final String CODE_TEMPLATES_PREFERENCE_PAGE= PREFIX + "code_templates_preference_context"; //$NON-NLS-1$
-
- public static final String CODE_MANIPULATION_PREFERENCE_PAGE= PREFIX + "code_manipulation_preference_context"; //$NON-NLS-1$
- public static final String ORGANIZE_IMPORTS_PREFERENCE_PAGE= PREFIX + "organizeimports_preference_page_context"; //$NON-NLS-1$
- public static final String JAVA_BASE_PREFERENCE_PAGE= PREFIX + "java_base_preference_page_context"; //$NON-NLS-1$
- public static final String REFACTORING_PREFERENCE_PAGE= PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$
- public static final String JAVA_EDITOR_PREFERENCE_PAGE= PREFIX + "java_editor_preference_page_context"; //$NON-NLS-1$
- public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$
- public static final String PROPERTIES_FILE_EDITOR_PREFERENCE_PAGE= PREFIX + "properties_file_editor_preference_page_context"; //$NON-NLS-1$
- public static final String COMPILER_PREFERENCE_PAGE= PREFIX + "compiler_preference_page_context"; //$NON-NLS-1$
- public static final String JAVA_BUILD_PREFERENCE_PAGE= PREFIX + "java_build_preference_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_PROBLEMS_PREFERENCE_PAGE= PREFIX + "javadoc_problems_preference_page_context"; //$NON-NLS-1$
- public static final String PROBLEM_SEVERITIES_PREFERENCE_PAGE= PREFIX + "problem_severities_preference_page_context"; //$NON-NLS-1$
- public static final String TODOTASK_PREFERENCE_PAGE= PREFIX + "tasktags_preference_page_context"; //$NON-NLS-1$
-
- public static final String TEMPLATE_PREFERENCE_PAGE= PREFIX + "template_preference_page_context"; //$NON-NLS-1$
- public static final String NEW_JAVA_PROJECT_PREFERENCE_PAGE= PREFIX + "new_java_project_preference_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_CONFIGURATION_PROPERTY_PAGE= PREFIX + "javadoc_configuration_property_page_context"; //$NON-NLS-1$
- public static final String JAVA_ELEMENT_INFO_PAGE= PREFIX + "java_element_info_page_context"; //$NON-NLS-1$
-
- // Wizard pages
- public static final String NEW_JAVAPROJECT_WIZARD_PAGE= PREFIX + "new_javaproject_wizard_page_context"; //$NON-NLS-1$
- public static final String NEW_PACKAGE_WIZARD_PAGE= PREFIX + "new_package_wizard_page_context"; //$NON-NLS-1$
- public static final String NEW_CLASS_WIZARD_PAGE= PREFIX + "new_class_wizard_page_context"; //$NON-NLS-1$
- public static final String NEW_INTERFACE_WIZARD_PAGE= PREFIX + "new_interface_wizard_page_context"; //$NON-NLS-1$
-
- // since 3.1
- public static final String NEW_ENUM_WIZARD_PAGE= PREFIX + "new_enum_wizard_page_context"; //$NON-NLS-1$
- // since 3.1
- public static final String NEW_ANNOTATION_WIZARD_PAGE= PREFIX + "new_annotation_wizard_page_context"; //$NON-NLS-1$
-
- public static final String NEW_PACKAGEROOT_WIZARD_PAGE= PREFIX + "new_packageroot_wizard_page_context"; //$NON-NLS-1$
- public static final String JARPACKAGER_WIZARD_PAGE= PREFIX + "jar_packager_wizard_page_context"; //$NON-NLS-1$
- // since 3.2
- public static final String JARPACKAGER_REFACTORING_DIALOG= PREFIX + "jar_packager_refactoring_dialog_context"; //$NON-NLS-1$
- // since 3.2
- public static final String JARIMPORT_WIZARD_PAGE= PREFIX + "jar_import_wizard_page_context"; //$NON-NLS-1$
- // since 3.2
- public static final String INCLUSION_EXCLUSION_WIZARD_PAGE= PREFIX + "edit_inclusion_exlusion_filter_wizard_page_context"; //$NON-NLS-1$
- public static final String JARMANIFEST_WIZARD_PAGE= PREFIX + "jar_manifest_wizard_page_context"; //$NON-NLS-1$
- public static final String JAROPTIONS_WIZARD_PAGE= PREFIX + "jar_options_wizard_page_context"; //$NON-NLS-1$
- public static final String JAVA_WORKING_SET_PAGE= PREFIX + "java_working_set_page_context"; //$NON-NLS-1$
-
- public static final String CLASSPATH_CONTAINER_DEFAULT_PAGE= PREFIX + "classpath_container_default_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_STANDARD_PAGE= PREFIX + "javadoc_standard_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_SPECIFICS_PAGE= PREFIX + "javadoc_specifics_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_TREE_PAGE= PREFIX + "javadoc_tree_page_context"; //$NON-NLS-1$
- public static final String JAVADOC_COMMAND_PAGE= PREFIX + "javadoc_command_page_context"; //$NON-NLS-1$
-
- // Same help for all refactoring error pages. Indidivual help can
- // be provided per a single refactoring status.
- // *** Don't delete this constants and the doc since it is still used in refactoring
- public static final String REFACTORING_ERROR_WIZARD_PAGE= PREFIX + "refactoring_error_wizard_page_context"; //$NON-NLS-1$
- // same help for all refactoring preview pages
- // *** Don't delete this constants and the doc since it is still used in refactoring
- public static final String REFACTORING_PREVIEW_WIZARD_PAGE= PREFIX + "refactoring_preview_wizard_page_context"; //$NON-NLS-1$
-
- public static final String RENAME_PARAMS_WIZARD_PAGE= PREFIX + "rename_params_wizard_page"; //$NON-NLS-1$
- public static final String EXTERNALIZE_WIZARD_KEYVALUE_PAGE= PREFIX + "externalize_wizard_keyvalue_page_context"; //$NON-NLS-1$
- public static final String EXTERNALIZE_WIZARD_PROPERTIES_FILE_PAGE= PREFIX + "externalize_wizard_properties_file_page_context"; //$NON-NLS-1$
- public static final String EXTRACT_INTERFACE_WIZARD_PAGE= PREFIX + "extract_interface_temp_page_context"; //$NON-NLS-1$
- public static final String EXTRACT_METHOD_WIZARD_PAGE= PREFIX + "extract_method_wizard_page_context"; //$NON-NLS-1$
- public static final String EXTRACT_TEMP_WIZARD_PAGE= PREFIX + "extract_temp_page_context"; //$NON-NLS-1$
- public static final String EXTRACT_CONSTANT_WIZARD_PAGE= PREFIX + "extract_constant_page_context"; //$NON-NLS-1$
- public static final String INTRODUCE_PARAMETER_WIZARD_PAGE= PREFIX + "introduce_parameter_page_context"; //$NON-NLS-1$
- public static final String INTRODUCE_FACTORY_WIZARD_PAGE= PREFIX + "introduce_factory_wizard_page_context"; //$NON-NLS-1$
- /**
- *
- */
- public static final String INTRODUCE_INDIRECTION_WIZARD_PAGE= PREFIX + "introduce_indirection_wizard_page_context"; //$NON-NLS-1$
-
- public static final String PROMOTE_TEMP_TO_FIELD_WIZARD_PAGE= PREFIX + "promote_temp_to_field_page_context"; //$NON-NLS-1$
- public static final String CONVERT_ANONYMOUS_TO_NESTED_WIZARD_PAGE= PREFIX + "convert_anonymous_to_nested_page_context"; //$NON-NLS-1$
- public static final String MODIFY_PARAMETERS_WIZARD_PAGE= PREFIX + "modify_parameters_wizard_page_context"; //$NON-NLS-1$
- public static final String MOVE_MEMBERS_WIZARD_PAGE= PREFIX + "move_members_wizard_page_context"; //$NON-NLS-1$
- public static final String MOVE_INNER_TO_TOP_WIZARD_PAGE= PREFIX + "move_inner_to_top_wizard_page_context"; //$NON-NLS-1$
- public static final String PULL_UP_WIZARD_PAGE= PREFIX + "pull_up_wizard_page_context"; //$NON-NLS-1$
- /**
- *
- */
- public static final String EXTRACT_SUPERTYPE_WIZARD_PAGE= PREFIX + "extract_supertype_wizard_page_context"; //$NON-NLS-1$
- public static final String PUSH_DOWN_WIZARD_PAGE= PREFIX + "push_down_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_PACKAGE_WIZARD_PAGE= PREFIX + "rename_package_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_TYPE_PARAMETER_WIZARD_PAGE= PREFIX + "rename_type_parameter_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_LOCAL_VARIABLE_WIZARD_PAGE= PREFIX + "rename_local_variable_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_CU_WIZARD_PAGE= PREFIX + "rename_cu_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_METHOD_WIZARD_PAGE= PREFIX + "rename_method_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_TYPE_WIZARD_PAGE= PREFIX + "rename_type_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_FIELD_WIZARD_PAGE= PREFIX + "rename_field_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_RESOURCE_WIZARD_PAGE= PREFIX + "rename_resource_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_JAVA_PROJECT_WIZARD_PAGE= PREFIX + "rename_java_project_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_SOURCE_FOLDER_WIZARD_PAGE= PREFIX + "rename_source_folder_wizard_page_context"; //$NON-NLS-1$
- public static final String SEF_WIZARD_PAGE= PREFIX + "self_encapsulate_field_wizard_page_context"; //$NON-NLS-1$
- public static final String USE_SUPERTYPE_WIZARD_PAGE= PREFIX + "use_supertype_wizard_page_context"; //$NON-NLS-1$
- public static final String INLINE_METHOD_WIZARD_PAGE= PREFIX + "inline_method_wizard_page_context"; //$NON-NLS-1$
- public static final String INLINE_CONSTANT_WIZARD_PAGE= PREFIX + "inline_constant_wizard_page_context"; //$NON-NLS-1$
- public static final String SELECT_CLEAN_UPS_PAGE= PREFIX + "select_clean_ups_wizard_page_context"; //$NON-NLS-1$
-
- public static final String INFER_TYPE_ARGUMENTS_WIZARD_PAGE= PREFIX + "infer_type_arguments_wizard_page_context"; //$NON-NLS-1$
- public static final String CHANGE_TYPE_WIZARD_PAGE= PREFIX + "change_type_wizard_page_context"; //$NON-NLS-1$
- public static final String INLINE_TEMP_WIZARD_PAGE= PREFIX + "inline_temp_wizard_page_context"; //$NON-NLS-1$
-
- // reused ui-blocks
- public static final String BUILD_PATH_BLOCK= PREFIX + "build_paths_context"; //$NON-NLS-1$
- public static final String SOURCE_ATTACHMENT_BLOCK= PREFIX + "source_attachment_context"; //$NON-NLS-1$
-
- // Custom Filters
- public static final String CUSTOM_FILTERS_DIALOG= PREFIX + "open_custom_filters_dialog_context"; //$NON-NLS-1$
-
- // Call Hierarchy
- public static final String CALL_HIERARCHY_VIEW= PREFIX + "call_hierarchy_view_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_FILTERS_DIALOG= PREFIX + "call_hierarchy_filters_dialog_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_FOCUS_ON_SELECTION_ACTION= PREFIX + "call_hierarchy_focus_on_selection_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_HISTORY_ACTION= PREFIX + "call_hierarchy_history_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_HISTORY_DROP_DOWN_ACTION= PREFIX + "call_hierarchy_history_drop_down_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_REFRESH_ACTION= PREFIX + "call_hierarchy_refresh_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_SEARCH_SCOPE_ACTION= PREFIX + "call_hierarchy_search_scope_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION= PREFIX + "call_hierarchy_toggle_call_mode_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_TOGGLE_JAVA_LABEL_FORMAT_ACTION= PREFIX + "call_hierarchy_toggle_java_label_format_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_TOGGLE_ORIENTATION_ACTION= PREFIX + "call_hierarchy_toggle_call_mode_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_COPY_ACTION= PREFIX + "call_hierarchy_copy_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_TOGGLE_IMPLEMENTORS_ACTION= PREFIX + "call_hierarchy_toggle_implementors_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_OPEN_ACTION= PREFIX + "call_hierarchy_open_action_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_CANCEL_SEARCH_ACTION= PREFIX + "call_hierarchy_cancel_search_action_context"; //$NON-NLS-1$
-
- /**
- *
- */
- //User library preference page
- public static final String CP_EDIT_USER_LIBRARY= PREFIX + "cp_edit_user_library"; //$NON-NLS-1$
- public static final String CP_EXPORT_USER_LIBRARY= PREFIX + "cp_export_user_library"; //$NON-NLS-1$
- public static final String CP_IMPORT_USER_LIBRARY= PREFIX + "cp_import_user_library"; //$NON-NLS-1$
- //Code style preference page
- public static final String CODE_STYLE_EDIT_PREFIX_SUFFIX= PREFIX + "code_style_edit_prefix_suffix"; //$NON-NLS-1$
- //Task tag preference page
- public static final String TASK_TAG_INPUT_DIALOG= PREFIX + "todo_task_input_dialog_context"; //$NON-NLS-1$
- //Build path
- public static final String BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER= PREFIX + "bp_choose_existing_folder_to_make_source_folder"; //$NON-NLS-1$
- public static final String BP_CREATE_NEW_FOLDER= PREFIX + "bp_create_new_folder_dialog"; //$NON-NLS-1$
- public static final String BP_SELECT_DEFAULT_OUTPUT_FOLDER_DIALOG= PREFIX + "bp_select_default_output_folder_dialog"; //$NON-NLS-1$
- public static final String BP_SELECT_CLASSPATH_CONTAINER= PREFIX + "bp_select_classpath_container"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaStatusConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaStatusConstants.java
deleted file mode 100644
index e9db530d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaStatusConstants.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-/**
- * Defines status codes relevant to the Java 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
- * Java UI plug-in use the codes defined in this interface.
- */
-public interface IJavaStatusConstants {
-
- // Java UI status constants start at 10000 to make sure that we don't
- // collide with resource and java model constants.
-
- public static final int INTERNAL_ERROR= 10001;
-
- /**
- * Status constant indicating that an exception occurred on
- * storing or loading templates.
- */
- public static final int TEMPLATE_IO_EXCEPTION = 10002;
-
- /**
- * Status constant indicating that an validateEdit call has changed the
- * content of a file on disk.
- */
- public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003;
-
- /**
- * Status constant indicating that a <tt>ChangeAbortException</tt> has been
- * caught.
- */
- public static final int CHANGE_ABORTED= 10004;
-
- /**
- * Status constant indicating that an exception occurred while
- * parsing template file.
- */
- public static final int TEMPLATE_PARSE_EXCEPTION = 10005;
-
- /**
- * Status constant indicating that a problem occurred while notifying a post
- * save listener.
- *
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.IPostSaveListener
- *
- */
- public static final int EDITOR_POST_SAVE_NOTIFICATION= 10006;
-
- }
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaThemeConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaThemeConstants.java
deleted file mode 100644
index 5e7b7048..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJavaThemeConstants.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Defines the constants used in the <code>org.eclipse.ui.themes</code>
- * extension contributed by this plug-in.
- *
- *
- */
-public interface IJavaThemeConstants {
-
- String ID_PREFIX= JavaScriptUI.ID_PLUGIN + "."; //$NON-NLS-1$
-
- /**
- * Theme constant for the color used to highlight matching brackets.
- */
- public final String EDITOR_MATCHING_BRACKETS_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
-
- /**
- * Theme constant for the color used to render multi-line comments.
- */
- public final String EDITOR_MULTI_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR;
-
- /**
- * Theme constant for the color used to render java keywords.
- */
- public final String EDITOR_JAVA_KEYWORD_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR;
-
- /**
- * A theme constant that holds the color used to render string constants.
- */
- public final String EDITOR_STRING_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_STRING_COLOR;
-
- /**
- * A theme constant that holds the color used to render single line comments.
- */
- public final String EDITOR_SINGLE_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR;
-
- /**
- * A theme constant that holds the color used to render operators.
- */
- public final String EDITOR_JAVA_OPERATOR_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR;
-
- /**
- * A theme constant that holds the color used to render java default text.
- */
- public final String EDITOR_JAVA_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR;
-
- /**
- * A theme constant that holds the color used to render the 'return' keyword.
- */
- public final String EDITOR_JAVA_KEYWORD_RETURN_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVA_KEYWORD_RETURN_COLOR;
-
- /**
- * A theme constant that holds the color used to render javadoc keywords.
- */
- public final String EDITOR_JAVADOC_KEYWORD_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR;
-
- /**
- * A theme constant that holds the color used to render javadoc tags.
- */
- public final String EDITOR_JAVADOC_TAG_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR;
-
- /**
- * A theme constant that holds the color used to render brackets.
- */
- public final String EDITOR_JAVA_BRACKET_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVA_BRACKET_COLOR;
-
- /**
- * A theme constant that holds the color used to render task tags.
- */
- public final String EDITOR_TASK_TAG_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_TASK_TAG_COLOR;
-
- /**
- * A theme constant that holds the color used to render javadoc links.
- */
- public final String EDITOR_JAVADOC_LINKS_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR;
-
- /**
- * A theme constant that holds the color used to render javadoc default text.
- */
- public final String EDITOR_JAVADOC_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR;
-
- /**
- * A theme constant that holds the background color used in the code assist selection dialog.
- */
- public final String CODEASSIST_PROPOSALS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
-
- /**
- * A theme constant that holds the foreground color used in the code assist selection dialog.
- */
- public final String CODEASSIST_PROPOSALS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
-
- /**
- * A theme constant that holds the background color used for parameter hints.
- */
- public final String CODEASSIST_PARAMETERS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
-
- /**
- * A theme constant that holds the foreground color used in the code assist selection dialog.
- */
- public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
-
- /**
- * Theme constant for the background color used in the code assist selection dialog to mark replaced code.
- */
- public final String CODEASSIST_REPLACEMENT_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND;
-
- /**
- * Theme constant for the foreground color used in the code
- * assist selection dialog to mark replaced code.
- */
- public final String CODEASSIST_REPLACEMENT_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND;
-
- /**
- * Theme constant for the color used to render values in a properties file.
- */
- String PROPERTIES_FILE_COLORING_VALUE= ID_PREFIX + PreferenceConstants.PROPERTIES_FILE_COLORING_VALUE;
-
- /**
- * Theme constant for the color used to render keys in a properties file.
- */
- String PROPERTIES_FILE_COLORING_KEY= ID_PREFIX + PreferenceConstants.PROPERTIES_FILE_COLORING_KEY;
-
- /**
- * Theme constant for the color used to render arguments in a properties file.
- */
- String PROPERTIES_FILE_COLORING_ARGUMENT= ID_PREFIX + PreferenceConstants.PROPERTIES_FILE_COLORING_ARGUMENT;
-
- /**
- * Theme constant for the color used to render assignments in a properties file.
- */
- String PROPERTIES_FILE_COLORING_ASSIGNMENT= ID_PREFIX + PreferenceConstants.PROPERTIES_FILE_COLORING_ASSIGNMENT;
-
- /**
- * Theme constant for the color used to render comments in a properties file.
- */
- String PROPERTIES_FILE_COLORING_COMMENT= ID_PREFIX + PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT;
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJsGlobalScopeContainerInitializerExtension.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJsGlobalScopeContainerInitializerExtension.java
deleted file mode 100644
index d67e6585..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IJsGlobalScopeContainerInitializerExtension.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-
-/**
- * @author childsb
- *
- */
-public interface IJsGlobalScopeContainerInitializerExtension{
- public ImageDescriptor getImage(IPath containerPath, String element, IJavaScriptProject project);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IResourceLocator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IResourceLocator.java
deleted file mode 100644
index d7dc05c1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IResourceLocator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * This interface allows to locate different
- * resources which are related to an object
- */
-public interface IResourceLocator {
- /**
- * Returns the underlying finest granularity resource that contains
- * the element, or <code>null</code> if the element is not contained
- * in a resource (for example, a working copy, or an element contained
- * in an external archive).
- *
- * @param element the element for which the resource is located
- * @return the underlying resource
- * @exception JavaScriptModelException if the element does not exist or if an
- * exception occurs while accessing its underlying resource
- * @see org.eclipse.wst.jsdt.core.IJavaScriptElement#getUnderlyingResource()
- */
- IResource getUnderlyingResource(Object element) throws JavaScriptModelException;
- /**
- * Returns the resource that corresponds directly to the element,
- * or <code>null</code> if there is no resource that corresponds to
- * the element.
- *
- * <p>For example, the corresponding resource for an <code>IJavaScriptUnit</code>
- * is its underlying <code>IFile</code>. The corresponding resource for
- * an <code>IPackageFragment</code> that is not contained in an archive
- * is its underlying <code>IFolder</code>. An <code>IPackageFragment</code>
- * contained in an archive has no corresponding resource. Similarly, there
- * are no corresponding resources for <code>IMethods</code>,
- * <code>IFields</code>, etc.
- *
- * @param element the element for which the resource is located
- * @return the corresponding resource
- * @exception JavaScriptModelException if the element does not exist or if an
- * exception occurs while accessing its corresponding resource
- * @see org.eclipse.wst.jsdt.core.IJavaScriptElement#getCorrespondingResource()
- */
- IResource getCorrespondingResource(Object element) throws JavaScriptModelException;
- /**
- * Returns the resource that contains the element. If the element is not
- * directly contained by a resource then a helper resource or <code>null</code>
- * is returned. Clients define the helper resource as needed.
- *
- * @param element the element for which the resource is located
- * @return the containing resource
- * @exception JavaScriptModelException if the element does not exist or if an
- * exception occurs while accessing its containing resource
- */
- IResource getContainingResource(Object element) throws JavaScriptModelException;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IUIConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IUIConstants.java
deleted file mode 100644
index 0d29b155..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/IUIConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public interface IUIConstants {
-
- public static final String KEY_OK= JavaScriptUI.ID_PLUGIN + ".ok.label"; //$NON-NLS-1$
- public static final String KEY_CANCEL= JavaScriptUI.ID_PLUGIN + ".cancel.label"; //$NON-NLS-1$
-
- public static final String P_ICON_NAME= JavaScriptUI.ID_PLUGIN + ".icon_name"; //$NON-NLS-1$
-
- public static final String DIALOGSTORE_LASTEXTJAR= JavaScriptUI.ID_PLUGIN + ".lastextjar"; //$NON-NLS-1$
- public static final String DIALOGSTORE_LASTJARATTACH= JavaScriptUI.ID_PLUGIN + ".lastjarattach"; //$NON-NLS-1$
- public static final String DIALOGSTORE_LASTVARIABLE= JavaScriptUI.ID_PLUGIN + ".lastvariable"; //$NON-NLS-1$
-
- public static final String DIALOGSTORE_TYPECOMMENT_DEPRECATED= JavaScriptUI.ID_PLUGIN + ".typecomment.deprecated"; //$NON-NLS-1$
-
- public static final boolean SUPPORT_REFACTORING=false;
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InitializeAfterLoadJob.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InitializeAfterLoadJob.java
deleted file mode 100644
index f72a059b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InitializeAfterLoadJob.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui;
-
-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.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class InitializeAfterLoadJob extends UIJob {
-
- private final class RealJob extends Job {
- public RealJob(String name) {
- super(name);
- }
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("", 10); //$NON-NLS-1$
- try {
- JavaScriptCore.initializeAfterLoad(new SubProgressMonitor(monitor, 6));
- JavaScriptPlugin.initializeAfterLoad(new SubProgressMonitor(monitor, 4));
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return e.getStatus();
- }
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
- public boolean belongsTo(Object family) {
- return JavaScriptUI.ID_PLUGIN.equals(family);
- }
- }
-
- public InitializeAfterLoadJob() {
- super(JavaUIMessages.InitializeAfterLoadJob_starter_job_name);
- setSystem(true);
- }
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Job job = new RealJob(JavaUIMessages.JavaPlugin_initializing_ui);
- job.setPriority(Job.SHORT);
- job.schedule();
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InterfaceIndicatorLabelDecorator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InterfaceIndicatorLabelDecorator.java
deleted file mode 100644
index 21b5c3c5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/InterfaceIndicatorLabelDecorator.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.core.search.TypeNameRequestor;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-
-public class InterfaceIndicatorLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator {
-
- private class IntefaceIndicatorChangeListener implements IElementChangedListener {
-
- /**
- * {@inheritDoc}
- */
- public void elementChanged(ElementChangedEvent event) {
- List changed= new ArrayList();
- processDelta(event.getDelta(), changed);
- if (changed.size() == 0)
- return;
-
- fireChange((IJavaScriptElement[])changed.toArray(new IJavaScriptElement[changed.size()]));
- }
-
- }
-
- private ListenerList fListeners;
- private IElementChangedListener fChangeListener;
-
- public InterfaceIndicatorLabelDecorator() {
- }
-
- /**
- * {@inheritDoc}
- */
- public Image decorateImage(Image image, Object element) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String decorateText(String text, Object element) {
- return text;
- }
-
- /**
- * {@inheritDoc}
- */
- public void addListener(ILabelProviderListener listener) {
- if (fChangeListener == null) {
- fChangeListener= new IntefaceIndicatorChangeListener();
- JavaScriptCore.addElementChangedListener(fChangeListener);
- }
-
- if (fListeners == null) {
- fListeners= new ListenerList();
- }
-
- fListeners.add(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- if (fChangeListener != null) {
- JavaScriptCore.removeElementChangedListener(fChangeListener);
- fChangeListener= null;
- }
- if (fListeners != null) {
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- fListeners.remove(listeners[i]);
- }
- fListeners= null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeListener(ILabelProviderListener listener) {
- if (fListeners == null)
- return;
-
- fListeners.remove(listener);
-
- if (fListeners.isEmpty() && fChangeListener != null) {
- JavaScriptCore.removeElementChangedListener(fChangeListener);
- fChangeListener= null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void decorate(Object element, IDecoration decoration) {
- try {
- ImageDescriptor overlay= getOverlay(element);
- if (overlay == null)
- return;
-
- decoration.addOverlay(overlay, IDecoration.TOP_RIGHT);
- } catch (JavaScriptModelException e) {
- return;
- }
- }
-
- private ImageDescriptor getOverlay(Object element) throws JavaScriptModelException {
- if (element instanceof IJavaScriptUnit) {
- IJavaScriptUnit unit= (IJavaScriptUnit) element;
- if (unit.isOpen()) {
- IType mainType= unit.findPrimaryType();
- if (mainType != null) {
- return getOverlayFromFlags(mainType.getFlags());
- }
- return null;
- }
- String typeName= JavaScriptCore.removeJavaScriptLikeExtension(unit.getElementName());
- return getOverlayWithSearchEngine(unit, typeName);
- } else if (element instanceof IClassFile) {
- IClassFile classFile= (IClassFile) element;
- if (classFile.isOpen()) {
- return getOverlayFromFlags(classFile.getType().getFlags());
- }
- String typeName= classFile.getType().getElementName();
- return getOverlayWithSearchEngine(classFile, typeName);
- }
- return null;
- }
-
- private ImageDescriptor getOverlayWithSearchEngine(ITypeRoot element, String typeName) {
- SearchEngine engine= new SearchEngine();
- IJavaScriptSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaScriptElement[] { element });
-
- class Result extends RuntimeException {
- private static final long serialVersionUID= 1L;
- int modifiers;
- public Result(int modifiers) {
- this.modifiers= modifiers;
- }
- }
-
- TypeNameRequestor requestor= new TypeNameRequestor() {
- public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
- if (enclosingTypeNames.length == 0 && Flags.isPublic(modifiers)) {
- throw new Result(modifiers);
- }
- }
- };
-
- try {
- String packName = element.getParent().getElementName();
- int matchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
- engine.searchAllTypeNames(packName.toCharArray(), matchRule, typeName.toCharArray(), matchRule, IJavaScriptSearchConstants.TYPE, scope, requestor, IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH , null);
- } catch (Result e) {
- return getOverlayFromFlags(e.modifiers);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return null;
-
- }
-
- private ImageDescriptor getOverlayFromFlags(int flags) {
- if (Flags.isAnnotation(flags)) {
- return JavaPluginImages.DESC_OVR_ANNOTATION;
- } else if (Flags.isEnum(flags)) {
- return JavaPluginImages.DESC_OVR_ENUM;
- } else if (Flags.isInterface(flags)) {
- return JavaPluginImages.DESC_OVR_INTERFACE;
- } else if (/* is class */ Flags.isAbstract(flags)) {
- return JavaPluginImages.DESC_OVR_ABSTRACT_CLASS;
- }
- return null;
- }
-
- private void fireChange(IJavaScriptElement[] elements) {
- if (fListeners != null && !fListeners.isEmpty()) {
- LabelProviderChangedEvent event= new LabelProviderChangedEvent(this, elements);
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ((ILabelProviderListener) listeners[i]).labelProviderChanged(event);
- }
- }
- }
-
- private void processDelta(IJavaScriptElementDelta delta, List result) {
- IJavaScriptElement elem= delta.getElement();
-
- boolean isChanged= delta.getKind() == IJavaScriptElementDelta.CHANGED;
- boolean isRemoved= delta.getKind() == IJavaScriptElementDelta.REMOVED;
- int flags= delta.getFlags();
-
- switch (elem.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- if (isRemoved || (isChanged &&
- (flags & IJavaScriptElementDelta.F_CLOSED) != 0)) {
- return;
- }
- processChildrenDelta(delta, result);
- return;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- if (isRemoved || (isChanged && (
- (flags & IJavaScriptElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 ||
- (flags & IJavaScriptElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) {
- return;
- }
- processChildrenDelta(delta, result);
- return;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- if (isRemoved)
- return;
- processChildrenDelta(delta, result);
- return;
- case IJavaScriptElement.TYPE:
- case IJavaScriptElement.CLASS_FILE:
- return;
- case IJavaScriptElement.JAVASCRIPT_MODEL:
- processChildrenDelta(delta, result);
- return;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- // Not the primary compilation unit. Ignore it
- if (!JavaModelUtil.isPrimary((IJavaScriptUnit) elem)) {
- return;
- }
-
- if (isChanged && ((flags & IJavaScriptElementDelta.F_CONTENT) != 0 || (flags & IJavaScriptElementDelta.F_FINE_GRAINED) != 0)) {
- if (delta.getAffectedChildren().length == 0)
- return;
-
- result.add(elem);
- }
- return;
- default:
- // fields, methods, imports ect
- return;
- }
- }
-
- private boolean processChildrenDelta(IJavaScriptElementDelta delta, List result) {
- IJavaScriptElementDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
- processDelta(children[i], result);
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementAdapterFactory.java
deleted file mode 100644
index ca731345..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementAdapterFactory.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.team.ui.history.IHistoryPageSource;
-import org.eclipse.ui.IContainmentAdapter;
-import org.eclipse.ui.IContributorResourceAdapter;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.ide.IContributorResourceAdapter2;
-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;
-import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaElementResourceMapping;
-import org.eclipse.wst.jsdt.internal.ui.compare.JavaElementHistoryPageSource;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchUtil;
-
-/**
- * Implements basic UI support for Java elements.
- * Implements handle to persistent support for Java elements.
- */
-public class JavaElementAdapterFactory implements IAdapterFactory, IContributorResourceAdapter, IContributorResourceAdapter2 {
-
- private static Class[] PROPERTIES= new Class[] {
- IPropertySource.class,
- IResource.class,
- IWorkbenchAdapter.class,
- IResourceLocator.class,
- IPersistableElement.class,
- IContributorResourceAdapter.class,
- IContributorResourceAdapter2.class,
- ITaskListResourceAdapter.class,
- IContainmentAdapter.class,
- IHistoryPageSource.class
- };
-
- /*
- * Do not use real type since this would cause
- * the Search plug-in to be loaded.
- */
- private Object fSearchPageScoreComputer;
- private static IResourceLocator fgResourceLocator;
- private static JavaWorkbenchAdapter fgJavaWorkbenchAdapter;
- private static ITaskListResourceAdapter fgTaskListAdapter;
- private static JavaElementContainmentAdapter fgJavaElementContainmentAdapter;
-
- public Class[] getAdapterList() {
- updateLazyLoadedAdapters();
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- updateLazyLoadedAdapters();
- IJavaScriptElement java= getJavaElement(element);
-
- if (IPropertySource.class.equals(key)) {
- return getProperties(java);
- } if (IResource.class.equals(key)) {
- return getResource(java);
- } if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) {
- return fSearchPageScoreComputer;
- } if (IWorkbenchAdapter.class.equals(key)) {
- return getJavaWorkbenchAdapter();
- } if (IResourceLocator.class.equals(key)) {
- return getResourceLocator();
- } if (IPersistableElement.class.equals(key)) {
- return new PersistableJavaElementFactory(java);
- } if (IContributorResourceAdapter.class.equals(key)) {
- if (getResource(java)!=null)
- return this;
- } if (IContributorResourceAdapter2.class.equals(key)) {
- return this;
- } if (ITaskListResourceAdapter.class.equals(key)) {
- return getTaskListAdapter();
- } if (IContainmentAdapter.class.equals(key)) {
- return getJavaElementContainmentAdapter();
- } if (IHistoryPageSource.class.equals(key) && JavaElementHistoryPageSource.hasEdition(java)) {
- return JavaElementHistoryPageSource.getInstance();
- }
- return null;
- }
-
- private IResource getResource(IJavaScriptElement element) {
- // can't use IJavaScriptElement.getResource directly as we are interested in the
- // corresponding resource
- switch (element.getElementType()) {
- case IJavaScriptElement.TYPE:
- // top level types behave like the CU
- IJavaScriptElement parent= element.getParent();
- if (parent instanceof IJavaScriptUnit) {
- return ((IJavaScriptUnit) parent).getPrimary().getResource();
- }
- return null;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return ((IJavaScriptUnit) element).getPrimary().getResource();
- case IJavaScriptElement.CLASS_FILE:
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- // test if in a archive
- IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (!root.isArchive()) {
- return element.getResource();
- }
- return null;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- case IJavaScriptElement.JAVASCRIPT_MODEL:
- return element.getResource();
- default:
- return null;
- }
- }
-
- public IResource getAdaptedResource(IAdaptable adaptable) {
- IJavaScriptElement je= getJavaElement(adaptable);
- if (je != null)
- return getResource(je);
-
- return null;
- }
-
- public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) {
- IJavaScriptElement je= getJavaElement(adaptable);
- if (je != null)
- return JavaElementResourceMapping.create(je);
-
- return null;
- }
-
- private IJavaScriptElement getJavaElement(Object element) {
- if (element instanceof IJavaScriptElement)
- return (IJavaScriptElement)element;
- if (element instanceof IClassFileEditorInput)
- return ((IClassFileEditorInput)element).getClassFile().getPrimaryElement();
-
- return null;
- }
-
- private IPropertySource getProperties(IJavaScriptElement element) {
- IResource resource= getResource(element);
- if (resource == null)
- return new JavaElementProperties(element);
- if (resource.getType() == IResource.FILE)
- return new FilePropertySource((IFile) resource);
- return new ResourcePropertySource(resource);
- }
-
- private void updateLazyLoadedAdapters() {
- if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
- createSearchPageScoreComputer();
- }
-
- private void createSearchPageScoreComputer() {
- fSearchPageScoreComputer= new JavaSearchPageScoreComputer();
- PROPERTIES= new Class[] {
- IPropertySource.class,
- IResource.class,
- ISearchPageScoreComputer.class,
- IWorkbenchAdapter.class,
- IResourceLocator.class,
- IPersistableElement.class,
- IProject.class,
- IContributorResourceAdapter.class,
- IContributorResourceAdapter2.class,
- ITaskListResourceAdapter.class,
- IContainmentAdapter.class
- };
- }
-
- private static IResourceLocator getResourceLocator() {
- if (fgResourceLocator == null)
- fgResourceLocator= new ResourceLocator();
- return fgResourceLocator;
- }
-
- private static JavaWorkbenchAdapter getJavaWorkbenchAdapter() {
- if (fgJavaWorkbenchAdapter == null)
- fgJavaWorkbenchAdapter= new JavaWorkbenchAdapter();
- return fgJavaWorkbenchAdapter;
- }
-
- private static ITaskListResourceAdapter getTaskListAdapter() {
- if (fgTaskListAdapter == null)
- fgTaskListAdapter= new JavaTaskListAdapter();
- return fgTaskListAdapter;
- }
-
- private static JavaElementContainmentAdapter getJavaElementContainmentAdapter() {
- if (fgJavaElementContainmentAdapter == null)
- fgJavaElementContainmentAdapter= new JavaElementContainmentAdapter();
- return fgJavaElementContainmentAdapter;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementContainmentAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementContainmentAdapter.java
deleted file mode 100644
index b1db9c57..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementContainmentAdapter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IContainmentAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-public class JavaElementContainmentAdapter implements IContainmentAdapter {
-
- private IJavaScriptModel fJavaModel= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
-
- public boolean contains(Object workingSetElement, Object element, int flags) {
- if (!(workingSetElement instanceof IJavaScriptElement) || element == null)
- return false;
-
- IJavaScriptElement workingSetJavaElement= (IJavaScriptElement)workingSetElement;
- IResource resource= null;
- IJavaScriptElement jElement= null;
- if (element instanceof IJavaScriptElement) {
- jElement= (IJavaScriptElement)element;
- resource= jElement.getResource();
- } else {
- if (element instanceof IAdaptable) {
- resource= (IResource)((IAdaptable)element).getAdapter(IResource.class);
- if (resource != null) {
- if (fJavaModel.contains(resource)) {
- jElement= JavaScriptCore.create(resource);
- if (jElement != null && !jElement.exists())
- jElement= null;
- }
- }
- }
- }
-
- if (jElement != null) {
- if (contains(workingSetJavaElement, jElement, flags))
- return true;
- if (workingSetJavaElement.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT &&
- resource.getType() == IResource.FOLDER && checkIfDescendant(flags))
- return isChild(workingSetJavaElement, resource);
- } else if (resource != null) {
- return contains(workingSetJavaElement, resource, flags);
- }
- return false;
- }
-
- private boolean contains(IJavaScriptElement workingSetElement, IJavaScriptElement element, int flags) {
- if (checkContext(flags) && workingSetElement.equals(element)) {
- return true;
- }
- if (checkIfChild(flags) && workingSetElement.equals(element.getParent())) {
- return true;
- }
- if (checkIfDescendant(flags) && check(workingSetElement, element)) {
- return true;
- }
- if (checkIfAncestor(flags) && check(element, workingSetElement)) {
- return true;
- }
- return false;
- }
-
- private boolean check(IJavaScriptElement ancestor, IJavaScriptElement descendent) {
- descendent= descendent.getParent();
- while (descendent != null) {
- if (ancestor.equals(descendent))
- return true;
- descendent= descendent.getParent();
- }
- return false;
- }
-
- private boolean isChild(IJavaScriptElement workingSetElement, IResource element) {
- IResource resource= workingSetElement.getResource();
- if (resource == null)
- return false;
- return check(element, resource);
- }
-
- private boolean contains(IJavaScriptElement workingSetElement, IResource element, int flags) {
- IResource workingSetResource= workingSetElement.getResource();
- if (workingSetResource == null)
- return false;
- if (checkContext(flags) && workingSetResource.equals(element)) {
- return true;
- }
- if (checkIfChild(flags) && workingSetResource.equals(element.getParent())) {
- return true;
- }
- if (checkIfDescendant(flags) && check(workingSetResource, element)) {
- return true;
- }
- if (checkIfAncestor(flags) && check(element, workingSetResource)) {
- return true;
- }
- return false;
- }
-
- private boolean check(IResource ancestor, IResource descendent) {
- descendent= descendent.getParent();
- while(descendent != null) {
- if (ancestor.equals(descendent))
- return true;
- descendent= descendent.getParent();
- }
- return false;
- }
-
- private boolean checkIfDescendant(int flags) {
- return (flags & CHECK_IF_DESCENDANT) != 0;
- }
-
- private boolean checkIfAncestor(int flags) {
- return (flags & CHECK_IF_ANCESTOR) != 0;
- }
-
- private boolean checkIfChild(int flags) {
- return (flags & CHECK_IF_CHILD) != 0;
- }
-
- private boolean checkContext(int flags) {
- return (flags & CHECK_CONTEXT) != 0;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementProperties.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementProperties.java
deleted file mode 100644
index 5fec3a91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaElementProperties.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-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.wst.jsdt.core.IJavaScriptElement;
-
-public class JavaElementProperties implements IPropertySource {
-
- private IJavaScriptElement fSource;
-
- // Property Descriptors
- private static final IPropertyDescriptor[] fgPropertyDescriptors= new IPropertyDescriptor[1];
- static {
- PropertyDescriptor descriptor;
-
- // resource name
- descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, JavaUIMessages.JavaElementProperties_name);
- descriptor.setAlwaysIncompatible(true);
- fgPropertyDescriptors[0]= descriptor;
- }
-
- public JavaElementProperties(IJavaScriptElement source) {
- fSource= source;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return fgPropertyDescriptors;
- }
-
- public Object getPropertyValue(Object name) {
- if (name.equals(IBasicPropertyConstants.P_TEXT)) {
- return fSource.getDisplayName();
- }
- return null;
- }
-
- public void setPropertyValue(Object name, Object value) {
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaHierarchyPerspectiveFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaHierarchyPerspectiveFactory.java
deleted file mode 100644
index 7c0f865e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaHierarchyPerspectiveFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.progress.IProgressConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavaHierarchyPerspectiveFactory implements IPerspectiveFactory {
-
- /**
- * Constructs a new Java hierarchy layout engine.
- */
- public JavaHierarchyPerspectiveFactory() {
- super();
- }
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
- folder.addView(JavaScriptUI.ID_TYPE_HIERARCHY);
- folder.addPlaceholder(IPageLayout.ID_OUTLINE);
- folder.addPlaceholder(JavaScriptUI.ID_PACKAGES);
- folder.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IPlaceholderFolderLayout outputfolder= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
- outputfolder.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- outputfolder.addPlaceholder(JavaScriptUI.ID_SOURCE_VIEW);
- outputfolder.addPlaceholder(JavaScriptUI.ID_JAVADOC_VIEW);
- outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
-
- layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ELEMENT_CREATION_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(JavaScriptUI.ID_PACKAGES);
- layout.addShowViewShortcut(JavaScriptUI.ID_TYPE_HIERARCHY);
-
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
- layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
-
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.JavaProjectWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPerspectiveFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPerspectiveFactory.java
deleted file mode 100644
index d3761f6a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPerspectiveFactory.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.progress.IProgressConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavaPerspectiveFactory implements IPerspectiveFactory {
-
- /**
- * Constructs a new Default layout engine.
- */
- public JavaPerspectiveFactory() {
- super();
- }
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
- folder.addView(JavaScriptUI.ID_PACKAGES);
- folder.addView(JavaScriptUI.ID_TYPE_HIERARCHY);
- folder.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
- outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW);
- outputfolder.addView(JavaScriptUI.ID_JAVADOC_VIEW);
- outputfolder.addView(JavaScriptUI.ID_SOURCE_VIEW);
- outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
-
- layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea);
-
- layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ACTION_SET2);
-// layout.addActionSet(JavaScriptUI.ID_ELEMENT_CREATION_ACTION_SET);
- layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(JavaScriptUI.ID_PACKAGES);
- layout.addShowViewShortcut(JavaScriptUI.ID_TYPE_HIERARCHY);
- layout.addShowViewShortcut(JavaScriptUI.ID_SOURCE_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_JAVADOC_VIEW);
-
- // views - search
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
- layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
-
- // new actions - Java project creation wizard
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.JavaProjectWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java
deleted file mode 100644
index 4bf48771..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.osgi.framework.Bundle;
-
-
-/**
- * Bundle of most images used by the Java plug-in.
- */
-public class JavaPluginImages {
-
- public static final IPath ICONS_PATH= new Path("$nl$/icons/full"); //$NON-NLS-1$
-
- private static final String NAME_PREFIX= "org.eclipse.wst.jsdt.ui."; //$NON-NLS-1$
- private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
-
- // The plug-in registry
- private static ImageRegistry fgImageRegistry= null;
- private static HashMap fgAvoidSWTErrorMap= null;
-
- private static final String T_OBJ= "obj16"; //$NON-NLS-1$
- private static final String T_OVR= "ovr16"; //$NON-NLS-1$
- private static final String T_WIZBAN= "wizban"; //$NON-NLS-1$
- private static final String T_ELCL= "elcl16"; //$NON-NLS-1$
- private static final String T_DLCL= "dlcl16"; //$NON-NLS-1$
- private static final String T_ETOOL= "etool16"; //$NON-NLS-1$
- private static final String T_EVIEW= "eview16"; //$NON-NLS-1$
-
- /*
- * Keys for images available from the Java-UI plug-in image registry.
- */
- public static final String IMG_MISC_PUBLIC= NAME_PREFIX + "methpub_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MISC_DEFAULT= NAME_PREFIX + "methdef_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_FIELD_PUBLIC= NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$
- public static final String IMG_FIELD_PROTECTED= NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_FIELD_PRIVATE= NAME_PREFIX + "field_private_obj.gif"; //$NON-NLS-1$
- public static final String IMG_FIELD_DEFAULT= NAME_PREFIX + "field_default_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_ELCL_VIEW_MENU= NAME_PREFIX + T_ELCL + "view_menu.gif"; //$NON-NLS-1$
- public static final String IMG_DLCL_VIEW_MENU= NAME_PREFIX + T_DLCL + "view_menu.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_GHOST= NAME_PREFIX + "ghost.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCH_TSK= NAME_PREFIX + "search_tsk.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PACKDECL= NAME_PREFIX + "packd_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_IMPDECL= NAME_PREFIX + "imp_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_IMPCONT= NAME_PREFIX + "impc_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_JSEARCH= NAME_PREFIX + "jsearch_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CLASSALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CLASS_DEFAULT= NAME_PREFIX + "class_default_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_INNER_CLASS_PUBLIC= NAME_PREFIX + "innerclass_public_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_CLASS_DEFAULT= NAME_PREFIX + "innerclass_default_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_CLASS_PROTECTED= NAME_PREFIX + "innerclass_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_CLASS_PRIVATE= NAME_PREFIX + "innerclass_private_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_INTERFACE= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INTERFACEALT= NAME_PREFIX + "intf_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INTERFACE_DEFAULT= NAME_PREFIX + "int_default_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_INNER_INTERFACE_PUBLIC= NAME_PREFIX + "innerinterface_public_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_INTERFACE_DEFAULT= NAME_PREFIX + "innerinterface_default_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_INTERFACE_PROTECTED= NAME_PREFIX + "innerinterface_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INNER_INTERFACE_PRIVATE= NAME_PREFIX + "innerinterface_private_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_ANNOTATION= NAME_PREFIX + "annotation_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ANNOTATION_DEFAULT= NAME_PREFIX + "annotation_default_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ANNOTATION_PROTECTED= NAME_PREFIX + "annotation_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ANNOTATION_PRIVATE= NAME_PREFIX + "annotation_private_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ANNOTATION_ALT= NAME_PREFIX + "annotation_alt_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_ENUM= NAME_PREFIX + "enum_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUM_DEFAULT= NAME_PREFIX + "enum_default_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUM_PROTECTED= NAME_PREFIX + "enum_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUM_PRIVATE= NAME_PREFIX + "enum_private_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUM_ALT= NAME_PREFIX + "enum_alt_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_CUNIT= NAME_PREFIX + "jcu_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CUNIT_RESOURCE= NAME_PREFIX + "jcu_resource_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CFILE= NAME_PREFIX + "classf_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CFILECLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CFILEINT= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LOGICAL_PACKAGE= NAME_PREFIX + "logical_package_obj.gif";//$NON-NLS-1$
- public static final String IMG_OBJS_EMPTY_LOGICAL_PACKAGE= NAME_PREFIX + "empty_logical_package_obj.gif";//$NON-NLS-1$
- public static final String IMG_OBJS_PACKAGE= NAME_PREFIX + "package_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EMPTY_PACK_RESOURCE= NAME_PREFIX + "empty_pack_fldr_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EMPTY_PACKAGE= NAME_PREFIX + "empty_pack_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_JAR= NAME_PREFIX + "jar_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EXTJAR= NAME_PREFIX + "jar_l_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_JAR_WSRC= NAME_PREFIX + "jar_src_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_JAVA_MODEL= NAME_PREFIX + "java_model_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LOCAL_VARIABLE= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PROJECT_SETTINGS= NAME_PREFIX + "settings_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TYPEVARIABLE= NAME_PREFIX + "typevariable_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_EXCEPTION= NAME_PREFIX + "jexception_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ERROR= NAME_PREFIX + "jrtexception_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_BREAKPOINT_INSTALLED= NAME_PREFIX + "brkpi_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_QUICK_ASSIST= NAME_PREFIX + "quickassist_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_ACCESSRULES_ATTRIB= NAME_PREFIX + "access_restriction_attrib.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_NLS_TRANSLATE= NAME_PREFIX + "translate.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_NLS_SKIP= NAME_PREFIX + "skip.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_SEARCH_READACCESS= NAME_PREFIX + "occ_read.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCH_WRITEACCESS= NAME_PREFIX + "occ_write.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCH_OCCURRENCE= NAME_PREFIX + "occ_match.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_HELP= NAME_PREFIX + "help.gif"; //$NON-NLS-1$
-
- /*
- * Set of predefined Image Descriptors.
- */
- public static final ImageDescriptor DESC_VIEW_ERRORWARNING_TAB= createUnManaged(T_EVIEW, "errorwarning_tab.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_VIEW_CLASSFILEGENERATION_TAB= createUnManaged(T_EVIEW, "classfilegeneration_tab.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_VIEW_JDKCOMPLIANCE_TAB= createUnManaged(T_EVIEW, "jdkcompliance_tab.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_ELCL_FILTER= createUnManaged(T_ELCL, "filter_ps.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_FILTER= createUnManaged(T_DLCL, "filter_ps.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_ELCL_CODE_ASSIST= createUnManaged(T_ELCL, "metharg_obj.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_CODE_ASSIST= createUnManaged(T_DLCL, "metharg_obj.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_ELCL_VIEW_MENU= createManaged(T_ELCL, "view_menu.gif", IMG_ELCL_VIEW_MENU); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_VIEW_MENU= createManaged(T_DLCL, "view_menu.gif", IMG_DLCL_VIEW_MENU); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_MISC_PUBLIC= createManagedFromKey(T_OBJ, IMG_MISC_PUBLIC);
- public static final ImageDescriptor DESC_MISC_PROTECTED= createManagedFromKey(T_OBJ, IMG_MISC_PROTECTED);
- public static final ImageDescriptor DESC_MISC_PRIVATE= createManagedFromKey(T_OBJ, IMG_MISC_PRIVATE);
- public static final ImageDescriptor DESC_MISC_DEFAULT= createManagedFromKey(T_OBJ, IMG_MISC_DEFAULT);
-
- public static final ImageDescriptor DESC_FIELD_PUBLIC= createManagedFromKey(T_OBJ, IMG_FIELD_PUBLIC);
- public static final ImageDescriptor DESC_FIELD_PROTECTED= createManagedFromKey(T_OBJ, IMG_FIELD_PROTECTED);
- public static final ImageDescriptor DESC_FIELD_PRIVATE= createManagedFromKey(T_OBJ, IMG_FIELD_PRIVATE);
- public static final ImageDescriptor DESC_FIELD_DEFAULT= createManagedFromKey(T_OBJ, IMG_FIELD_DEFAULT);
-
- public static final ImageDescriptor DESC_MENU_SHIFT_RIGHT= createUnManaged(T_ETOOL, "shift_r_edit.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_MENU_SHIFT_LEFT= createUnManaged(T_ETOOL, "shift_l_edit.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJS_GHOST= createManagedFromKey(T_OBJ, IMG_OBJS_GHOST);
- public static final ImageDescriptor DESC_OBJS_PACKDECL= createManagedFromKey(T_OBJ, IMG_OBJS_PACKDECL);
- public static final ImageDescriptor DESC_OBJS_IMPDECL= createManagedFromKey(T_OBJ, IMG_OBJS_IMPDECL);
- public static final ImageDescriptor DESC_OBJS_IMPCONT= createManagedFromKey(T_OBJ, IMG_OBJS_IMPCONT);
- public static final ImageDescriptor DESC_OBJS_JSEARCH= createManagedFromKey(T_OBJ, IMG_OBJS_JSEARCH);
- public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_DECL);
- public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_REF);
- public static final ImageDescriptor DESC_OBJS_CUNIT= createManagedFromKey(T_OBJ, IMG_OBJS_CUNIT);
- public static final ImageDescriptor DESC_OBJS_CUNIT_RESOURCE= createManagedFromKey(T_OBJ, IMG_OBJS_CUNIT_RESOURCE);
- public static final ImageDescriptor DESC_OBJS_CFILE= createManagedFromKey(T_OBJ, IMG_OBJS_CFILE);
- public static final ImageDescriptor DESC_OBJS_CFILECLASS= createManagedFromKey(T_OBJ, IMG_OBJS_CFILECLASS);
- public static final ImageDescriptor DESC_ELCL_CLEAR= createUnManaged(T_ELCL, "clear_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_CLEAR= createUnManaged(T_DLCL, "clear_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_CFILEINT= createManagedFromKey(T_OBJ, IMG_OBJS_CFILEINT);
- public static final ImageDescriptor DESC_OBJS_PACKAGE= createManagedFromKey(T_OBJ, IMG_OBJS_PACKAGE);
- public static final ImageDescriptor DESC_OBJS_EMPTY_LOGICAL_PACKAGE= createManagedFromKey(T_OBJ, IMG_OBJS_EMPTY_LOGICAL_PACKAGE);
- public static final ImageDescriptor DESC_OBJS_LOGICAL_PACKAGE= createManagedFromKey(T_OBJ, IMG_OBJS_LOGICAL_PACKAGE);
- public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE_RESOURCES= createManagedFromKey(T_OBJ, IMG_OBJS_EMPTY_PACK_RESOURCE);
- public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE= createManagedFromKey(T_OBJ, IMG_OBJS_EMPTY_PACKAGE);
- public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT= createManagedFromKey(T_OBJ, IMG_OBJS_PACKFRAG_ROOT);
- public static final ImageDescriptor DESC_OBJS_PROJECT_SETTINGS= createManagedFromKey(T_OBJ, IMG_OBJS_PROJECT_SETTINGS);
-
- public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManagedFromKey(T_OBJ, IMG_OBJS_JAVA_MODEL);
-
- public static final ImageDescriptor DESC_OBJS_CLASS= createManagedFromKey(T_OBJ, IMG_OBJS_CLASS);
- public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_CLASS_DEFAULT);
-
- public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PUBLIC= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_CLASS_PUBLIC);
- public static final ImageDescriptor DESC_OBJS_INNER_CLASS_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_CLASS_DEFAULT);
- public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PROTECTED= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_CLASS_PROTECTED);
- public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PRIVATE= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_CLASS_PRIVATE);
-
- public static final ImageDescriptor DESC_OBJS_CLASSALT= createManagedFromKey(T_OBJ, IMG_OBJS_CLASSALT);
-
- public static final ImageDescriptor DESC_OBJS_INTERFACE= createManagedFromKey(T_OBJ, IMG_OBJS_INTERFACE);
- public static final ImageDescriptor DESC_OBJS_INTERFACE_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_INTERFACE_DEFAULT);
-
- public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PUBLIC= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_INTERFACE_PUBLIC);
- public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_INTERFACE_DEFAULT);
- public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PROTECTED= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_INTERFACE_PROTECTED);
- public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PRIVATE= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_INTERFACE_PRIVATE);
-
- public static final ImageDescriptor DESC_OBJS_INTERFACEALT= createManagedFromKey(T_OBJ, IMG_OBJS_INTERFACEALT);
-
- public static final ImageDescriptor DESC_OBJS_ANNOTATION= createManagedFromKey(T_OBJ, IMG_OBJS_ANNOTATION);
- public static final ImageDescriptor DESC_OBJS_ANNOTATION_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_ANNOTATION_DEFAULT);
- public static final ImageDescriptor DESC_OBJS_ANNOTATION_PROTECTED= createManagedFromKey(T_OBJ, IMG_OBJS_ANNOTATION_PROTECTED);
- public static final ImageDescriptor DESC_OBJS_ANNOTATION_PRIVATE= createManagedFromKey(T_OBJ, IMG_OBJS_ANNOTATION_PRIVATE);
- public static final ImageDescriptor DESC_OBJS_ANNOTATION_ALT= createManagedFromKey(T_OBJ, IMG_OBJS_ANNOTATION_ALT);
-
- public static final ImageDescriptor DESC_OBJS_ENUM= createManagedFromKey(T_OBJ, IMG_OBJS_ENUM);
- public static final ImageDescriptor DESC_OBJS_ENUM_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_ENUM_DEFAULT);
- public static final ImageDescriptor DESC_OBJS_ENUM_PROTECTED= createManagedFromKey(T_OBJ, IMG_OBJS_ENUM_PROTECTED);
- public static final ImageDescriptor DESC_OBJS_ENUM_PRIVATE= createManagedFromKey(T_OBJ, IMG_OBJS_ENUM_PRIVATE);
- public static final ImageDescriptor DESC_OBJS_ENUM_ALT= createManagedFromKey(T_OBJ, IMG_OBJS_ENUM_ALT);
-
- public static final ImageDescriptor DESC_OBJS_JAR= createManagedFromKey(T_OBJ, IMG_OBJS_JAR);
- public static final ImageDescriptor DESC_OBJS_EXTJAR= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR);
- public static final ImageDescriptor DESC_OBJS_JAR_WSRC= createManagedFromKey(T_OBJ, IMG_OBJS_JAR_WSRC);
- public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
- public static final ImageDescriptor DESC_OBJS_ENV_VAR= createManagedFromKey(T_OBJ, IMG_OBJS_ENV_VAR);
-
- public static final ImageDescriptor DESC_OBJS_LIBRARY= createManagedFromKey(T_OBJ, IMG_OBJS_LIBRARY);
-
- public static final ImageDescriptor DESC_OBJS_JAVADOCTAG= createManagedFromKey(T_OBJ, IMG_OBJS_JAVADOCTAG);
- public static final ImageDescriptor DESC_OBJS_HTMLTAG= createManagedFromKey(T_OBJ, IMG_OBJS_HTMLTAG);
-
- public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManagedFromKey(T_OBJ, IMG_OBJS_TEMPLATE);
-
- public static final ImageDescriptor DESC_OBJS_TYPEVARIABLE= createManagedFromKey(T_OBJ, IMG_OBJS_TYPEVARIABLE);
-
- public static final ImageDescriptor DESC_OBJS_EXCEPTION= createManagedFromKey(T_OBJ, IMG_OBJS_EXCEPTION);
- public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED= createManagedFromKey(T_OBJ, IMG_OBJS_BREAKPOINT_INSTALLED);
- public static final ImageDescriptor DESC_OBJS_ERROR= createManagedFromKey(T_OBJ, IMG_OBJS_ERROR);
- public static final ImageDescriptor DESC_OBJS_QUICK_ASSIST= createManagedFromKey(T_OBJ, IMG_OBJS_QUICK_ASSIST);
- public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
- public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
-
- // public static final ImageDescriptor DESC_OBJS_SNIPPET_EVALUATING= createManaged(T_OBJ, IMG_OBJS_SNIPPET_EVALUATING);
-
- public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= createUnManaged(T_OBJ, "change.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB= createUnManaged(T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_INCLUSION_FILTER_ATTRIB= createUnManaged(T_OBJ, "inclusion_filter_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER_ATTRIB= createUnManaged(T_OBJ, "output_folder_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createUnManaged(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= createUnManaged(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJS_ACCESSRULES_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_ACCESSRULES_ATTRIB);
- public static final ImageDescriptor DESC_OBJS_NATIVE_LIB_PATH_ATTRIB= createUnManaged(T_OBJ, "native_lib_path_attrib.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_FATAL);
- public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_ERROR);
- public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_WARNING);
- public static final ImageDescriptor DESC_OBJS_REFACTORING_INFO= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_INFO);
-
- public static final ImageDescriptor DESC_OBJS_NLS_TRANSLATE= createManagedFromKey(T_OBJ, IMG_OBJS_NLS_TRANSLATE);
- public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManagedFromKey(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
- public static final ImageDescriptor DESC_OBJS_NLS_SKIP= createManagedFromKey(T_OBJ, IMG_OBJS_NLS_SKIP);
-
- public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManagedFromKey(T_OBJ, IMG_OBJS_UNKNOWN);
-
- public static final ImageDescriptor DESC_OBJS_TYPE_SEPARATOR= createUnManaged(T_OBJ, "type_separator.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJS_SEARCH_READACCESS= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_READACCESS);
- public static final ImageDescriptor DESC_OBJS_SEARCH_WRITEACCESS= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_WRITEACCESS);
- public static final ImageDescriptor DESC_OBJS_SEARCH_OCCURRENCE= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_OCCURRENCE);
-
- public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManagedFromKey(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
-
- public static final ImageDescriptor DESC_OBJS_HELP= createManagedFromKey(T_ELCL, IMG_OBJS_HELP);
-
- public static final ImageDescriptor DESC_ELCL_ADD_TO_BP= createUnManaged(T_ELCL, "add_to_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_REMOVE_FROM_BP= createUnManaged(T_ELCL, "remove_from_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_INCLUSION= createUnManaged(T_ELCL, "inclusion_filter_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_EXCLUSION= createUnManaged(T_ELCL, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
-// public static final ImageDescriptor DESC_ELCL_INCLUSION_UNDO= createUnManaged(T_ELCL, "inclusion_filter_attrib_undo.gif"); //$NON-NLS-1$
-// public static final ImageDescriptor DESC_ELCL_EXCLUSION_UNDO= createUnManaged(T_ELCL, "exclusion_filter_attrib_undo.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_ADD_TO_BP= createUnManaged(T_DLCL, "add_to_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_REMOVE_FROM_BP= createUnManaged(T_DLCL, "remove_from_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_INCLUSION= createUnManaged(T_DLCL, "inclusion_filter_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_EXCLUSION= createUnManaged(T_DLCL, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_OUTPUT_FOLDER_ATTRIB= createUnManaged(T_DLCL, "output_folder_attrib.gif"); //$NON-NLS-1$
-// public static final ImageDescriptor DESC_DLCL_INCLUSION_UNDO= createUnManaged(T_DLCL, "inclusion_filter_attrib_undo.gif"); //$NON-NLS-1$
-// public static final ImageDescriptor DESC_DLCL_EXCLUSION_UNDO= createUnManaged(T_DLCL, "exclusion_filter_attrib_undo.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_ADD_LINKED_SOURCE_TO_BUILDPATH= createUnManaged(T_DLCL, "add_linked_source_to_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH= createUnManaged(T_ELCL, "add_linked_source_to_buildpath.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_CONFIGURE_BUILDPATH= createUnManaged(T_DLCL, "configure_build_path.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_CONFIGURE_BUILDPATH= createUnManaged(T_ELCL, "configure_build_path.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS= createUnManaged(T_DLCL, "configure_buildpath_filters.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS= createUnManaged(T_ELCL, "configure_buildpath_filters.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_CONFIGURE_OUTPUT_FOLDER= createUnManaged(T_DLCL, "configure_output_folder.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_CONFIGURE_OUTPUT_FOLDER= createUnManaged(T_ELCL, "configure_output_folder.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_EXCLUDE_FROM_BUILDPATH= createUnManaged(T_DLCL, "exclude_from_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_EXCLUDE_FROM_BUILDPATH= createUnManaged(T_ELCL, "exclude_from_buildpath.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_INCLUDE_ON_BUILDPATH= createUnManaged(T_DLCL, "include_on_buildpath.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_INCLUDE_ON_BUILDPATH= createUnManaged(T_ELCL, "include_on_buildpath.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_ADD_AS_SOURCE_FOLDER= createUnManaged(T_DLCL, "add_as_source_folder.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_ADD_AS_SOURCE_FOLDER= createUnManaged(T_ELCL, "add_as_source_folder.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_REMOVE_AS_SOURCE_FOLDER= createUnManaged(T_DLCL, "remove_as_source_folder.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_REMOVE_AS_SOURCE_FOLDER= createUnManaged(T_ELCL, "remove_as_source_folder.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_DLCL_COPY_QUALIFIED_NAME= createUnManaged(T_DLCL, "cpyqual_menu.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_COPY_QUALIFIED_NAME= createUnManaged(T_ELCL, "cpyqual_menu.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OBJ_OVERRIDES= createUnManaged(T_OBJ, "over_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJ_IMPLEMENTS= createUnManaged(T_OBJ, "implm_co.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OVR_STATIC= createUnManagedCached(T_OVR, "static_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_FINAL= createUnManagedCached(T_OVR, "final_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ABSTRACT= createUnManagedCached(T_OVR, "abstract_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_SYNCH= createUnManagedCached(T_OVR, "synch_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_VOLATILE= createUnManagedCached(T_OVR, "volatile_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_TRANSIENT= createUnManagedCached(T_OVR, "transient_co.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OVR_RUN= createUnManagedCached(T_OVR, "run_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_WARNING= createUnManagedCached(T_OVR, "warning_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ERROR= createUnManagedCached(T_OVR, "error_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_OVERRIDES= createUnManagedCached(T_OVR, "over_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_IMPLEMENTS= createUnManagedCached(T_OVR, "implm_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_SYNCH_AND_OVERRIDES= createUnManagedCached(T_OVR, "sync_over.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_SYNCH_AND_IMPLEMENTS= createUnManagedCached(T_OVR, "sync_impl.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_CONSTRUCTOR= createUnManagedCached(T_OVR, "constr_ovr.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_DEPRECATED= createUnManagedCached(T_OVR, "deprecated.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_FOCUS= createUnManagedCached(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ANNOTATION= createUnManagedCached(T_OVR, "annotation_tsk.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ENUM= createUnManagedCached(T_OVR, "enum_tsk.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_INTERFACE= createUnManagedCached(T_OVR, "interface_tsk.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_CLASS= createUnManagedCached(T_OVR, "class_tsk.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ABSTRACT_CLASS= createUnManagedCached(T_OVR, "class_abs_tsk.gif"); //$NON-NLS-1$
-
- // Call Hierarchy
- public static final ImageDescriptor DESC_OVR_RECURSIVE= createUnManaged(T_OVR, "recursive_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_MAX_LEVEL= createUnManaged(T_OVR, "maxlevel_co.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= createUnManaged(T_WIZBAN, "newclass_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWINT= createUnManaged(T_WIZBAN, "newint_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWENUM= createUnManaged(T_WIZBAN, "newenum_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWANNOT= createUnManaged(T_WIZBAN, "newannotation_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ= createUnManaged(T_WIZBAN, "newjprj_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= createUnManaged(T_WIZBAN, "newsrcfldr_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWMETH= createUnManaged(T_WIZBAN, "newmeth_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWPACK= createUnManaged(T_WIZBAN, "newpack_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWSCRAPPAGE= createUnManaged(T_WIZBAN, "newsbook_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_JAVA_LAUNCH= createUnManaged(T_WIZBAN, "java_app_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_JAVA_ATTACH= createUnManaged(T_WIZBAN, "java_attach_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR= createUnManaged(T_WIZBAN, "refactor_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= createUnManaged(T_WIZBAN, "fieldrefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= createUnManaged(T_WIZBAN, "methrefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= createUnManaged(T_WIZBAN, "typerefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PACKAGE= createUnManaged(T_WIZBAN, "packrefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CODE= createUnManaged(T_WIZBAN, "coderefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CU= createUnManaged(T_WIZBAN, "compunitrefact_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PULL_UP= createUnManaged(T_WIZBAN, "pullup_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIX_DEPRECATION= createUnManaged(T_WIZBAN, "fixdepr_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_JAR_PACKAGER= createUnManaged(T_WIZBAN, "jar_pack_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_EXTRACT_SUPERTYPE= createUnManaged(T_WIZBAN, "extractsupertype_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REPLACE_JAR= createUnManaged(T_WIZBAN, "replacejar_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_JAVA_WORKINGSET= createUnManaged(T_WIZBAN, "java_workingset_wiz.png");//$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_EXPORT_JAVADOC= createUnManaged(T_WIZBAN, "export_javadoc_wiz.png");//$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_EXTERNALIZE_STRINGS= createUnManaged(T_WIZBAN, "extstr_wiz.png");//$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY= createUnManaged(T_WIZBAN, "addlibrary_wiz.png");//$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_CLEAN_UP= createUnManaged(T_WIZBAN, "cleanup_wiz.png"); //$NON-NLS-1$
-
-
- public static final ImageDescriptor DESC_TOOL_SHOW_EMPTY_PKG= createUnManaged(T_ETOOL, "show_empty_pkg.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_SHOW_SEGMENTS= createUnManaged(T_ETOOL, "segment_edit.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_TOOL_OPENTYPE= createUnManaged(T_ETOOL, "opentype.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWPROJECT= createUnManaged(T_ETOOL, "newjprj_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWPACKAGE= createUnManaged(T_ETOOL, "newpack_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWCLASS= createUnManaged(T_ETOOL, "newclass_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWINTERFACE= createUnManaged(T_ETOOL, "newint_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWSNIPPET= createUnManaged(T_ETOOL, "newsbook_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_TOOL_NEWPACKROOT= createUnManaged(T_ETOOL, "newpackfolder_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_NEWPACKROOT= createUnManaged(T_DLCL, "newpackfolder_wiz.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_TOOL_CLASSPATH_ORDER= createUnManaged(T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_COLLAPSEALL= createUnManaged(T_ELCL, "collapseall.gif"); //$NON-NLS-1$
-
- // Keys for correction proposal. We have to put the image into the registry since "code assist" doesn't
- // have a life cycle. So no change to dispose icons.
-
- public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_MOVE= NAME_PREFIX + "correction_move.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_LINKED_RENAME= NAME_PREFIX + "correction_linked_rename.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_DELETE_IMPORT= NAME_PREFIX + "correction_delete_import.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_LOCAL= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_REMOVE= NAME_PREFIX + "remove_correction.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$
- public static final String IMG_CORRECTION_CAST= NAME_PREFIX + "correction_cast.gif"; //$NON-NLS-1$
-
- static {
- createManagedFromKey(T_OBJ, IMG_CORRECTION_CHANGE);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_MOVE);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_RENAME);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_LINKED_RENAME);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_DELETE_IMPORT);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_LOCAL);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_REMOVE);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_ADD);
- createManagedFromKey(T_OBJ, IMG_CORRECTION_CAST);
- }
-
- private static final class CachedImageDescriptor extends ImageDescriptor {
- private ImageDescriptor fDescriptor;
- private ImageData fData;
-
- public CachedImageDescriptor(ImageDescriptor descriptor) {
- fDescriptor = descriptor;
- }
-
- public ImageData getImageData() {
- if (fData == null) {
- fData= fDescriptor.getImageData();
- }
- return fData;
- }
- }
-
- /**
- * Returns the image managed under the given key in this registry.
- *
- * @param key the image's key
- * @return the image managed under the given key
- */
- public static Image get(String key) {
- return getImageRegistry().get(key);
- }
-
- /**
- * Returns the image descriptor for the given key in this registry. Might be called in a non-UI thread.
- *
- * @param key the image's key
- * @return the image descriptor for the given key
- */
- public static ImageDescriptor getDescriptor(String key) {
- if (fgImageRegistry == null) {
- return (ImageDescriptor) fgAvoidSWTErrorMap.get(key);
- }
- return getImageRegistry().getDescriptor(key);
- }
-
- /**
- * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
- * are retrieved from the *tool16 folders.
- *
- * @param action the action
- * @param iconName the icon name
- */
- public static void setToolImageDescriptors(IAction action, String iconName) {
- setImageDescriptors(action, "tool16", iconName); //$NON-NLS-1$
- }
-
- /**
- * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
- * are retrieved from the *lcl16 folders.
- *
- * @param action the action
- * @param iconName the icon name
- */
- public static void setLocalImageDescriptors(IAction action, String iconName) {
- setImageDescriptors(action, "lcl16", iconName); //$NON-NLS-1$
- }
-
- /*
- * Helper method to access the image registry from the JavaScriptPlugin class.
- */
- /* package */ static ImageRegistry getImageRegistry() {
- if (fgImageRegistry == null) {
- fgImageRegistry= new ImageRegistry();
- for (Iterator iter= fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) {
- String key= (String) iter.next();
- fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap.get(key));
- }
- fgAvoidSWTErrorMap= null;
- }
- return fgImageRegistry;
- }
-
- //---- Helper methods to access icons on the file system --------------------------------------
-
- private static void setImageDescriptors(IAction action, String type, String relPath) {
- ImageDescriptor id= create("d" + type, relPath, false); //$NON-NLS-1$
- if (id != null)
- action.setDisabledImageDescriptor(id);
-
- /*
- * id= create("c" + type, relPath, false); //$NON-NLS-1$
- * if (id != null)
- * action.setHoverImageDescriptor(id);
- */
-
- ImageDescriptor descriptor= create("e" + type, relPath, true); //$NON-NLS-1$
- action.setHoverImageDescriptor(descriptor);
- action.setImageDescriptor(descriptor);
- }
-
- private static ImageDescriptor createManagedFromKey(String prefix, String key) {
- return createManaged(prefix, key.substring(NAME_PREFIX_LENGTH), key);
- }
-
- private static ImageDescriptor createManaged(String prefix, String name, String key) {
- ImageDescriptor result= create(prefix, name, true);
-
- if (fgAvoidSWTErrorMap == null) {
- fgAvoidSWTErrorMap= new HashMap();
- }
- fgAvoidSWTErrorMap.put(key, result);
- if (fgImageRegistry != null) {
- JavaScriptPlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
- }
- return result;
- }
-
- /*
- * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
- * contain variables like $NL$.
- * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
- * the 'missing image descriptor' is returned or <code>null</code>.
- * or <code>null</code>.
- */
- private static ImageDescriptor create(String prefix, String name, boolean useMissingImageDescriptor) {
- IPath path= ICONS_PATH.append(prefix).append(name);
- return createImageDescriptor(JavaScriptPlugin.getDefault().getBundle(), path, useMissingImageDescriptor);
- }
-
- /*
- * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
- * contain variables like $NL$.
- * If no image could be found, the 'missing image descriptor' is returned.
- */
- private static ImageDescriptor createUnManaged(String prefix, String name) {
- return create(prefix, name, true);
- }
-
- /*
- * Creates an image descriptor for the given prefix and name in the JDT UI bundle and let tye descriptor cache the image data.
- * If no image could be found, the 'missing image descriptor' is returned.
- */
- private static ImageDescriptor createUnManagedCached(String prefix, String name) {
- return new CachedImageDescriptor(create(prefix, name, true));
- }
-
- /*
- * Creates an image descriptor for the given path in a bundle. The path can contain variables
- * like $NL$.
- * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
- * the 'missing image descriptor' is returned or <code>null</code>.
- * Added for 3.1.1.
- */
- public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
- URL url= FileLocator.find(bundle, path, null);
- if (url != null) {
- return ImageDescriptor.createFromURL(url);
- }
- if (useMissingImageDescriptor) {
- return ImageDescriptor.getMissingImageDescriptor();
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaProjectAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaProjectAdapterFactory.java
deleted file mode 100644
index 1909d474..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaProjectAdapterFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-
-/**
- * An adapter factory for IJavaProjects.
- */
-public class JavaProjectAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- IProject.class,
- };
-
- public Class[] getAdapterList() {
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- if (IProject.class.equals(key)) {
- IJavaScriptProject javaProject= (IJavaScriptProject)element;
- return javaProject.getProject();
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaScriptPlugin.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaScriptPlugin.java
deleted file mode 100644
index 2c3c2a48..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaScriptPlugin.java
+++ /dev/null
@@ -1,930 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
-import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.navigator.ICommonMenuConstants;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.ConfigurationElementSorter;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.themes.IThemeManager;
-import org.eclipse.wst.jsdt.core.IBuffer;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.manipulation.JavaScriptManipulation;
-import org.eclipse.wst.jsdt.internal.corext.javadoc.JavaDocLocations;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.corext.template.java.JavaContextType;
-import org.eclipse.wst.jsdt.internal.corext.template.java.JavaDocContextType;
-import org.eclipse.wst.jsdt.internal.corext.util.OpenTypeHistory;
-import org.eclipse.wst.jsdt.internal.corext.util.QualifiedTypeNameHistory;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeFilter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ClassFileDocumentProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.DocumentAdapter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.WorkingCopyManager;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.SaveParticipantRegistry;
-import org.eclipse.wst.jsdt.internal.ui.preferences.MembersOrderPreferenceCache;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.FormatterProfileStore;
-import org.eclipse.wst.jsdt.internal.ui.text.PreferencesAdapter;
-import org.eclipse.wst.jsdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry;
-import org.eclipse.wst.jsdt.internal.ui.text.java.ContentAssistHistory;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
-import org.eclipse.wst.jsdt.internal.ui.text.spelling.SpellCheckEngine;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemMarkerManager;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.ClasspathAttributeConfigurationDescriptors;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-import org.osgi.framework.BundleContext;
-
-/**
- * Represents the java plug-in. It provides a series of convenience methods such as
- * access to the workbench, keeps track of elements shared by all editors and viewers
- * of the plug-in such as document providers and find-replace-dialogs.
- */
-public class JavaScriptPlugin extends AbstractUIPlugin {
-
- /**
- * The key to store customized templates.
- *
- */
- private static final String TEMPLATES_KEY= "org.eclipse.wst.jsdt.ui.text.custom_templates"; //$NON-NLS-1$
- /**
- * The key to store customized code templates.
- *
- */
- private static final String CODE_TEMPLATES_KEY= "org.eclipse.wst.jsdt.ui.text.custom_code_templates"; //$NON-NLS-1$
- /**
- * The key to store whether the legacy templates have been migrated
- *
- */
- private static final String TEMPLATES_MIGRATION_KEY= "org.eclipse.wst.jsdt.ui.text.templates_migrated"; //$NON-NLS-1$
- /**
- * The key to store whether the legacy code templates have been migrated
- *
- */
- private static final String CODE_TEMPLATES_MIGRATION_KEY= "org.eclipse.wst.jsdt.ui.text.code_templates_migrated"; //$NON-NLS-1$
-
- private static JavaScriptPlugin fgJavaPlugin;
-
- private static LinkedHashMap fgRepeatedMessages= new LinkedHashMap(20, 0.75f, true) {
- private static final long serialVersionUID= 1L;
- protected boolean removeEldestEntry(java.util.Map.Entry eldest) {
- return size() >= 20;
- }
- };
-
- /**
- * The template context type registry for the java editor.
- *
- */
- private ContextTypeRegistry fContextTypeRegistry;
- /**
- * The code template context type registry for the java editor.
- *
- */
- private ContextTypeRegistry fCodeTemplateContextTypeRegistry;
-
- /**
- * The template store for the java editor.
- *
- */
- private TemplateStore fTemplateStore;
- /**
- * The coded template store for the java editor.
- *
- */
- private TemplateStore fCodeTemplateStore;
-
- /**
- * Default instance of the appearance type filters.
- *
- */
- private TypeFilter fTypeFilter;
-
-
- private WorkingCopyManager fWorkingCopyManager;
-
- /**
- * @deprecated
- */
- private ICompilationUnitDocumentProvider fCompilationUnitDocumentProvider;
- private ClassFileDocumentProvider fClassFileDocumentProvider;
- private JavaScriptTextTools fJavaTextTools;
- private ProblemMarkerManager fProblemMarkerManager;
- private ImageDescriptorRegistry fImageDescriptorRegistry;
-
- private MembersOrderPreferenceCache fMembersOrderPreferenceCache;
- private IPropertyChangeListener fFontPropertyChangeListener;
-
- /**
- * Property change listener on this plugin's preference store.
- *
- *
- */
- private IPropertyChangeListener fPropertyChangeListener;
-
- private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors;
-
- /**
- * The AST provider.
- *
- */
- private ASTProvider fASTProvider;
-
- /**
- * The combined preference store.
- *
- */
- private IPreferenceStore fCombinedPreferenceStore;
-
- /**
- * The extension point registry for the <code>org.eclipse.wst.jsdt.ui.javaFoldingStructureProvider</code>
- * extension point.
- *
- *
- */
- private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry;
-
- /**
- * The shared Java properties file document provider.
- *
- */
- private IDocumentProvider fPropertiesFileDocumentProvider;
-
- /**
- * Content assist history.
- *
- *
- */
- private ContentAssistHistory fContentAssistHistory;
-
- /**
- * The save participant registry.
- *
- *
- */
- private SaveParticipantRegistry fSaveParticipantRegistry;
-
- /**
- * The descriptors from the 'classpathAttributeConfiguration' extension point.
- *
- *
- */
- private ClasspathAttributeConfigurationDescriptors fClasspathAttributeConfigurationDescriptors;
-
- private FormToolkit fDialogsFormToolkit;
-
- /**
- * Theme listener.
- *
- */
- private IPropertyChangeListener fThemeListener;
-
- public static JavaScriptPlugin getDefault() {
- return fgJavaPlugin;
- }
-
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- public static IWorkbenchPage getActivePage() {
- return getDefault().internalGetActivePage();
- }
-
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- return getDefault().getWorkbench().getActiveWorkbenchWindow();
- }
-
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window= getActiveWorkbenchWindow();
- if (window != null) {
- return window.getShell();
- }
- return null;
- }
-
- public static String getPluginId() {
- return JavaScriptUI.ID_PLUGIN;
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void logErrorMessage(String message) {
- log(new Status(IStatus.ERROR, getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null));
- }
-
- public static void logErrorStatus(String message, IStatus status) {
- if (status == null) {
- logErrorMessage(message);
- return;
- }
- MultiStatus multi= new MultiStatus(getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null);
- multi.add(status);
- log(multi);
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.JavaPlugin_internal_error, e));
- }
-
- /**
- * Log a message that is potentially repeated after a very short time.
- * The first time this method is called with a given message, the
- * message is written to the log along with the detail message and a stack trace.
- * <p>
- * Only intended for use in debug statements.
- *
- * @param message the (generic) message
- * @param detail the detail message
- */
- public static void logRepeatedMessage(String message, String detail) {
- long now= System.currentTimeMillis();
- boolean writeToLog= true;
- if (fgRepeatedMessages.containsKey(message)) {
- long last= ((Long) fgRepeatedMessages.get(message)).longValue();
- writeToLog= now - last > 5000;
- }
- fgRepeatedMessages.put(message, new Long(now));
- if (writeToLog)
- log(new Exception(message + detail).fillInStackTrace());
- }
-
- public static boolean isDebug() {
- return getDefault().isDebugging();
- }
-
- public static ImageDescriptorRegistry getImageDescriptorRegistry() {
- return getDefault().internalGetImageDescriptorRegistry();
- }
-
- public JavaScriptPlugin() {
- super();
- fgJavaPlugin = this;
- }
-
- /* (non - Javadoc)
- * Method declared in plug-in
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
- public IBuffer createBuffer(IJavaScriptUnit workingCopy) {
- IJavaScriptUnit original= workingCopy.getPrimary();
- IResource resource= original.getResource();
- if (resource instanceof IFile)
- return new DocumentAdapter(workingCopy, (IFile) resource);
- return DocumentAdapter.NULL;
- }
- });
-
- ensurePreferenceStoreBackwardsCompatibility();
-
- // Initialize AST provider
- getASTProvider();
-
- new InitializeAfterLoadJob().schedule();
-
- // make sure is loaded too for org.eclipse.wst.jsdt.core.manipulation
- // can be removed if JavaElementPropertyTester is moved down to jdt.core (bug 127085)
- JavaScriptManipulation.class.toString();
-
- fThemeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty()))
- new JavaUIPreferenceInitializer().initializeDefaultPreferences();
- }
- };
- PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener);
-
- }
-
- /* package */ static void initializeAfterLoad(IProgressMonitor monitor) {
- OpenTypeHistory.getInstance().checkConsistency(monitor);
- }
-
- /** @deprecated */
- private static IPreferenceStore getDeprecatedWorkbenchPreferenceStore() {
- return PlatformUI.getWorkbench().getPreferenceStore();
- }
-
- /** @deprecated */
- private static final String DEPRECATED_EDITOR_TAB_WIDTH= PreferenceConstants.EDITOR_TAB_WIDTH;
-
- /** @deprecated */
- private static final String DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD= PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD;
-
- /** @deprecated */
- private static final String DEPRECATED_CODEASSIST_ORDER_PROPOSALS= PreferenceConstants.CODEASSIST_ORDER_PROPOSALS;
-
- /**
- * Installs backwards compatibility for the preference store.
- */
- private void ensurePreferenceStoreBackwardsCompatibility() {
-
- IPreferenceStore store= getPreferenceStore();
-
- // must add here to guarantee that it is the first in the listener list
- fMembersOrderPreferenceCache= new MembersOrderPreferenceCache();
- fMembersOrderPreferenceCache.install(store);
-
-
- /*
- * Installs backwards compatibility: propagate the Java editor font from a
- * pre-2.1 plug-in to the Platform UI's preference store to preserve
- * the Java editor font from a pre-2.1 workspace. This is done only
- * once.
- */
- String fontPropagatedKey= "fontPropagated"; //$NON-NLS-1$
- if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
- if (!store.getBoolean(fontPropagatedKey))
- PreferenceConverter.setValue(
- getDeprecatedWorkbenchPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT));
- }
- store.setValue(fontPropagatedKey, true);
-
- /*
- * Backwards compatibility: set the Java editor font in this plug-in's
- * preference store to let older versions access it. Since 2.1 the
- * Java editor font is managed by the workbench font preference page.
- */
- PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
-
- fFontPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty()))
- PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
- }
- };
- JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
-
- /*
- * Backwards compatibility: propagate the Java editor tab width from a
- * pre-3.0 plug-in to the new preference key. This is done only once.
- */
- final String oldTabWidthKey= DEPRECATED_EDITOR_TAB_WIDTH;
- final String newTabWidthKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH;
- String tabWidthPropagatedKey= "tabWidthPropagated"; //$NON-NLS-1$
- if (store.contains(oldTabWidthKey) && !store.isDefault(oldTabWidthKey)) {
- if (!store.getBoolean(tabWidthPropagatedKey))
- store.setValue(newTabWidthKey, store.getInt(oldTabWidthKey));
- }
- store.setValue(tabWidthPropagatedKey, true);
-
- /*
- * Backwards compatibility: set the Java editor tab width in this plug-in's
- * preference store with the old key to let older versions access it.
- * Since 3.0 the tab width is managed by the extended text editor and
- * uses a new key.
- */
- store.putValue(oldTabWidthKey, store.getString(newTabWidthKey));
-
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (newTabWidthKey.equals(event.getProperty())) {
- IPreferenceStore prefStore= getPreferenceStore();
- prefStore.putValue(oldTabWidthKey, prefStore.getString(newTabWidthKey));
- }
- }
- };
- store.addPropertyChangeListener(fPropertyChangeListener);
-
- /*
- * Backward compatibility for the refactoring preference key.
- */
-// store.setValue(
-// PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD,
-// RefactoringCore.getConditionCheckingFailedSeverity());
-
- // The commented call above triggers the eager loading of the LTK core plug-in
- // Since the condition checking failed severity is guaranteed to be of RefactoringStatus.SEVERITY_WARNING,
- // we directly insert the inlined value of this constant
- store.setToDefault(DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD);
-
- if (!store.getBoolean(JavaDocLocations.PREF_JAVADOCLOCATIONS_MIGRATED)) {
- JavaDocLocations.migrateToClasspathAttributes();
- }
-
- FormatterProfileStore.checkCurrentOptionsVersion();
-
- /*
- * Backward compatibility: migrate "alphabetic ordering" preference to point the sorter
- * preference to the alphabetic sorter.
- */
- String proposalOrderMigrated= "proposalOrderMigrated"; //$NON-NLS-1$
-
- if (store.contains(DEPRECATED_CODEASSIST_ORDER_PROPOSALS)) {
- if (!store.getBoolean(proposalOrderMigrated)) {
- boolean alphabetic= store.getBoolean(DEPRECATED_CODEASSIST_ORDER_PROPOSALS);
- if (alphabetic)
- store.setValue(PreferenceConstants.CODEASSIST_SORTER, "org.eclipse.wst.jsdt.ui.AlphabeticSorter"); //$NON-NLS-1$
- }
- }
- store.setValue(proposalOrderMigrated, true);
-
- }
-
- /**
- * Uninstalls backwards compatibility for the preference store.
- */
- private void uninstallPreferenceStoreBackwardsCompatibility() {
- JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
- getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry()
- */
- protected ImageRegistry createImageRegistry() {
- return JavaPluginImages.getImageRegistry();
- }
-
- /*
- * @see org.eclipse.core.runtime.Plugin#stop
- */
- public void stop(BundleContext context) throws Exception {
- try {
- if (fImageDescriptorRegistry != null)
- fImageDescriptorRegistry.dispose();
-
- if (fASTProvider != null) {
- fASTProvider.dispose();
- fASTProvider= null;
- }
-
- if (fWorkingCopyManager != null) {
- fWorkingCopyManager.shutdown();
- fWorkingCopyManager= null;
- }
-
- if (fCompilationUnitDocumentProvider != null) {
- fCompilationUnitDocumentProvider.shutdown();
- fCompilationUnitDocumentProvider= null;
- }
-
- if (fJavaTextTools != null) {
- fJavaTextTools.dispose();
- fJavaTextTools= null;
- }
-
- if (fTypeFilter != null) {
- fTypeFilter.dispose();
- fTypeFilter= null;
- }
-
- if (fContentAssistHistory != null) {
- ContentAssistHistory.store(fContentAssistHistory, getPluginPreferences(), PreferenceConstants.CODEASSIST_LRU_HISTORY);
- fContentAssistHistory= null;
- }
-
- uninstallPreferenceStoreBackwardsCompatibility();
-
- if (fTemplateStore != null) {
- fTemplateStore.stopListeningForPreferenceChanges();
- fTemplateStore= null;
- }
-
- if (fCodeTemplateStore != null) {
- fCodeTemplateStore.stopListeningForPreferenceChanges();
- fCodeTemplateStore= null;
- }
-
- if (fMembersOrderPreferenceCache != null) {
- fMembersOrderPreferenceCache.dispose();
- fMembersOrderPreferenceCache= null;
- }
-
- if (fSaveParticipantRegistry != null) {
- fSaveParticipantRegistry.dispose();
- fSaveParticipantRegistry= null;
- }
-
- if (fDialogsFormToolkit != null) {
- fDialogsFormToolkit.dispose();
- fDialogsFormToolkit= null;
- }
-
- if (fThemeListener != null) {
- PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener);
- fThemeListener= null;
- }
-
- SpellCheckEngine.shutdownInstance();
-
- QualifiedTypeNameHistory.getDefault().save();
-
- // must add here to guarantee that it is the first in the listener list
-
- OpenTypeHistory.shutdown();
- } finally {
- super.stop(context);
- }
- }
-
- private IWorkbenchPage internalGetActivePage() {
- IWorkbenchWindow window= getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return null;
- return window.getActivePage();
- }
-
- public synchronized ICompilationUnitDocumentProvider getCompilationUnitDocumentProvider() {
- if (fCompilationUnitDocumentProvider == null)
- fCompilationUnitDocumentProvider= new CompilationUnitDocumentProvider();
- return fCompilationUnitDocumentProvider;
- }
-
-
-
- public synchronized ClassFileDocumentProvider getClassFileDocumentProvider() {
- if (fClassFileDocumentProvider == null)
- fClassFileDocumentProvider= new ClassFileDocumentProvider();
- return fClassFileDocumentProvider;
- }
-
- public synchronized WorkingCopyManager getWorkingCopyManager() {
- if (fWorkingCopyManager == null) {
- ICompilationUnitDocumentProvider provider= getCompilationUnitDocumentProvider();
- fWorkingCopyManager= new WorkingCopyManager(provider);
- }
- return fWorkingCopyManager;
- }
-
- public synchronized ProblemMarkerManager getProblemMarkerManager() {
- if (fProblemMarkerManager == null)
- fProblemMarkerManager= new ProblemMarkerManager();
- return fProblemMarkerManager;
- }
-
- public synchronized JavaScriptTextTools getJavaTextTools() {
- if (fJavaTextTools == null)
- fJavaTextTools= new JavaScriptTextTools(getPreferenceStore(), JavaScriptCore.getPlugin().getPluginPreferences());
- return fJavaTextTools;
- }
-
- /**
- * Returns the AST provider.
- *
- * @return the AST provider
- *
- */
- public synchronized ASTProvider getASTProvider() {
- if (fASTProvider == null)
- fASTProvider= new ASTProvider();
-
- return fASTProvider;
- }
-
- public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() {
- // initialized on startup
- return fMembersOrderPreferenceCache;
- }
-
-
- public synchronized TypeFilter getTypeFilter() {
- if (fTypeFilter == null)
- fTypeFilter= new TypeFilter();
- return fTypeFilter;
- }
-
- public FormToolkit getDialogsFormToolkit() {
- if (fDialogsFormToolkit == null) {
- FormColors colors= new FormColors(Display.getCurrent());
- colors.setBackground(null);
- colors.setForeground(null);
- fDialogsFormToolkit= new FormToolkit(colors);
- }
- return fDialogsFormToolkit;
- }
-
- /**
- * Returns all Java editor text hovers contributed to the workbench.
- *
- * @return an array of JavaEditorTextHoverDescriptor
- *
- */
- public synchronized JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
- if (fJavaEditorTextHoverDescriptors == null) {
- fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers();
- ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
- /*
- * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)
- */
- public IConfigurationElement getConfigurationElement(Object object) {
- return ((JavaEditorTextHoverDescriptor)object).getConfigurationElement();
- }
- };
- sorter.sort(fJavaEditorTextHoverDescriptors);
-
- // Move Best Match hover to front
- for (int i= 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {
- if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fJavaEditorTextHoverDescriptors[i].getId())) {
- JavaEditorTextHoverDescriptor hoverDescriptor= fJavaEditorTextHoverDescriptors[i];
- for (int j= i; j > 0; j--)
- fJavaEditorTextHoverDescriptors[j]= fJavaEditorTextHoverDescriptors[j-1];
- fJavaEditorTextHoverDescriptors[0]= hoverDescriptor;
- break;
- }
-
- }
- }
-
- return fJavaEditorTextHoverDescriptors;
- }
-
- /**
- * Resets the Java editor text hovers contributed to the workbench.
- * <p>
- * This will force a rebuild of the descriptors the next time
- * a client asks for them.
- * </p>
- *
- *
- */
- public synchronized void resetJavaEditorTextHoverDescriptors() {
- fJavaEditorTextHoverDescriptors= null;
- }
-
- /**
- * Creates the Java plug-in's standard groups for view context menus.
- *
- * @param menu the menu manager to be populated
- */
- public static void createStandardGroups(IMenuManager menu) {
- if (!menu.isEmpty())
- return;
-
- menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
- menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
- menu.add(new Separator(ICommonMenuConstants.GROUP_EDIT));
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
- }
-
- /**
- * Returns the template context type registry for the java plug-in.
- *
- * @return the template context type registry for the java plug-in
- *
- */
- public ContextTypeRegistry getTemplateContextRegistry() {
- if (fContextTypeRegistry == null) {
- ContributionContextTypeRegistry registry= new ContributionContextTypeRegistry();
- registry.addContextType(JavaContextType.NAME);
- registry.addContextType(JavaDocContextType.NAME);
-
- fContextTypeRegistry= registry;
- }
-
- return fContextTypeRegistry;
- }
-
- /**
- * Returns the template store for the java editor templates.
- *
- * @return the template store for the java editor templates
- *
- */
- public TemplateStore getTemplateStore() {
- if (fTemplateStore == null) {
- final IPreferenceStore store= getPreferenceStore();
- boolean alreadyMigrated= store.getBoolean(TEMPLATES_MIGRATION_KEY);
- if (alreadyMigrated)
- fTemplateStore= new ContributionTemplateStore(getTemplateContextRegistry(), store, TEMPLATES_KEY);
- else {
- fTemplateStore= new CompatibilityTemplateStore(getTemplateContextRegistry(), store, TEMPLATES_KEY, getOldTemplateStoreInstance());
- store.setValue(TEMPLATES_MIGRATION_KEY, true);
- }
-
- try {
- fTemplateStore.load();
- } catch (IOException e) {
- log(e);
- }
- fTemplateStore.startListeningForPreferenceChanges();
- }
-
- return fTemplateStore;
- }
-
- /**
- * @deprecated Indirection added to avoid deprecated warning on file
- */
- private org.eclipse.wst.jsdt.internal.corext.template.java.Templates getOldTemplateStoreInstance() {
- return org.eclipse.wst.jsdt.internal.corext.template.java.Templates.getInstance();
- }
-
- /**
- * Returns the template context type registry for the code generation
- * templates.
- *
- * @return the template context type registry for the code generation
- * templates
- *
- */
- public ContextTypeRegistry getCodeTemplateContextRegistry() {
- if (fCodeTemplateContextTypeRegistry == null) {
- fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry();
-
- CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
- }
-
- return fCodeTemplateContextTypeRegistry;
- }
-
- /**
- * Returns the template store for the code generation templates.
- *
- * @return the template store for the code generation templates
- *
- */
- public TemplateStore getCodeTemplateStore() {
- if (fCodeTemplateStore == null) {
- IPreferenceStore store= getPreferenceStore();
- boolean alreadyMigrated= store.getBoolean(CODE_TEMPLATES_MIGRATION_KEY);
- if (alreadyMigrated)
- fCodeTemplateStore= new ContributionTemplateStore(getCodeTemplateContextRegistry(), store, CODE_TEMPLATES_KEY);
- else {
- fCodeTemplateStore= new CompatibilityTemplateStore(getCodeTemplateContextRegistry(), store, CODE_TEMPLATES_KEY, getOldCodeTemplateStoreInstance());
- store.setValue(CODE_TEMPLATES_MIGRATION_KEY, true);
- }
-
- try {
- fCodeTemplateStore.load();
- } catch (IOException e) {
- log(e);
- }
-
- fCodeTemplateStore.startListeningForPreferenceChanges();
-
- // compatibility / bug fixing code for duplicated templates
- // TODO remove for 3.0
- CompatibilityTemplateStore.pruneDuplicates(fCodeTemplateStore, true);
-
- }
-
- return fCodeTemplateStore;
- }
-
- /**
- * @deprecated Indirection added to avoid deprecated warning on file
- */
- private org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplates getOldCodeTemplateStoreInstance() {
- return org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplates.getInstance();
- }
-
- private synchronized ImageDescriptorRegistry internalGetImageDescriptorRegistry() {
- if (fImageDescriptorRegistry == null)
- fImageDescriptorRegistry= new ImageDescriptorRegistry();
- return fImageDescriptorRegistry;
- }
-
- /**
- * Returns a combined preference store, this store is read-only.
- *
- * @return the combined preference store
- *
- *
- */
- public IPreferenceStore getCombinedPreferenceStore() {
- if (fCombinedPreferenceStore == null) {
- IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
- fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(JavaScriptCore.getPlugin().getPluginPreferences()), generalTextStore });
- }
- return fCombinedPreferenceStore;
- }
-
- /**
- * Returns the registry of the extensions to the <code>org.eclipse.wst.jsdt.ui.javaFoldingStructureProvider</code>
- * extension point.
- *
- * @return the registry of contributed <code>IJavaFoldingStructureProvider</code>
- *
- */
- public synchronized JavaFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() {
- if (fFoldingStructureProviderRegistry == null)
- fFoldingStructureProviderRegistry= new JavaFoldingStructureProviderRegistry();
- return fFoldingStructureProviderRegistry;
- }
-
- /**
- * Returns the save participant registry.
- *
- * @return the save participant registry, not null
- *
- */
- public synchronized SaveParticipantRegistry getSaveParticipantRegistry() {
- if (fSaveParticipantRegistry == null)
- fSaveParticipantRegistry= new SaveParticipantRegistry();
- return fSaveParticipantRegistry;
- }
-
- /**
- * Returns the Java content assist history.
- *
- * @return the Java content assist history
- *
- */
- public ContentAssistHistory getContentAssistHistory() {
- if (fContentAssistHistory == null) {
- try {
- fContentAssistHistory= ContentAssistHistory.load(getPluginPreferences(), PreferenceConstants.CODEASSIST_LRU_HISTORY);
- } catch (CoreException x) {
- log(x);
- }
- if (fContentAssistHistory == null)
- fContentAssistHistory= new ContentAssistHistory();
- }
-
- return fContentAssistHistory;
- }
-
- /**
- * Returns a section in the Java plugin's dialog settings. If the section doesn't exist yet, it is created.
- *
- * @param name the name of the section
- * @return the section of the given name
- *
- */
- public IDialogSettings getDialogSettingsSection(String name) {
- IDialogSettings dialogSettings= getDialogSettings();
- IDialogSettings section= dialogSettings.getSection(name);
- if (section == null) {
- section= dialogSettings.addNewSection(name);
- }
- return section;
- }
-
- /**
- *
- */
- public ClasspathAttributeConfigurationDescriptors getClasspathAttributeConfigurationDescriptors() {
- if (fClasspathAttributeConfigurationDescriptors == null) {
- fClasspathAttributeConfigurationDescriptors= new ClasspathAttributeConfigurationDescriptors();
- }
- return fClasspathAttributeConfigurationDescriptors;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaTaskListAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaTaskListAdapter.java
deleted file mode 100644
index 601c06b9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaTaskListAdapter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-public class JavaTaskListAdapter implements ITaskListResourceAdapter {
-
- /*
- * @see ITaskListResourceAdapter#getAffectedResource(IAdaptable)
- */
- public IResource getAffectedResource(IAdaptable element) {
- IJavaScriptElement java = (IJavaScriptElement) element;
- IResource resource= java.getResource();
- if (resource != null)
- return resource;
-
- IJavaScriptUnit cu= (IJavaScriptUnit) java.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- return cu.getPrimary().getResource();
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIException.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIException.java
deleted file mode 100644
index e48accdf..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-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 JavaUIException extends CoreException {
-
- private static final long serialVersionUID= 1L;
-
- public JavaUIException(IStatus status) {
- super(status);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java
deleted file mode 100644
index 0864494e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class JavaUIMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.JavaUIMessages";//$NON-NLS-1$
-
- private JavaUIMessages() {
- // Do not instantiate
- }
-
- public static String FilteredTypesSelectionDialog_TypeFiltersPreferencesAction_label;
- public static String JavaPlugin_internal_error;
- public static String JavaPlugin_initializing_ui;
-
- public static String JavaElementProperties_name;
- public static String JsNature_Global;
-
- public static String OpenTypeAction_description;
- public static String OpenTypeAction_tooltip;
- public static String OpenTypeAction_errorMessage;
- public static String OpenTypeAction_errorTitle;
- public static String OpenTypeAction_label;
- public static String OpenTypeAction_dialogTitle;
- public static String OpenTypeAction_dialogMessage;
-
- public static String JavaUI_defaultDialogMessage;
-
- public static String MultiElementListSelectionDialog_pageInfoMessage;
- public static String PackageSelectionDialog_progress_findEmpty;
- public static String PackageSelectionDialog_progress_search;
-
- public static String TypeSelectionDialog_dialogMessage;
- public static String TypeSelectionDialog_errorTitle;
- public static String TypeSelectionDialog_error3Message;
- public static String TypeSelectionDialog_error3Title;
- public static String TypeSelectionDialog_progress_consistency;
- public static String TypeSelectionDialog_error_type_doesnot_exist;
-
- public static String ExceptionDialog_seeErrorLogMessage;
-
- public static String MainTypeSelectionDialog_errorTitle;
- public static String MultiMainTypeSelectionDialog_errorTitle;
-
- public static String PackageSelectionDialog_error_title;
- public static String PackageSelectionDialog_error3Message;
- public static String PackageSelectionDialog_nopackages_title;
- public static String PackageSelectionDialog_nopackages_message;
-
- public static String BuildPathDialog_title;
-
- public static String OverrideMethodDialog_groupMethodsByTypes;
- public static String OverrideMethodDialog_dialog_title;
- public static String OverrideMethodDialog_dialog_description;
- public static String OverrideMethodDialog_selectioninfo_more;
- public static String OverrideMethodDialog_link_tooltip;
- public static String OverrideMethodDialog_link_message;
-
-
-
- public static String JavaElementLabels_default_package;
- public static String JavaElementLabels_anonym_type;
- public static String JavaElementLabels_anonym;
- public static String JavaElementLabels_import_container;
- public static String JavaElementLabels_initializer;
- public static String JavaElementLabels_category;
- public static String JavaElementLabels_concat_string;
- public static String JavaElementLabels_comma_string;
- public static String JavaElementLabels_declseparator_string;
- public static String JavaElementLabels_category_separator_string;
-
- public static String StatusBarUpdater_num_elements_selected;
-
- public static String OpenTypeHierarchyUtil_error_open_view;
- public static String OpenTypeHierarchyUtil_error_open_perspective;
- public static String OpenTypeHierarchyUtil_error_open_editor;
- public static String OpenTypeHierarchyUtil_selectionDialog_title;
- public static String OpenTypeHierarchyUtil_selectionDialog_message;
-
- public static String TypeInfoLabelProvider_default_package;
-
- public static String JavaUIHelp_link_label;
- public static String JavaUIHelpContext_javaHelpCategory_label;
-
- public static String ResourceTransferDragAdapter_cannot_delete_resource;
- public static String ResourceTransferDragAdapter_moving_resource;
- public static String ResourceTransferDragAdapter_cannot_delete_files;
-
- public static String Spelling_error_label;
- public static String Spelling_correct_label;
- public static String Spelling_add_info;
- public static String Spelling_add_label;
- public static String Spelling_add_askToConfigure_title;
- public static String Spelling_add_askToConfigure_question;
- public static String Spelling_add_askToConfigure_ignoreMessage;
- public static String Spelling_ignore_info;
- public static String Spelling_ignore_label;
- public static String Spelling_disable_label;
- public static String Spelling_disable_info;
- public static String Spelling_case_label;
- public static String Spelling_error_case_label;
- public static String AbstractSpellingDictionary_encodingError;
-
- public static String JavaAnnotationHover_multipleMarkersAtThisLine;
- public static String JavaEditor_codeassist_noCompletions;
-
- public static String OptionalMessageDialog_dontShowAgain;
- public static String ElementValidator_cannotPerform;
- public static String SelectionListenerWithASTManager_job_title;
-
- public static String JavaOutlineControl_statusFieldText_hideInheritedMembers;
- public static String JavaOutlineControl_statusFieldText_showInheritedMembers;
-
- public static String RenameSupport_not_available;
- public static String RenameSupport_dialog_title;
-
- public static String CoreUtility_job_title;
- public static String CoreUtility_buildall_taskname;
- public static String CoreUtility_buildproject_taskname;
-
- public static String FilteredTypesSelectionDialog_default_package;
- public static String FilteredTypesSelectionDialog_dialogMessage;
- public static String FilteredTypesSelectionDialog_error_type_doesnot_exist;
- public static String FilteredTypesSelectionDialog_library_name_format;
- public static String FilteredTypesSelectionDialog_searchJob_taskName;
- public static String FilteredTypeSelectionDialog_showContainerForDuplicatesAction;
- public static String FilteredTypeSelectionDialog_titleFormat;
-
- public static String TypeSelectionDialog2_title_format;
-
- public static String TypeSelectionComponent_label;
- public static String TypeSelectionComponent_menu;
- public static String TypeSelectionComponent_show_status_line_label;
- public static String TypeSelectionComponent_fully_qualify_duplicates_label;
-
- public static String TypeInfoViewer_job_label;
- public static String TypeInfoViewer_job_error;
- public static String TypeInfoViewer_job_cancel;
- public static String TypeInfoViewer_default_package;
- public static String TypeInfoViewer_progress_label;
- public static String TypeInfoViewer_searchJob_taskName;
- public static String TypeInfoViewer_syncJob_label;
- public static String TypeInfoViewer_syncJob_taskName;
- public static String TypeInfoViewer_progressJob_label;
- public static String TypeInfoViewer_remove_from_history;
- public static String TypeInfoViewer_separator_message;
- public static String TypeInfoViewer_library_name_format;
-
- public static String InitializeAfterLoadJob_starter_job_name;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JavaUIMessages.class);
- }
-
- public static String HistoryListAction_remove;
- public static String HistoryListAction_max_entries_constraint;
- public static String HistoryListAction_remove_all;
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties
deleted file mode 100644
index ef932d93..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties
+++ /dev/null
@@ -1,179 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-JavaPlugin_internal_error=Internal Error
-JavaElementProperties_name=Name
-
-InitializeAfterLoadJob_starter_job_name=Starting JavaScript Tooling initialization
-JavaPlugin_initializing_ui=Initializing JavaScript Tooling
-
-#########
-## actions
-#########
-
-OpenTypeAction_description=Open a type in the editor
-OpenTypeAction_tooltip=Open a Type
-OpenTypeAction_errorMessage=An exception occurred while opening the type.
-OpenTypeAction_errorTitle=Open JavaScript Type
-OpenTypeAction_label=Open JavaScript Type...
-
-OpenTypeAction_dialogTitle=Open JavaScript Type
-OpenTypeAction_dialogMessage=&Enter type name prefix or pattern (*, ?, or camel case):
-
-#######
-## dialogs
-#######
-JavaUI_defaultDialogMessage=Select entries:
-
-MultiElementListSelectionDialog_pageInfoMessage=Page {0} of {1}
-
-TypeSelectionDialog_dialogMessage=Type ''{0}'' could not be found in ''{1}''. Make sure all workspace resources are refreshed.
-TypeSelectionDialog_errorTitle=Select Type
-TypeSelectionDialog_progress_consistency=Initializing search indices
-TypeSelectionDialog_error_type_doesnot_exist=Type {0} does not exist.
-TypeSelectionDialog_error3Message=Unexpected exception. See log for details.
-TypeSelectionDialog_error3Title=Exception
-
-ExceptionDialog_seeErrorLogMessage= See error log for more details.
-
-MainTypeSelectionDialog_errorTitle=Error
-MultiMainTypeSelectionDialog_errorTitle=Error
-
-PackageSelectionDialog_error3Message=Unexpected exception. See log for details.
-PackageSelectionDialog_error_title=Error
-PackageSelectionDialog_nopackages_title=Package Selection
-PackageSelectionDialog_progress_search=Searching for all packages in workspace
-PackageSelectionDialog_nopackages_message=No packages available.
-PackageSelectionDialog_progress_findEmpty=Find empty packages
-
-BuildPathDialog_title= JavaScript Include Path for {0}
-
-
-OverrideMethodDialog_groupMethodsByTypes=Group functions by types
-OverrideMethodDialog_dialog_title=Override/Implement Functions
-OverrideMethodDialog_dialog_description=Select functions to override or implement:
-OverrideMethodDialog_selectioninfo_more={0} of {1} selected.
-
-OverrideMethodDialog_link_tooltip=Show the code templates preferences.
-OverrideMethodDialog_link_message=The format of the function stubs may be configured on the <a>Code Templates</a> preference page.
-
-TypeSelectionDialog2_title_format={0} - {1}
-
-TypeSelectionComponent_label= &Matching types:
-TypeSelectionComponent_menu=Menu
-TypeSelectionComponent_fully_qualify_duplicates_label=Show &Container for Duplicates
-TypeSelectionComponent_show_status_line_label=&Show Status Line
-
-TypeInfoViewer_job_label=Searching for all types
-TypeInfoViewer_job_error=Searching for all types failed
-TypeInfoViewer_job_cancel=Operation got canceled
-TypeInfoViewer_default_package=./
-TypeInfoViewer_progress_label={0} ({1}%)
-TypeInfoViewer_progressJob_label=Progress Update Job
-TypeInfoViewer_searchJob_taskName=Searching...
-TypeInfoViewer_separator_message=Workspace matches
-TypeInfoViewer_remove_from_history=&Remove from History
-TypeInfoViewer_library_name_format=[{0}]
-TypeInfoViewer_syncJob_label=Synchronizing search tables
-TypeInfoViewer_syncJob_taskName=Refreshing indices...
-
-FilteredTypesSelectionDialog_default_package=./
-FilteredTypesSelectionDialog_dialogMessage=Type ''{0}'' could not be found in ''{1}''. Make sure all workspace resources are refreshed.
-FilteredTypesSelectionDialog_error_type_doesnot_exist=Type {0} does not exist.
-FilteredTypesSelectionDialog_TypeFiltersPreferencesAction_label=&Type Filters...
-FilteredTypesSelectionDialog_library_name_format=[{0}]
-FilteredTypesSelectionDialog_searchJob_taskName=Searching
-FilteredTypeSelectionDialog_showContainerForDuplicatesAction=Show &Container for Duplicates
-FilteredTypeSelectionDialog_titleFormat={0} - {1}
-
-###########
-## viewsupport
-###########
-JavaElementLabels_anonym_type=new {0}() '{'...}
-JavaElementLabels_anonym=new Anonymous
-JavaElementLabels_category=[{0}]
-JavaElementLabels_concat_string=\ -\
-JavaElementLabels_comma_string=,\
-JavaElementLabels_declseparator_string=\ :\
-JavaElementLabels_category_separator_string=\
-JavaElementLabels_default_package=./
-JavaElementLabels_import_container=import declarations
-JavaElementLabels_initializer={...}
-
-StatusBarUpdater_num_elements_selected={0} items selected
-
-HistoryListAction_remove=&Remove
-HistoryListAction_remove_all=Remove &All
-HistoryListAction_max_entries_constraint=Please enter a positive integer smaller than {0}.
-OpenTypeHierarchyUtil_error_open_view=Problems opening Type Hierarchy View
-OpenTypeHierarchyUtil_error_open_perspective=Problems opening Type Hierarchy Perspective
-OpenTypeHierarchyUtil_error_open_editor=Problems opening JavaScript Editor
-OpenTypeHierarchyUtil_selectionDialog_title=Open In Type Hierarchy
-OpenTypeHierarchyUtil_selectionDialog_message=&Select the type to be shown in the Type Hierarchy:
-
-TypeInfoLabelProvider_default_package=/.
-
-JavaUIHelp_link_label=Jsdoc for ''{0}''
-JavaUIHelpContext_javaHelpCategory_label= JavaScript help:
-
-#########
-# DnD
-#########
-ResourceTransferDragAdapter_cannot_delete_resource=Cannot delete resources
-ResourceTransferDragAdapter_moving_resource=Moving Resources with Drag and Drop
-ResourceTransferDragAdapter_cannot_delete_files=Cannot delete the following file(s)
-
-#########
-# Spelling
-#########
-
-Spelling_error_label=The word ''{0}'' is not correctly spelled
-Spelling_correct_label=Change to ''{0}''
-Spelling_add_info=Adds the word ''{0}'' to the dictionary
-Spelling_add_label=Add ''{0}'' to dictionary
-Spelling_add_askToConfigure_title=Missing User Dictionary
-Spelling_add_askToConfigure_question=A user dictionary is needed to add words.\nDo you want to configure it now?\n
-Spelling_add_askToConfigure_ignoreMessage= &Do not show 'Add word' proposals if user dictionary is missing
-Spelling_ignore_info=Ignores ''{0}'' during the current session
-Spelling_ignore_label=Ignore ''{0}'' during the current session
-Spelling_case_label=Change to upper case
-Spelling_disable_label=Disable spell checking
-Spelling_disable_info=Disables spell checking.
-Spelling_error_case_label= The word ''{0}'' should have an initial upper case letter
-AbstractSpellingDictionary_encodingError= Could not read: ''{0}'', where the bad characters are replaced by ''{1}''. Check the encoding of the spelling dictionary ({2}).
-
-#########
-# misc
-#########
-
-JavaAnnotationHover_multipleMarkersAtThisLine=Multiple markers at this line
-JavaEditor_codeassist_noCompletions=No completions available.
-
-OptionalMessageDialog_dontShowAgain= Do not show this &message again
-
-ElementValidator_cannotPerform= The requested operation cannot be performed.
-
-SelectionListenerWithASTManager_job_title=Requesting JavaScript AST from selection
-JavaOutlineControl_statusFieldText_hideInheritedMembers= Press ''{0}'' to hide inherited members
-JavaOutlineControl_statusFieldText_showInheritedMembers= Press ''{0}'' to show inherited members
-
-##########
-# Rename support
-##########
-RenameSupport_not_available=The refactoring operation is not available
-RenameSupport_dialog_title=Rename Refactoring
-
-CoreUtility_job_title=Rebuilding
-CoreUtility_buildall_taskname=Build all...
-CoreUtility_buildproject_taskname=Build project ''{0}''...
-
-
-JsNature_Global=Global
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIPreferenceInitializer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIPreferenceInitializer.java
deleted file mode 100644
index f4db448e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIPreferenceInitializer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class JavaUIPreferenceInitializer extends AbstractPreferenceInitializer {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- IPreferenceStore store = PreferenceConstants.getPreferenceStore();
-
- EditorsUI.useAnnotationsPreferencePage(store);
- EditorsUI.useQuickDiffPreferencePage(store);
- PreferenceConstants.initializeDefaultValues(store);
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIStatus.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIStatus.java
deleted file mode 100644
index 4a8a2681..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIStatus.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Convenience class for error exceptions thrown inside JavaScriptUI plugin.
- */
-public class JavaUIStatus extends Status {
-
- private JavaUIStatus(int severity, int code, String message, Throwable throwable) {
- super(severity, JavaScriptPlugin.getPluginId(), code, message, throwable);
- }
-
- public static IStatus createError(int code, Throwable throwable) {
- String message= throwable.getMessage();
- if (message == null) {
- message= throwable.getClass().getName();
- }
- return new JavaUIStatus(IStatus.ERROR, code, message, throwable);
- }
-
- public static IStatus createError(int code, String message, Throwable throwable) {
- return new JavaUIStatus(IStatus.ERROR, code, message, throwable);
- }
-
- public static IStatus createWarning(int code, String message, Throwable throwable) {
- return new JavaUIStatus(IStatus.WARNING, code, message, throwable);
- }
-
- public static IStatus createInfo(int code, String message, Throwable throwable) {
- return new JavaUIStatus(IStatus.INFO, code, message, throwable);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaWorkbenchAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaWorkbenchAdapter.java
deleted file mode 100644
index 0a07e56f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaWorkbenchAdapter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * An imlementation of the IWorkbenchAdapter for IJavaElements.
- */
-public class JavaWorkbenchAdapter implements IWorkbenchAdapter {
-
- protected static final Object[] NO_CHILDREN= new Object[0];
-
- private JavaElementImageProvider fImageProvider;
-
- public JavaWorkbenchAdapter() {
- fImageProvider= new JavaElementImageProvider();
- }
-
- public Object[] getChildren(Object element) {
- IJavaScriptElement je= getJavaElement(element);
- if (je instanceof IParent) {
- try {
- return ((IParent)je).getChildren();
- } catch(JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return NO_CHILDREN;
- }
-
- public ImageDescriptor getImageDescriptor(Object element) {
- IJavaScriptElement je= getJavaElement(element);
- if (je != null)
- return fImageProvider.getJavaImageDescriptor(je, JavaElementImageProvider.OVERLAY_ICONS | JavaElementImageProvider.SMALL_ICONS);
-
- return null;
-
- }
-
- public String getLabel(Object element) {
- return JavaScriptElementLabels.getTextLabel(getJavaElement(element), JavaScriptElementLabels.ALL_DEFAULT);
- }
-
- public Object getParent(Object element) {
- IJavaScriptElement je= getJavaElement(element);
- return je != null ? je.getParent() : null;
- }
-
- private IJavaScriptElement getJavaElement(Object element) {
- if (element instanceof IJavaScriptElement)
- return (IJavaScriptElement)element;
- if (element instanceof IClassFileEditorInput)
- return ((IClassFileEditorInput)element).getClassFile().getPrimaryElement();
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/LogicalPackageAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/LogicalPackageAdapterFactory.java
deleted file mode 100644
index 287a917a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/LogicalPackageAdapterFactory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaElementResourceMapping;
-import org.eclipse.wst.jsdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchUtil;
-
-/**
- * Implements basic UI support for LogicalPackage.
- */
-public class LogicalPackageAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- ResourceMapping.class
- };
-
- // Must be Object to allow lazy loading
- private Object fSearchPageScoreComputer;
-
- public Class[] getAdapterList() {
- updateLazyLoadedAdapters();
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- updateLazyLoadedAdapters();
-
- if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) {
- return fSearchPageScoreComputer;
- } else if (ResourceMapping.class.equals(key)) {
- if (!(element instanceof LogicalPackage))
- return null;
- return JavaElementResourceMapping.create((LogicalPackage)element);
- }
- return null;
- }
-
- private void updateLazyLoadedAdapters() {
- if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
- createSearchPageScoreComputer();
- }
-
- private void createSearchPageScoreComputer() {
- fSearchPageScoreComputer= new JavaSearchPageScoreComputer();
- PROPERTIES= new Class[] {
- ISearchPageScoreComputer.class,
- ResourceMapping.class
- };
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/MarkerAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/MarkerAdapterFactory.java
deleted file mode 100644
index 6e7ce805..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/MarkerAdapterFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchPageScoreComputer;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchUtil;
-
-
-/**
- * Adapter factory to support basic UI operations for markers.
- */
-public class MarkerAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[0];
-
-
- private Object fSearchPageScoreComputer;
-
- public Class[] getAdapterList() {
- updateLazyLoadedAdapters();
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- updateLazyLoadedAdapters();
- if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key))
- return fSearchPageScoreComputer;
- return null;
- }
-
- private void updateLazyLoadedAdapters() {
- if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
- createSearchPageScoreComputer();
- }
-
- private void createSearchPageScoreComputer() {
- fSearchPageScoreComputer= new JavaSearchPageScoreComputer();
- PROPERTIES= new Class[] {ISearchPageScoreComputer.class};
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/PersistableJavaElementFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/PersistableJavaElementFactory.java
deleted file mode 100644
index 7595ca92..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/PersistableJavaElementFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-/**
- * The JavaElementFactory is used to save and recreate an IJavaScriptElement object.
- * As such, it implements the IPersistableElement interface for storage
- * and the IElementFactory interface for recreation.
- *
- * @see IMemento
- * @see IPersistableElement
- * @see IElementFactory
- */
-public class PersistableJavaElementFactory implements IElementFactory, IPersistableElement {
-
- private static final String KEY= "elementID"; //$NON-NLS-1$
- private static final String FACTORY_ID= "org.eclipse.wst.jsdt.ui.PersistableJavaElementFactory"; //$NON-NLS-1$
-
- private IJavaScriptElement fElement;
-
- /**
- * Create a JavaElementFactory.
- */
- public PersistableJavaElementFactory() {
- }
-
- /**
- * Create a JavaElementFactory. This constructor is typically used
- * for our IPersistableElement side.
- */
- public PersistableJavaElementFactory(IJavaScriptElement element) {
- fElement= element;
- }
-
- /*
- * @see IElementFactory
- */
- public IAdaptable createElement(IMemento memento) {
-
- String identifier= memento.getString(KEY);
- if (identifier != null) {
- return JavaScriptCore.create(identifier);
- }
- return null;
- }
-
- /*
- * @see IPersistableElement.
- */
- public String getFactoryId() {
- return FACTORY_ID;
- }
- /*
- * @see IPersistableElement
- */
- public void saveState(IMemento memento) {
- memento.putString(KEY, fElement.getHandleIdentifier());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceAdapterFactory.java
deleted file mode 100644
index 24659de7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceAdapterFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-public class ResourceAdapterFactory implements IAdapterFactory {
-
- private static Class[] PROPERTIES= new Class[] {
- IJavaScriptElement.class
- };
-
- public Class[] getAdapterList() {
- return PROPERTIES;
- }
-
- public Object getAdapter(Object element, Class key) {
- if (IJavaScriptElement.class.equals(key)) {
-
- // Performance optimization, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141
- if (element instanceof IFile) {
- IJavaScriptElement je= JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput((IFile)element));
- if (je != null)
- return je;
- }
-
- return JavaScriptCore.create((IResource)element);
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceLocator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceLocator.java
deleted file mode 100644
index fbd1f699..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/ResourceLocator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * This class locates different resources
- * which are related to an object
- */
-public class ResourceLocator implements IResourceLocator {
-
- public IResource getUnderlyingResource(Object element) throws JavaScriptModelException {
- if (element instanceof IJavaScriptElement)
- return ((IJavaScriptElement) element).getUnderlyingResource();
- else
- return null;
- }
-
- public IResource getCorrespondingResource(Object element) throws JavaScriptModelException {
- if (element instanceof IJavaScriptElement)
- return ((IJavaScriptElement) element).getCorrespondingResource();
- else
- return null;
- }
-
- public IResource getContainingResource(Object element) throws JavaScriptModelException {
- IResource resource= null;
- if (element instanceof IResource)
- resource= (IResource) element;
- if (element instanceof IJavaScriptElement) {
- resource= ((IJavaScriptElement) element).getResource();
- if (resource == null)
- resource= ((IJavaScriptElement) element).getJavaScriptProject().getProject();
- }
- return resource;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SetupProjectsWizzard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SetupProjectsWizzard.java
deleted file mode 100644
index 64d9c119..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SetupProjectsWizzard.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.jsdt.ui.project.JsNature;
-
-/**
- * @author childsb
- *
- */
-public class SetupProjectsWizzard implements IObjectActionDelegate, IActionDelegate {
-
- Object[] fTarget;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
-// throw new UnimplementedException("setActivePart(IAction action, IWorkbenchPart targetPart)"); //$NON-NLS-1$
- }
-
- public void run(IAction action) {
- if(fTarget==null) return;
-
- for(int i=0;i<fTarget.length;i++) {
- if(fTarget[i] instanceof IProject) {
- IProject project = (IProject)fTarget[i];
-
- if(!JsNature.hasNature(project)) {
- JsNature nature = new JsNature(project,null);
- try {
- nature.configure();
- } catch (CoreException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- }
-
- }
- }
-
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
-
- if(selection instanceof StructuredSelection) {
- fTarget = ((StructuredSelection)selection).toArray();
- }else {
- fTarget = null;
- }
- }
-
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SharedImages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SharedImages.java
deleted file mode 100644
index 4a0fae3d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/SharedImages.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.ui.ISharedImages;
-
-/**
- * Default implementation of ISharedImages
- */
-public class SharedImages implements ISharedImages {
-
- public SharedImages() {
- }
-
- /* (Non-Javadoc)
- * Method declared in ISharedImages
- */
- public Image getImage(String key) {
- return JavaPluginImages.get(key);
- }
-
- /* (Non-Javadoc)
- * Method declared in ISharedImages
- */
- public ImageDescriptor getImageDescriptor(String key) {
- return JavaPluginImages.getDescriptor(key);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AbstractToggleLinkingAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AbstractToggleLinkingAction.java
deleted file mode 100644
index 72dfdc57..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AbstractToggleLinkingAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-
-/**
- * This is an action template for actions that toggle whether
- * it links its selection to the active editor.
- *
- *
- */
-public abstract class AbstractToggleLinkingAction extends Action {
-
- /**
- * Constructs a new action.
- */
- public AbstractToggleLinkingAction() {
- super(ActionMessages.ToggleLinkingAction_label);
- setDescription(ActionMessages.ToggleLinkingAction_description);
- setToolTipText(ActionMessages.ToggleLinkingAction_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "synced.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LINK_EDITOR_ACTION);
- }
-
- /**
- * Runs the action.
- */
- public abstract void run();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.java
deleted file mode 100644
index 3e10b3b5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class ActionMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages";//$NON-NLS-1$
-
- private ActionMessages() {
- // Do not instantiate
- }
-
- public static String ActionUtil_warning_derived_dontShowAgain;
- public static String ActionUtil_warning_derived_message;
- public static String ActionUtil_warning_derived_title;
- public static String AddDelegateMethodsAction_not_in_source_file;
-
- public static String AddDelegateMethodsAction_template_link_message;
- public static String AddDelegateMethodsAction_template_link_tooltip;
- public static String AddGetterSetterAction_allow_setters_for_finals_description;
- public static String AddGetterSetterAction_error_not_in_source_file;
- public static String AddGetterSetterAction_template_link_description;
- public static String AddGetterSetterAction_template_link_tooltip;
- public static String AddUnimplementedConstructorsAction_template_link_message;
- public static String AddUnimplementedConstructorsAction_template_link_tooltip;
-
- public static String GenerateConstructorUsingFieldsSelectionDialog_template_link_message;
- public static String GenerateConstructorUsingFieldsSelectionDialog_template_link_tooltip;
- public static String CopyQualifiedNameAction_ActionName;
- public static String CopyQualifiedNameAction_ErrorDescription;
- public static String CopyQualifiedNameAction_ErrorTitle;
- public static String CopyQualifiedNameAction_InfoDialogTitel;
- public static String CopyQualifiedNameAction_NoElementToQualify;
- public static String CopyQualifiedNameAction_ToolTipText;
-
- public static String FindNLSProblemsAction_Description;
- public static String FindNLSProblemsAction_ErrorDialogTitle;
- public static String FindNLSProblemsAction_Name;
- public static String FindNLSProblemsAction_NoPropertieFilesFoundErrorDescription;
- public static String FindNLSProblemsAction_ToolTip;
- public static String FormatAllAction_problem_accessing;
- public static String FormatAllAction_read_only_skipped;
- public static String GenerateNewConstructorUsingFieldsAction_error_not_a_source_file;
- public static String OpenAction_error_problem_opening_editor;
- public static String OpenAction_multistatus_message;
- public static String OpenViewActionGroup_showInAction_label;
- public static String OpenWithMenu_label;
-
- public static String RefactorMenu_label;
- public static String SourceMenu_label;
- public static String BuildPath_label;
- public static String BuildAction_label;
- public static String SelectionConverter_codeResolve_failed;
- public static String OpenAction_label;
- public static String OpenAction_tooltip;
- public static String OpenAction_description;
- public static String OpenAction_declaration_label;
- public static String OpenAction_select_element;
- public static String OpenAction_error_title;
- public static String OpenAction_error_message;
- public static String OpenAction_error_messageBadSelection;
- public static String OpenSuperImplementationAction_label;
- public static String OpenSuperImplementationAction_tooltip;
- public static String OpenSuperImplementationAction_description;
- public static String OpenSuperImplementationAction_error_title;
- public static String OpenSuperImplementationAction_error_message;
- public static String OpenSuperImplementationAction_not_applicable;
- public static String OpenSuperImplementationAction_no_super_implementation;
- public static String OpenTypeHierarchyAction_label;
- public static String OpenTypeHierarchyAction_tooltip;
- public static String OpenTypeHierarchyAction_description;
- public static String OpenTypeHierarchyAction_dialog_title;
- public static String OpenTypeHierarchyAction_messages_title;
- public static String OpenTypeHierarchyAction_messages_no_java_element;
- public static String OpenTypeHierarchyAction_messages_no_java_resources;
- public static String OpenTypeHierarchyAction_messages_no_types;
- public static String OpenTypeHierarchyAction_messages_no_valid_java_element;
- public static String OpenTypeHierarchyAction_messages_unknown_import_decl;
- public static String ShowInPackageViewAction_label;
- public static String ShowInPackageViewAction_description;
- public static String ShowInPackageViewAction_tooltip;
- public static String ShowInPackageViewAction_dialog_title;
- public static String ShowInPackageViewAction_error_message;
- public static String ShowInNavigatorView_label;
- public static String ShowInNavigatorView_dialog_title;
- public static String ShowInNavigatorView_dialog_message;
- public static String ShowInNavigatorView_error_activation_failed;
- public static String OverrideMethodsAction_label;
- public static String OverrideMethodsAction_description;
- public static String OverrideMethodsAction_tooltip;
- public static String OverrideMethodsAction_error_actionfailed;
- public static String OverrideMethodsAction_error_title;
- public static String OverrideMethodsAction_error_nothing_found;
- public static String OverrideMethodsAction_not_applicable;
- public static String OverrideMethodsAction_interface_not_applicable;
- public static String OverrideMethodsAction_annotation_not_applicable;
-
- public static String CleanUpAction_label;
- public static String CleanUpAction_labelWizard;
- public static String CleanUpAction_tooltip;
- public static String CleanUpAction_description;
- public static String CleanUpAction_MultiStateErrorTitle;
- public static String CleanUpAction_UnexpectedErrorMessage;
- public static String CleanUpAction_CUNotOnBuildpathMessage;
- public static String CleanUpAction_EmptySelection_description;
- public static String CleanUpAction_actionName;
-
- public static String AddGetterSetterAction_no_primary_type_title;
- public static String AddGetterSetterAction_no_primary_type_message;
- public static String AddGetterSetterAction_label;
- public static String AddGetterSetterAction_description;
- public static String AddGetterSetterAction_tooltip;
- public static String AddGetterSetterAction_error_duplicate_methods;
- public static String AddGetterSetterAction_error_title;
- public static String AddGetterSetterAction_error_actionfailed;
- public static String AddGetterSetterAction_not_applicable;
- public static String AddGetterSetterAction_interface_not_applicable;
- public static String AddGetterSetterAction_annotation_not_applicable;
- public static String AddGetterSetterAction_QueryDialog_title;
- public static String AddGetterSetterAction_SkipExistingDialog_message;
- public static String AddGetterSetterAction_SkipExistingDialog_skip_label;
- public static String AddGetterSetterAction_SkipExistingDialog_replace_label;
- public static String AddGetterSetterAction_SkipExistingDialog_skipAll_label;
- public static String AddGetterSetterAction_dialog_label;
- public static String AddGetterSetterAction_methods_selected;
- public static String AddGettSetterAction_typeContainsNoFields_message;
-
-
- public static String GetterSetterTreeSelectionDialog_select_getters;
- public static String GetterSetterTreeSelectionDialog_select_setters;
- public static String GetterSetterTreeSelectionDialog_alpha_pair_sort;
- public static String GetterSetterTreeSelectionDialog_alpha_method_sort;
- public static String GetterSetterTreeSelectionDialog_sort_label;
- public static String SourceActionDialog_enterAt_label;
- public static String SourceActionDialog_modifier_group;
- public static String SourceActionDialog_modifier_public;
- public static String SourceActionDialog_modifier_protected;
- public static String SourceActionDialog_modifier_default;
- public static String SourceActionDialog_modifier_private;
- public static String SourceActionDialog_modifier_synchronized;
- public static String SourceActionDialog_modifier_final;
- public static String SourceActionDialog_first_method;
- public static String SourceActionDialog_last_method;
- public static String SourceActionDialog_cursor;
- public static String SourceActionDialog_after;
- public static String SourceActionDialog_createMethodComment;
- public static String SourceActionDialog_no_entries;
- public static String SourceActionDialog_createConstructorComment;
- public static String AddUnimplementedConstructorsAction_label;
- public static String AddUnimplementedConstructorsAction_description;
- public static String AddUnimplementedConstructorsAction_tooltip;
- public static String AddUnimplementedConstructorsAction_error_title;
- public static String AddUnimplementedConstructorsAction_not_applicable;
- public static String AddUnimplementedConstructorsAction_interface_not_applicable;
- public static String AddUnimplementedConstructorsAction_enum_not_applicable;
- public static String AddUnimplementedConstructorsAction_annotation_not_applicable;
- public static String AddUnimplementedConstructorsAction_methods_selected;
- public static String AddUnimplementedConstructorsAction_error_nothing_found;
- public static String AddUnimplementedConstructorsAction_dialog_title;
- public static String AddUnimplementedConstructorsAction_dialog_label;
- public static String AddUnimplementedConstructorsDialog_omit_super;
- public static String GenerateConstructorUsingFieldsAction_label;
- public static String GenerateConstructorUsingFieldsAction_description;
- public static String GenerateConstructorUsingFieldsAction_tooltip;
- public static String GenerateConstructorUsingFieldsAction_error_title;
- public static String GenerateConstructorUsingFieldsAction_not_applicable;
- public static String GenerateConstructorUsingFieldsAction_fields_selected;
- public static String GenerateConstructorUsingFieldsAction_error_duplicate_constructor;
- public static String GenerateConstructorUsingFieldsAction_error_nothing_found;
- public static String GenerateConstructorUsingFieldsAction_dialog_title;
- public static String GenerateConstructorUsingFieldsAction_dialog_label;
- public static String GenerateConstructorUsingFieldsAction_interface_not_applicable;
- public static String GenerateConstructorUsingFieldsAction_enum_not_applicable;
- public static String GenerateConstructorUsingFieldsAction_annotation_not_applicable;
- public static String GenerateConstructorUsingFieldsAction_typeContainsNoFields_message;
- public static String GenerateConstructorUsingFieldsAction_error_actionfailed;
- public static String GenerateConstructorUsingFieldsSelectionDialog_up_button;
- public static String GenerateConstructorUsingFieldsSelectionDialog_down_button;
- public static String GenerateConstructorUsingFieldsSelectionDialog_sort_constructor_choices_label;
- public static String GenerateConstructorUsingFieldsSelectionDialog_omit_super;
- public static String GenerateConstructorUsingFieldsAction_error_anonymous_class;
-
- public static String AddJavaDocStubAction_label;
- public static String AddJavaDocStubAction_description;
- public static String AddJavaDocStubAction_tooltip;
- public static String AddJavaDocStubsAction_error_dialogTitle;
- public static String AddJavaDocStubsAction_error_actionFailed;
- public static String AddJavaDocStubsAction_not_applicable;
- public static String ExternalizeStringsAction_label;
- public static String ExternalizeStringsAction_dialog_title;
- public static String ExternalizeStringsAction_dialog_message;
- public static String FindStringsToExternalizeAction_label;
- public static String FindStringsToExternalizeAction_dialog_title;
- public static String FindStringsToExternalizeAction_error_message;
- public static String FindStringsToExternalizeAction_error_cannotBeParsed;
- public static String FindStringsToExternalizeAction_foundStrings;
- public static String FindStringsToExternalizeAction_noStrings;
- public static String FindStringsToExternalizeAction_non_externalized;
- public static String FindStringsToExternalizeAction_button_label;
- public static String FindStringsToExternalizeAction_find_strings;
- public static String OpenExternalJavadocAction_label;
- public static String OpenExternalJavadocAction_description;
- public static String OpenExternalJavadocAction_tooltip;
- public static String OpenExternalJavadocAction_select_element;
- public static String OpenExternalJavadocAction_libraries_no_location;
- public static String OpenExternalJavadocAction_source_no_location;
- public static String OpenExternalJavadocAction_opening_failed;
- public static String OpenExternalJavadocAction_dialog_title;
- public static String OpenExternalJavadocAction_code_resolve_failed;
- public static String SelfEncapsulateFieldAction_label;
- public static String SelfEncapsulateFieldAction_dialog_title;
- public static String SelfEncapsulateFieldAction_dialog_unavailable;
- public static String SelfEncapsulateFieldAction_dialog_cannot_perform;
- public static String OrganizeImportsAction_label;
- public static String OrganizeImportsAction_tooltip;
- public static String OrganizeImportsAction_description;
- public static String OrganizeImportsAction_multi_error_parse;
- public static String OrganizeImportsAction_multi_error_unresolvable;
- public static String OrganizeImportsAction_selectiondialog_title;
- public static String OrganizeImportsAction_selectiondialog_message;
- public static String OrganizeImportsAction_error_title;
- public static String OrganizeImportsAction_error_message;
- public static String OrganizeImportsAction_single_error_parse;
- public static String OrganizeImportsAction_summary_added;
- public static String OrganizeImportsAction_summary_removed;
- public static String OrganizeImportsAction_EmptySelection_description;
- public static String OrganizeImportsAction_EmptySelection_title;
-
- public static String FormatAllAction_label;
- public static String FormatAllAction_tooltip;
- public static String FormatAllAction_description;
- public static String FormatAllAction_status_description;
- public static String FormatAllAction_multi_status_title;
- public static String FormatAllAction_error_title;
- public static String FormatAllAction_error_message;
- public static String FormatAllAction_operation_description;
- public static String FormatAllAction_noundo_title;
- public static String FormatAllAction_noundo_message;
- public static String FormatAllAction_EmptySelection_description;
- public static String FormatAllAction_EmptySelection_title;
-
- public static String SortMembersAction_label;
- public static String SortMembersAction_tooltip;
- public static String SortMembersAction_description;
- public static String SortMembersAction_not_applicable;
- public static String SortMembersAction_containsmarkers;
- public static String SortMembersAction_dialog_title;
- public static String MemberFilterActionGroup_hide_fields_label;
- public static String MemberFilterActionGroup_hide_fields_tooltip;
- public static String MemberFilterActionGroup_hide_fields_description;
- public static String MemberFilterActionGroup_hide_static_label;
- public static String MemberFilterActionGroup_hide_static_tooltip;
- public static String MemberFilterActionGroup_hide_static_description;
- public static String MemberFilterActionGroup_hide_nonpublic_label;
- public static String MemberFilterActionGroup_hide_nonpublic_tooltip;
- public static String MemberFilterActionGroup_hide_nonpublic_description;
- public static String MemberFilterActionGroup_hide_localtypes_label;
- public static String MemberFilterActionGroup_hide_localtypes_tooltip;
- public static String MemberFilterActionGroup_hide_localtypes_description;
- public static String NewWizardsActionGroup_new;
- public static String OpenProjectAction_dialog_title;
- public static String OpenProjectAction_dialog_message;
- public static String OpenProjectAction_error_message;
- public static String OpenJavaPerspectiveAction_dialog_title;
- public static String OpenJavaPerspectiveAction_error_open_failed;
- public static String OpenJavaBrowsingPerspectiveAction_dialog_title;
- public static String OpenJavaBrowsingPerspectiveAction_error_open_failed;
- public static String OpenTypeInHierarchyAction_label;
- public static String OpenTypeInHierarchyAction_description;
- public static String OpenTypeInHierarchyAction_tooltip;
- public static String OpenTypeInHierarchyAction_dialogMessage;
- public static String OpenTypeInHierarchyAction_dialogTitle;
- public static String RefreshAction_label;
- public static String RefreshAction_toolTip;
- public static String RefreshAction_progressMessage;
- public static String RefreshAction_error_title;
- public static String RefreshAction_error_message;
- public static String RefreshAction_locationDeleted_title;
- public static String RefreshAction_locationDeleted_message;
- public static String ModifyParameterAction_problem_title;
- public static String ModifyParameterAction_problem_message;
- public static String ActionUtil_notOnBuildPath_title;
- public static String ActionUtil_notOnBuildPath_message;
- public static String ActionUtil_notOnBuildPath_resource_message;
- public static String ActionUtil_not_possible;
- public static String ActionUtil_no_linked;
- public static String SelectAllAction_label;
- public static String SelectAllAction_tooltip;
- public static String AddToClasspathAction_label;
- public static String AddToClasspathAction_toolTip;
- public static String AddToClasspathAction_progressMessage;
- public static String AddToClasspathAction_error_title;
- public static String AddToClasspathAction_error_message;
- public static String RemoveFromClasspathAction_Remove;
- public static String RemoveFromClasspathAction_tooltip;
- public static String RemoveFromClasspathAction_Removing;
- public static String RemoveFromClasspathAction_exception_dialog_title;
- public static String RemoveFromClasspathAction_Problems_occurred;
- public static String AddDelegateMethodsAction_error_title;
- public static String AddDelegateMethodsAction_error_actionfailed;
- public static String AddDelegateMethodsAction_label;
- public static String AddDelegateMethodsAction_description;
- public static String AddDelegateMethodsAction_tooltip;
- public static String AddDelegateMethodsAction_not_applicable;
- public static String AddDelegateMethodsAction_annotation_not_applicable;
- public static String AddDelegateMethodsAction_interface_not_applicable;
- public static String AddDelegateMethodsAction_duplicate_methods;
- public static String AddDelegateMethodsAction_title;
- public static String AddDelegateMethodsAction_message;
- public static String AddDelegateMethodsAction_selectioninfo_more;
-
- public static String SurroundWithTemplateMenuAction_ConfigureTemplatesActionName;
- public static String SurroundWithTemplateMenuAction_NoneApplicable;
- public static String SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName;
- public static String SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName;
-
- public static String ToggleLinkingAction_label;
- public static String ToggleLinkingAction_tooltip;
- public static String ToggleLinkingAction_description;
- public static String ConfigureContainerAction_error_title;
- public static String ConfigureContainerAction_error_creationfailed_message;
- public static String ConfigureContainerAction_error_applyingfailed_message;
- public static String FindExceptionOccurrences_text;
- public static String FindExceptionOccurrences_toolTip;
- public static String FindImplementOccurrencesAction_text;
- public static String FindImplementOccurrencesAction_toolTip;
-
- public static String CategoryFilterActionGroup_JavaCategoryFilter_title;
- public static String CategoryFilterActionGroup_SelectAllCategories;
- public static String CategoryFilterActionGroup_DeselectAllCategories;
- public static String CategoryFilterActionGroup_SelectCategoriesDescription;
- public static String CategoryFilterActionGroup_ShowCategoriesActionDescription;
- public static String CategoryFilterActionGroup_ShowCategoriesToolTip;
- public static String CategoryFilterActionGroup_ShowCategoriesLabel;
- public static String CategoryFilterActionGroup_ShowUncategorizedMembers;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
- }
-
-// public static String OpenNewAnnotationWizardAction_text;
-// public static String OpenNewAnnotationWizardAction_description;
-// public static String OpenNewAnnotationWizardAction_tooltip;
- public static String OpenNewClassWizardAction_text;
- public static String OpenNewClassWizardAction_description;
- public static String OpenNewClassWizardAction_tooltip;
-// public static String OpenNewEnumWizardAction_text;
-// public static String OpenNewEnumWizardAction_description;
-// public static String OpenNewEnumWizardAction_tooltip;
- public static String OpenNewInterfaceWizardAction_text;
- public static String OpenNewInterfaceWizardAction_description;
- public static String OpenNewInterfaceWizardAction_tooltip;
- public static String OpenNewJavaProjectWizardAction_text;
- public static String OpenNewJavaProjectWizardAction_description;
- public static String OpenNewJavaProjectWizardAction_tooltip;
- public static String OpenNewPackageWizardAction_text;
- public static String OpenNewPackageWizardAction_description;
- public static String OpenNewPackageWizardAction_tooltip;
- public static String OpenNewSourceFolderWizardAction_text;
- public static String OpenNewSourceFolderWizardAction_text2;
- public static String OpenNewSourceFolderWizardAction_description;
- public static String OpenNewSourceFolderWizardAction_tooltip;
-// public static String GenerateBuildPathActionGroup_update_jar_text;
-// public static String GenerateBuildPathActionGroup_update_jar_description;
-// public static String GenerateBuildPathActionGroup_update_jar_tooltip;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.properties
deleted file mode 100644
index c4d1c3f9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionMessages.properties
+++ /dev/null
@@ -1,412 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Sebastian Davids <sdavids@gmx.de> - Bug 114276
-###############################################################################
-
-OpenWithMenu_label=Open Wit&h
-RefactorMenu_label=Refac&tor
-SourceMenu_label=&Source
-BuildPath_label=&Build Path
-
-BuildAction_label=&Build Project
-SelectionConverter_codeResolve_failed=Could not convert text selection into a JavaScript 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=Problems opening an editor.
-OpenAction_multistatus_message=See details for editors that could not be opened.
-OpenAction_error_messageBadSelection=Current text selection does not resolve to a JavaScript element
-OpenAction_error_problem_opening_editor=Problem opening editor for ''{0}'': ''{1}''
-
-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 the super implementation failed. Check log for details.
-OpenSuperImplementationAction_not_applicable=The operation is not applicable to the current selection. Select an overriding function.
-OpenSuperImplementationAction_no_super_implementation=The super implementation of function ''{0}'' does not exist.
-
-OpenTypeHierarchyAction_label=Ope&n Type Hierarchy
-OpenNewClassWizardAction_text=Class
-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=Cannot create type hierarchy
-OpenTypeHierarchyAction_messages_no_java_element=A JavaScript element must be selected.
-OpenTypeHierarchyAction_messages_no_java_resources=The selected package does not contain any JavaScript resource.
-OpenTypeHierarchyAction_messages_no_types=The selected JavaScript file does not contain a type.
-#OpenNewAnnotationWizardAction_description=Opens the new annotation type wizard
-OpenNewJavaProjectWizardAction_description=Opens the new JavaScript project wizard
-OpenNewSourceFolderWizardAction_description=Opens the new JavaScript source folder wizard
-OpenNewInterfaceWizardAction_description=Opens the new interface wizard
-OpenTypeHierarchyAction_messages_no_valid_java_element=A valid JavaScript element must be selected.
-OpenTypeHierarchyAction_messages_unknown_import_decl=The selected import declaration can not be resolved.
-
-ShowInPackageViewAction_label=Show in Pac&kage Explorer
-ShowInPackageViewAction_description=Show the selected element in Script Explorer
-ShowInPackageViewAction_tooltip=Show in Script Explorer
-ShowInPackageViewAction_dialog_title=Show In Script Explorer
-ShowInPackageViewAction_error_message=An internal error occurred. Please see log for details.
-
-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=Cannot activate Resource Navigator
-
-OverrideMethodsAction_label=O&verride/Implement Functions...
-OverrideMethodsAction_description=Override or implement functions declared in supertypes
-OverrideMethodsAction_tooltip=Override/Implement Functions
-OverrideMethodsAction_error_actionfailed=An error occurred while creating the functions
-
-OverrideMethodsAction_error_title=Override/Implement Functions
-OverrideMethodsAction_error_nothing_found=No functions to override found for this type.
-OverrideMethodsAction_not_applicable=The operation is not applicable to the current selection. Select a type.
-OverrideMethodsAction_interface_not_applicable=The Override Functions operation is not applicable to interfaces.
-OverrideMethodsAction_annotation_not_applicable=The Override Functions operation is not applicable to annotations.
-
-AddGetterSetterAction_label=Gene&rate Getters and Setters...
-AddGetterSetterAction_description=Generate Getter and Setter functions for type's vars
-AddGetterSetterAction_tooltip=Generate Getter and Setter Functions for the Type's Vars
-
-AddGetterSetterAction_error_duplicate_methods=Possible duplicate function(s) selected
-AddGetterSetterAction_no_primary_type_title=Add Setter and Getter
-AddGetterSetterAction_no_primary_type_message=No primary type found.
-AddGetterSetterAction_error_title=Generate Getters and Setters
-AddGetterSetterAction_error_actionfailed=Generating Getters and Setters Failed.
-
-AddGetterSetterAction_not_applicable=The operation is not applicable to the current selection. Select a var which is not declared as type variable or a type that declares such vars.
-AddGetterSetterAction_interface_not_applicable=The Generate Getters and Setters operation is not applicable to interfaces.
-AddGetterSetterAction_annotation_not_applicable=The Generate Getters and Setters operation is not applicable to annotations.
-AddGetterSetterAction_error_not_in_source_file=The Generate Getters and Setters operation is only applicable to types and vars in source files.
-AddGetterSetterAction_template_link_description=The format of the getters/setters may be configured on the <a>Code Templates</a> preference page.
-AddGetterSetterAction_template_link_tooltip=Show the code templates preferences.
-
-AddGetterSetterAction_QueryDialog_title=Generate Getters and Setters
-AddGetterSetterAction_SkipExistingDialog_message=Function ''{0}'' already exists.\nSkip creation?
-AddGetterSetterAction_SkipExistingDialog_skip_label=&Skip
-AddGetterSetterAction_SkipExistingDialog_replace_label=&Replace
-AddGetterSetterAction_SkipExistingDialog_skipAll_label=Skip &All
-AddGetterSetterAction_allow_setters_for_finals_description=Allow setters for final vars (remove 'final' modifier from vars if necessary)
-
-AddGetterSetterAction_dialog_label=&Select getters and setters to create:
-AddGetterSetterAction_methods_selected={0} of {1} selected.
-AddGettSetterAction_typeContainsNoFields_message=The type contains no vars or all vars have getters/setters already.
-
-GetterSetterTreeSelectionDialog_select_getters=Select &Getters
-GetterSetterTreeSelectionDialog_select_setters=Se&lect Setters
-GetterSetterTreeSelectionDialog_alpha_pair_sort=Vars in getter/setter pairs
-GetterSetterTreeSelectionDialog_alpha_method_sort=First getters, then setters
-GetterSetterTreeSelectionDialog_sort_label=S&ort by:
-
-SourceActionDialog_enterAt_label=&Insertion point:
-SourceActionDialog_modifier_group=Access modifier
-SourceActionDialog_modifier_public=&public
-SourceActionDialog_modifier_protected=protec&ted
-SourceActionDialog_modifier_default=d&efault
-SourceActionDialog_modifier_private=pri&vate
-SourceActionDialog_modifier_synchronized=s&ynchronized
-SourceActionDialog_modifier_final=&final
-SourceActionDialog_first_method=First function
-SourceActionDialog_last_method=Last function
-SourceActionDialog_cursor=Cursor position
-SourceActionDialog_after=After ''{0}''
-SourceActionDialog_createMethodComment=Generate function &comments
-SourceActionDialog_no_entries=No functions available.
-SourceActionDialog_createConstructorComment=Generate constructor &comments
-
-AddUnimplementedConstructorsAction_label=Generate &Constructors from Superclass...
-AddUnimplementedConstructorsAction_description=Generate constructors from superclass
-AddUnimplementedConstructorsAction_tooltip=Generate Constructors from Superclass
-AddUnimplementedConstructorsAction_error_title=Generate Constructors from Superclass
-AddUnimplementedConstructorsAction_not_applicable=The operation is not applicable to the current selection. Select a class.
-AddUnimplementedConstructorsAction_interface_not_applicable=The Generate Constructors from Superclass operation is not applicable to interfaces.
-AddUnimplementedConstructorsAction_enum_not_applicable=The Generate Constructors from Superclass operation is not applicable to enums.
-AddUnimplementedConstructorsAction_annotation_not_applicable=The Generate Constructors from Superclass operation is not applicable to annotations.
-AddUnimplementedConstructorsAction_methods_selected={0} of {1} selected.
-AddUnimplementedConstructorsAction_error_nothing_found=There are no constructors from the superclass which may be added.
-AddUnimplementedConstructorsAction_dialog_title=Generate Constructors from Superclass
-AddUnimplementedConstructorsAction_dialog_label=&Select constructors to implement:
-
-AddUnimplementedConstructorsDialog_omit_super=&Omit call to default constructor super()
-
-GenerateConstructorUsingFieldsAction_label=Generate C&onstructor using Vars...
-GenerateConstructorUsingFieldsAction_description=Generate Constructor using vars
-GenerateConstructorUsingFieldsAction_tooltip=Generate Constructor Using Vars
-GenerateConstructorUsingFieldsAction_error_title=Generate Constructor using Vars
-GenerateConstructorUsingFieldsAction_not_applicable=The operation is not applicable to the current selection. Select a class.
-GenerateConstructorUsingFieldsAction_fields_selected={0} of {1} selected.
-GenerateConstructorUsingFieldsAction_error_duplicate_constructor=The constructor to be created is possibly a duplicate
-GenerateConstructorUsingFieldsAction_error_nothing_found=There are no constructors from the superclass which may be used.
-GenerateConstructorUsingFieldsAction_dialog_title=Generate Constructor using Vars
-GenerateConstructorUsingFieldsAction_dialog_label=&Select vars to initialize:
-GenerateConstructorUsingFieldsAction_interface_not_applicable=The Generate Constructor using Vars operation is not applicable to interfaces.
-GenerateConstructorUsingFieldsAction_enum_not_applicable=The Generate Constructor using Vars operation is not applicable to enums.
-GenerateConstructorUsingFieldsAction_annotation_not_applicable=The Generate Constructor using Vars operation is not applicable to annotations.
-GenerateConstructorUsingFieldsAction_typeContainsNoFields_message=The selected type contains no vars which may be initialized in a constructor.
-GenerateConstructorUsingFieldsAction_error_actionfailed=Unexpected error while creating constructors. See log for details.
-GenerateConstructorUsingFieldsAction_error_anonymous_class=Anonymous classes cannot contain explicitly declared constructors.
-GenerateNewConstructorUsingFieldsAction_error_not_a_source_file=The selected type is not in a source file
-
-GenerateConstructorUsingFieldsSelectionDialog_up_button=&Up
-GenerateConstructorUsingFieldsSelectionDialog_down_button=Do&wn
-GenerateConstructorUsingFieldsSelectionDialog_sort_constructor_choices_label=Select super constructor to invo&ke:
-GenerateConstructorUsingFieldsSelectionDialog_omit_super=&Omit call to default constructor super()
-
-AddUnimplementedConstructorsAction_template_link_tooltip=Show the code templates preferences.
-AddUnimplementedConstructorsAction_template_link_message=The format of the constructors may be configured on the <a>Code Templates</a> preference page.
-
-GenerateConstructorUsingFieldsSelectionDialog_template_link_tooltip=Show the code templates preferences.
-GenerateConstructorUsingFieldsSelectionDialog_template_link_message=The format of the constructors may be configured on the <a>Code Templates</a> preference page.
-
-AddJavaDocStubAction_label=Generate Element Commen&t
-AddJavaDocStubAction_description=Add a comment stub to the member element
-AddJavaDocStubAction_tooltip=Add a Comment Stub to the Member Element
-
-AddJavaDocStubsAction_error_dialogTitle=Generate Element Comment
-AddJavaDocStubsAction_error_actionFailed=Error while adding comment
-AddJavaDocStubsAction_not_applicable=The operation is not applicable to the current selection. Select a type or function.
-
-ExternalizeStringsAction_label= &Externalize Strings...
-ExternalizeStringsAction_dialog_title= Externalize Strings
-ExternalizeStringsAction_dialog_message=Could not open Externalize String Wizard
-
-FindStringsToExternalizeAction_label= Find Strings to Externali&ze...
-FindStringsToExternalizeAction_dialog_title= Find Strings to Externalize
-FindStringsToExternalizeAction_error_message= Unexpected Exception. See log.
-FindStringsToExternalizeAction_error_cannotBeParsed= JavaScript file ''{0}'' can not be parsed.
-FindStringsToExternalizeAction_foundStrings= {0} in {1}
-FindStringsToExternalizeAction_noStrings= No non-externalized strings found.
-FindStringsToExternalizeAction_non_externalized= {0} &non-externalized string(s) found.
-FindStringsToExternalizeAction_button_label= &Externalize...
-FindStringsToExternalizeAction_find_strings= Finding non-externalized strings...
-
-OpenExternalJavadocAction_label=Open E&xternal Jsdoc
-OpenExternalJavadocAction_description=Opens the Jsdoc of the selected element in an external browser
-OpenExternalJavadocAction_tooltip=Opens the Jsdoc of the Selected Element in an External Browser
-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 Jsdoc location URL on the properties 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 Jsdoc location URL on the properties page of the parent project (''{1}'')
-OpenExternalJavadocAction_opening_failed=Opening Jsdoc failed. See log for details
-OpenExternalJavadocAction_dialog_title=Open External Jsdoc
-OpenExternalJavadocAction_code_resolve_failed=Could not convert text selection into a JavaScript element
-
-SelfEncapsulateFieldAction_label=Encap&sulate Var...
-SelfEncapsulateFieldAction_dialog_title=Encapsulate Var
-SelfEncapsulateFieldAction_dialog_unavailable=The operation is not applicable to the current selection. Select a var of a class or enum.
-SelfEncapsulateFieldAction_dialog_cannot_perform=Cannot perform refactoring. See log for more details.
-
-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
-
-CleanUpAction_label=Clean &Up
-CleanUpAction_labelWizard=Clean &Up...
-CleanUpAction_tooltip=Solve Problems and Improve Code Style on Selected Resources
-CleanUpAction_description=Solve problems and improve code style on selected resources
-CleanUpAction_MultiStateErrorTitle=Problems while processing some JavaScript files. See 'Details' for more information.
-CleanUpAction_actionName=Clean Up
-CleanUpAction_UnexpectedErrorMessage={0}: Unexpected error. See log for details.
-CleanUpAction_CUNotOnBuildpathMessage={0}: JavaScript file not on include path. No changes applied.
-CleanUpAction_EmptySelection_description=The selection contains no JavaScript files.
-
-OrganizeImportsAction_EmptySelection_title=Organize Imports
-OrganizeImportsAction_multi_error_parse=Problem while Organize Imports: {0} has parse errors. No changes applied.
-OrganizeImportsAction_multi_error_unresolvable=Problem while Organize Imports: {0} contains ambiguous references. User interaction required.
-
-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=JavaScript file has parse errors: ''{0}''. No changes applied.
-
-OrganizeImportsAction_summary_added={0} import(s) added.
-OrganizeImportsAction_summary_removed={0} import(s) removed.
-
-OrganizeImportsAction_EmptySelection_description=The selection contains no JavaScript files.
-
-FormatAllAction_label=Format
-FormatAllAction_tooltip=Format all selected JavaScript files
-FormatAllAction_description=Format all selected JavaScript files
-FormatAllAction_status_description=Problems while formatting some JavaScript files. See 'Details' for more information.
-FormatAllAction_multi_status_title=Format
-FormatAllAction_read_only_skipped=File ''{0}'' is read-only and has been skipped.
-FormatAllAction_problem_accessing=Problems accessing file ''{0}'': {1}
-FormatAllAction_error_title=Format
-FormatAllAction_error_message=Unexpected error while formatting. See log for details.
-
-FormatAllAction_operation_description=Formatting...
-FormatAllAction_EmptySelection_title=Format
-FormatAllAction_EmptySelection_description=The selection contains no JavaScript files.
-FormatAllAction_noundo_title=Format
-FormatAllAction_noundo_message='Undo' is not supported by this operation. Do you want to continue?
-
-
-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_dialog_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?
-
-#OpenNewAnnotationWizardAction_text=Annotation
-OpenNewPackageWizardAction_tooltip=Opens the new JavaScript package wizard
-OpenNewClassWizardAction_tooltip=Opens the new class wizard
-OpenNewInterfaceWizardAction_text=Interface
-#OpenNewEnumWizardAction_tooltip=Opens the new enum type wizard
-OpenNewPackageWizardAction_text=Package
-
-MemberFilterActionGroup_hide_fields_label=Hide Fiel&ds
-MemberFilterActionGroup_hide_fields_tooltip=Hide Vars
-MemberFilterActionGroup_hide_fields_description=Toggles the visibility of vars
-
-MemberFilterActionGroup_hide_static_label=Hide &Static Vars and Functions
-MemberFilterActionGroup_hide_static_tooltip=Hide Static Vars and Functions
-MemberFilterActionGroup_hide_static_description=Toggles the visibility of static vars and functions
-
-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
-
-MemberFilterActionGroup_hide_localtypes_label=Hide Local &Types
-MemberFilterActionGroup_hide_localtypes_tooltip=Hide Local Types
-MemberFilterActionGroup_hide_localtypes_description=Toggles the visibility of local types
-
-
-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
-
-OpenJavaPerspectiveAction_dialog_title=Open JavaScript Perspective
-OpenJavaPerspectiveAction_error_open_failed=Could not open JavaScript perspective
-
-OpenJavaBrowsingPerspectiveAction_dialog_title=Open JavaScript Browsing Perspective
-OpenJavaBrowsingPerspectiveAction_error_open_failed=Could not open JavaScript 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
-#OpenNewAnnotationWizardAction_tooltip=Opens the new annotation type wizard
-OpenNewJavaProjectWizardAction_tooltip=Opens the new JavaScript project wizard
-OpenNewPackageWizardAction_description=Opens the new JavaScript package wizard
-OpenViewActionGroup_showInAction_label=Sho&w In
-OpenNewSourceFolderWizardAction_tooltip=Opens the new JavaScript source folder wizard
-OpenNewClassWizardAction_description=Opens the new class wizard
-OpenNewInterfaceWizardAction_tooltip=Opens the new interface wizard
-OpenNewSourceFolderWizardAction_text=Source Folder
-OpenNewSourceFolderWizardAction_text2=New Source Folder...
-#OpenNewEnumWizardAction_description=Opens the new enum type wizard
-OpenNewJavaProjectWizardAction_text=JavaScript Project
-
-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=Cannot perform operation.
-
-ActionUtil_notOnBuildPath_title=Cannot Perform Operation
-ActionUtil_notOnBuildPath_message=The resource is not on the build path of a JavaScript project.
-ActionUtil_notOnBuildPath_resource_message=The resource ''{0}'' is not on the build path of a JavaScript project.
-ActionUtil_not_possible=Cannot Perform Operation
-ActionUtil_no_linked=This operation is unavailable on linked packages and package fragment roots.
-ActionUtil_warning_derived_title=Derived File Encountered
-ActionUtil_warning_derived_message=The file ''{0}'' is derived. Do you really want to edit it?
-ActionUtil_warning_derived_dontShowAgain=In the future, never warn if editing a derived file.
-
-SelectAllAction_label= Select A&ll
-SelectAllAction_tooltip= Select All
-
-AddToClasspathAction_label=Add to &Build Path
-AddToClasspathAction_toolTip=Add JAR to the JavaScript 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 JavaScript 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 Functions
-AddDelegateMethodsAction_error_actionfailed=Generating delegate functions failed.
-AddDelegateMethodsAction_label=Generate Delegate &Functions...
-AddDelegateMethodsAction_description=Adds delegate functions for a type's vars
-AddDelegateMethodsAction_tooltip=Adds Delegates Functions for a Type's Vars
-AddDelegateMethodsAction_not_applicable=The operation is not applicable to the current selection. Select a var which is not declared as type variable or a type that declares such fields.
-AddDelegateMethodsAction_annotation_not_applicable=The Generate Delegate Functions operation is not applicable to annotations.
-AddDelegateMethodsAction_interface_not_applicable=The Generate Delegate Functions operation is not applicable to interfaces.
-AddDelegateMethodsAction_duplicate_methods=Duplicate function(s) selected
-
-AddDelegateMethodsAction_title=Generate Delegate Functions
-AddDelegateMethodsAction_message=Select &functions to create delegates for:
-AddDelegateMethodsAction_selectioninfo_more={0} of {1} selected.
-AddDelegateMethodsAction_not_in_source_file=The Generate Delegate Functions operation is only applicable to vars and types in source files.
-AddDelegateMethodsAction_template_link_message=The format of the delegate functions may be configured on the <a>Code Templates</a> preference page.
-AddDelegateMethodsAction_template_link_tooltip=Show the code templates preferences.
-
-ToggleLinkingAction_label=Lin&k With Editor
-ToggleLinkingAction_tooltip=Link with Editor
-ToggleLinkingAction_description=Link with active editor
-
-ConfigureContainerAction_error_title=Configure Includepath Container
-ConfigureContainerAction_error_creationfailed_message=Configuration of the includepath container failed.
-ConfigureContainerAction_error_applyingfailed_message=Application of the includepath container changes failed.
-
-FindExceptionOccurrences_text= Throwing E&xception
-FindExceptionOccurrences_toolTip= Find All Occurrences Throwing this Exception
-
-FindImplementOccurrencesAction_text= I&mplementing Functions
-FindImplementOccurrencesAction_toolTip= Find All Functions Implementing or Overriding the Selected Type
-
-
-CategoryFilterActionGroup_JavaCategoryFilter_title=Visible JavaScript Categories
-CategoryFilterActionGroup_SelectAllCategories=Select &All
-CategoryFilterActionGroup_DeselectAllCategories=&Deselect All
-CategoryFilterActionGroup_SelectCategoriesDescription=Select the categories to show in the view:
-CategoryFilterActionGroup_ShowCategoriesActionDescription=Select the visible categories in the view
-CategoryFilterActionGroup_ShowCategoriesToolTip=Select Visible Categories
-CategoryFilterActionGroup_ShowUncategorizedMembers=&0 Show Uncategorized Members
-CategoryFilterActionGroup_ShowCategoriesLabel=&Visible Categories...
-
-FindNLSProblemsAction_Description=Finds undefined, duplicate, and unused NLS keys in property files
-FindNLSProblemsAction_ErrorDialogTitle=Find Broken Externalized Strings
-FindNLSProblemsAction_Name=Find Broken Ex&ternalized Strings
-FindNLSProblemsAction_NoPropertieFilesFoundErrorDescription=No NLS property files with corresponding accessor class found in selection.
-FindNLSProblemsAction_ToolTip=Finds undefined, duplicate, and unused NLS keys in property files
-
-CopyQualifiedNameAction_ToolTipText=Copy to fully qualified name to the system Clipboard
-CopyQualifiedNameAction_InfoDialogTitel=Copy Qualified Name
-CopyQualifiedNameAction_ErrorDescription=There was a problem when accessing the system clipboard. Retry?
-CopyQualifiedNameAction_ActionName=Copy Qualified Name
-CopyQualifiedNameAction_ErrorTitle=Problem Copying to Clipboard
-CopyQualifiedNameAction_NoElementToQualify=No Element to qualify found in selection.
-
-SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName=Surround &With
-SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName=Tr&y/catch Block
-SurroundWithTemplateMenuAction_ConfigureTemplatesActionName=&Configure Templates...
-SurroundWithTemplateMenuAction_NoneApplicable=(no template applicable)
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionUtil.java
deleted file mode 100644
index f7b6db76..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ActionUtil.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.ResourceUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-/*
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
- */
-public class ActionUtil {
-
- private ActionUtil(){
- }
-
- //bug 31998 we will have to disable renaming of linked packages (and cus)
- public static boolean mustDisableJavaModelAction(Shell shell, Object element) {
- if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
- return false;
-
- IResource resource= ResourceUtil.getResource(element);
- if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
- return false;
-
- MessageDialog.openInformation(shell, ActionMessages.ActionUtil_not_possible, ActionMessages.ActionUtil_no_linked);
- return true;
- }
-
- public static boolean isProcessable(JavaEditor editor) {
- if (editor == null)
- return true;
- Shell shell= editor.getSite().getShell();
- IJavaScriptElement input= SelectionConverter.getInput(editor);
- // if a Java editor doesn't have an input of type Java element
- // then it is for sure not on the build path
- if (input == null) {
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- ActionMessages.ActionUtil_notOnBuildPath_message);
- return false;
- }
- return isProcessable(shell, input);
- }
-
- public static boolean isProcessable(Shell shell, IJavaScriptElement element) {
- if (element == null)
- return true;
- if (isOnBuildPath(element))
- return true;
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- ActionMessages.ActionUtil_notOnBuildPath_message);
- return false;
- }
-
- public static boolean isOnBuildPath(IJavaScriptElement element) {
- //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
- if (element.getElementType() == IJavaScriptElement.JAVASCRIPT_PROJECT)
- return true;
- IJavaScriptProject project= element.getJavaScriptProject();
- try {
- //if (!project.isOnClasspath(element))
- // return false;
- IProject resourceProject= project.getProject();
- if (resourceProject == null)
- return false;
- IProjectNature nature= resourceProject.getNature(JavaScriptCore.NATURE_ID);
- // We have a Java project
- if (nature != null)
- return true;
- } catch (CoreException e) {
- }
- return false;
- }
-
- public static boolean areProcessable(Shell shell, IJavaScriptElement[] elements) {
- for (int i= 0; i < elements.length; i++) {
- if (! isOnBuildPath(elements[i])) {
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- Messages.format(ActionMessages.ActionUtil_notOnBuildPath_resource_message, new Object[] {elements[i].getPath()}));
- return false;
- }
- }
- return true;
- }
-
- /**
- * Check whether <code>editor</code> and <code>element</code> are
- * processable and editable. If the editor edits the element, the validation
- * is only performed once. If necessary, ask the user whether the file(s)
- * should be edited.
- *
- * @param editor an editor, or <code>null</code> iff the action was not
- * executed from an editor
- * @param shell a shell to serve as parent for a dialog
- * @param element the element to check, cannot be <code>null</code>
- * @return <code>true</code> if the element can be edited,
- * <code>false</code> otherwise
- */
- public static boolean isEditable(JavaEditor editor, Shell shell, IJavaScriptElement element) {
- if (editor != null) {
- IJavaScriptElement input= SelectionConverter.getInput(editor);
- if (input != null && input.equals(element.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT)))
- return isEditable(editor);
- else
- return isEditable(editor) && isEditable(shell, element);
- }
- return isEditable(shell, element);
- }
-
- public static boolean isEditable(JavaEditor editor) {
- if (! isProcessable(editor))
- return false;
-
- return editor.validateEditorInputState();
- }
-
- public static boolean isEditable(Shell shell, IJavaScriptElement element) {
- if (! isProcessable(shell, element))
- return false;
-
- IJavaScriptElement cu= element.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- IResource resource= cu.getResource();
- if (resource != null && resource.isDerived()) {
-
- // see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
- final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
- IPreferenceStore store= EditorsUI.getPreferenceStore();
- if (!store.getBoolean(warnKey))
- return true;
-
- MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
- shell,
- ActionMessages.ActionUtil_warning_derived_title,
- Messages.format(ActionMessages.ActionUtil_warning_derived_message, resource.getFullPath().toString()),
- ActionMessages.ActionUtil_warning_derived_dontShowAgain,
- false,
- null,
- null);
-
- EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());
-
- return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
- }
- }
- return true;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddBlockCommentAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddBlockCommentAction.java
deleted file mode 100644
index dc87220f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddBlockCommentAction.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-/**
- * Action that encloses the editor's current selection with Java block comment terminators
- * (<code>&#47;&#42;</code> and <code>&#42;&#47;</code>).
- *
- *
- */
-public class AddBlockCommentAction extends BlockCommentAction {
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
- * <code>null</code> if none
- * @param editor the text editor
- */
- public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction#runInternal(org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.IDocumentExtension3, org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction.Edit.EditFactory)
- */
- protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException {
- int selectionOffset= selection.getOffset();
- int selectionEndOffset= selectionOffset + selection.getLength();
- List edits= new LinkedList();
- ITypedRegion partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, selectionOffset, false);
-
- handleFirstPartition(partition, edits, factory, selectionOffset);
-
- while (partition.getOffset() + partition.getLength() < selectionEndOffset) {
- partition= handleInteriorPartition(partition, edits, factory, docExtension);
- }
-
- handleLastPartition(partition, edits, factory, selectionEndOffset);
-
- executeEdits(edits);
- }
-
- /**
- * Handle the partition under the start offset of the selection.
- *
- * @param partition the partition under the start of the selection
- * @param edits the list of edits to later execute
- * @param factory the factory for edits
- * @param offset the start of the selection, which must lie inside
- * <code>partition</code>
- */
- private void handleFirstPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int offset) throws BadLocationException {
-
- int partOffset= partition.getOffset();
- String partType= partition.getType();
-
- Assert.isTrue(partOffset <= offset, "illegal partition"); //$NON-NLS-1$
-
- // first partition: mark start of comment
- if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
- // Java code: right where selection starts
- edits.add(factory.createEdit(offset, 0, getCommentStart()));
- } else if (isSpecialPartition(partType)) {
- // special types: include the entire partition
- edits.add(factory.createEdit(partOffset, 0, getCommentStart()));
- } // javadoc: no mark, will only start after comment
-
- }
-
- /**
- * Handles partition boundaries within the selection. The end of the current
- * partition and the start of the next partition are examined for whether
- * they contain comment tokens that interfere with the created comment.
- * <p>
- * Comment tokens are removed from interior multi-line comments. Javadoc
- * comments are left as is; instead, multi-line comment tokens are inserted
- * before and after Javadoc partitions to ensure that the entire selected
- * area is commented.
- * </p>
- * <p>
- * The next partition is returned.
- * </p>
- *
- * @param partition the current partition
- * @param edits the list of edits to add to
- * @param factory the edit factory
- * @param docExtension the document to get the partitions from
- * @return the next partition after the current
- * @throws BadLocationException if accessing the document fails - this can
- * only happen if the document gets modified concurrently
- * @throws BadPartitioningException if the document does not have a Java
- * partitioning
- */
- private ITypedRegion handleInteriorPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, IDocumentExtension3 docExtension) throws BadPartitioningException, BadLocationException {
-
- // end of previous partition
- String partType= partition.getType();
- int partEndOffset= partition.getOffset() + partition.getLength();
- int tokenLength= getCommentStart().length();
-
- boolean wasJavadoc= false; // true if the previous partition is javadoc
-
- if (partType == IJavaScriptPartitions.JAVA_DOC) {
-
- wasJavadoc= true;
-
- } else if (partType == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {
-
- // already in a comment - remove ending mark
- edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
-
- }
-
- // advance to next partition
- partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, partEndOffset, false);
- partType= partition.getType();
-
- // start of next partition
- if (wasJavadoc) {
-
- // if previous was javadoc, and the current one is not a comment,
- // then add a block comment start
- if (partType == IDocument.DEFAULT_CONTENT_TYPE
- || isSpecialPartition(partType)) {
- edits.add(factory.createEdit(partition.getOffset(), 0, getCommentStart()));
- }
-
- } else { // !wasJavadoc
-
- if (partType == IJavaScriptPartitions.JAVA_DOC) {
- // if next is javadoc, end block comment before
- edits.add(factory.createEdit(partition.getOffset(), 0, getCommentEnd()));
- } else if (partType == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {
- // already in a comment - remove startToken
- edits.add(factory.createEdit(partition.getOffset(), getCommentStart().length(), "")); //$NON-NLS-1$
- }
- }
-
- return partition;
- }
-
- /**
- * Handles the partition under the end of the selection. For normal java
- * code, the comment end token is inserted at the selection end; if the
- * selection ends inside a special (i.e. string, character, line comment)
- * partition, the entire partition is included inside the comment.
- *
- * @param partition the partition under the selection end offset
- * @param edits the list of edits to add to
- * @param factory the edit factory
- * @param endOffset the end offset of the selection
- */
- private void handleLastPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int endOffset) throws BadLocationException {
-
- String partType= partition.getType();
-
- if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
- // normal java: end comment where selection ends
- edits.add(factory.createEdit(endOffset, 0, getCommentEnd()));
- } else if (isSpecialPartition(partType)) {
- // special types: consume entire partition
- edits.add(factory.createEdit(partition.getOffset() + partition.getLength(), 0, getCommentEnd()));
- }
-
- }
-
- /**
- * Returns whether <code>partType</code> is special, i.e. a Java
- * <code>String</code>,<code>Character</code>, or
- * <code>Line End Comment</code> partition.
- *
- * @param partType the partition type to check
- * @return <code>true</code> if <code>partType</code> is special,
- * <code>false</code> otherwise
- */
- private boolean isSpecialPartition(String partType) {
- return partType == IJavaScriptPartitions.JAVA_CHARACTER
- || partType == IJavaScriptPartitions.JAVA_STRING
- || partType == IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction#validSelection(org.eclipse.jface.text.ITextSelection)
- */
- protected boolean isValidSelection(ITextSelection selection) {
- return selection != null && !selection.isEmpty() && selection.getLength() > 0;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddTaskAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddTaskAction.java
deleted file mode 100644
index 16a9bc7e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AddTaskAction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class AddTaskAction extends SelectionDispatchAction {
-
- public AddTaskAction(IWorkbenchSite site) {
- super(site);
- setEnabled(false);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ADD_TASK_ACTION);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(getElement(selection) != null);
- }
-
- public void run(IStructuredSelection selection) {
- IResource resource= getElement(selection);
- if (resource == null)
- return;
-
- TaskPropertiesDialog dialog= new TaskPropertiesDialog(getShell());
- dialog.setResource(resource);
- dialog.open();
- }
-
- private IResource getElement(IStructuredSelection selection) {
- if (selection.size() != 1)
- return null;
-
- Object element= selection.getFirstElement();
- if (!(element instanceof IAdaptable))
- return null;
- return (IResource)((IAdaptable)element).getAdapter(IResource.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AllCleanUpsAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AllCleanUpsAction.java
deleted file mode 100644
index 7321c770..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/AllCleanUpsAction.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class AllCleanUpsAction extends CleanUpAction {
-
- private IPreferenceChangeListener fPreferenceChangeListener;
-
- public AllCleanUpsAction(IWorkbenchSite site) {
- super(site);
- setToolTipText(ActionMessages.CleanUpAction_tooltip);
- setDescription(ActionMessages.CleanUpAction_description);
- installPreferenceListener();
- updateActionLabel();
-
- // PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
- }
-
- public AllCleanUpsAction(JavaEditor editor) {
- super(editor);
- setToolTipText(ActionMessages.CleanUpAction_tooltip);
- setDescription(ActionMessages.CleanUpAction_description);
- installPreferenceListener();
- updateActionLabel();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ICleanUp[] createCleanUps(IJavaScriptUnit[] units) {
- return CleanUpRefactoring.createCleanUps();
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getActionName() {
- return ActionMessages.CleanUpAction_actionName;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void performRefactoring(IJavaScriptUnit[] cus, ICleanUp[] cleanUps) throws JavaScriptModelException, InvocationTargetException {
- RefactoringExecutionStarter.startCleanupRefactoring(cus, cleanUps, getShell(), showWizard(), getActionName());
- }
-
- private boolean showWizard() {
- InstanceScope instanceScope= new InstanceScope();
- IEclipsePreferences instanceNode= instanceScope.getNode(JavaScriptUI.ID_PLUGIN);
- if (instanceNode.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null)
- return instanceNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
-
- DefaultScope defaultScope= new DefaultScope();
- IEclipsePreferences defaultNode= defaultScope.getNode(JavaScriptUI.ID_PLUGIN);
- return defaultNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
- }
-
- private void updateActionLabel() {
- if (showWizard()) {
- setText(ActionMessages.CleanUpAction_labelWizard);
- } else {
- setText(ActionMessages.CleanUpAction_label);
- }
- }
-
- private void installPreferenceListener() {
- fPreferenceChangeListener= new IPreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) {
- updateActionLabel();
- }
- }
- };
- new InstanceScope().getNode(JavaScriptUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener);
- }
-
- public void dispose() {
- if (fPreferenceChangeListener != null) {
- new InstanceScope().getNode(JavaScriptUI.ID_PLUGIN).removePreferenceChangeListener(fPreferenceChangeListener);
- fPreferenceChangeListener= null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/BlockCommentAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/BlockCommentAction.java
deleted file mode 100644
index 76b0bf74..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/BlockCommentAction.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension2;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-
-/**
- * Common block comment code.
- *
- *
- */
-public abstract class BlockCommentAction extends TextEditorAction {
-
- /**
- * Creates a new instance.
- * @param bundle
- * @param prefix
- * @param editor
- */
- public BlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /**
- * An edit is a kind of <code>DocumentEvent</code>, in this case an edit instruction, that is
- * affiliated with a <code>Position</code> on a document. The offset of the document event is
- * not stored statically, but taken from the affiliated <code>Position</code>, which gets
- * updated when other edits occur.
- */
- static class Edit extends DocumentEvent {
-
- /**
- * Factory for edits which manages the creation, installation and destruction of
- * position categories, position updaters etc. on a certain document. Once a factory has
- * been obtained, <code>Edit</code> objects can be obtained from it which will be linked to
- * the document by positions of one position category.
- * <p>Clients are required to call <code>release</code> once the <code>Edit</code>s are not
- * used any more, so the positions can be discarded.</p>
- */
- public static class EditFactory {
-
- /** The position category basename for this edits. */
- private static final String CATEGORY= "__positionalEditPositionCategory"; //$NON-NLS-1$
-
- /** The count of factories. */
- private static int fgCount= 0;
-
- /** This factory's category. */
- private final String fCategory;
- private IDocument fDocument;
- private IPositionUpdater fUpdater;
-
- /**
- * Creates a new <code>EditFactory</code> with an unambiguous position category name.
- * @param document the document that is being edited.
- */
- public EditFactory(IDocument document) {
- fCategory= CATEGORY + fgCount++;
- fDocument= document;
- }
-
- /**
- * Creates a new edition on the document of this factory.
- *
- * @param offset the offset of the edition at the point when is created.
- * @param length the length of the edition (not updated via the position update mechanism)
- * @param text the text to be replaced on the document
- * @return an <code>Edit</code> reflecting the edition on the document
- */
- public Edit createEdit(int offset, int length, String text) throws BadLocationException {
-
- if (!fDocument.containsPositionCategory(fCategory)) {
- fDocument.addPositionCategory(fCategory);
- fUpdater= new DefaultPositionUpdater(fCategory);
- fDocument.addPositionUpdater(fUpdater);
- }
-
- Position position= new Position(offset);
- try {
- fDocument.addPosition(fCategory, position);
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- return new Edit(fDocument, length, text, position);
- }
-
- /**
- * Releases the position category on the document and uninstalls the position updater.
- * <code>Edit</code>s managed by this factory are not updated after this call.
- */
- public void release() {
- if (fDocument != null && fDocument.containsPositionCategory(fCategory)) {
- fDocument.removePositionUpdater(fUpdater);
- try {
- fDocument.removePositionCategory(fCategory);
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- fDocument= null;
- fUpdater= null;
- }
- }
- }
-
- /** The position in the document where this edit be executed. */
- private Position fPosition;
-
- /**
- * Creates a new edition on <code>document</code>, taking its offset from <code>position</code>.
- *
- * @param document the document being edited
- * @param length the length of the edition
- * @param text the replacement text of the edition
- * @param position the position keeping the edition's offset
- */
- protected Edit(IDocument document, int length, String text, Position position) {
- super(document, 0, length, text);
- fPosition= position;
- }
-
- /*
- * @see org.eclipse.jface.text.DocumentEvent#getOffset()
- */
- public int getOffset() {
- return fPosition.getOffset();
- }
-
- /**
- * Executes the edition on document. The offset is taken from the position.
- *
- * @throws BadLocationException if the execution of the document fails.
- */
- public void perform() throws BadLocationException {
- getDocument().replace(getOffset(), getLength(), getText());
- }
-
- }
-
- public void run() {
- if (!isEnabled())
- return;
-
- ITextEditor editor= getTextEditor();
- if (editor == null || !ensureEditable(editor))
- return;
-
- ITextSelection selection= getCurrentSelection();
- if (!isValidSelection(selection))
- return;
-
- if (!validateEditorInputState())
- return;
-
- IDocumentProvider docProvider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
- if (docProvider == null || input == null)
- return;
-
- IDocument document= docProvider.getDocument(input);
- if (document == null)
- return;
-
- IDocumentExtension3 docExtension;
- if (document instanceof IDocumentExtension3)
- docExtension= (IDocumentExtension3) document;
- else
- return;
-
- IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
- if (target != null) {
- target.beginCompoundChange();
- }
-
- Edit.EditFactory factory= new Edit.EditFactory(document);
-
- try {
- runInternal(selection, docExtension, factory);
-
- } catch (BadLocationException e) {
- // can happen on concurrent modification, deletion etc. of the document
- // -> don't complain, just bail out
- } catch (BadPartitioningException e) {
- // should not happen
- Assert.isTrue(false, "bad partitioning"); //$NON-NLS-1$
- } finally {
- factory.release();
-
- if (target != null) {
- target.endCompoundChange();
- }
- }
- }
-
- /**
- * Calls <code>perform</code> on all <code>Edit</code>s in <code>edits</code>.
- *
- * @param edits a list of <code>Edit</code>s
- * @throws BadLocationException if an <code>Edit</code> threw such an exception.
- */
- protected void executeEdits(List edits) throws BadLocationException {
- for (Iterator it= edits.iterator(); it.hasNext();) {
- Edit edit= (Edit) it.next();
- edit.perform();
- }
- }
-
- /**
- * Ensures that the editor is modifyable. If the editor is an instance of
- * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method
- * is called, otherwise, the result of <code>isEditable</code> is returned.
- *
- * @param editor the editor to be checked
- * @return <code>true</code> if the editor is editable, <code>false</code> otherwise
- */
- protected boolean ensureEditable(ITextEditor editor) {
- Assert.isNotNull(editor);
-
- if (editor instanceof ITextEditorExtension2) {
- ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
- return ext.validateEditorInputState();
- }
-
- return editor.isEditable();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (isEnabled()) {
- if (!canModifyEditor() || !isValidSelection(getCurrentSelection()))
- setEnabled(false);
- }
- }
-
- /**
- * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the
- * editor is <code>null</code>.
- *
- * @return the selection of the action's editor, or <code>null</code>
- */
- protected ITextSelection getCurrentSelection() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- ISelectionProvider provider= editor.getSelectionProvider();
- if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof ITextSelection)
- return (ITextSelection) selection;
- }
- }
- return null;
- }
-
- /**
- * Runs the real command once all the editor, document, and selection checks have succeeded.
- *
- * @param selection the current selection we are being called for
- * @param docExtension the document extension where we get the partitioning from
- * @param factory the edit factory we can use to create <code>Edit</code>s
- * @throws BadLocationException if an edition fails
- * @throws BadPartitioningException if a partitioning call fails
- */
- protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
-
- /**
- * Checks whether <code>selection</code> is valid.
- *
- * @param selection the selection to check
- * @return <code>true</code> if the selection is valid, <code>false</code> otherwise
- */
- protected abstract boolean isValidSelection(ITextSelection selection);
-
- /**
- * Returns the text to be inserted at the selection start.
- *
- * @return the text to be inserted at the selection start
- */
- protected String getCommentStart() {
- // for now: no space story
- return "/*"; //$NON-NLS-1$
- }
-
- /**
- * Returns the text to be inserted at the selection end.
- *
- * @return the text to be inserted at the selection end
- */
- protected String getCommentEnd() {
- // for now: no space story
- return "*/"; //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CategoryFilterActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CategoryFilterActionGroup.java
deleted file mode 100644
index 1df1501b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CategoryFilterActionGroup.java
+++ /dev/null
@@ -1,530 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-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.Shell;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-
-import com.ibm.icu.text.Collator;
-
-public class CategoryFilterActionGroup extends ActionGroup {
-
- private class CategoryFilter extends ViewerFilter {
-
- /**
- * {@inheritDoc}
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IMember) {
- IMember member= (IMember)element;
- try {
- String[] categories= member.getCategories();
- if (categories.length == 0)
- return !fFilterUncategorizedMembers;
-
- for (int i= 0; i < categories.length; i++) {
- if (!fFilteredCategories.contains(categories[i]))
- return true;
- }
- return false;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return true;
- }
-
- }
-
- private class CategoryFilterSelectionDialog extends SelectionStatusDialog implements IListAdapter {
-
- private static final int SELECT_ALL= 0;
- private static final int DESELECT_ALL= 1;
-
- private final CheckedListDialogField fCategoryList;
-
- public CategoryFilterSelectionDialog(Shell parent, List categories, List selectedCategories) {
- super(parent);
-
- setTitle(ActionMessages.CategoryFilterActionGroup_JavaCategoryFilter_title);
-
- String[] buttons= {
- ActionMessages.CategoryFilterActionGroup_SelectAllCategories,
- ActionMessages.CategoryFilterActionGroup_DeselectAllCategories
- };
-
- fCategoryList= new CheckedListDialogField(this, buttons, new ILabelProvider() {
- public Image getImage(Object element) {return null;}
- public String getText(Object element) {return (String)element;}
- public void addListener(ILabelProviderListener listener) {}
- public void dispose() {}
- public boolean isLabelProperty(Object element, String property) {return false;}
- public void removeListener(ILabelProviderListener listener) {}
- });
- fCategoryList.addElements(categories);
- fCategoryList.setViewerComparator(new ViewerComparator());
- fCategoryList.setLabelText(ActionMessages.CategoryFilterActionGroup_SelectCategoriesDescription);
- fCategoryList.checkAll(true);
- for (Iterator iter= selectedCategories.iterator(); iter.hasNext();) {
- String selected= (String)iter.next();
- fCategoryList.setChecked(selected, false);
- }
- if (categories.size() == 0) {
- fCategoryList.setEnabled(false);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setLayout(new GridLayout(1, true));
- composite.setFont(parent.getFont());
-
- Composite list= new Composite(composite, SWT.NONE);
- list.setFont(composite.getFont());
- LayoutUtil.doDefaultLayout(list, new DialogField[] { fCategoryList }, true);
- LayoutUtil.setHorizontalGrabbing(fCategoryList.getListControl(null));
- Dialog.applyDialogFont(composite);
-
- setHelpAvailable(false);
-
- return composite;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void computeResult() {
- setResult(fCategoryList.getCheckedElements());
- }
-
- /**
- * {@inheritDoc}
- */
- public void customButtonPressed(ListDialogField field, int index) {
- if (index == SELECT_ALL) {
- fCategoryList.checkAll(true);
- fCategoryList.refresh();
- } else if (index == DESELECT_ALL) {
- fCategoryList.checkAll(false);
- fCategoryList.refresh();
- }
- }
-
- public void doubleClicked(ListDialogField field) {
- List selectedElements= field.getSelectedElements();
- if (selectedElements.size() == 1) {
- Object selected= selectedElements.get(0);
- fCategoryList.setChecked(selected, !fCategoryList.isChecked(selected));
- }
- }
- public void selectionChanged(ListDialogField field) {}
- }
-
- private class CategoryFilterMenuAction extends Action {
-
- public CategoryFilterMenuAction() {
- setDescription(ActionMessages.CategoryFilterActionGroup_ShowCategoriesActionDescription);
- setToolTipText(ActionMessages.CategoryFilterActionGroup_ShowCategoriesToolTip);
- setText(ActionMessages.CategoryFilterActionGroup_ShowCategoriesLabel);
- JavaPluginImages.setLocalImageDescriptors(this, "category_menu.gif"); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- showCategorySelectionDialog(fInputElement);
- }
-
- }
-
- private class CategoryFilterAction extends Action {
-
- private final String fCategory;
-
- public CategoryFilterAction(String category, int count) {
- fCategory= category;
- StringBuffer buf = new StringBuffer();
- buf.append('&').append(count).append(' ').append(fCategory);
- setText(buf.toString());
- setChecked(!fFilteredCategories.contains(fCategory));
- setId(FILTER_CATEGORY_ACTION_ID);
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- super.run();
- if (fFilteredCategories.contains(fCategory)) {
- fFilteredCategories.remove(fCategory);
- } else {
- fFilteredCategories.add(fCategory);
- }
- fLRUList.put(fCategory, fCategory);
- storeSettings();
- fireSelectionChange();
- }
-
- }
-
- private class FilterUncategorizedMembersAction extends Action {
-
- public FilterUncategorizedMembersAction() {
- setText(ActionMessages.CategoryFilterActionGroup_ShowUncategorizedMembers);
- setChecked(!fFilterUncategorizedMembers);
- setId(FILTER_CATEGORY_ACTION_ID);
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- fFilterUncategorizedMembers= !fFilterUncategorizedMembers;
- storeSettings();
- fireSelectionChange();
- }
- }
-
- private interface IResultCollector {
- public boolean accept(String[] category);
- }
-
- private static int COUNTER= 0;//WORKAROUND for Bug 132669 https://bugs.eclipse.org/bugs/show_bug.cgi?id=132669
-
- private static final String FILTER_CATEGORY_ACTION_ID= "FilterCategoryActionId"; //$NON-NLS-1$
- private final String CATEGORY_MENU_GROUP_NAME= "CategoryMenuGroup" + (COUNTER++); //$NON-NLS-1$
- private static final int MAX_NUMBER_OF_CATEGORIES_IN_MENU= 5;
-
- private final StructuredViewer fViewer;
- private final String fViewerId;
- private final CategoryFilter fFilter;
- private final HashSet fFilteredCategories;
- private IJavaScriptElement[] fInputElement;
- private final CategoryFilterMenuAction fMenuAction;
- private IMenuManager fMenuManager;
- private IMenuListener fMenuListener;
- private final LinkedHashMap fLRUList;
- private boolean fFilterUncategorizedMembers;
-
- public CategoryFilterActionGroup(final StructuredViewer viewer, final String viewerId, IJavaScriptElement[] input) {
- Assert.isLegal(viewer != null);
- Assert.isLegal(viewerId != null);
- Assert.isLegal(input != null);
-
- fLRUList= new LinkedHashMap(MAX_NUMBER_OF_CATEGORIES_IN_MENU * 2, 0.75f, true) {
- private static final long serialVersionUID= 1L;
- protected boolean removeEldestEntry(Map.Entry eldest) {
- return size() > MAX_NUMBER_OF_CATEGORIES_IN_MENU;
- }
- };
- fViewer= viewer;
- fViewerId= viewerId;
- fInputElement= input;
-
- fFilter= new CategoryFilter();
-
- fFilteredCategories= new HashSet();
- loadSettings();
-
- fMenuAction= new CategoryFilterMenuAction();
-
- fViewer.addFilter(fFilter);
- }
-
- public void setInput(IJavaScriptElement[] input) {
- Assert.isLegal(input != null);
- fInputElement= input;
- }
-
- private void loadSettings() {
- fFilteredCategories.clear();
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- String string= store.getString(getPreferenceKey());
- if (string != null && string.length() > 0) {
- String[] categories= string.split(";"); //$NON-NLS-1$
- for (int i= 0; i < categories.length; i++) {
- fFilteredCategories.add(categories[i]);
- }
- }
- string= store.getString(getPreferenceKey()+".LRU"); //$NON-NLS-1$
- if (string != null && string.length() > 0) {
- String[] categories= string.split(";"); //$NON-NLS-1$
- for (int i= categories.length - 1; i >= 0; i--) {
- fLRUList.put(categories[i], categories[i]);
- }
- }
- fFilterUncategorizedMembers= store.getBoolean(getPreferenceKey()+".FilterUncategorized"); //$NON-NLS-1$
- }
-
- private void storeSettings() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- if (fFilteredCategories.size() == 0) {
- store.setValue(getPreferenceKey(), ""); //$NON-NLS-1$
- } else {
- StringBuffer buf= new StringBuffer();
- Iterator iter= fFilteredCategories.iterator();
- String element= (String)iter.next();
- buf.append(element);
- while (iter.hasNext()) {
- element= (String)iter.next();
- buf.append(';');
- buf.append(element);
- }
- store.setValue(getPreferenceKey(), buf.toString());
- buf= new StringBuffer();
- iter= fLRUList.values().iterator();
- element= (String)iter.next();
- buf.append(element);
- while (iter.hasNext()) {
- element= (String)iter.next();
- buf.append(';');
- buf.append(element);
- }
- store.setValue(getPreferenceKey()+".LRU", buf.toString()); //$NON-NLS-1$
- store.setValue(getPreferenceKey()+".FilterUncategorized", fFilterUncategorizedMembers); //$NON-NLS-1$
- }
- }
-
- public void contributeToViewMenu(IMenuManager menuManager) {
- menuManager.add(new Separator(CATEGORY_MENU_GROUP_NAME));
- menuManager.appendToGroup(CATEGORY_MENU_GROUP_NAME, fMenuAction);
- fMenuListener= new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- if (!manager.isVisible())
- return;
- updateMenu(manager);
- }
- };
- menuManager.addMenuListener(fMenuListener);
- fMenuManager= menuManager;
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- super.dispose();
- if (fMenuManager != null) {
- fMenuManager.removeMenuListener(fMenuListener);
- fMenuManager= null;
- fMenuListener= null;
- }
- }
-
- private void updateMenu(IMenuManager manager) {
- IContributionItem[] items= manager.getItems();
- if (items != null) {
- for (int i= 0; i < items.length; i++) {
- IContributionItem item= items[i];
- if (item != null && item.getId() != null && item.getId().equals(FILTER_CATEGORY_ACTION_ID)) {
- IContributionItem removed= manager.remove(item);
- if (removed != null) {
- item.dispose();
- }
- }
- }
- }
- List menuEntries= new ArrayList();
- boolean hasUncategorizedMembers= getMenuCategories(menuEntries);
- Collections.sort(menuEntries, Collator.getInstance());
-
- if (menuEntries.size() > 0 && hasUncategorizedMembers)
- manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new FilterUncategorizedMembersAction());
-
- int count= 0;
- for (Iterator iter= menuEntries.iterator(); iter.hasNext();) {
- String category= (String)iter.next();
- manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new CategoryFilterAction(category, count + 1));
- count++;
- }
- }
-
- private boolean getMenuCategories(List result) {
- final HashSet/*<String>*/ categories= new HashSet();
- final HashSet/*<String>*/ foundLRUCategories= new HashSet();
- final boolean hasUncategorizedMember[]= new boolean[] {false};
- for (int i= 0; i < fInputElement.length && !(hasUncategorizedMember[0] && foundLRUCategories.size() >= MAX_NUMBER_OF_CATEGORIES_IN_MENU); i++) {
- collectCategories(fInputElement[i], new IResultCollector() {
- public boolean accept(String[] cats) {
- if (cats.length > 0) {
- for (int j= 0; j < cats.length; j++) {
- String category= cats[j];
- categories.add(category);
- if (fLRUList.containsKey(category)) {
- foundLRUCategories.add(category);
- }
- }
- } else {
- hasUncategorizedMember[0]= true;
- }
- return hasUncategorizedMember[0] && foundLRUCategories.size() >= MAX_NUMBER_OF_CATEGORIES_IN_MENU;
- }
- });
- }
- int count= 0;
- for (Iterator iter= foundLRUCategories.iterator(); iter.hasNext();) {
- String element= (String)iter.next();
- result.add(element);
- count++;
- }
- if (count < MAX_NUMBER_OF_CATEGORIES_IN_MENU) {
- List sortedCategories= new ArrayList(categories);
- Collections.sort(sortedCategories, Collator.getInstance());
- for (Iterator iter= sortedCategories.iterator(); iter.hasNext() && count < MAX_NUMBER_OF_CATEGORIES_IN_MENU;) {
- String element= (String)iter.next();
- if (!foundLRUCategories.contains(element)) {
- result.add(element);
- count++;
- }
- }
- }
- return hasUncategorizedMember[0];
- }
-
- private boolean collectCategories(IJavaScriptElement element, IResultCollector collector) {//HashSet result, int max, LinkedHashMap lruList) {
- try {
- if (element instanceof IMember) {
- IMember member= (IMember)element;
- collector.accept(member.getCategories());
- return processChildren(member.getChildren(), collector);
- } else if (element instanceof IJavaScriptUnit) {
- return processChildren(((IJavaScriptUnit)element).getChildren(), collector);
- } else if (element instanceof IClassFile) {
- return processChildren(((IClassFile)element).getChildren(), collector);
- } else if (element instanceof IJavaScriptModel) {
- return processChildren(((IJavaScriptModel)element).getChildren(), collector);
- } else if (element instanceof IJavaScriptProject) {
- return processChildren(((IJavaScriptProject)element).getChildren(), collector);
- } else if (element instanceof IPackageFragment) {
- return processChildren(((IPackageFragment)element).getChildren(), collector);
- } else if (element instanceof IPackageFragmentRoot) {
- return processChildren(((IPackageFragmentRoot)element).getChildren(), collector);
- }
- return false;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return true;
- }
- }
-
- private boolean processChildren(IJavaScriptElement[] children, IResultCollector collector) {
- for (int i= 0; i < children.length; i++) {
- if (collectCategories(children[i], collector))
- return true;
- }
- return false;
- }
-
- private void fireSelectionChange() {
- fViewer.getControl().setRedraw(false);
- BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- fViewer.refresh();
- }
- });
- fViewer.getControl().setRedraw(true);
- }
-
- private String getPreferenceKey() {
- return "CategoryFilterActionGroup." + fViewerId; //$NON-NLS-1$
- }
-
- private void showCategorySelectionDialog(IJavaScriptElement[] input) {
- final HashSet/*<String>*/ categories= new HashSet();
- for (int i= 0; i < input.length; i++) {
- collectCategories(input[i], new IResultCollector() {
- public boolean accept(String[] cats) {
- for (int j= 0; j < cats.length; j++) {
- categories.add(cats[j]);
- }
- return false;
- }
- });
- }
- CategoryFilterSelectionDialog dialog= new CategoryFilterSelectionDialog(fViewer.getControl().getShell(), new ArrayList(categories), new ArrayList(fFilteredCategories));
- if (dialog.open() == Window.OK) {
- Object[] selected= dialog.getResult();
- for (Iterator iter= categories.iterator(); iter.hasNext();) {
- String category= (String)iter.next();
- if (contains(selected, category)) {
- if (fFilteredCategories.remove(category))
- fLRUList.put(category, category);
- } else {
- if (fFilteredCategories.add(category))
- fLRUList.put(category, category);
- }
- }
- storeSettings();
- fireSelectionChange();
- }
- }
-
- private boolean contains(Object[] selected, String category) {
- for (int i= 0; i < selected.length; i++) {
- if (selected[i].equals(category))
- return true;
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java
deleted file mode 100644
index 498b493b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.eclipse.core.runtime.CoreException;
-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.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ElementValidator;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public abstract class CleanUpAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- public CleanUpAction(IWorkbenchSite site) {
- super(site);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call
- * this constructor.
- *
- * @param editor
- * the Java editor
- */
- public CleanUpAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(getCompilationUnit(fEditor) != null);
- }
-
- /**
- * @return the name of this action, not <b>null</b>
- */
- protected abstract String getActionName();
-
- /**
- * @param units
- * the units to clean up
- * @return the clean ups to be performed or <b>null</b> if none to be
- * performed
- */
- protected abstract ICleanUp[] createCleanUps(IJavaScriptUnit[] units);
-
- /**
- * @param units
- * to clean up
- * @param cleanUps
- * clean ups to execute on units
- *
- * @throws JavaScriptModelException
- * @throws InvocationTargetException
- */
- protected void performRefactoring(IJavaScriptUnit[] units, ICleanUp[] cleanUps) throws JavaScriptModelException, InvocationTargetException {
- RefactoringExecutionStarter.startCleanupRefactoring(units, cleanUps, getShell(), false, getActionName());
- }
-
- public void run(ITextSelection selection) {
- IJavaScriptUnit cu= getCompilationUnit(fEditor);
- if (cu != null) {
- run(cu);
- }
- }
-
- public void run(IStructuredSelection selection) {
- IJavaScriptUnit[] cus= getCompilationUnits(selection);
- if (cus.length == 0) {
- MessageDialog.openInformation(getShell(), getActionName(), ActionMessages.CleanUpAction_EmptySelection_description);
- } else if (cus.length == 1) {
- run(cus[0]);
- } else {
- runOnMultiple(cus);
- }
- }
-
- public void selectionChanged(ITextSelection selection) {
- setEnabled(getCompilationUnit(fEditor) != null);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(isEnabled(selection));
- }
-
- private boolean isEnabled(IStructuredSelection selection) {
- Object[] selected= selection.toArray();
- for (int i= 0; i < selected.length; i++) {
- try {
- if (selected[i] instanceof IJavaScriptElement) {
- IJavaScriptElement elem= (IJavaScriptElement)selected[i];
- if (elem.exists()) {
- switch (elem.getElementType()) {
- case IJavaScriptElement.TYPE:
- return elem.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT; // for browsing perspective
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return true;
- case IJavaScriptElement.IMPORT_CONTAINER:
- return true;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- IPackageFragmentRoot root= (IPackageFragmentRoot)elem.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638
- return true;
- }
- }
- } else if (selected[i] instanceof LogicalPackage) {
- return true;
- }
- } catch (JavaScriptModelException e) {
- if (!e.isDoesNotExist()) {
- JavaScriptPlugin.log(e);
- }
- }
- }
- return false;
- }
-
- private void run(IJavaScriptUnit cu) {
- if (!ActionUtil.isEditable(fEditor, getShell(), cu))
- return;
-
- ICleanUp[] cleanUps= createCleanUps(new IJavaScriptUnit[] {
- cu
- });
- if (cleanUps == null)
- return;
-
- if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null))
- return;
-
- try {
- performRefactoring(new IJavaScriptUnit[] {
- cu
- }, cleanUps);
- } catch (InvocationTargetException e) {
- JavaScriptPlugin.log(e);
- if (e.getCause() instanceof CoreException)
- showUnexpectedError((CoreException)e.getCause());
- } catch (JavaScriptModelException e) {
- showUnexpectedError(e);
- }
- }
-
- private void runOnMultiple(final IJavaScriptUnit[] cus) {
- ICleanUp[] cleanUps= createCleanUps(cus);
- if (cleanUps == null)
- return;
-
- MultiStatus status= new MultiStatus(JavaScriptUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null);
- for (int i= 0; i < cus.length; i++) {
- IJavaScriptUnit cu= cus[i];
-
- if (!ActionUtil.isOnBuildPath(cu)) {
- String cuLocation= cu.getPath().makeRelative().toString();
- String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation);
- status.add(new Status(IStatus.INFO, JavaScriptUI.ID_PLUGIN, IStatus.ERROR, message, null));
- }
- }
- if (!status.isOK()) {
- ErrorDialog.openError(getShell(), getActionName(), null, status);
- return;
- }
-
- try {
- performRefactoring(cus, cleanUps);
- } catch (InvocationTargetException e) {
- JavaScriptPlugin.log(e);
- if (e.getCause() instanceof CoreException)
- showUnexpectedError((CoreException)e.getCause());
- } catch (JavaScriptModelException e) {
- showUnexpectedError(e);
- }
- }
-
- private void showUnexpectedError(CoreException e) {
- String message2= Messages.format(ActionMessages.CleanUpAction_UnexpectedErrorMessage, e.getStatus().getMessage());
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.ERROR, message2, null);
- ErrorDialog.openError(getShell(), getActionName(), null, status);
- }
-
- public IJavaScriptUnit[] getCompilationUnits(IStructuredSelection selection) {
- HashSet result= new HashSet();
- Object[] selected= selection.toArray();
- for (int i= 0; i < selected.length; i++) {
- try {
- if (selected[i] instanceof IJavaScriptElement) {
- IJavaScriptElement elem= (IJavaScriptElement)selected[i];
- if (elem.exists()) {
- switch (elem.getElementType()) {
- case IJavaScriptElement.TYPE:
- if (elem.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT) {
- result.add(elem.getParent());
- }
- break;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- result.add(elem);
- break;
- case IJavaScriptElement.IMPORT_CONTAINER:
- result.add(elem.getParent());
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- collectCompilationUnits((IPackageFragment)elem, result);
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- collectCompilationUnits((IPackageFragmentRoot)elem, result);
- break;
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- IPackageFragmentRoot[] roots= ((IJavaScriptProject)elem).getPackageFragmentRoots();
- for (int k= 0; k < roots.length; k++) {
- collectCompilationUnits(roots[k], result);
- }
- break;
- }
- }
- } else if (selected[i] instanceof LogicalPackage) {
- IPackageFragment[] packageFragments= ((LogicalPackage)selected[i]).getFragments();
- for (int k= 0; k < packageFragments.length; k++) {
- IPackageFragment pack= packageFragments[k];
- if (pack.exists()) {
- collectCompilationUnits(pack, result);
- }
- }
- }
- } catch (JavaScriptModelException e) {
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- }
- }
- return (IJavaScriptUnit[])result.toArray(new IJavaScriptUnit[result.size()]);
- }
-
- private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaScriptModelException {
- result.addAll(Arrays.asList(pack.getJavaScriptUnits()));
- }
-
- private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaScriptModelException {
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
- IJavaScriptElement[] children= root.getChildren();
- for (int i= 0; i < children.length; i++) {
- collectCompilationUnits((IPackageFragment)children[i], result);
- }
- }
- }
-
- private static IJavaScriptUnit getCompilationUnit(JavaEditor editor) {
- IJavaScriptElement element= JavaScriptUI.getEditorInputJavaElement(editor.getEditorInput());
- if (!(element instanceof IJavaScriptUnit))
- return null;
-
- return (IJavaScriptUnit)element;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CompositeActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CompositeActionGroup.java
deleted file mode 100644
index e6fb04c0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CompositeActionGroup.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-
-public class CompositeActionGroup extends ActionGroup {
-
- private ActionGroup[] fGroups;
-
- public CompositeActionGroup() {
- }
-
- public CompositeActionGroup(ActionGroup[] groups) {
- setGroups(groups);
- }
-
- protected void setGroups(ActionGroup[] groups) {
- Assert.isTrue(fGroups == null);
- Assert.isNotNull(groups);
- fGroups= groups;
- }
-
- public ActionGroup get(int index) {
- if (fGroups == null)
- return null;
- return fGroups[index];
- }
-
- public void addGroup(ActionGroup group) {
- if (fGroups == null) {
- fGroups= new ActionGroup[] { group };
- } else {
- ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
- System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
- newGroups[fGroups.length]= group;
- fGroups= newGroups;
- }
- }
-
- public void dispose() {
- super.dispose();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].dispose();
- }
- }
-
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillActionBars(actionBars);
- }
- }
-
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillContextMenu(menu);
- }
- }
-
- public void setContext(ActionContext context) {
- super.setContext(context);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].setContext(context);
- }
- }
-
- public void updateActionBars() {
- super.updateActionBars();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].updateActionBars();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ConfigureContainerAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ConfigureContainerAction.java
deleted file mode 100644
index 5e689723..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ConfigureContainerAction.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.packageview.JsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.wizards.BuildPathDialogAccess;
-
-/**
- * Action to open a dialog to configure classpath containers. Added as a <code>objectContribution</code>
- * to {@link JsGlobalScopeContainer}.
- */
-public class ConfigureContainerAction implements IObjectActionDelegate {
-
- private ISelection fCurrentSelection;
- private IWorkbenchPart fPart;
-
- /*
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fPart= targetPart;
- }
-
- /*
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- if (fCurrentSelection instanceof IStructuredSelection) {
- JsGlobalScopeContainer container= (JsGlobalScopeContainer) ((IStructuredSelection) fCurrentSelection).getFirstElement();
- openWizard(container.getClasspathEntry(), container.getLabel(), container.getJavaProject());
- }
- }
-
- private void openWizard(IIncludePathEntry entry, String label, final IJavaScriptProject project) {
- Shell shell= fPart.getSite().getShell();
- try {
- IIncludePathEntry[] entries= project.getRawIncludepath();
-
- IIncludePathEntry result= BuildPathDialogAccess.configureContainerEntry(shell, entry, project, entries);
- if (result == null || result.equals(entry)) {
- return; // user cancelled or no changes
- }
-
- int idx= indexInClasspath(entries, entry);
- if (idx == -1) {
- return;
- }
-
- final IIncludePathEntry[] newEntries= new IIncludePathEntry[entries.length];
- System.arraycopy(entries, 0, newEntries, 0, entries.length);
- newEntries[idx]= result;
-
- IRunnableContext context= fPart.getSite().getWorkbenchWindow();
- if (context == null) {
- context= PlatformUI.getWorkbench().getProgressService();
- }
- context.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- project.setRawIncludepath(newEntries, project.getOutputLocation(), monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
- });
- } catch (JavaScriptModelException e) {
- String title= ActionMessages.ConfigureContainerAction_error_title;
- String message= ActionMessages.ConfigureContainerAction_error_creationfailed_message;
- ExceptionHandler.handle(e, shell, title, message);
- } catch (InvocationTargetException e) {
- String title= ActionMessages.ConfigureContainerAction_error_title;
- String message= ActionMessages.ConfigureContainerAction_error_applyingfailed_message;
- ExceptionHandler.handle(e, shell, title, message);
- } catch (InterruptedException e) {
- // user cancelled
- }
- }
-
- protected static int indexInClasspath(IIncludePathEntry[] entries, IIncludePathEntry entry) {
- for (int i= 0; i < entries.length; i++) {
- if (entries[i] == entry) {
- return i;
- }
- }
- return -1;
- }
-
- /*
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fCurrentSelection= selection;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CopyQualifiedNameAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CopyQualifiedNameAction.java
deleted file mode 100644
index 61f90ce2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CopyQualifiedNameAction.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Expression;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.MemberRef;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.TypeParameter;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclaration;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class CopyQualifiedNameAction extends SelectionDispatchAction {
-
- private static final long LABEL_FLAGS= new Long(JavaScriptElementLabels.F_FULLY_QUALIFIED | JavaScriptElementLabels.M_FULLY_QUALIFIED | JavaScriptElementLabels.I_FULLY_QUALIFIED | JavaScriptElementLabels.T_FULLY_QUALIFIED | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.USE_RESOLVED | JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.CU_QUALIFIED | JavaScriptElementLabels.CF_QUALIFIED).longValue();
-
- //TODO: Make API
- public static final String ACTION_DEFINITION_ID= "org.eclipse.wst.jsdt.ui.edit.text.java.copy.qualified.name"; //$NON-NLS-1$
-
- //TODO: Make API
- public static final String ACTION_HANDLER_ID= "org.eclipse.wst.jsdt.ui.actions.CopyQualifiedName"; //$NON-NLS-1$
-
- private JavaEditor fEditor;
-
- public CopyQualifiedNameAction(JavaEditor editor) {
- this(editor.getSite());
- fEditor= editor;
- setEnabled(true);
- }
-
- public CopyQualifiedNameAction(IWorkbenchSite site) {
- super(site);
-
- setText(ActionMessages.CopyQualifiedNameAction_ActionName);
- setToolTipText(ActionMessages.CopyQualifiedNameAction_ToolTipText);
- setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_COPY_QUALIFIED_NAME);
- setImageDescriptor(JavaPluginImages.DESC_ELCL_COPY_QUALIFIED_NAME);
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(canEnable(selection.toArray()));
- }
-
- public void selectionChanged(ITextSelection selection) {
- //Must not create an AST
- }
-
- private boolean canEnable(Object[] objects) {
- for (int i= 0; i < objects.length; i++) {
- Object element= objects[i];
- if (isValideElement(element))
- return true;
- }
-
- return false;
- }
-
- private boolean isValideElement(Object element) {
- if (element instanceof IMember)
- return true;
-
- if (element instanceof IClassFile)
- return true;
-
- if (element instanceof IJavaScriptUnit)
- return true;
-
- if (element instanceof IPackageDeclaration)
- return true;
-
- if (element instanceof IImportDeclaration)
- return true;
-
- if (element instanceof IPackageFragment)
- return true;
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
-
- try {
- IJavaScriptElement[] elements= getSelectedElements();
- if (elements == null) {
- MessageDialog.openInformation(getShell(), ActionMessages.CopyQualifiedNameAction_InfoDialogTitel, ActionMessages.CopyQualifiedNameAction_NoElementToQualify);
- return;
- }
-
- Object[] data= null;
- Transfer[] dataTypes= null;
-
- if (elements.length == 1) {
- String qualifiedName= JavaScriptElementLabels.getElementLabel(elements[0], LABEL_FLAGS);
- IResource resource= elements[0].getCorrespondingResource();
-
- if (resource != null) {
- IPath location= resource.getLocation();
- if (location != null) {
- data= new Object[] {qualifiedName, resource, new String[] {location.toOSString()}};
- dataTypes= new Transfer[] {TextTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};
- } else {
- data= new Object[] {qualifiedName, resource};
- dataTypes= new Transfer[] {TextTransfer.getInstance(), ResourceTransfer.getInstance()};
- }
- } else {
- data= new Object[] {qualifiedName};
- dataTypes= new Transfer[] {TextTransfer.getInstance()};
- }
- } else {
- StringBuffer buf= new StringBuffer();
- buf.append(JavaScriptElementLabels.getElementLabel(elements[0], LABEL_FLAGS));
- for (int i= 1; i < elements.length; i++) {
- IJavaScriptElement element= elements[i];
-
- String qualifiedName= JavaScriptElementLabels.getElementLabel(element, LABEL_FLAGS);
- buf.append('\r').append('\n').append(qualifiedName);
- }
- data= new Object[] {buf.toString()};
- dataTypes= new Transfer[] {TextTransfer.getInstance()};
- }
-
- Clipboard clipboard= new Clipboard(getShell().getDisplay());
- try {
- clipboard.setContents(data, dataTypes);
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
- throw e;
- }
- if (MessageDialog.openQuestion(getShell(), ActionMessages.CopyQualifiedNameAction_ErrorTitle, ActionMessages.CopyQualifiedNameAction_ErrorDescription)) {
- clipboard.setContents(data, dataTypes);
- }
- } finally {
- clipboard.dispose();
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- private IJavaScriptElement[] getSelectedElements() throws JavaScriptModelException {
- if (fEditor != null) {
- IJavaScriptElement element= getSelectedElement(fEditor);
- if (element == null)
- return null;
-
- return new IJavaScriptElement[] {element};
- }
-
- ISelection selection= getSelection();
- if (!(selection instanceof IStructuredSelection))
- return null;
-
- List result= new ArrayList();
- for (Iterator iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (isValideElement(element))
- result.add(element);
- }
- if (result.isEmpty())
- return null;
-
- return (IJavaScriptElement[])result.toArray(new IJavaScriptElement[result.size()]);
- }
-
- private IJavaScriptElement getSelectedElement(JavaEditor editor) {
- ISourceViewer viewer= editor.getViewer();
- if (viewer == null)
- return null;
-
- Point selectedRange= viewer.getSelectedRange();
- int length= selectedRange.y;
- int offset= selectedRange.x;
-
- IJavaScriptElement element= JavaScriptUI.getEditorInputJavaElement(editor.getEditorInput());
- JavaScriptUnit ast= ASTProvider.getASTProvider().getAST(element, ASTProvider.WAIT_YES, null);
- if (ast == null)
- return null;
-
- NodeFinder finder= new NodeFinder(offset, length);
- ast.accept(finder);
- ASTNode node= finder.getCoveringNode();
-
- IBinding binding= null;
- if (node instanceof Name) {
- binding= ((Name)node).resolveBinding();
- } else if (node instanceof FunctionInvocation) {
- binding= ((FunctionInvocation)node).resolveMethodBinding();
- } else if (node instanceof FunctionDeclaration) {
- binding= ((FunctionDeclaration)node).resolveBinding();
- } else if (node instanceof Type) {
- binding= ((Type)node).resolveBinding();
- } else if (node instanceof AnonymousClassDeclaration) {
- binding= ((AnonymousClassDeclaration)node).resolveBinding();
- } else if (node instanceof TypeDeclaration) {
- binding= ((TypeDeclaration)node).resolveBinding();
- } else if (node instanceof JavaScriptUnit) {
- return ((JavaScriptUnit)node).getJavaElement();
- } else if (node instanceof Expression) {
- binding= ((Expression)node).resolveTypeBinding();
- } else if (node instanceof ImportDeclaration) {
- binding= ((ImportDeclaration)node).resolveBinding();
- } else if (node instanceof MemberRef) {
- binding= ((MemberRef)node).resolveBinding();
- } else if (node instanceof PackageDeclaration) {
- binding= ((PackageDeclaration)node).resolveBinding();
- } else if (node instanceof TypeParameter) {
- binding= ((TypeParameter)node).resolveBinding();
- } else if (node instanceof VariableDeclaration) {
- binding= ((VariableDeclaration)node).resolveBinding();
- }
-
- if (binding != null)
- return binding.getJavaElement();
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ExtractSuperClassAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ExtractSuperClassAction.java
deleted file mode 100644
index 716d285e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/ExtractSuperClassAction.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.io.CharConversionException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-/**
- * Action to extract a supertype from a class.
- * <p>
- * Action is applicable to selections containing elements of type
- * <code>IType</code> (top-level types only), <code>IField</code> and
- * <code>IFunction</code>.
- * </p>
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- *
- */
-public class ExtractSuperClassAction extends SelectionDispatchAction {
-
- /**
- * Action definition ID of the refactor -> extract supertype action (value
- * <code>"org.eclipse.wst.jsdt.ui.edit.text.java.extract.superclass"</code>).
- *
- *
- */
- public static final String EXTRACT_SUPERTYPE= "org.eclipse.wst.jsdt.ui.edit.text.java.extract.superclass"; //$NON-NLS-1$
-
- /**
- * Refactor menu: name of standard Extract Supertype global action (value
- * <code>"org.eclipse.wst.jsdt.ui.actions.ExtractSuperclass"</code>).
- *
- *
- */
- public static final String EXTRACT_SUPERTYPES= "org.eclipse.wst.jsdt.ui.actions.ExtractSuperclass"; //$NON-NLS-1$
-
- private static IMember[] getSelectedMembers(final IStructuredSelection selection) {
- if (selection.isEmpty())
- return null;
- if (selection.size() == 1) {
- try {
- final IType type= RefactoringAvailabilityTester.getSingleSelectedType(selection);
- if (type != null)
- return new IType[] {type};
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- for (final Iterator iterator= selection.iterator(); iterator.hasNext();) {
- if (!(iterator.next() instanceof IMember))
- return null;
- }
- final Set set= new HashSet();
- set.addAll(Arrays.asList(selection.toArray()));
- return (IMember[]) set.toArray(new IMember[set.size()]);
- }
-
- /** The java editor */
- private JavaEditor fEditor;
-
- /**
- * Note: This constructor is for internal use only. Clients should not call
- * this constructor.
- *
- * @param editor
- * the java editor
- */
- public ExtractSuperClassAction(final JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- /**
- * Creates a new extract super type action. The action requires that the
- * selection provided by the site's selection provider is of type
- * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site
- * the workbench site
- */
- public ExtractSuperClassAction(final IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.ExtractSuperTypeAction_label);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.EXTRACT_SUPERTYPE_ACTION);
- }
-
- private IMember getSelectedMemberFromEditor() throws JavaScriptModelException {
- final IJavaScriptElement element= SelectionConverter.resolveEnclosingElement(fEditor, (ITextSelection) fEditor.getSelectionProvider().getSelection());
- if (element == null || !(element instanceof IMember))
- return null;
- return (IMember) element;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final IStructuredSelection selection) {
- try {
- final IMember[] members= getSelectedMembers(selection);
- if (RefactoringAvailabilityTester.isExtractSupertypeAvailable(members) && ActionUtil.isEditable(getShell(), members[0]))
- RefactoringExecutionStarter.startExtractSupertypeRefactoring(members, getShell());
- } catch (final JavaScriptModelException exception) {
- ExceptionHandler.handle(exception, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final ITextSelection selection) {
- try {
- if (! ActionUtil.isEditable(fEditor))
- return;
- final IMember member= getSelectedMemberFromEditor();
- final IMember[] array= new IMember[] { member};
- if (member != null && RefactoringAvailabilityTester.isExtractSupertypeAvailable(array)) {
- RefactoringExecutionStarter.startExtractSupertypeRefactoring(array, getShell());
- } else {
- MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.ExtractSuperTypeAction_unavailable);
- }
- } catch (JavaScriptModelException exception) {
- ExceptionHandler.handle(exception, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final IStructuredSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isExtractSupertypeAvailable(selection));
- } catch (JavaScriptModelException exception) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (!(exception.getException() instanceof CharConversionException) && JavaModelUtil.isExceptionToBeLogged(exception))
- JavaScriptPlugin.log(exception);
- setEnabled(false);//no UI - happens on selection changes
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isExtractSupertypeAvailable(selection));
- } catch (JavaScriptModelException event) {
- setEnabled(false);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java
deleted file mode 100644
index b423495b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSHintHelper;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search.SearchBrokenNLSKeysUtil;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class FindBrokenNLSKeysAction extends SelectionDispatchAction {
-
- private static class SearchPatternData {
-
- private final IType fAccessorType;
- private final IFile fPropertyFile;
-
- public SearchPatternData(IType accessorType, IFile propertyFile) {
- fAccessorType= accessorType;
- fPropertyFile= propertyFile;
- }
-
- public IFile getPropertyFile() {
- return fPropertyFile;
- }
-
- public IType getWrapperClass() {
- return fAccessorType;
- }
-
- }
-
- //TODO: Add to API: IJavaEditorActionDefinitionIds
- public static final String FIND_BROKEN_NLS_KEYS_ACTION_ID= "org.eclipse.wst.jsdt.ui.edit.text.java.find.broken.nls.keys"; //$NON-NLS-1$
-
- //TODO: Add to API: JdtActionConstants
- public static final String ACTION_HANDLER_ID= "org.eclipse.wst.jsdt.ui.actions.FindNLSProblems"; //$NON-NLS-1$
-
- private JavaEditor fEditor;
-
- public FindBrokenNLSKeysAction(IWorkbenchSite site) {
- super(site);
- setText(ActionMessages.FindNLSProblemsAction_Name);
- setToolTipText(ActionMessages.FindNLSProblemsAction_ToolTip);
- setDescription(ActionMessages.FindNLSProblemsAction_Description);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- * @param editor the Java editor
- */
- public FindBrokenNLSKeysAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(getCompilationUnit(editor) != null);
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(ITextSelection selection) {
- ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
- if (selectionProvider == null)
- return;
-
- run(new StructuredSelection(selectionProvider.getSelection()));
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(IStructuredSelection selection) {
- if (selection.size() == 1) {
- Object firstElement= selection.getFirstElement();
- if (firstElement instanceof IJavaScriptElement) {
- IJavaScriptElement javaElement= (IJavaScriptElement) firstElement;
- if (!ActionUtil.isProcessable(getShell(), javaElement)) {
- return;
- }
- }
- }
-
- SearchPatternData[] data= getNLSFiles(selection);
- if (data == null || data.length == 0) {
- MessageDialog.openInformation(getShell(), ActionMessages.FindNLSProblemsAction_ErrorDialogTitle, ActionMessages.FindNLSProblemsAction_NoPropertieFilesFoundErrorDescription);
- return;
- }
-
- String scope= "workspace"; //$NON-NLS-1$
- if (selection.size() == 1) {
- Object firstElement= selection.getFirstElement();
- if (firstElement instanceof IJavaScriptElement) {
- scope= ((IJavaScriptElement)firstElement).getElementName();
- } else if (firstElement instanceof IFile) {
- scope= ((IFile)firstElement).getName();
- } else if (firstElement instanceof IFolder) {
- scope= ((IFolder)firstElement).getName();
- }
- }
- run(data, scope);
- }
-
- private void run(SearchPatternData[] data, String scope) {
- List wrappers= new ArrayList();
- List properties= new ArrayList();
- for (int i= 0; i < data.length; i++) {
- SearchPatternData current= data[i];
- if (current.getWrapperClass() != null || current.getPropertyFile() != null) {
- wrappers.add(current.getWrapperClass());
- properties.add(current.getPropertyFile());
- }
- }
- IType[] accessorClasses= (IType[])wrappers.toArray(new IType[wrappers.size()]);
- IFile[] propertieFiles= (IFile[])properties.toArray(new IFile[properties.size()]);
- SearchBrokenNLSKeysUtil.search(scope, accessorClasses, propertieFiles);
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(ITextSelection selection) {
- ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
- if (selectionProvider == null) {
- setEnabled(false);
- } else {
- selectionChanged(new StructuredSelection(selectionProvider.getSelection()));
- }
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(canEnable(selection));
- }
-
- private SearchPatternData[] getNLSFiles(IStructuredSelection selection) {
- Object[] selectedElements= selection.toArray();
- List result= new ArrayList();
- collectNLSFiles(selectedElements, result);
- return (SearchPatternData[])result.toArray(new SearchPatternData[result.size()]);
- }
-
- private boolean canEnable(IStructuredSelection selection) {
- Object[] selected= selection.toArray();
- for (int i= 0; i < selected.length; i++) {
- try {
- if (selected[i] instanceof IJavaScriptElement) {
- IJavaScriptElement elem= (IJavaScriptElement) selected[i];
- if (elem.exists()) {
- switch (elem.getElementType()) {
- case IJavaScriptElement.TYPE:
- if (elem.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT) {
- return true;
- }
- return false;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return true;
- case IJavaScriptElement.IMPORT_CONTAINER:
- return false;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- IPackageFragmentRoot root= (IPackageFragmentRoot) elem.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- return true;
- }
- }
- } else if (selected[i] instanceof LogicalPackage) {
- return true;
- } else if (selected[i] instanceof IFile) {
- IFile file= (IFile)selected[i];
- if ("properties".equalsIgnoreCase(file.getFileExtension())) //$NON-NLS-1$
- return true;
- }
- } catch (JavaScriptModelException e) {
- if (!e.isDoesNotExist()) {
- JavaScriptPlugin.log(e);
- }
- }
- }
- return false;
- }
-
- private void collectNLSFiles(Object[] objects, List result) {
- try {
- for (int i= 0; i < objects.length; i++) {
- if (objects[i] instanceof IJavaScriptElement) {
- IJavaScriptElement elem= (IJavaScriptElement) objects[i];
- if (elem.exists()) {
- switch (elem.getElementType()) {
- case IJavaScriptElement.TYPE:
- if (elem.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT) {
- SearchPatternData data= tryIfPropertyCuSelected((IJavaScriptUnit)elem.getParent());
- if (data != null) {
- result.add(data);
- }
- }
- break;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- SearchPatternData data= tryIfPropertyCuSelected((IJavaScriptUnit)elem);
- if (data != null) {
- result.add(data);
- }
- break;
- case IJavaScriptElement.IMPORT_CONTAINER:
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- IPackageFragment fragment= (IPackageFragment)elem;
- if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE)
- collectNLSFiles(new Object[] {fragment.getCorrespondingResource()}, result);
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- {
- IPackageFragmentRoot root= (IPackageFragmentRoot) elem;
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
- collectNLSFiles(new Object[] {root.getCorrespondingResource()}, result);
- break;
- }
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- {
- IJavaScriptProject javaProject= (IJavaScriptProject)elem;
- IPackageFragmentRoot[] allPackageFragmentRoots= javaProject.getAllPackageFragmentRoots();
- for (int j= 0; j < allPackageFragmentRoots.length; j++) {
- IPackageFragmentRoot root= allPackageFragmentRoots[j];
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
- if (javaProject.equals(root.getJavaScriptProject())) {
- collectNLSFiles(new Object[] {root.getCorrespondingResource()}, result);
- }
- }
- }
- break;
- }
- }
- }
- } else if (objects[i] instanceof LogicalPackage) {
- LogicalPackage logicalPackage= (LogicalPackage)objects[i];
- collectNLSFiles(new Object[] {logicalPackage.getJavaProject()}, result);
- } else if (objects[i] instanceof IFolder) {
- collectNLSFiles(((IFolder)objects[i]).members(), result);
- } else if (objects[i] instanceof IFile) {
- SearchPatternData data= tryIfPropertyFileSelected((IFile)objects[i]);
- if (data != null) {
- result.add(data);
- }
- }
- }
- } catch (JavaScriptModelException e) {
- if (!e.isDoesNotExist()) {
- JavaScriptPlugin.log(e);
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- private SearchPatternData tryIfPropertyCuSelected(IJavaScriptUnit compilationUnit) throws JavaScriptModelException {
- if (compilationUnit == null)
- return null;
-
- if (!ActionUtil.isOnBuildPath(compilationUnit))
- return null;
-
- IType[] types= compilationUnit.getTypes();
- if (types.length > 1)
- return null;
-
- IStorage bundle= NLSHintHelper.getResourceBundle(compilationUnit);
- if (!(bundle instanceof IFile))
- return null;
-
- return new SearchPatternData(types[0], (IFile)bundle);
- }
-
- private SearchPatternData tryIfPropertyFileSelected(IFile file) throws JavaScriptModelException {
- if (!"properties".equalsIgnoreCase(file.getFileExtension())) //$NON-NLS-1$
- return null;
-
- IPath propertyFullPath= file.getFullPath();
- // Try to find a corresponding CU
- String[] javaExtensions= JavaScriptCore.getJavaScriptLikeExtensions();
- for (int i= 0; i < javaExtensions.length; i++) {
- String extension= javaExtensions[i];
- IPath cuPath= propertyFullPath.removeFileExtension().addFileExtension(extension);
- IFile cuFile= (IFile)JavaScriptPlugin.getWorkspace().getRoot().findMember(cuPath);
-
- if (cuFile == null) { //try with uppercase first char
- String filename= cuPath.removeFileExtension().lastSegment();
- if (filename != null && filename.length() > 0) {
- filename= Character.toUpperCase(filename.charAt(0)) + filename.substring(1);
- IPath dirPath= propertyFullPath.removeLastSegments(1).addTrailingSeparator();
- cuPath= dirPath.append(filename).addFileExtension(extension);
- cuFile= (IFile)JavaScriptPlugin.getWorkspace().getRoot().findMember(cuPath);
- }
- }
-
- if (cuFile != null && cuFile.exists()) {
- IJavaScriptElement element= JavaScriptCore.create(cuFile);
- if (element != null && element.exists() && element.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT && ActionUtil.isOnBuildPath(element)) {
- IJavaScriptUnit compilationUnit= (IJavaScriptUnit)element;
- IType type= (compilationUnit).findPrimaryType();
- if (type != null) {
- String resourceBundleName= NLSHintHelper.getResourceBundleName(compilationUnit);
- if (resourceBundleName != null) {
- String resourceName= resourceBundleName + NLSRefactoring.PROPERTY_FILE_EXT;
- String name= file.getName();
- if (resourceName.endsWith(name)) {
- return new SearchPatternData(type, file);
- }
- }
- }
- }
- }
- }
-
- return null;
- }
-
- private static IJavaScriptUnit getCompilationUnit(JavaEditor editor) {
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- IJavaScriptUnit cu= manager.getWorkingCopy(editor.getEditorInput());
- return cu;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingActionGroup.java
deleted file mode 100644
index ffb1c91e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingActionGroup.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.source.projection.IProjectionListener;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.editors.text.IFoldingCommandIds;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.ResourceAction;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-
-
-/**
- * Groups the JDT folding actions.
- *
- *
- */
-public class FoldingActionGroup extends ActionGroup {
- private static abstract class PreferenceAction extends ResourceAction implements IUpdate {
- PreferenceAction(ResourceBundle bundle, String prefix, int style) {
- super(bundle, prefix, style);
- }
- }
-
- /**
- *
- */
- private class FoldingAction extends PreferenceAction {
-
- FoldingAction(ResourceBundle bundle, String prefix) {
- super(bundle, prefix, IAction.AS_PUSH_BUTTON);
- }
-
- public void update() {
- setEnabled(FoldingActionGroup.this.isEnabled() && fViewer.isProjectionMode());
- }
-
- }
-
- private ProjectionViewer fViewer;
-
- private final PreferenceAction fToggle;
- private final TextOperationAction fExpand;
- private final TextOperationAction fCollapse;
- private final TextOperationAction fExpandAll;
- private final IProjectionListener fProjectionListener;
-
- /* since 3.2 */
- private final PreferenceAction fRestoreDefaults;
- private final FoldingAction fCollapseMembers;
- private final FoldingAction fCollapseComments;
- private final TextOperationAction fCollapseAll;
-
-
- /**
- * Creates a new projection action group for <code>editor</code>. If the
- * supplied viewer is not an instance of <code>ProjectionViewer</code>, the
- * action group is disabled.
- *
- * @param editor the text editor to operate on
- * @param viewer the viewer of the editor
- */
- public FoldingActionGroup(final ITextEditor editor, ITextViewer viewer) {
- if (!(viewer instanceof ProjectionViewer)) {
- fToggle= null;
- fExpand= null;
- fCollapse= null;
- fExpandAll= null;
- fCollapseAll= null;
- fRestoreDefaults= null;
- fCollapseMembers= null;
- fCollapseComments= null;
- fProjectionListener= null;
- return;
- }
-
- fViewer= (ProjectionViewer) viewer;
-
- fProjectionListener= new IProjectionListener() {
-
- public void projectionEnabled() {
- update();
- }
-
- public void projectionDisabled() {
- update();
- }
- };
-
- fViewer.addProjectionListener(fProjectionListener);
-
- fToggle= new PreferenceAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", IAction.AS_CHECK_BOX) { //$NON-NLS-1$
- public void run() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- boolean current= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
- store.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, !current);
- }
-
- public void update() {
- ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
-
- boolean isEnabled= (target != null && target.canDoOperation(ProjectionViewer.TOGGLE));
- setEnabled(isEnabled);
- }
- };
- fToggle.setChecked(true);
- fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
- editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
-
- fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
- fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
- editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
-
- fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$
- fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
- editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$
-
- fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
- fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
- editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
-
- fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
- fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
- editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
-
- fRestoreDefaults= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
- public void run() {
- if (editor instanceof JavaEditor) {
- JavaEditor javaEditor= (JavaEditor) editor;
- javaEditor.resetProjection();
- }
- }
- };
- fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE);
- editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$
-
- fCollapseMembers= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.CollapseMembers.") { //$NON-NLS-1$
- public void run() {
- if (editor instanceof JavaEditor) {
- JavaEditor javaEditor= (JavaEditor) editor;
- javaEditor.collapseMembers();
- }
- }
- };
- fCollapseMembers.setActionDefinitionId(IJavaEditorActionDefinitionIds.FOLDING_COLLAPSE_MEMBERS);
- editor.setAction("FoldingCollapseMembers", fCollapseMembers); //$NON-NLS-1$
-
- fCollapseComments= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.CollapseComments.") { //$NON-NLS-1$
- public void run() {
- if (editor instanceof JavaEditor) {
- JavaEditor javaEditor= (JavaEditor) editor;
- javaEditor.collapseComments();
- }
- }
- };
- fCollapseComments.setActionDefinitionId(IJavaEditorActionDefinitionIds.FOLDING_COLLAPSE_COMMENTS);
- editor.setAction("FoldingCollapseComments", fCollapseComments); //$NON-NLS-1$
- }
-
- /**
- * Returns <code>true</code> if the group is enabled.
- * <pre>
- * Invariant: isEnabled() <=> fViewer and all actions are != null.
- * </pre>
- *
- * @return <code>true</code> if the group is enabled
- */
- protected boolean isEnabled() {
- return fViewer != null;
- }
-
- /*
- * @see org.eclipse.ui.actions.ActionGroup#dispose()
- */
- public void dispose() {
- if (isEnabled()) {
- fViewer.removeProjectionListener(fProjectionListener);
- fViewer= null;
- }
- super.dispose();
- }
-
- /**
- * Updates the actions.
- */
- protected void update() {
- if (isEnabled()) {
- fToggle.update();
- fToggle.setChecked(fViewer.isProjectionMode());
- fExpand.update();
- fExpandAll.update();
- fCollapse.update();
- fCollapseAll.update();
- fRestoreDefaults.update();
- fCollapseMembers.update();
- fCollapseComments.update();
- }
- }
-
- /**
- * Fills the menu with all folding actions.
- *
- * @param manager the menu manager for the folding submenu
- */
- public void fillMenu(IMenuManager manager) {
- if (isEnabled()) {
- update();
- manager.add(fToggle);
- manager.add(fExpandAll);
- manager.add(fExpand);
- manager.add(fCollapse);
- manager.add(fCollapseAll);
- manager.add(fRestoreDefaults);
- manager.add(fCollapseMembers);
- manager.add(fCollapseComments);
- }
- }
-
- /*
- * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
- */
- public void updateActionBars() {
- update();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.java
deleted file mode 100644
index c4ad9d9d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import com.ibm.icu.text.MessageFormat;
-
-/**
- * Class that gives access to the folding messages resource bundle.
- */
-public class FoldingMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private FoldingMessages() {
- // 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 resource bundle managed by the receiver.
- *
- * @return the resource bundle
- *
- */
- public static ResourceBundle getResourceBundle() {
- return RESOURCE_BUNDLE;
- }
-
- /**
- * 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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.properties
deleted file mode 100644
index b801ed91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FoldingMessages.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-Projection.Toggle.label= &Enable Folding
-Projection.Toggle.tooltip= Toggles Folding
-Projection.Toggle.description= Toggles folding for the current editor
-Projection.Toggle.image=
-
-Projection.ExpandAll.label= Expand &All
-Projection.ExpandAll.tooltip= Expands All Collapsed Regions
-Projection.ExpandAll.description= Expands any collapsed regions in the current editor
-Projection.ExpandAll.image=
-
-Projection.Expand.label= E&xpand
-Projection.Expand.tooltip= Expands the Current Collapsed Region
-Projection.Expand.description= Expands the collapsed region at the current selection
-Projection.Expand.image=
-
-Projection.CollapseAll.label= Collapse A&ll
-Projection.CollapseAll.tooltip= Collapses All Expanded Regions
-Projection.CollapseAll.description= Collapse any expanded regions in the current editor
-Projection.CollapseAll.image=
-
-Projection.Collapse.label= Colla&pse
-Projection.Collapse.tooltip= Collapses the Current Region
-Projection.Collapse.description= Collapses the Current Region
-Projection.Collapse.image=
-
-Projection.Restore.label= &Reset Structure
-Projection.Restore.tooltip= Restore the Original Folding Structure
-Projection.Restore.description= Restores the original folding structure
-Projection.Restore.image=
-
-Projection.CollapseComments.label= Collapse &Comments
-Projection.CollapseComments.tooltip= Collapses All Comments
-Projection.CollapseComments.description= Collapses all comments
-Projection.CollapseComments.image=
-
-Projection.CollapseMembers.label= Collapse &Members
-Projection.CollapseMembers.tooltip= Collapses All Members
-Projection.CollapseMembers.description= Collapses all members
-Projection.CollapseMembers.image=
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsContentProvider.java
deleted file mode 100644
index 7d7cb95b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsContentProvider.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.RefactoringASTParser;
-
-public class GenerateConstructorUsingFieldsContentProvider implements ITreeContentProvider {
-
- private static final Object[] EMPTY= new Object[0];
-
- private List fFields= new ArrayList();
-
- private List fSelected= new ArrayList();
-
- private ITypeBinding fType= null;
-
- private final JavaScriptUnit fUnit;
-
- public GenerateConstructorUsingFieldsContentProvider(IType type, List fields, List selected) throws JavaScriptModelException {
- RefactoringASTParser parser= new RefactoringASTParser(AST.JLS3);
- fUnit= parser.parse(type.getJavaScriptUnit(), true);
- fType= ASTNodes.getTypeBinding(fUnit, type);
- if (fType != null) {
- IField field= null;
- for (Iterator iterator= fields.iterator(); iterator.hasNext();) {
- field= (IField) iterator.next();
- VariableDeclarationFragment fragment= ASTNodeSearchUtil.getFieldDeclarationFragmentNode(field, fUnit);
- if (fragment != null) {
- IVariableBinding binding= fragment.resolveBinding();
- if (binding != null)
- fFields.add(binding);
- }
- }
- for (Iterator iterator= selected.iterator(); iterator.hasNext();) {
- field= (IField) iterator.next();
- VariableDeclarationFragment fragment= ASTNodeSearchUtil.getFieldDeclarationFragmentNode(field, fUnit);
- if (fragment != null) {
- IVariableBinding binding= fragment.resolveBinding();
- if (binding != null)
- fSelected.add(binding);
- }
- }
- }
- }
-
- public JavaScriptUnit getCompilationUnit() {
- return fUnit;
- }
-
- public boolean canMoveDown(List selectedElements) {
- int nSelected= selectedElements.size();
- for (int index= fFields.size() - 1; index >= 0 && nSelected > 0; index--) {
- if (!selectedElements.contains(fFields.get(index))) {
- return true;
- }
- nSelected--;
- }
- return false;
- }
-
- public boolean canMoveUp(List selected) {
- int nSelected= selected.size();
- for (int index= 0; index < fFields.size() && nSelected > 0; index++) {
- if (!selected.contains(fFields.get(index))) {
- return true;
- }
- nSelected--;
- }
- return false;
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- public void down(List checked, CheckboxTreeViewer tree) {
- if (checked.size() > 0) {
- setElements(reverse(moveUp(reverse(fFields), checked)), tree);
- tree.reveal(checked.get(checked.size() - 1));
- }
- tree.setSelection(new StructuredSelection(checked));
- }
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- return EMPTY;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- return fFields.toArray();
- }
-
- public List getFieldsList() {
- return fFields;
- }
-
- public Object[] getInitiallySelectedElements() {
- if (fSelected.isEmpty())
- return getElements(null);
- return fSelected.toArray();
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
- public ITypeBinding getType() {
- return fType;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- private List moveUp(List elements, List move) {
- List result= new ArrayList(elements.size());
- Object floating= null;
- for (int index= 0; index < elements.size(); index++) {
- Object current= elements.get(index);
- if (move.contains(current)) {
- result.add(current);
- } else {
- if (floating != null) {
- result.add(floating);
- }
- floating= current;
- }
- }
- if (floating != null) {
- result.add(floating);
- }
- return result;
- }
-
- private List reverse(List list) {
- List reverse= new ArrayList(list.size());
- for (int index= list.size() - 1; index >= 0; index--) {
- reverse.add(list.get(index));
- }
- return reverse;
- }
-
- public void setElements(List elements, CheckboxTreeViewer tree) {
- fFields= new ArrayList(elements);
- if (tree != null)
- tree.refresh();
- }
-
- public void up(List checked, CheckboxTreeViewer tree) {
- if (checked.size() > 0) {
- setElements(moveUp(fFields, checked), tree);
- tree.reveal(checked.get(0));
- }
- tree.setSelection(new StructuredSelection(checked));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java
deleted file mode 100644
index 884eb724..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-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.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.SourceActionDialog;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.IVisibilityChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.BindingLabelProvider;
-
-public class GenerateConstructorUsingFieldsSelectionDialog extends SourceActionDialog {
-
- class GenerateConstructorUsingFieldsTreeViewerAdapter implements ISelectionChangedListener, IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- // Do nothing
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection= (IStructuredSelection) getTreeViewer().getSelection();
-
- List selectedList= selection.toList();
- GenerateConstructorUsingFieldsContentProvider cp= (GenerateConstructorUsingFieldsContentProvider) getContentProvider();
-
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.UP_INDEX].setEnabled(cp.canMoveUp(selectedList));
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.DOWN_INDEX].setEnabled(cp.canMoveDown(selectedList));
- }
- }
-
- private static final int DOWN_BUTTON= IDialogConstants.CLIENT_ID + 2;
-
- private static final int UP_BUTTON= IDialogConstants.CLIENT_ID + 1;
-
- protected Button[] fButtonControls;
-
- boolean[] fButtonsEnabled;
-
- IDialogSettings fGenConstructorSettings;
-
- int fHeight= 18;
-
- boolean fOmitSuper;
-
- Button fOmitSuperButton;
-
- IFunctionBinding[] fSuperConstructors;
-
- int fSuperIndex;
-
- GenerateConstructorUsingFieldsTreeViewerAdapter fTreeViewerAdapter;
-
- int fWidth= 60;
-
- final String OMIT_SUPER= "OmitCallToSuper"; //$NON-NLS-1$
-
- final String SETTINGS_SECTION= "GenerateConstructorUsingFieldsSelectionDialog"; //$NON-NLS-1$
-
- private static final int DOWN_INDEX= 1;
-
- private static final int UP_INDEX= 0;
-
- public GenerateConstructorUsingFieldsSelectionDialog(Shell parent, ILabelProvider labelProvider, GenerateConstructorUsingFieldsContentProvider contentProvider, CompilationUnitEditor editor, IType type, IFunctionBinding[] superConstructors) throws JavaScriptModelException {
- super(parent, labelProvider, contentProvider, editor, type, true);
- fTreeViewerAdapter= new GenerateConstructorUsingFieldsTreeViewerAdapter();
-
- fSuperConstructors= superConstructors;
-
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- fGenConstructorSettings= dialogSettings.getSection(SETTINGS_SECTION);
- if (fGenConstructorSettings == null) {
- fGenConstructorSettings= dialogSettings.addNewSection(SETTINGS_SECTION);
- fGenConstructorSettings.put(OMIT_SUPER, false);
- }
-
- final boolean isEnum= type.isEnum();
- fOmitSuper= fGenConstructorSettings.getBoolean(OMIT_SUPER) || isEnum;
- if (isEnum)
- setVisibility(Modifier.PRIVATE);
- }
-
- Composite addSuperClassConstructorChoices(Composite composite) {
- Label label= new Label(composite, SWT.NONE);
- label.setText(ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_sort_constructor_choices_label);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- label.setLayoutData(gd);
-
- BindingLabelProvider provider= new BindingLabelProvider();
- final Combo combo= new Combo(composite, SWT.READ_ONLY);
- for (int i= 0; i < fSuperConstructors.length; i++) {
- combo.add(provider.getText(fSuperConstructors[i]));
- }
-
- // TODO: Can we be a little more intelligent about guessing the super() ?
- combo.setText(combo.getItem(0));
- combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- combo.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- fSuperIndex= combo.getSelectionIndex();
- // Disable omit super checkbox unless default constructor
- fOmitSuperButton.setEnabled(getSuperConstructorChoice().getParameterTypes().length == 0);
- updateOKStatus();
- }
- });
-
- return composite;
- }
-
- protected void buttonPressed(int buttonId) {
- super.buttonPressed(buttonId);
- switch (buttonId) {
- case UP_BUTTON: {
- GenerateConstructorUsingFieldsContentProvider contentProvider= (GenerateConstructorUsingFieldsContentProvider) getTreeViewer().getContentProvider();
- contentProvider.up(getElementList(), getTreeViewer());
- updateOKStatus();
- break;
- }
- case DOWN_BUTTON: {
- GenerateConstructorUsingFieldsContentProvider contentProvider= (GenerateConstructorUsingFieldsContentProvider) getTreeViewer().getContentProvider();
- contentProvider.down(getElementList(), getTreeViewer());
- updateOKStatus();
- break;
- }
- }
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IJavaHelpContextIds.GENERATE_CONSTRUCTOR_USING_FIELDS_SELECTION_DIALOG);
- }
-
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- GridData gd= null;
-
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
-
- Composite classConstructorComposite= addSuperClassConstructorChoices(composite);
- gd= new GridData(GridData.FILL_BOTH);
- classConstructorComposite.setLayoutData(gd);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout innerLayout= new GridLayout();
- innerLayout.numColumns= 2;
- innerLayout.marginHeight= 0;
- innerLayout.marginWidth= 0;
- inner.setLayout(innerLayout);
-
- Label messageLabel= createMessageArea(inner);
- if (messageLabel != null) {
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- messageLabel.setLayoutData(gd);
- }
-
- CheckboxTreeViewer treeViewer= createTreeViewer(inner);
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(fWidth);
- gd.heightHint= convertHeightInCharsToPixels(fHeight);
- treeViewer.getControl().setLayoutData(gd);
- treeViewer.addSelectionChangedListener(fTreeViewerAdapter);
-
- Composite buttonComposite= createSelectionButtons(inner);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- buttonComposite.setLayoutData(gd);
-
- gd= new GridData(GridData.FILL_BOTH);
- inner.setLayoutData(gd);
-
- Composite entryComposite= createInsertPositionCombo(composite);
- entryComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite commentComposite= createCommentSelection(composite);
- commentComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite overrideSuperComposite= createOmitSuper(composite);
- overrideSuperComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control linkControl= createLinkControl(composite);
- if (linkControl != null)
- linkControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- applyDialogFont(composite);
-
- return composite;
- }
-
- protected Composite createInsertPositionCombo(Composite composite) {
- Composite entryComposite= super.createInsertPositionCombo(composite);
- addVisibilityAndModifiersChoices(entryComposite);
- return entryComposite;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.dialogs.SourceActionDialog#createLinkControl(org.eclipse.swt.widgets.Composite)
- */
- protected Control createLinkControl(Composite composite) {
- Link link= new Link(composite, SWT.WRAP);
- link.setText(ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_template_link_message);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- openCodeTempatePage(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID);
- }
- });
- link.setToolTipText(ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_template_link_tooltip);
-
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= convertWidthInCharsToPixels(40); // only expand further if anyone else requires it
- link.setLayoutData(gridData);
- return link;
- }
-
- protected Composite createOmitSuper(Composite composite) {
- Composite omitSuperComposite= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- omitSuperComposite.setLayout(layout);
-
- fOmitSuperButton= new Button(omitSuperComposite, SWT.CHECK);
- fOmitSuperButton.setText(ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_omit_super);
- fOmitSuperButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- fOmitSuperButton.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- boolean isSelected= (((Button) e.widget).getSelection());
- setOmitSuper(isSelected);
- }
- });
- fOmitSuperButton.setSelection(isOmitSuper());
- try {
- // Disable omit super checkbox unless default constructor and enum
- final boolean hasContructor= getSuperConstructorChoice().getParameterTypes().length == 0;
- fOmitSuperButton.setEnabled(hasContructor && !getType().isEnum());
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- fOmitSuperButton.setLayoutData(gd);
-
- return omitSuperComposite;
- }
-
- protected Composite createSelectionButtons(Composite composite) {
- Composite buttonComposite= super.createSelectionButtons(composite);
-
- GridLayout layout= new GridLayout();
- buttonComposite.setLayout(layout);
-
- createUpDownButtons(buttonComposite);
-
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 1;
-
- return buttonComposite;
- }
-
- void createUpDownButtons(Composite buttonComposite) {
- int numButtons= 2; // up, down
- fButtonControls= new Button[numButtons];
- fButtonsEnabled= new boolean[numButtons];
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.UP_INDEX]= createButton(buttonComposite, UP_BUTTON, ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_up_button, false);
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.DOWN_INDEX]= createButton(buttonComposite, DOWN_BUTTON, ActionMessages.GenerateConstructorUsingFieldsSelectionDialog_down_button, false);
- boolean defaultState= false;
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.UP_INDEX].setEnabled(defaultState);
- fButtonControls[GenerateConstructorUsingFieldsSelectionDialog.DOWN_INDEX].setEnabled(defaultState);
- fButtonsEnabled[GenerateConstructorUsingFieldsSelectionDialog.UP_INDEX]= defaultState;
- fButtonsEnabled[GenerateConstructorUsingFieldsSelectionDialog.DOWN_INDEX]= defaultState;
- }
-
- protected Composite createVisibilityControlAndModifiers(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) {
- int[] visibilities= availableVisibilities;
- try {
- if (getType().isEnum())
- visibilities= new int[] { };
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- return createVisibilityControl(parent, visibilityChangeListener, visibilities, correctVisibility);
- }
-
- List getElementList() {
- IStructuredSelection selection= (IStructuredSelection) getTreeViewer().getSelection();
- List elements= selection.toList();
- ArrayList elementList= new ArrayList();
-
- for (int i= 0; i < elements.size(); i++) {
- elementList.add(elements.get(i));
- }
- return elementList;
- }
-
- public IFunctionBinding getSuperConstructorChoice() {
- return fSuperConstructors[fSuperIndex];
- }
-
- public boolean isOmitSuper() {
- return fOmitSuper;
- }
-
- public void setOmitSuper(boolean omitSuper) {
- if (fOmitSuper != omitSuper) {
- fOmitSuper= omitSuper;
- fGenConstructorSettings.put(OMIT_SUPER, omitSuper);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsValidator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsValidator.java
deleted file mode 100644
index 2f6e2432..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateConstructorUsingFieldsValidator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-
-public class GenerateConstructorUsingFieldsValidator implements ISelectionStatusValidator {
-
- private GenerateConstructorUsingFieldsSelectionDialog fDialog;
-
- private final int fEntries;
-
- private List fSignatures;
-
- private ITypeBinding fType= null;
-
- public GenerateConstructorUsingFieldsValidator(GenerateConstructorUsingFieldsSelectionDialog dialog, ITypeBinding type, int entries) {
- fEntries= entries;
- fDialog= dialog;
- fType= type;
- fSignatures= getExistingConstructorSignatures();
- }
-
- public GenerateConstructorUsingFieldsValidator(int entries) {
- fEntries= entries;
- fType= null;
- }
-
- private int countSelectedFields(Object[] selection) {
- int count= 0;
- for (int index= 0; index < selection.length; index++) {
- if (selection[index] instanceof IVariableBinding)
- count++;
- }
- return count;
- }
-
- private void createSignature(final IFunctionBinding constructor, StringBuffer buffer, Object[] selection) {
- ITypeBinding types[]= constructor.getParameterTypes();
- for (int index= 0; index < types.length; index++)
- buffer.append(types[index].getName());
- if (selection != null) {
- for (int index= 0; index < selection.length; index++)
- if (selection[index] instanceof IVariableBinding)
- buffer.append(((IVariableBinding) selection[index]).getType().getErasure().getName());
- }
- }
-
- private List getExistingConstructorSignatures() {
- List existing= new ArrayList();
- IFunctionBinding[] methods= fType.getDeclaredMethods();
- for (int index= 0; index < methods.length; index++) {
- if (methods[index].isConstructor()) {
- StringBuffer buffer= new StringBuffer();
- createSignature(methods[index], buffer, null);
- existing.add(buffer.toString());
- }
- }
- return existing;
- }
-
- public IStatus validate(Object[] selection) {
- StringBuffer buffer= new StringBuffer();
- final IFunctionBinding constructor= fDialog.getSuperConstructorChoice();
- createSignature(constructor, buffer, selection);
- if (fSignatures.contains(buffer.toString()))
- return new StatusInfo(IStatus.WARNING, ActionMessages.GenerateConstructorUsingFieldsAction_error_duplicate_constructor);
- return new StatusInfo(IStatus.INFO, Messages.format(ActionMessages.GenerateConstructorUsingFieldsAction_fields_selected, new Object[] { String.valueOf(countSelectedFields(selection)), String.valueOf(fEntries)}));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateJavadocAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateJavadocAction.java
deleted file mode 100644
index 54b9e272..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/GenerateJavadocAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-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.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.wst.jsdt.internal.ui.javadocexport.JavadocWizard;
-
-public class GenerateJavadocAction implements IWorkbenchWindowActionDelegate {
-
- private ISelection fSelection;
- private Shell fCurrentShell;
-
- public void dispose() {
- }
-
- public void init(IWorkbenchWindow window) {
- fCurrentShell= window.getShell();
- }
-
- public void run(IAction action) {
- JavadocWizard wizard= new JavadocWizard();
- IStructuredSelection selection= null;
- if (fSelection instanceof IStructuredSelection) {
- selection= (IStructuredSelection)fSelection;
- } else {
- selection= new StructuredSelection();
- }
- JavadocWizard.openJavadocWizard(wizard, fCurrentShell, selection);
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection= selection;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/IndentAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/IndentAction.java
deleted file mode 100644
index 1c871179..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/IndentAction.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaIndenter;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-/**
- * Indents a line or range of lines in a Java document to its correct position. No complete
- * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for
- * single lines, but does not store any information and therefore not so efficient for large line
- * ranges.
- *
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaIndenter
- *
- */
-public class IndentAction extends TextEditorAction {
-
- /** The caret offset after an indent operation. */
- private int fCaretOffset;
-
- /**
- * Whether this is the action invoked by TAB. When <code>true</code>, indentation behaves
- * differently to accommodate normal TAB operation.
- */
- private final boolean fIsTabAction;
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix the prefix to use for keys in <code>bundle</code>
- * @param editor the text editor
- * @param isTabAction whether the action should insert tabs if over the indentation
- */
- public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean isTabAction) {
- super(bundle, prefix, editor);
- fIsTabAction= isTabAction;
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- // update has been called by the framework
- if (!isEnabled() || !validateEditorInputState())
- return;
-
- ITextSelection selection= getSelection();
- final IDocument document= getDocument();
-
- if (document != null) {
-
- final int offset= selection.getOffset();
- final int length= selection.getLength();
- final Position end= new Position(offset + length);
- final int firstLine, nLines;
- fCaretOffset= -1;
-
- try {
- document.addPosition(end);
- firstLine= document.getLineOfOffset(offset);
- // check for marginal (zero-length) lines
- int minusOne= length == 0 ? 0 : 1;
- nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
- } catch (BadLocationException e) {
- // will only happen on concurrent modification
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$
- return;
- }
-
- Runnable runnable= new Runnable() {
- public void run() {
- IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class);
- if (target != null)
- target.beginCompoundChange();
-
- try {
- JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
- JavaIndenter indenter= new JavaIndenter(document, scanner, getJavaProject());
- final boolean multiLine= nLines > 1;
- boolean hasChanged= false;
- for (int i= 0; i < nLines; i++) {
- hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine);
- }
-
- // update caret position: move to new position when indenting just one line
- // keep selection when indenting multiple
- int newOffset, newLength;
- if (!fIsTabAction && multiLine) {
- newOffset= offset;
- newLength= end.getOffset() - offset;
- } else {
- newOffset= fCaretOffset;
- newLength= 0;
- }
-
- // always reset the selection if anything was replaced
- // but not when we had a single line non-tab invocation
- if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length))
- selectAndReveal(newOffset, newLength);
-
- document.removePosition(end);
- } catch (BadLocationException e) {
- // will only happen on concurrent modification
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
-
- } finally {
- if (target != null)
- target.endCompoundChange();
- }
- }
- };
-
- if (nLines > 50) {
- Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
- BusyIndicator.showWhile(display, runnable);
- } else
- runnable.run();
-
- }
- }
-
- /**
- * Selects the given range on the editor.
- *
- * @param newOffset the selection offset
- * @param newLength the selection range
- */
- private void selectAndReveal(int newOffset, int newLength) {
- Assert.isTrue(newOffset >= 0);
- Assert.isTrue(newLength >= 0);
- ITextEditor editor= getTextEditor();
- if (editor instanceof JavaEditor) {
- ISourceViewer viewer= ((JavaEditor)editor).getViewer();
- if (viewer != null)
- viewer.setSelectedRange(newOffset, newLength);
- } else
- // this is too intrusive, but will never get called anyway
- getTextEditor().selectAndReveal(newOffset, newLength);
-
- }
-
- /**
- * Indents a single line using the java heuristic scanner. Javadoc and multiline comments are
- * indented as specified by the <code>JavaDocAutoIndentStrategy</code>.
- *
- * @param document the document
- * @param line the line to be indented
- * @param caret the caret position
- * @param indenter the java indenter
- * @param scanner the heuristic scanner
- * @param multiLine <code>true</code> if more than one line is being indented
- * @return <code>true</code> if <code>document</code> was modified, <code>false</code> otherwise
- * @throws BadLocationException if the document got changed concurrently
- */
- private boolean indentLine(IDocument document, int line, int caret, JavaIndenter indenter, JavaHeuristicScanner scanner, boolean multiLine) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- int offset= currentLine.getOffset();
- int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
-
- String indent= null;
- if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, false);
- String type= partition.getType();
- if (type.equals(IJavaScriptPartitions.JAVA_DOC) || type.equals(IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT)) {
- indent= computeJavadocIndent(document, line, scanner, startingPartition);
- } else if (!fIsTabAction && startingPartition.getOffset() == offset && startingPartition.getType().equals(IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT)) {
-
- // line comment starting at position 0 -> indent inside
- int max= document.getLength() - offset;
- int slashes= 2;
- while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$
- slashes+= 2;
-
- wsStart= offset + slashes;
-
- StringBuffer computed= indenter.computeIndentation(offset);
- if (computed == null)
- computed= new StringBuffer(0);
- int tabSize= getTabSize();
- while (slashes > 0 && computed.length() > 0) {
- char c= computed.charAt(0);
- if (c == '\t')
- if (slashes > tabSize)
- slashes-= tabSize;
- else
- break;
- else if (c == ' ')
- slashes--;
- else break;
-
- computed.deleteCharAt(0);
- }
-
- indent= document.get(offset, wsStart - offset) + computed;
-
- }
- }
-
- // standard java indentation
- if (indent == null) {
- StringBuffer computed= indenter.computeIndentation(offset);
- if (computed != null)
- indent= computed.toString();
- else
- indent= ""; //$NON-NLS-1$
- }
-
- // change document:
- // get current white space
- int lineLength= currentLine.getLength();
- int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
- if (end == JavaHeuristicScanner.NOT_FOUND) {
- // an empty line
- end= offset + lineLength;
- if (multiLine && !indentEmptyLines())
- indent= ""; //$NON-NLS-1$
- }
- int length= end - offset;
- String currentIndent= document.get(offset, length);
-
- // if we are right before the text start / line end, and already after the insertion point
- // then just insert a tab.
- if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) {
- String tab= getTabEquivalent();
- document.replace(caret, 0, tab);
- fCaretOffset= caret + tab.length();
- return true;
- }
-
- // set the caret offset so it can be used when setting the selection
- if (caret >= offset && caret <= end)
- fCaretOffset= offset + indent.length();
- else
- fCaretOffset= -1;
-
- // only change the document if it is a real change
- if (!indent.equals(currentIndent)) {
- document.replace(offset, length, indent);
- return true;
- } else
- return false;
- }
-
- /**
- * Computes and returns the indentation for a javadoc line. The line
- * must be inside a javadoc comment.
- *
- * @param document the document
- * @param line the line in document
- * @param scanner the scanner
- * @param partition the javadoc partition
- * @return the indent, or <code>null</code> if not computable
- * @throws BadLocationException
- *
- */
- private String computeJavadocIndent(IDocument document, int line, JavaHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
- if (line == 0) // impossible - the first line is never inside a javadoc comment
- return null;
-
- // don't make any assumptions if the line does not start with \s*\* - it might be
- // commented out code, for which we don't want to change the indent
- final IRegion lineInfo= document.getLineInformation(line);
- final int lineStart= lineInfo.getOffset();
- final int lineLength= lineInfo.getLength();
- final int lineEnd= lineStart + lineLength;
- int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
- if (nonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
- if (nonWS == JavaHeuristicScanner.NOT_FOUND)
- return document.get(lineStart, lineLength);
- return document.get(lineStart, nonWS - lineStart);
- }
-
- // take the indent from the previous line and reuse
- IRegion previousLine= document.getLineInformation(line - 1);
- int previousLineStart= previousLine.getOffset();
- int previousLineLength= previousLine.getLength();
- int previousLineEnd= previousLineStart + previousLineLength;
-
- StringBuffer buf= new StringBuffer();
- int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
- if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
- // align with the comment start if the previous line is not an asterisked line
- previousLine= document.getLineInformationOfOffset(partition.getOffset());
- previousLineStart= previousLine.getOffset();
- previousLineLength= previousLine.getLength();
- previousLineEnd= previousLineStart + previousLineLength;
- previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
- if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND)
- previousLineNonWS= previousLineEnd;
-
- // add the initial space
- // TODO this may be controlled by a formatter preference in the future
- buf.append(' ');
- }
-
- String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
- buf.insert(0, indentation);
- return buf.toString();
- }
-
- /**
- * Returns the size in characters of a string. All characters count one, tabs count the editor's
- * preference for the tab display
- *
- * @param indent the string to be measured.
- * @return the size in characters of a string
- */
- private int whiteSpaceLength(String indent) {
- if (indent == null)
- return 0;
- else {
- int size= 0;
- int l= indent.length();
- int tabSize= getTabSize();
-
- for (int i= 0; i < l; i++)
- size += indent.charAt(i) == '\t' ? tabSize : 1;
- return size;
- }
- }
-
- /**
- * Returns a tab equivalent, either as a tab character or as spaces, depending on the editor and
- * formatter preferences.
- *
- * @return a string representing one tab in the editor, never <code>null</code>
- */
- private String getTabEquivalent() {
- String tab;
- if (JavaScriptCore.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
- int size= getTabSize();
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i< size; i++)
- buf.append(' ');
- tab= buf.toString();
- } else
- tab= "\t"; //$NON-NLS-1$
-
- return tab;
- }
-
- /**
- * Returns the tab size used by the java editor, which is deduced from the
- * formatter preferences.
- *
- * @return the tab size as defined in the current formatter preferences
- */
- private int getTabSize() {
- return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 4);
- }
-
- /**
- * Returns <code>true</code> if empty lines should be indented, false otherwise.
- *
- * @return <code>true</code> if empty lines should be indented, false otherwise
- *
- */
- private boolean indentEmptyLines() {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
- }
-
- /**
- * Returns the possibly project-specific core preference defined under <code>key</code>.
- *
- * @param key the key of the preference
- * @return the value of the preference
- *
- */
- private String getCoreFormatterOption(String key) {
- IJavaScriptProject project= getJavaProject();
- if (project == null)
- return JavaScriptCore.getOption(key);
- return project.getOption(key, true);
- }
-
- /**
- * Returns the possibly project-specific core preference defined under <code>key</code>, or
- * <code>def</code> if the value is not a integer.
- *
- * @param key the key of the preference
- * @param def the default value
- * @return the value of the preference
- *
- */
- private int getCoreFormatterOption(String key, int def) {
- try {
- return Integer.parseInt(getCoreFormatterOption(key));
- } catch (NumberFormatException e) {
- return def;
- }
- }
-
- /**
- * Returns the <code>IJavaScriptProject</code> of the current editor input, or
- * <code>null</code> if it cannot be found.
- *
- * @return the <code>IJavaScriptProject</code> of the current editor input, or
- * <code>null</code> if it cannot be found
- *
- */
- private IJavaScriptProject getJavaProject() {
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return null;
-
- IJavaScriptUnit cu= JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- if (cu == null)
- return null;
- return cu.getJavaScriptProject();
- }
-
- /**
- * Returns the editor's selection provider.
- *
- * @return the editor's selection provider or <code>null</code>
- */
- private ISelectionProvider getSelectionProvider() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- return editor.getSelectionProvider();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (isEnabled())
- if (fIsTabAction)
- setEnabled(canModifyEditor() && isSmartMode() && isValidSelection());
- else
- setEnabled(canModifyEditor() && !getSelection().isEmpty());
- }
-
- /**
- * Returns if the current selection is valid, i.e. whether it is empty and the caret in the
- * whitespace at the start of a line, or covers multiple lines.
- *
- * @return <code>true</code> if the selection is valid for an indent operation
- */
- private boolean isValidSelection() {
- ITextSelection selection= getSelection();
- if (selection.isEmpty())
- return false;
-
- int offset= selection.getOffset();
- int length= selection.getLength();
-
- IDocument document= getDocument();
- if (document == null)
- return false;
-
- try {
- IRegion firstLine= document.getLineInformationOfOffset(offset);
- int lineOffset= firstLine.getOffset();
-
- // either the selection has to be empty and the caret in the WS at the line start
- // or the selection has to extend over multiple lines
- if (length == 0)
- return document.get(lineOffset, offset - lineOffset).trim().length() == 0;
- else
-// return lineOffset + firstLine.getLength() < offset + length;
- return false; // only enable for empty selections for now
-
- } catch (BadLocationException e) {
- }
-
- return false;
- }
-
- /**
- * Returns the smart preference state.
- *
- * @return <code>true</code> if smart mode is on, <code>false</code> otherwise
- */
- private boolean isSmartMode() {
- ITextEditor editor= getTextEditor();
-
- if (editor instanceof ITextEditorExtension3)
- return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
-
- return false;
- }
-
- /**
- * Returns the document currently displayed in the editor, or <code>null</code> if none can be
- * obtained.
- *
- * @return the current document or <code>null</code>
- */
- private IDocument getDocument() {
-
- ITextEditor editor= getTextEditor();
- if (editor != null) {
-
- IDocumentProvider provider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
- if (provider != null && input != null)
- return provider.getDocument(input);
-
- }
- return null;
- }
-
- /**
- * Returns the selection on the editor or an invalid selection if none can be obtained. Returns
- * never <code>null</code>.
- *
- * @return the current selection, never <code>null</code>
- */
- private ITextSelection getSelection() {
- ISelectionProvider provider= getSelectionProvider();
- if (provider != null) {
-
- ISelection selection= provider.getSelection();
- if (selection instanceof ITextSelection)
- return (ITextSelection) selection;
- }
-
- // null object
- return TextSelection.emptySelection();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/JDTQuickMenuAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/JDTQuickMenuAction.java
deleted file mode 100644
index 570c9ac6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/JDTQuickMenuAction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
-
-
-public abstract class JDTQuickMenuAction extends QuickMenuAction {
-
- private JavaEditor fEditor;
-
- public JDTQuickMenuAction(String commandId) {
- super(commandId);
- }
-
- public JDTQuickMenuAction(JavaEditor editor, String commandId) {
- super(commandId);
- fEditor= editor;
- }
-
- protected Point computeMenuLocation(StyledText text) {
- if (fEditor == null || text != fEditor.getViewer().getTextWidget())
- return null;
- return computeWordStart();
- }
-
- private Point computeWordStart() {
- ITextSelection selection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
- IRegion textRegion= JavaWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
- if (textRegion == null)
- return null;
-
- IRegion widgetRegion= modelRange2WidgetRange(textRegion);
- if (widgetRegion == null)
- return null;
-
- int start= widgetRegion.getOffset();
-
- StyledText styledText= fEditor.getViewer().getTextWidget();
- Point result= styledText.getLocationAtOffset(start);
- result.y+= styledText.getLineHeight(start);
-
- if (!styledText.getClientArea().contains(result))
- return null;
- return result;
- }
-
- private IRegion modelRange2WidgetRange(IRegion region) {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= viewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/LexicalSortingAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/LexicalSortingAction.java
deleted file mode 100644
index 7ddd0d13..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/LexicalSortingAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingMessages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.SourcePositionComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-
-/*
- * XXX: This class should become part of the MemberFilterActionGroup
- * which should be renamed to MemberActionsGroup
- */
-public class LexicalSortingAction extends Action {
- private JavaScriptElementComparator fComparator= new JavaScriptElementComparator();
- private SourcePositionComparator fSourcePositonComparator= new SourcePositionComparator();
- private StructuredViewer fViewer;
- private String fPreferenceKey;
-
- public LexicalSortingAction(StructuredViewer viewer, String id) {
- super();
- fViewer= viewer;
- fPreferenceKey= "LexicalSortingAction." + id + ".isChecked"; //$NON-NLS-1$ //$NON-NLS-2$
- setText(JavaBrowsingMessages.LexicalSortingAction_label);
- JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
- setToolTipText(JavaBrowsingMessages.LexicalSortingAction_tooltip);
- setDescription(JavaBrowsingMessages.LexicalSortingAction_description);
- boolean checked= JavaScriptPlugin.getDefault().getPreferenceStore().getBoolean(fPreferenceKey);
- valueChanged(checked, false);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_BROWSING_ACTION);
- }
-
- public void run() {
- valueChanged(isChecked(), true);
- }
-
- private void valueChanged(final boolean on, boolean store) {
- setChecked(on);
- BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- if (on)
- fViewer.setComparator(fComparator);
- else
- fViewer.setComparator(fSourcePositonComparator);
- }
- });
-
- if (store)
- JavaScriptPlugin.getDefault().getPreferenceStore().setValue(fPreferenceKey, on);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiActionGroup.java
deleted file mode 100644
index dbb31db3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiActionGroup.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * A MultiActionGroup will display a list of IActions in a menu by transforming them
- * into MenuItems. The list of labels given will be what is displayed in the ViewMenu for
- * the corresponding action (the action at the same position in the action array).
- * The actions are currently implemented as state based
- * so that after an action is executed the label will have a selection check.
- *
- *
- */
-public class MultiActionGroup extends ActionGroup {
-
- public IAction[] NO_ACTIONS = new IAction[0];
-
- private IAction[] fActions;
-
- private int fCurrentSelection;
- private MenuItem[] fItems;
-
- /**
- * Creates a new action group with a given set of actions.
- *
- * @param actions the actions for this multi group
- * @param currentSelection decides which action is selected in the menu on start up.
- * Denotes the location in the actions array of the current
- * selected state. It cannot be null.
- */
- public MultiActionGroup(IAction[] actions, int currentSelection) {
- super();
- setActions(actions, currentSelection);
- }
-
- /**
- * Creates a new action group. Clients using this constructor must set the actions
- * immediately after creating the multi action group by calling {@link #setActions(IAction[], int)}.
- */
- protected MultiActionGroup() {
- super();
- }
-
- /**
- * Sets the given actions.
- *
- * @param actions the actions for this multi group, at least one
- * @param currentSelection decides which action is selected in the menu on start up.
- * Denotes the location in the actions array of the current
- * selected state. It cannot be null.
- */
- protected final void setActions(IAction[] actions, int currentSelection) {
- fCurrentSelection= currentSelection;
- fActions = actions;
- }
-
- /**
- * Adds the actions to the given menu manager.
- */
- protected void addActions(IMenuManager viewMenu) {
-
- viewMenu.add(new Separator());
- fItems= new MenuItem[fActions.length];
-
- for (int i= 0; i < fActions.length; i++) {
- final int j= i;
-
- viewMenu.add(new ContributionItem() {
-
- public void fill(Menu menu, int index) {
-
- int style= SWT.CHECK;
- if ((fActions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0)
- style= SWT.RADIO;
-
- MenuItem mi= new MenuItem(menu, style, index);
- ImageDescriptor d= fActions[j].getImageDescriptor();
- mi.setImage(JavaScriptPlugin.getImageDescriptorRegistry().get(d));
- fItems[j]= mi;
- mi.setText(fActions[j].getText());
- mi.setSelection(fCurrentSelection == j);
- mi.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if (fCurrentSelection == j) {
- fItems[fCurrentSelection].setSelection(true);
- return;
- }
- fActions[j].run();
-
- // Update checked state
- fItems[fCurrentSelection].setSelection(false);
- fCurrentSelection= j;
- fItems[fCurrentSelection].setSelection(true);
- }
-
- });
- }
- public boolean isDynamic() {
- return false;
- }
- });
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiOrganizeImportAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiOrganizeImportAction.java
deleted file mode 100644
index 21c9cf61..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiOrganizeImportAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.ImportsCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class MultiOrganizeImportAction extends CleanUpAction {
-
- public MultiOrganizeImportAction(IWorkbenchSite site) {
- super(site);
-
- setText(ActionMessages.OrganizeImportsAction_label);
- setToolTipText(ActionMessages.OrganizeImportsAction_tooltip);
- setDescription(ActionMessages.OrganizeImportsAction_description);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
- }
-
- public MultiOrganizeImportAction(JavaEditor editor) {
- super(editor);
-
- setText(ActionMessages.OrganizeImportsAction_label);
- setToolTipText(ActionMessages.OrganizeImportsAction_tooltip);
- setDescription(ActionMessages.OrganizeImportsAction_description);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
- }
-
- protected ICleanUp[] createCleanUps(IJavaScriptUnit[] units) {
- Map settings= new Hashtable();
- settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE);
- ImportsCleanUp importsCleanUp= new ImportsCleanUp(settings);
-
- return new ICleanUp[] {
- importsCleanUp
- };
- }
-
- protected String getActionName() {
- return ActionMessages.OrganizeImportsAction_error_title;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiSortMembersAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiSortMembersAction.java
deleted file mode 100644
index 6ae20588..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/MultiSortMembersAction.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.Hashtable;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.SortMembersMessageDialog;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.SortMembersCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class MultiSortMembersAction extends CleanUpAction {
-
- public MultiSortMembersAction(IWorkbenchSite site) {
- super(site);
-
- setText(ActionMessages.SortMembersAction_label);
- setDescription(ActionMessages.SortMembersAction_description);
- setToolTipText(ActionMessages.SortMembersAction_tooltip);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SORT_MEMBERS_ACTION);
- }
-
- public MultiSortMembersAction(JavaEditor editor) {
- super(editor);
-
- setText(ActionMessages.SortMembersAction_label);
- setDescription(ActionMessages.SortMembersAction_description);
- setToolTipText(ActionMessages.SortMembersAction_tooltip);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SORT_MEMBERS_ACTION);
- }
-
- /**
- * {@inheritDoc}
- */
- protected ICleanUp[] createCleanUps(IJavaScriptUnit[] units) {
- try {
- if (!hasMembersToSort(units))
- return null;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return null;
- }
-
- SortMembersMessageDialog dialog= new SortMembersMessageDialog(getShell());
- if (dialog.open() != Window.OK)
- return null;
-
- Hashtable settings= new Hashtable();
- settings.put(CleanUpConstants.SORT_MEMBERS, CleanUpConstants.TRUE);
- settings.put(CleanUpConstants.SORT_MEMBERS_ALL, !dialog.isNotSortingFieldsEnabled() ? CleanUpConstants.TRUE : CleanUpConstants.FALSE);
-
- return new ICleanUp[] {
- new SortMembersCleanUp(settings)
- };
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getActionName() {
- return ActionMessages.SortMembersAction_dialog_title;
- }
-
- private boolean hasMembersToSort(IJavaScriptUnit[] units) throws JavaScriptModelException {
- for (int i= 0; i < units.length; i++) {
- if (hasMembersToSort(units[i].getChildren()))
- return true;
- }
-
- return false;
- }
-
- private boolean hasMembersToSort(IJavaScriptElement[] members) throws JavaScriptModelException {
- if (members.length > 1)
- return true;
-
- if (members.length == 0)
- return false;
-
- IJavaScriptElement elem= members[0];
- if (!(elem instanceof IParent))
- return false;
-
- return hasMembersToSort(((IParent)elem).getChildren());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/NewWizardsActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/NewWizardsActionGroup.java
deleted file mode 100644
index 3e26a215..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/NewWizardsActionGroup.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.NewWizardMenu;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-
-
-/**
- * Action group that adds the 'new' menu to a context menu.
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- *
- */
-public class NewWizardsActionGroup extends ActionGroup {
-
- private IWorkbenchSite fSite;
-
- /**
- * Creates a new <code>NewWizardsActionGroup</code>. The group requires
- * that the selection provided by the part's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the view part that owns this action group
- */
- public NewWizardsActionGroup(IWorkbenchSite site) {
- fSite= site;
- }
-
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
-
- ISelection selection= getContext().getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection sel= (IStructuredSelection) selection;
- if (sel.size() <= 1 && isNewTarget(sel.getFirstElement())) {
- MenuManager newMenu = new MenuManager(ActionMessages.NewWizardsActionGroup_new);
- menu.appendToGroup(IContextMenuConstants.GROUP_NEW, newMenu);
- newMenu.add(new NewWizardMenu(fSite.getWorkbenchWindow()));
- }
- }
-
- }
-
- private boolean isNewTarget(Object element) {
- if (element == null)
- return true;
- if (element instanceof IResource) {
- return true;
- }
- if (element instanceof IJavaScriptElement) {
- int type= ((IJavaScriptElement)element).getElementType();
- return type == IJavaScriptElement.JAVASCRIPT_PROJECT ||
- type == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT ||
- type == IJavaScriptElement.PACKAGE_FRAGMENT ||
- type == IJavaScriptElement.JAVASCRIPT_UNIT ||
- type == IJavaScriptElement.TYPE;
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OccurrencesSearchMenuAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OccurrencesSearchMenuAction.java
deleted file mode 100644
index b4b515c3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OccurrencesSearchMenuAction.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-import org.eclipse.ui.actions.RetargetAction;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchMessages;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants;
-
-/**
- * <p>
- * This is required because of
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79162
- * and
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=137679
- * </p>
- */
-public class OccurrencesSearchMenuAction implements IWorkbenchWindowPulldownDelegate2 {
-
- private static Action NO_ACTION_AVAILABLE= new Action(SearchMessages.group_occurrences_quickMenu_noEntriesAvailable) {
- public boolean isEnabled() {
- return false;
- }
- };
-
- private Menu fMenu;
-
- private IPartService fPartService;
- private RetargetAction[] fRetargetActions;
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Menu parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- return fMenu;
- }
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Control parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- return fMenu;
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- setMenu(null);
- disposeSubmenuActions();
- }
-
- private RetargetAction createSubmenuAction(IPartService partService, String actionID, String text, String actionDefinitionId) {
- RetargetAction action= new RetargetAction(actionID, text);
- action.setActionDefinitionId(actionDefinitionId);
-
- partService.addPartListener(action);
- IWorkbenchPart activePart = partService.getActivePart();
- if (activePart != null) {
- action.partActivated(activePart);
- }
- return action;
- }
-
- private void disposeSubmenuActions() {
- if (fPartService != null && fRetargetActions != null) {
- for (int i= 0; i < fRetargetActions.length; i++) {
- fPartService.removePartListener(fRetargetActions[i]);
- fRetargetActions[i].dispose();
- }
- }
- fRetargetActions= null;
- fPartService= null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(IWorkbenchWindow window) {
- disposeSubmenuActions(); // paranoia code: double initialization should not happen
- if (window != null) {
- fPartService= window.getPartService();
- if (fPartService != null) {
- fRetargetActions= new RetargetAction[] {
- createSubmenuAction(fPartService, JdtActionConstants.FIND_OCCURRENCES_IN_FILE, SearchMessages.Search_FindOccurrencesInFile_shortLabel, IJavaEditorActionDefinitionIds.SEARCH_OCCURRENCES_IN_FILE),
-// createSubmenuAction(fPartService, JdtActionConstants.FIND_IMPLEMENT_OCCURRENCES, ActionMessages.FindImplementOccurrencesAction_text, IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENT_OCCURRENCES_IN_FILE),
-// createSubmenuAction(fPartService, JdtActionConstants.FIND_EXCEPTION_OCCURRENCES, ActionMessages.FindExceptionOccurrences_text, IJavaEditorActionDefinitionIds.SEARCH_EXCEPTION_OCCURRENCES_IN_FILE),
- };
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IAction action) {
- JavaEditor editor= null;
- IWorkbenchPart activePart= JavaScriptPlugin.getActivePage().getActivePart();
- if (activePart instanceof JavaEditor)
- editor= (JavaEditor) activePart;
-
- (new JDTQuickMenuAction(editor, IJavaEditorActionDefinitionIds.SEARCH_OCCURRENCES_IN_FILE_QUICK_MENU) {
- protected void fillMenu(IMenuManager menu) {
- fillQuickMenu(menu);
- }
- }).run();
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- private void fillQuickMenu(IMenuManager manager) {
- IAction[] actions= fRetargetActions;
- if (actions != null) {
- boolean hasAction= false;
- for (int i= 0; i < actions.length; i++) {
- IAction action= actions[i];
- if (action.isEnabled()) {
- hasAction= true;
- manager.add(action);
- }
- }
- if (!hasAction) {
- manager.add(NO_ACTION_AVAILABLE);
- }
- } else {
- manager.add(NO_ACTION_AVAILABLE);
- }
- }
-
- /**
- * The menu to show in the workbench menu
- */
- private void fillMenu(Menu menu) {
- if (fRetargetActions != null) {
- for (int i= 0; i < fRetargetActions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(fRetargetActions[i]);
- item.fill(menu, -1);
- }
- } else {
- // can only happen if 'init' was not called: programming error
- ActionContributionItem item= new ActionContributionItem(NO_ACTION_AVAILABLE);
- item.fill(menu, -1);
- }
- }
-
- private void setMenu(Menu menu) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu = menu;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenBrowserUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenBrowserUtil.java
deleted file mode 100644
index 4c34e5b9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenBrowserUtil.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.net.URL;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-public class OpenBrowserUtil {
-
- public static void open(final URL url, Display display, final String dialogTitle) {
- display.syncExec(new Runnable() {
- public void run() {
- internalOpen(url, dialogTitle);
- }
- });
- }
-
- private static void internalOpen(final URL url, String title) {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(url.toExternalForm() + "?noframes=true"); //$NON-NLS-1$
- }
- });
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeAction.java
deleted file mode 100644
index 80437a76..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeAction.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.OpenTypeSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class OpenTypeAction extends Action implements IWorkbenchWindowActionDelegate, IActionDelegate2 {
-
- public OpenTypeAction() {
- super();
- setText(JavaUIMessages.OpenTypeAction_label);
- setDescription(JavaUIMessages.OpenTypeAction_description);
- setToolTipText(JavaUIMessages.OpenTypeAction_tooltip);
- setImageDescriptor(JavaPluginImages.DESC_TOOL_OPENTYPE);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_TYPE_ACTION);
- }
-
- public void run() {
- runWithEvent(null);
- }
-
- public void runWithEvent(Event e) {
- Shell parent= JavaScriptPlugin.getActiveWorkbenchShell();
- SelectionDialog dialog;
- if (e != null && e.stateMask == SWT.MOD1) {
- // use old open type dialog when MOD1 (but no other modifier) is down:
- dialog= createOpenTypeSelectionDialog2(parent);
- } else {
- dialog= new OpenTypeSelectionDialog(parent, true, PlatformUI.getWorkbench().getProgressService(), null, IJavaScriptSearchConstants.TYPE);
- }
- dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle);
- dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage);
-
- int result= dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- Object[] types= dialog.getResult();
- if (types != null && types.length > 0) {
- IType type= null;
- for (int i= 0; i < types.length; i++) {
- type= (IType) types[i];
- try {
- JavaScriptUI.openInEditor(type, true, true);
- } catch (CoreException x) {
- ExceptionHandler.handle(x, JavaUIMessages.OpenTypeAction_errorTitle, JavaUIMessages.OpenTypeAction_errorMessage);
- }
- }
- }
- }
-
- /**
- * @deprecated
- * @param parent
- * @return the dialog
- */
- private SelectionDialog createOpenTypeSelectionDialog2(Shell parent) {
- return new org.eclipse.wst.jsdt.internal.ui.dialogs.OpenTypeSelectionDialog2(parent, false, PlatformUI.getWorkbench().getProgressService(), null, IJavaScriptSearchConstants.TYPE);
- }
-
- // ---- IWorkbenchWindowActionDelegate
- // ------------------------------------------------
-
- public void run(IAction action) {
- run();
- }
-
- public void dispose() {
- // do nothing.
- }
-
- public void init(IWorkbenchWindow window) {
- // do nothing.
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing. Action doesn't depend on selection.
- }
-
- // ---- IActionDelegate2
- // ------------------------------------------------
-
- public void runWithEvent(IAction action, Event event) {
- runWithEvent(event);
- }
-
- public void init(IAction action) {
- // do nothing.
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeInHierarchyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeInHierarchyAction.java
deleted file mode 100644
index f2f1485f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/OpenTypeInHierarchyAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.OpenTypeSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.util.OpenTypeHierarchyUtil;
-
-public class OpenTypeInHierarchyAction extends Action implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow fWindow;
-
- public OpenTypeInHierarchyAction() {
- super();
- setText(ActionMessages.OpenTypeInHierarchyAction_label);
- setDescription(ActionMessages.OpenTypeInHierarchyAction_description);
- setToolTipText(ActionMessages.OpenTypeInHierarchyAction_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_TYPE_IN_HIERARCHY_ACTION);
- }
-
- public void run() {
- Shell parent= JavaScriptPlugin.getActiveWorkbenchShell();
- OpenTypeSelectionDialog dialog= new OpenTypeSelectionDialog(parent, false,
- PlatformUI.getWorkbench().getProgressService(),
- SearchEngine.createWorkspaceScope(), IJavaScriptSearchConstants.TYPE);
-
- dialog.setTitle(ActionMessages.OpenTypeInHierarchyAction_dialogTitle);
- dialog.setMessage(ActionMessages.OpenTypeInHierarchyAction_dialogMessage);
- int result= dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- Object[] types= dialog.getResult();
- if (types != null && types.length > 0) {
- IType type= (IType)types[0];
- OpenTypeHierarchyUtil.open(new IType[] { type }, fWindow);
- }
- }
-
- //---- IWorkbenchWindowActionDelegate ------------------------------------------------
-
- public void run(IAction action) {
- run();
- }
-
- public void dispose() {
- fWindow= null;
- }
-
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing. Action doesn't depend on selection.
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/QuickMenuAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/QuickMenuAction.java
deleted file mode 100644
index c21fe3bc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/QuickMenuAction.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.keys.IBindingService;
-
-/**
- * A quick menu actions provides support to assign short cuts
- * to sub menus.
- *
- *
- */
-public abstract class QuickMenuAction extends Action {
-
- private static final int CHAR_INDENT= 3;
-
- /**
- * Creates a new quick menu action with the given command id.
- *
- * @param commandId the command id of the short cut used to open
- * the sub menu
- */
- public QuickMenuAction(String commandId) {
- setActionDefinitionId(commandId);
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- Display display= Display.getCurrent();
- if (display == null)
- return;
- Control focus= display.getFocusControl();
- if (focus == null || focus.isDisposed())
- return;
-
- MenuManager menu= new MenuManager();
- fillMenu(menu);
- final Menu widget= menu.createContextMenu(focus.getShell());
- Point location= computeMenuLocation(focus, widget);
- if (location == null)
- return;
- widget.setLocation(location);
- widget.setVisible(true);
- while (!widget.isDisposed() && widget.isVisible()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- if (!widget.isDisposed()) {
- widget.dispose();
- }
- }
-
- /**
- * Hook to fill a menu manager with the items of the sub menu.
- *
- * @param menu the sub menu to fill
- */
- protected abstract void fillMenu(IMenuManager menu);
-
- /**
- * Adds the shortcut to the given menu text and returns it.
- *
- * @param menuText the menu text
- * @return the menu text with the shortcut
- *
- */
- public String addShortcut(String menuText) {
- String shortcut= getShortcutString();
- if (menuText == null || shortcut == null)
- return menuText;
-
- return menuText + '\t' + shortcut;
- }
-
- /**
- * Returns the shortcut assigned to the sub menu or <code>null</code> if
- * no short cut is assigned.
- *
- * @return the shortcut as a human readable string or <code>null</code>
- */
- private String getShortcutString() {
- IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- if (bindingService == null)
- return null;
- return bindingService.getBestActiveBindingFormattedFor(getActionDefinitionId());
- }
-
- private Point computeMenuLocation(Control focus, Menu menu) {
- Point cursorLocation= focus.getDisplay().getCursorLocation();
- Rectangle clientArea= null;
- Point result= null;
- if (focus instanceof StyledText) {
- StyledText styledText= (StyledText)focus;
- clientArea= styledText.getClientArea();
- result= computeMenuLocation(styledText);
- } else if (focus instanceof Tree) {
- Tree tree= (Tree)focus;
- clientArea= tree.getClientArea();
- result= computeMenuLocation(tree);
- } else if (focus instanceof Table) {
- Table table= (Table)focus;
- clientArea= table.getClientArea();
- result= computeMenuLocation(table);
- }
- if (result == null) {
- result= focus.toControl(cursorLocation);
- }
- if (clientArea != null && !clientArea.contains(result)) {
- result= new Point(
- clientArea.x + clientArea.width / 2,
- clientArea.y + clientArea.height / 2);
- }
- Rectangle shellArea= focus.getShell().getClientArea();
- if (!shellArea.contains(focus.getShell().toControl(focus.toDisplay(result)))) {
- result= new Point(
- shellArea.x + shellArea.width / 2,
- shellArea.y + shellArea.height / 2);
- }
- return focus.toDisplay(result);
- }
-
- /**
- * Hook to compute the menu location if the focus widget is
- * a styled text widget.
- *
- * @param text the styled text widget that has the focus
- *
- * @return a widget relative position of the menu to pop up or
- * <code>null</code> if now position inside the widget can
- * be computed
- */
- protected Point computeMenuLocation(StyledText text) {
- int offset= text.getCaretOffset();
- Point result= text.getLocationAtOffset(offset);
- result.y+= text.getLineHeight(offset);
- if (!text.getClientArea().contains(result))
- return null;
- return result;
- }
-
- /**
- * Hook to compute the menu location if the focus widget is
- * a tree widget.
- *
- * @param tree the tree widget that has the focus
- *
- * @return a widget relative position of the menu to pop up or
- * <code>null</code> if now position inside the widget can
- * be computed
- */
- protected Point computeMenuLocation(Tree tree) {
- TreeItem[] items= tree.getSelection();
- Rectangle clientArea= tree.getClientArea();
- switch (items.length) {
- case 0:
- return null;
- case 1:
- Rectangle bounds= items[0].getBounds();
- Rectangle intersect= clientArea.intersection(bounds);
- if (intersect != null && intersect.height == bounds.height) {
- return new Point(
- Math.max(0, bounds.x + getAvarageCharWith(tree) * CHAR_INDENT),
- bounds.y + bounds.height);
- } else {
- return null;
- }
- default:
- Rectangle[] rectangles= new Rectangle[items.length];
- for (int i= 0; i < rectangles.length; i++) {
- rectangles[i]= items[i].getBounds();
- }
- Point cursorLocation= tree.getDisplay().getCursorLocation();
- Point result= findBestLocation(getIncludedPositions(rectangles, clientArea),
- tree.toControl(cursorLocation));
- if (result != null)
- result.x= result.x + getAvarageCharWith(tree) * CHAR_INDENT;
- return result;
- }
- }
-
- /**
- * Hook to compute the menu location if the focus widget is
- * a table widget.
- *
- * @param table the table widget that has the focus
- *
- * @return a widget relative position of the menu to pop up or
- * <code>null</code> if now position inside the widget can
- * be computed
- */
- protected Point computeMenuLocation(Table table) {
- TableItem[] items= table.getSelection();
- Rectangle clientArea= table.getClientArea();
- switch (items.length) {
- case 0: {
- return null;
- } case 1: {
- Rectangle bounds= items[0].getBounds(0);
- Rectangle iBounds= items[0].getImageBounds(0);
- Rectangle intersect= clientArea.intersection(bounds);
- if (intersect != null && intersect.height == bounds.height) {
- return new Point(
- Math.max(0, bounds.x + iBounds.width + getAvarageCharWith(table) * CHAR_INDENT),
- bounds.y + bounds.height);
- } else {
- return null;
- }
- } default: {
- Rectangle[] rectangles= new Rectangle[items.length];
- for (int i= 0; i < rectangles.length; i++) {
- rectangles[i]= items[i].getBounds(0);
- }
- Rectangle iBounds= items[0].getImageBounds(0);
- Point cursorLocation= table.getDisplay().getCursorLocation();
- Point result= findBestLocation(getIncludedPositions(rectangles, clientArea),
- table.toControl(cursorLocation));
- if (result != null)
- result.x= result.x + iBounds.width + getAvarageCharWith(table) * CHAR_INDENT;
- return result;
- }
- }
- }
-
- private Point[] getIncludedPositions(Rectangle[] rectangles, Rectangle widgetBounds) {
- List result= new ArrayList();
- for (int i= 0; i < rectangles.length; i++) {
- Rectangle rectangle= rectangles[i];
- Rectangle intersect= widgetBounds.intersection(rectangle);
- if (intersect != null && intersect.height == rectangle.height) {
- result.add(new Point(intersect.x, intersect.y + intersect.height));
- }
- }
- return (Point[]) result.toArray(new Point[result.size()]);
- }
-
- private Point findBestLocation(Point[] points, Point relativeCursor) {
- Point result= null;
- double bestDist= Double.MAX_VALUE;
- for (int i= 0; i < points.length; i++) {
- Point point= points[i];
- int a= 0;
- int b= 0;
- if (point.x > relativeCursor.x) {
- a= point.x - relativeCursor.x;
- } else {
- a= relativeCursor.x - point.x;
- }
- if (point.y > relativeCursor.y) {
- b= point.y - relativeCursor.y;
- } else {
- b= relativeCursor.y - point.y;
- }
- double dist= Math.sqrt(a * a + b * b);
- if (dist < bestDist) {
- result= point;
- bestDist= dist;
- }
- }
- return result;
- }
-
- private int getAvarageCharWith(Control control) {
- GC gc= null;
- try {
- gc= new GC(control);
- return gc.getFontMetrics().getAverageCharWidth();
- } finally {
- if (gc != null)
- gc.dispose();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/RemoveBlockCommentAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/RemoveBlockCommentAction.java
deleted file mode 100644
index 0cdddeed..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/RemoveBlockCommentAction.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-/**
- * Action that removes the enclosing comment marks from a Java block comment.
- *
- *
- */
-public class RemoveBlockCommentAction extends BlockCommentAction {
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
- * <code>null</code> if none
- * @param editor the text editor
- */
- public RemoveBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.actions.AddBlockCommentAction#runInternal(org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.IDocumentExtension3, org.eclipse.wst.jsdt.internal.ui.actions.AddBlockCommentAction.Edit.EditFactory)
- */
- protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException {
- List edits= new LinkedList();
- int tokenLength= getCommentStart().length();
-
- int offset= selection.getOffset();
- int endOffset= offset + selection.getLength();
-
- ITypedRegion partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, offset, false);
- int partOffset= partition.getOffset();
- int partEndOffset= partOffset + partition.getLength();
-
- while (partEndOffset < endOffset) {
-
- if (partition.getType() == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {
- edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
- edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
- }
-
- partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, partEndOffset, false);
- partOffset= partition.getOffset();
- partEndOffset= partOffset + partition.getLength();
- }
-
- if (partition.getType() == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {
- edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
- edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
- }
-
- executeEdits(edits);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.actions.AddBlockCommentAction#validSelection(org.eclipse.jface.text.ITextSelection)
- */
- protected boolean isValidSelection(ITextSelection selection) {
- return selection != null && !selection.isEmpty();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectAllAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectAllAction.java
deleted file mode 100644
index 77bdfa35..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectAllAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-/**
- * This action selects all entries currently showing in view.
- */
-public class SelectAllAction extends Action {
-
- private StructuredViewer fViewer;
-
- /**
- * Creates the action for a TreeViewer
- */
- public SelectAllAction(TreeViewer viewer) {
- this((StructuredViewer) viewer);
- }
-
- /**
- * Creates the action for a TableViewer
- */
- public SelectAllAction(TableViewer viewer) {
- this((StructuredViewer) viewer);
- }
-
- private SelectAllAction(StructuredViewer viewer) {
- super("selectAll"); //$NON-NLS-1$
- setText(ActionMessages.SelectAllAction_label);
- setToolTipText(ActionMessages.SelectAllAction_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SELECT_ALL_ACTION);
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- private void collectExpandedAndVisible(TreeItem[] items, List result) {
- for (int i= 0; i < items.length; i++) {
- TreeItem item= items[i];
- if (item.getData() != null) {
- result.add(item);
- if (item.getExpanded()) {
- collectExpandedAndVisible(item.getItems(), result);
- }
- }
- }
- }
-
- /**
- * Selects all resources in the view.
- */
- public void run() {
- if (fViewer instanceof TreeViewer) {
- ArrayList allVisible= new ArrayList();
- Tree tree= ((TreeViewer) fViewer).getTree();
- collectExpandedAndVisible(tree.getItems(), allVisible);
- tree.setSelection((TreeItem[]) allVisible.toArray(new TreeItem[allVisible.size()]));
- fViewer.setSelection(fViewer.getSelection());
- } else if (fViewer instanceof TableViewer) {
- ((TableViewer) fViewer).getTable().selectAll();
- // force viewer selection change
- fViewer.setSelection(fViewer.getSelection());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectionConverter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectionConverter.java
deleted file mode 100644
index 96342955..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SelectionConverter.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-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.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.ICodeAssist;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class SelectionConverter {
-
- private static final IJavaScriptElement[] EMPTY_RESULT= new IJavaScriptElement[0];
-
- private SelectionConverter() {
- // no instance
- }
-
- /**
- * Converts the selection provided by the given part into a structured selection.
- * The following conversion rules are used:
- * <ul>
- * <li><code>part instanceof JavaEditor</code>: returns a structured selection
- * using code resolve to convert the editor's text selection.</li>
- * <li><code>part instanceof IWorkbenchPart</code>: returns the part's selection
- * if it is a structured selection.</li>
- * <li><code>default</code>: returns an empty structured selection.</li>
- * </ul>
- */
- public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws JavaScriptModelException {
- if (part instanceof JavaEditor)
- return new StructuredSelection(codeResolve((JavaEditor)part));
- ISelectionProvider provider= part.getSite().getSelectionProvider();
- if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof IStructuredSelection)
- return (IStructuredSelection)selection;
- }
- return StructuredSelection.EMPTY;
- }
-
-
- /**
- * Converts the given structured selection into an array of Java elements.
- * An empty array is returned if one of the elements stored in the structured
- * selection is not of type <code>IJavaScriptElement</code>
- */
- public static IJavaScriptElement[] getElements(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- IJavaScriptElement[] result= new IJavaScriptElement[selection.size()];
- int i= 0;
- for (Iterator iter= selection.iterator(); iter.hasNext(); i++) {
- Object element= iter.next();
- if (!(element instanceof IJavaScriptElement))
- return EMPTY_RESULT;
- result[i]= (IJavaScriptElement)element;
- }
- return result;
- }
- return EMPTY_RESULT;
- }
-
- public static boolean canOperateOn(JavaEditor editor) {
- if (editor == null)
- return false;
- return getInput(editor) != null;
-
- }
-
- public static IJavaScriptElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException {
- IJavaScriptElement input= getInput(editor);
- ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection();
- IJavaScriptElement[] result= performForkedCodeResolve(input, selection);
- if (result.length == 0) {
- result= new IJavaScriptElement[] {input};
- }
- return result;
- }
-
- public static IJavaScriptElement[] codeResolve(JavaEditor editor) throws JavaScriptModelException {
- return codeResolve(editor, true);
- }
-
- /**
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- *
- */
- public static IJavaScriptElement[] codeResolve(JavaEditor editor, boolean primaryOnly) throws JavaScriptModelException {
- return codeResolve(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection());
- }
-
- /**
- * Perform a code resolve in a separate thread.
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- * @throws InterruptedException
- * @throws InvocationTargetException
- *
- */
- public static IJavaScriptElement[] codeResolveForked(JavaEditor editor, boolean primaryOnly) throws InvocationTargetException, InterruptedException {
- return performForkedCodeResolve(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection());
- }
-
- public static IJavaScriptElement getElementAtOffset(JavaEditor editor) throws JavaScriptModelException {
- return getElementAtOffset(editor, true);
- }
-
- /**
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- *
- */
- private static IJavaScriptElement getElementAtOffset(JavaEditor editor, boolean primaryOnly) throws JavaScriptModelException {
- return getElementAtOffset(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection());
- }
-
- public static IType getTypeAtOffset(JavaEditor editor) throws JavaScriptModelException {
- IJavaScriptElement element= SelectionConverter.getElementAtOffset(editor);
- IType type= (IType)element.getAncestor(IJavaScriptElement.TYPE);
- if (type == null) {
- IJavaScriptUnit unit= SelectionConverter.getInputAsCompilationUnit(editor);
- if (unit != null)
- type= unit.findPrimaryType();
- }
- return type;
- }
-
- public static IJavaScriptElement getInput(JavaEditor editor) {
- return getInput(editor, true);
- }
-
- /**
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- *
- */
- private static IJavaScriptElement getInput(JavaEditor editor, boolean primaryOnly) {
- if (editor == null)
- return null;
- return EditorUtility.getEditorInputJavaElement(editor, primaryOnly);
- }
-
- public static ITypeRoot getInputAsTypeRoot(JavaEditor editor) {
- Object editorInput= SelectionConverter.getInput(editor);
- if (editorInput instanceof ITypeRoot)
- return (ITypeRoot)editorInput;
- return null;
- }
-
- public static IJavaScriptUnit getInputAsCompilationUnit(JavaEditor editor) {
- Object editorInput= SelectionConverter.getInput(editor);
- if (editorInput instanceof IJavaScriptUnit)
- return (IJavaScriptUnit)editorInput;
- return null;
- }
-
- public static IClassFile getInputAsClassFile(JavaEditor editor) {
- Object editorInput= SelectionConverter.getInput(editor);
- if (editorInput instanceof IClassFile)
- return (IClassFile)editorInput;
- return null;
- }
-
- private static IJavaScriptElement[] performForkedCodeResolve(final IJavaScriptElement input, final ITextSelection selection) throws InvocationTargetException, InterruptedException {
- final class CodeResolveRunnable implements IRunnableWithProgress {
- IJavaScriptElement[] result;
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- result= codeResolve(input, selection);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- CodeResolveRunnable runnable= new CodeResolveRunnable();
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
- return runnable.result;
- }
-
- public static IJavaScriptElement[] codeResolve(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof ICodeAssist) {
- if (input instanceof IJavaScriptUnit) {
- JavaModelUtil.reconcile((IJavaScriptUnit) input);
- }
- IJavaScriptElement[] elements= ((ICodeAssist)input).codeSelect(selection.getOffset() + selection.getLength(), 0);
- if (elements.length > 0) {
- return elements;
- }
- }
- return EMPTY_RESULT;
- }
-
- public static IJavaScriptElement getElementAtOffset(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cunit= (IJavaScriptUnit) input;
- JavaModelUtil.reconcile(cunit);
- IJavaScriptElement ref= cunit.getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- } else if (input instanceof IClassFile) {
- IJavaScriptElement ref= ((IClassFile)input).getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- }
- return null;
- }
-
-// public static IJavaScriptElement[] resolveSelectedElements(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
-// IJavaScriptElement enclosing= resolveEnclosingElement(input, selection);
-// if (enclosing == null)
-// return EMPTY_RESULT;
-// if (!(enclosing instanceof ISourceReference))
-// return EMPTY_RESULT;
-// ISourceRange sr= ((ISourceReference)enclosing).getSourceRange();
-// if (selection.getOffset() == sr.getOffset() && selection.getLength() == sr.getLength())
-// return new IJavaScriptElement[] {enclosing};
-// }
-
- public static IJavaScriptElement resolveEnclosingElement(JavaEditor editor, ITextSelection selection) throws JavaScriptModelException {
- return resolveEnclosingElement(getInput(editor), selection);
- }
-
- public static IJavaScriptElement resolveEnclosingElement(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- IJavaScriptElement atOffset= null;
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cunit= (IJavaScriptUnit)input;
- JavaModelUtil.reconcile(cunit);
- atOffset= cunit.getElementAt(selection.getOffset());
- } else if (input instanceof IClassFile) {
- IClassFile cfile= (IClassFile)input;
- atOffset= cfile.getElementAt(selection.getOffset());
- } else {
- return null;
- }
- if (atOffset == null) {
- return input;
- } else {
- int selectionEnd= selection.getOffset() + selection.getLength();
- IJavaScriptElement result= atOffset;
- if (atOffset instanceof ISourceReference) {
- ISourceRange range= ((ISourceReference)atOffset).getSourceRange();
- while (range.getOffset() + range.getLength() < selectionEnd) {
- result= result.getParent();
- if (! (result instanceof ISourceReference)) {
- result= input;
- break;
- }
- range= ((ISourceReference)result).getSourceRange();
- }
- }
- return result;
- }
- }
-
- /**
- * Shows a dialog for resolving an ambiguous java element.
- * Utility method that can be called by subclasses.
- */
- public static IJavaScriptElement selectJavaElement(IJavaScriptElement[] elements, Shell shell, String title, String message) {
- int nResults= elements.length;
- if (nResults == 0)
- return null;
- if (nResults == 1)
- return elements[0];
-
- int flags= JavaScriptElementLabelProvider.SHOW_DEFAULT | JavaScriptElementLabelProvider.SHOW_QUALIFIED | JavaScriptElementLabelProvider.SHOW_ROOT;
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new JavaScriptElementLabelProvider(flags));
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.setElements(elements);
-
- if (dialog.open() == Window.OK) {
- return (IJavaScriptElement) dialog.getFirstResult();
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithActionGroup.java
deleted file mode 100644
index 4ae8d0f6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithActionGroup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-
-public class SurroundWithActionGroup extends ActionGroup {
-
- private CompilationUnitEditor fEditor;
-// private SurroundWithTryCatchAction fSurroundWithTryCatchAction;
- private final String fGroup;
-
- public SurroundWithActionGroup(CompilationUnitEditor editor, String group) {
- fEditor= editor;
- fGroup= group;
-// fSurroundWithTryCatchAction= createSurroundWithTryCatchAction(fEditor);
- }
-
- public void fillActionBars(IActionBars actionBar) {
-// actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_CATCH, fSurroundWithTryCatchAction);
- }
-
- /**
- * The Menu to show when right click on the editor
- * {@inheritDoc}
- */
- public void fillContextMenu(IMenuManager menu) {
- ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
- if (selectionProvider == null)
- return;
-
- ISelection selection= selectionProvider.getSelection();
- if (!(selection instanceof ITextSelection))
- return;
-
- ITextSelection textSelection= (ITextSelection)selection;
- if (textSelection.getLength() == 0)
- return;
-
- String menuText= ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName;
-
- String shortcutString= getShortcutString();
- if (shortcutString != null) {
- menuText= menuText + '\t' + shortcutString;
- }
-
- MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
- menu.appendToGroup(fGroup, subMenu);
- subMenu.add(new Action() {});
- subMenu.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- manager.removeAll();
- SurroundWithTemplateMenuAction.fillMenu(manager, fEditor);
- }
- });
- }
-
- private String getShortcutString() {
- IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- if (bindingService == null)
- return null;
- return bindingService.getBestActiveBindingFormattedFor(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
- }
-
-// private static SurroundWithTryCatchAction createSurroundWithTryCatchAction(CompilationUnitEditor editor) {
-// SurroundWithTryCatchAction result= new SurroundWithTryCatchAction(editor);
-// result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName);
-// result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
-// editor.setAction("SurroundWithTryCatch", result); //$NON-NLS-1$
-// return result;
-// }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
deleted file mode 100644
index 809ebc0e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEditingSupport;
-import org.eclipse.jface.text.IEditingSupportRegistry;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.AssistContext;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.QuickTemplateProcessor;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.ui.actions.SurroundWithTryCatchAction;
-import org.eclipse.wst.jsdt.ui.text.java.IInvocationContext;
-import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal;
-
-public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownDelegate2 {
-
- //TODO make api
- public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID= "org.eclipse.wst.jsdt.ui.edit.text.java.surround.with.quickMenu"; //$NON-NLS-1$
-
- private static final String JAVA_TEMPLATE_PREFERENCE_PAGE_ID= "org.eclipse.wst.jsdt.ui.preferences.JavaTemplatePreferencePage"; //$NON-NLS-1$
-
- private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$
-
- private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$
-
- private static class ConfigureTemplatesAction extends Action {
-
- public ConfigureTemplatesAction() {
- super(ActionMessages.SurroundWithTemplateMenuAction_ConfigureTemplatesActionName);
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- PreferencesUtil.createPreferenceDialogOn(getShell(), JAVA_TEMPLATE_PREFERENCE_PAGE_ID, new String[] {JAVA_TEMPLATE_PREFERENCE_PAGE_ID}, null).open();
- }
-
- private Shell getShell() {
- return JavaScriptPlugin.getActiveWorkbenchWindow().getShell();
- }
- }
-
- private static Action NONE_APPLICABLE_ACTION= new Action(ActionMessages.SurroundWithTemplateMenuAction_NoneApplicable) {
- public void run() {
- //Do nothing
- }
- public boolean isEnabled() {
- return false;
- }
- };
-
- private Menu fMenu;
- private IPartService fPartService;
- private IPartListener fPartListener= new IPartListener() {
-
- public void partActivated(IWorkbenchPart part) {
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- public void partClosed(IWorkbenchPart part) {
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- disposeMenuItems();
- }
-
- public void partOpened(IWorkbenchPart part) {
- }
-
- };
-
- protected void disposeMenuItems() {
- if (fMenu == null || fMenu.isDisposed()) {
- return;
- }
- MenuItem[] items = fMenu.getItems();
- for (int i=0; i < items.length; i++) {
- MenuItem menuItem= items[i];
- if (!menuItem.isDisposed()) {
- menuItem.dispose();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Menu parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- initMenu();
- return fMenu;
- }
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Control parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- initMenu();
- return fMenu;
- }
-
- public static void fillMenu(IMenuManager menu, CompilationUnitEditor editor) {
- IAction[] actions= getTemplateActions(editor);
-// surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection());
-
- if (actions == null /* && !surroundWithTryCatchAction.isEnabled()*/) {
- menu.add(NONE_APPLICABLE_ACTION);
- } else {
-// menu.add(surroundWithTryCatchAction);
- menu.add(new Separator(TEMPLATE_GROUP));
-
- if (actions == null) {
- menu.add(NONE_APPLICABLE_ACTION);
- } else {
- for (int i= 0; i < actions.length; i++) {
- menu.add(actions[i]);
- }
- }
- }
-
- menu.add(new Separator(CONFIG_GROUP));
- menu.add(new ConfigureTemplatesAction());
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- if (fPartService != null) {
- fPartService.removePartListener(fPartListener);
- fPartService= null;
- }
- setMenu(null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(IWorkbenchWindow window) {
- if (fPartService != null) {
- fPartService.removePartListener(fPartListener);
- fPartService= null;
- }
-
- if (window != null) {
- IPartService partService= window.getPartService();
- if (partService != null) {
- fPartService= partService;
- partService.addPartListener(fPartListener);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IAction action) {
- IWorkbenchPart activePart= JavaScriptPlugin.getActivePage().getActivePart();
- if (!(activePart instanceof CompilationUnitEditor))
- return;
-
- final CompilationUnitEditor editor= (CompilationUnitEditor)activePart;
-
- (new JDTQuickMenuAction(editor, SURROUND_WITH_QUICK_MENU_ACTION_ID) {
- protected void fillMenu(IMenuManager menu) {
-// SurroundWithTryCatchAction surroundWithTryCatch= createSurroundWithTryCatchAction(editor);
- SurroundWithTemplateMenuAction.fillMenu(menu, editor);
- }
- }).run();
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(IAction action, ISelection selection) {
- // Default do nothing
- }
-
- /**
- * The menu to show in the workbench menu
- */
- protected void fillMenu(Menu menu) {
-
- IWorkbenchPart activePart= JavaScriptPlugin.getActivePage().getActivePart();
- if (!(activePart instanceof CompilationUnitEditor)) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
- item.fill(menu, -1);
- return;
- }
-
- CompilationUnitEditor editor= (CompilationUnitEditor)activePart;
-
- IAction[] actions= getTemplateActions(editor);
-
- SurroundWithTryCatchAction surroundAction= createSurroundWithTryCatchAction(editor);
- ActionContributionItem surroundItem= new ActionContributionItem(surroundAction);
- surroundItem.fill(menu, -1);
-
- Separator templateGroup= new Separator(TEMPLATE_GROUP);
- templateGroup.fill(menu, -1);
-
- if (actions == null || actions.length == 0) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
- item.fill(menu, -1);
- } else {
- for (int i= 0; i < actions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(actions[i]);
- item.fill(menu, -1);
- }
- }
-
- Separator configGroup= new Separator(CONFIG_GROUP);
- configGroup.fill(menu, -1);
-
- ActionContributionItem configAction= new ActionContributionItem(new ConfigureTemplatesAction());
- configAction.fill(menu, -1);
-
- }
-
- private static SurroundWithTryCatchAction createSurroundWithTryCatchAction(CompilationUnitEditor editor) {
- SurroundWithTryCatchAction result= new SurroundWithTryCatchAction(editor);
- result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName);
- result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
- editor.setAction("SurroundWithTryCatch", result); //$NON-NLS-1$
- return result;
- }
-
- protected void initMenu() {
- fMenu.addMenuListener(new MenuAdapter() {
- public void menuShown(MenuEvent e) {
- Menu m = (Menu)e.widget;
- MenuItem[] items = m.getItems();
- for (int i=0; i < items.length; i++) {
- items[i].dispose();
- }
- fillMenu(m);
- }
- });
- }
-
- private void setMenu(Menu menu) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu = menu;
- }
-
- private static IAction[] getTemplateActions(JavaEditor editor) {
- ISelectionProvider selectionProvider= editor.getSelectionProvider();
- if (selectionProvider == null)
- return null;
-
- ISelection selection= selectionProvider.getSelection();
- if (!(selection instanceof ITextSelection))
- return null;
-
- ITextSelection textSelection= (ITextSelection)selection;
- if (textSelection.getLength() == 0)
- return null;
-
- IJavaScriptUnit cu= JavaScriptUI.getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- if (cu == null)
- return null;
-
- QuickTemplateProcessor quickTemplateProcessor= new QuickTemplateProcessor();
- IInvocationContext context= new AssistContext(cu, textSelection.getOffset(), textSelection.getLength());
-
- try {
- IJavaCompletionProposal[] proposals= quickTemplateProcessor.getAssists(context, null);
- if (proposals == null || proposals.length == 0)
- return null;
-
- return getActionsFromProposals(proposals, context.getSelectionOffset(), editor.getViewer());
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- return null;
- }
-
- private static IAction[] getActionsFromProposals(IJavaCompletionProposal[] proposals, final int offset, final ITextViewer viewer) {
- List result= new ArrayList();
-
- for (int i= 0, j= 1; i < proposals.length; i++) {
- if (proposals[i] instanceof ICompletionProposalExtension2) {
- final IJavaCompletionProposal proposal= proposals[i];
-
- StringBuffer actionName= new StringBuffer();
- if (j<10) {
- actionName.append('&').append(j).append(' ');
- }
- actionName.append(proposals[i].getDisplayString());
-
- Action action= new Action(actionName.toString()) {
- /**
- * {@inheritDoc}
- */
- public void run() {
- applyProposal(proposal, viewer, (char)0, 0, offset);
- }
- };
-
- result.add(action);
- j++;
- }
- }
- if (result.size() == 0)
- return null;
-
- return (IAction[])result.toArray(new IAction[result.size()]);
- }
-
- private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger, int stateMask, final int offset) {
- Assert.isTrue(proposal instanceof ICompletionProposalExtension2);
-
- IRewriteTarget target= null;
- IEditingSupportRegistry registry= null;
- IEditingSupport helper= new IEditingSupport() {
-
- public boolean isOriginator(DocumentEvent event, IRegion focus) {
- return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
- }
-
- public boolean ownsFocusShell() {
- return false;
- }
-
- };
-
- try {
- IDocument document= viewer.getDocument();
-
- if (viewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) viewer;
- target= extension.getRewriteTarget();
- }
-
- if (target != null)
- target.beginCompoundChange();
-
- if (viewer instanceof IEditingSupportRegistry) {
- registry= (IEditingSupportRegistry) viewer;
- registry.register(helper);
- }
-
- ((ICompletionProposalExtension2)proposal).apply(viewer, trigger, stateMask, offset);
-
- Point selection= proposal.getSelection(document);
- if (selection != null) {
- viewer.setSelectedRange(selection.x, selection.y);
- viewer.revealRange(selection.x, selection.y);
- }
- } finally {
- if (target != null)
- target.endCompoundChange();
-
- if (registry != null)
- registry.unregister(helper);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/WorkbenchRunnableAdapter.java
deleted file mode 100644
index a75bda34..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-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.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.IThreadListener;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-
-/**
- * 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 adapted runnable are caught and re-thrown as a <code>InterruptedException</code>.
- */
-public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener {
-
- private boolean fTransfer= false;
- private IWorkspaceRunnable fWorkspaceRunnable;
- private ISchedulingRule fRule;
-
- /**
- * Runs a workspace runnable with the workspace lock.
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
- this(runnable, ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- }
-
- /**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
- * @param transfer <code>true</code> if the rule is to be transfered
- * to the model context thread. Otherwise <code>false</code>
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- fTransfer= transfer;
- }
-
- public ISchedulingRule getSchedulingRule() {
- return fRule;
- }
-
- /**
- * {@inheritDoc}
- */
- public void threadChange(Thread thread) {
- if (fTransfer)
- Job.getJobManager().transferRule(fRule, thread);
- }
-
- /*
- * @see IRunnableWithProgress#run(IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- JavaScriptCore.run(fWorkspaceRunnable, fRule, monitor);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- public void runAsUserJob(String name, final Object jobFamiliy) {
- Job buildJob = new Job(name){
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- try {
- WorkbenchRunnableAdapter.this.run(monitor);
- } catch (InvocationTargetException e) {
- Throwable cause= e.getCause();
- if (cause instanceof CoreException) {
- return ((CoreException) cause).getStatus();
- } else {
- return JavaUIStatus.createError(IStatus.ERROR, cause);
- }
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
- public boolean belongsTo(Object family) {
- return jobFamiliy == family;
- }
- };
- buildJob.setRule(fRule);
- buildJob.setUser(true);
- buildJob.schedule();
-
- // TODO: should block until user pressed 'to background'
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/IPackagesViewViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/IPackagesViewViewer.java
deleted file mode 100644
index 656da368..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/IPackagesViewViewer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.List;
-
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Allows accessing the PackagesViewTableViewer and the
- * PackagesViewTreeViewer with identical API.
- *
- *
- */
-interface IPackagesViewViewer {
-
- public void mapElement(Object element, Widget item);
-
- public void unmapElement(Object element, Widget item);
-
- public Widget doFindInputItem(Object element);
-
- public Widget doFindItem(Object element);
-
- public void doUpdateItem(Widget item, Object element, boolean fullMap);
-
- public List getSelectionFromWidget();
-
- public void internalRefresh(Object element);
-
- public void setSelectionToWidget(List l, boolean reveal);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java
deleted file mode 100644
index 0ba04e66..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java
+++ /dev/null
@@ -1,539 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IImportContainer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.IWorkingCopy;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-class JavaBrowsingContentProvider extends StandardJavaScriptElementContentProvider implements IElementChangedListener {
-
- private StructuredViewer fViewer;
- private Object fInput;
- private JavaBrowsingPart fBrowsingPart;
- private int fReadsInDisplayThread;
-
-
- public JavaBrowsingContentProvider(boolean provideMembers, JavaBrowsingPart browsingPart) {
- super(provideMembers);
- fBrowsingPart= browsingPart;
- fViewer= fBrowsingPart.getViewer();
- JavaScriptCore.addElementChangedListener(this);
- }
-
- public boolean hasChildren(Object element) {
- startReadInDisplayThread();
- try{
- return super.hasChildren(element);
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- public Object[] getChildren(Object element) {
- if (!exists(element))
- return NO_CHILDREN;
-
- startReadInDisplayThread();
- try {
- if (element instanceof Collection) {
- Collection elements= (Collection)element;
- if (elements.isEmpty())
- return NO_CHILDREN;
- Object[] result= new Object[0];
- Iterator iter= ((Collection)element).iterator();
- while (iter.hasNext()) {
- Object[] children= getChildren(iter.next());
- if (children != NO_CHILDREN)
- result= concatenate(result, children);
- }
- return result;
- }
- if (element instanceof IPackageFragment)
- return getPackageContents((IPackageFragment)element);
- if (fProvideMembers && element instanceof IType)
- return getChildren((IType)element);
- if (fProvideMembers && element instanceof ISourceReference && element instanceof IParent)
- return removeImportAndPackageDeclarations(super.getChildren(element));
- if (element instanceof IJavaScriptProject)
- return getPackageFragmentRoots((IJavaScriptProject)element);
- return super.getChildren(element);
- } catch (JavaScriptModelException e) {
- return NO_CHILDREN;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- private Object[] getPackageContents(IPackageFragment fragment) throws JavaScriptModelException {
- ISourceReference[] sourceRefs;
- if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) {
- sourceRefs= fragment.getJavaScriptUnits();
- }
- else {
- IClassFile[] classFiles= fragment.getClassFiles();
- List topLevelClassFile= new ArrayList();
- for (int i= 0; i < classFiles.length; i++) {
- IType type= classFiles[i].getType();
- if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal())
- topLevelClassFile.add(classFiles[i]);
- }
- sourceRefs= (ISourceReference[])topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]);
- }
-
- Object[] result= new Object[0];
- for (int i= 0; i < sourceRefs.length; i++)
- result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i])));
- return concatenate(result, fragment.getNonJavaScriptResources());
- }
-
- private Object[] removeImportAndPackageDeclarations(Object[] members) {
- ArrayList tempResult= new ArrayList(members.length);
- for (int i= 0; i < members.length; i++)
- if (!(members[i] instanceof IImportContainer) && !(members[i] instanceof IPackageDeclaration))
- tempResult.add(members[i]);
- return tempResult.toArray();
- }
-
- private Object[] getChildren(IType type) throws JavaScriptModelException{
- IParent parent;
- if (type.isBinary())
- parent= type.getClassFile();
- else {
- parent= type.getJavaScriptUnit();
- }
- if (type.getDeclaringType() != null)
- return type.getChildren();
-
- // Add import declarations
- IJavaScriptElement[] members= parent.getChildren();
- ArrayList tempResult= new ArrayList(members.length);
- for (int i= 0; i < members.length; i++)
- if ((members[i] instanceof IImportContainer))
- tempResult.add(members[i]);
- tempResult.addAll(Arrays.asList(type.getChildren()));
- return tempResult.toArray();
- }
-
- protected Object[] getPackageFragmentRoots(IJavaScriptProject project) throws JavaScriptModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- List list= new ArrayList(roots.length);
- // filter out package fragments that correspond to projects and
- // replace them with the package fragments directly
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- if (!root.isExternal()) {
- Object[] children= root.getChildren();
- for (int k= 0; k < children.length; k++)
- list.add(children[k]);
- }
- else if (hasChildren(root)) {
- list.add(root);
- }
- }
- return concatenate(list.toArray(), project.getNonJavaScriptResources());
- }
-
- // ---------------- Element change handling
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
-
- if (newInput instanceof Collection) {
- // Get a template object from the collection
- Collection col= (Collection)newInput;
- if (!col.isEmpty())
- newInput= col.iterator().next();
- else
- newInput= null;
- }
- fInput= newInput;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- super.dispose();
- JavaScriptCore.removeElementChangedListener(this);
- }
-
- /* (non-Javadoc)
- * Method declared on IElementChangedListener.
- */
- public void elementChanged(final ElementChangedEvent event) {
- try {
- processDelta(event.getDelta());
- } catch(JavaScriptModelException e) {
- JavaScriptPlugin.log(e.getStatus());
- }
- }
-
-
- /**
- * Processes a delta recursively. When more than two children are affected the
- * tree is fully refreshed starting at this node. The delta is processed in the
- * current thread but the viewer updates are posted to the UI thread.
- */
- protected void processDelta(IJavaScriptElementDelta delta) throws JavaScriptModelException {
- int kind= delta.getKind();
- int flags= delta.getFlags();
- final IJavaScriptElement element= delta.getElement();
- final boolean isElementValidForView= fBrowsingPart.isValidElement(element);
-
- if (!getProvideWorkingCopy() && element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy())
- return;
-
- if (element != null && element.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT && !isOnClassPath((IJavaScriptUnit)element))
- return;
-
- // handle open and closing of a solution or project
- if (((flags & IJavaScriptElementDelta.F_CLOSED) != 0) || ((flags & IJavaScriptElementDelta.F_OPENED) != 0)) {
- postRefresh(null);
- return;
- }
-
- if (kind == IJavaScriptElementDelta.REMOVED) {
- Object parent= internalGetParent(element);
- if (isElementValidForView) {
- if (element instanceof IClassFile) {
- postRemove(((IClassFile)element).getType());
- } else if (element instanceof IJavaScriptUnit && !((IJavaScriptUnit)element).isWorkingCopy()) {
- postRefresh(null);
- } else if (element instanceof IJavaScriptUnit && ((IJavaScriptUnit)element).isWorkingCopy()) {
- if (getProvideWorkingCopy())
- postRefresh(null);
- } else if (parent instanceof IJavaScriptUnit && getProvideWorkingCopy() && !((IJavaScriptUnit)parent).isWorkingCopy()) {
- if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) {
- // working copy removed from system - refresh
- postRefresh(null);
- }
- } else if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy() && parent != null && parent.equals(fInput))
- // closed editor - removing working copy
- postRefresh(null);
- else
- postRemove(element);
- }
-
- if (fBrowsingPart.isAncestorOf(element, fInput)) {
- if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) {
- postAdjustInputAndSetSelection(((IJavaScriptElement) fInput).getPrimaryElement());
- } else
- postAdjustInputAndSetSelection(null);
- }
-
- if (fInput != null && fInput.equals(element))
- postRefresh(null);
-
- if (parent instanceof IPackageFragment && fBrowsingPart.isValidElement(parent)) {
- // refresh if package gets empty (might be filtered)
- if (isPackageFragmentEmpty((IPackageFragment)parent) && fViewer.testFindItem(parent) != null)
- postRefresh(null);
- }
-
- return;
- }
- if (kind == IJavaScriptElementDelta.ADDED && delta.getMovedFromElement() != null && element instanceof IJavaScriptUnit)
- return;
-
- if (kind == IJavaScriptElementDelta.ADDED) {
- if (isElementValidForView) {
- Object parent= internalGetParent(element);
- if (element instanceof IClassFile) {
- postAdd(parent, ((IClassFile)element).getType());
- } else if (element instanceof IJavaScriptUnit && !((IJavaScriptUnit)element).isWorkingCopy()) {
- postAdd(parent, ((IJavaScriptUnit)element).getTypes());
- } else if (parent instanceof IJavaScriptUnit && getProvideWorkingCopy() && !((IJavaScriptUnit)parent).isWorkingCopy()) {
- // do nothing
- } else if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) {
- // new working copy comes to live
- postRefresh(null);
- } else
- postAdd(parent, element);
- } else if (fInput == null) {
- IJavaScriptElement newInput= fBrowsingPart.findInputForJavaElement(element);
- if (newInput != null)
- postAdjustInputAndSetSelection(element);
- } else if (element instanceof IType && fBrowsingPart.isValidInput(element)) {
- IJavaScriptElement cu1= element.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- IJavaScriptElement cu2= ((IJavaScriptElement)fInput).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu1 != null && cu2 != null && cu1.equals(cu2))
- postAdjustInputAndSetSelection(element);
- }
- return;
- }
-
- if (kind == IJavaScriptElementDelta.CHANGED) {
- if (fInput != null && fInput.equals(element) && (flags & IJavaScriptElementDelta.F_CHILDREN) != 0 && (flags & IJavaScriptElementDelta.F_FINE_GRAINED) != 0) {
- postRefresh(null, true);
- return;
- }
- if (isElementValidForView && (flags & IJavaScriptElementDelta.F_MODIFIERS) != 0) {
- postUpdateIcon(element);
- }
- }
-
- if (isClassPathChange(delta))
- // throw the towel and do a full refresh
- postRefresh(null);
-
- if ((flags & IJavaScriptElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 && fInput instanceof IJavaScriptElement) {
- IPackageFragmentRoot pkgRoot= (IPackageFragmentRoot)element;
- IJavaScriptElement inputsParent= ((IJavaScriptElement)fInput).getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (pkgRoot.equals(inputsParent))
- postRefresh(null);
- }
-
- // the source attachment of a JAR has changed
- if (element instanceof IPackageFragmentRoot && (((flags & IJavaScriptElementDelta.F_SOURCEATTACHED) != 0 || ((flags & IJavaScriptElementDelta.F_SOURCEDETACHED)) != 0)))
- postUpdateIcon(element);
-
- IJavaScriptElementDelta[] affectedChildren= delta.getAffectedChildren();
- if (affectedChildren.length > 1) {
- // a package fragment might become non empty refresh from the parent
- if (element instanceof IPackageFragment) {
- IJavaScriptElement parent= (IJavaScriptElement)internalGetParent(element);
- // avoid posting a refresh to an invisible parent
- if (element.equals(fInput)) {
- postRefresh(element);
- } else {
- postRefresh(parent);
- }
- }
- // more than one child changed, refresh from here downwards
- if (element instanceof IPackageFragmentRoot && isElementValidForView) {
- postRefresh(skipProjectPackageFragmentRoot((IPackageFragmentRoot)element));
- return;
- }
- }
- for (int i= 0; i < affectedChildren.length; i++) {
- processDelta(affectedChildren[i]);
- }
- }
-
- private boolean isOnClassPath(IJavaScriptUnit element) throws JavaScriptModelException {
- IJavaScriptProject project= element.getJavaScriptProject();
- if (project == null || !project.exists())
- return false;
- return project.isOnIncludepath(element);
- }
-
- /**
- * Updates the package icon
- */
- private void postUpdateIcon(final IJavaScriptElement element) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
- fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE});
- }
- });
- }
-
- private void postRefresh(final Object root, final boolean updateLabels) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
- fViewer.refresh(root, updateLabels);
- }
- });
- }
-
- private void postRefresh(final Object root) {
- postRefresh(root, false);
- }
-
- private void postAdd(final Object parent, final Object element) {
- postAdd(parent, new Object[] {element});
- }
-
- private void postAdd(final Object parent, final Object[] elements) {
- if (elements == null || elements.length <= 0)
- return;
-
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- Object[] newElements= getNewElements(elements);
- if (fViewer instanceof AbstractTreeViewer) {
- if (fViewer.testFindItem(parent) == null) {
- Object root= ((AbstractTreeViewer)fViewer).getInput();
- if (root != null)
- ((AbstractTreeViewer)fViewer).add(root, newElements);
- }
- else
- ((AbstractTreeViewer)fViewer).add(parent, newElements);
- }
- else if (fViewer instanceof ListViewer)
- ((ListViewer)fViewer).add(newElements);
- else if (fViewer instanceof TableViewer)
- ((TableViewer)fViewer).add(newElements);
- if (fViewer.testFindItem(elements[0]) != null)
- fBrowsingPart.adjustInputAndSetSelection(elements[0]);
- }
- }
- });
- }
-
- private Object[] getNewElements(Object[] elements) {
- int elementsLength= elements.length;
- ArrayList result= new ArrayList(elementsLength);
- for (int i= 0; i < elementsLength; i++) {
- Object element= elements[i];
- if (fViewer.testFindItem(element) == null)
- result.add(element);
- }
- return result.toArray();
- }
-
- private void postRemove(final Object element) {
- postRemove(new Object[] {element});
- }
-
- private void postRemove(final Object[] elements) {
- if (elements.length <= 0)
- return;
-
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- if (fViewer instanceof AbstractTreeViewer)
- ((AbstractTreeViewer)fViewer).remove(elements);
- else if (fViewer instanceof ListViewer)
- ((ListViewer)fViewer).remove(elements);
- else if (fViewer instanceof TableViewer)
- ((TableViewer)fViewer).remove(elements);
- }
- }
- });
- }
-
- private void postAdjustInputAndSetSelection(final Object element) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.setRedraw(false);
- fBrowsingPart.adjustInputAndSetSelection(element);
- ctrl.setRedraw(true);
- }
- }
- });
- }
-
- protected void startReadInDisplayThread() {
- if (isDisplayThread())
- fReadsInDisplayThread++;
- }
-
- protected void finishedReadInDisplayThread() {
- if (isDisplayThread())
- fReadsInDisplayThread--;
- }
-
- private boolean isDisplayThread() {
- Control ctrl= fViewer.getControl();
- if (ctrl == null)
- return false;
-
- Display currentDisplay= Display.getCurrent();
- return currentDisplay != null && currentDisplay.equals(ctrl.getDisplay());
- }
-
- private void postRunnable(final Runnable r) {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- fBrowsingPart.setProcessSelectionEvents(false);
- try {
- if (isDisplayThread() && fReadsInDisplayThread == 0)
- ctrl.getDisplay().syncExec(r);
- else
- ctrl.getDisplay().asyncExec(r);
- } finally {
- fBrowsingPart.setProcessSelectionEvents(true);
- }
- }
- }
-
- /**
- * Returns the parent for the element.
- * <p>
- * Note: This method will return a working copy if the
- * parent is a working copy. The super class implementation
- * returns the original element instead.
- * </p>
- */
- protected Object internalGetParent(Object element) {
- if (element instanceof IJavaScriptProject) {
- return ((IJavaScriptProject)element).getJavaScriptModel();
- }
- // try to map resources to the containing package fragment
- if (element instanceof IResource) {
- IResource parent= ((IResource)element).getParent();
- Object jParent= JavaScriptCore.create(parent);
- if (jParent != null)
- return jParent;
- return parent;
- }
-
- // for package fragments that are contained in a project package fragment
- // we have to skip the package fragment root as the parent.
- if (element instanceof IPackageFragment) {
- IPackageFragmentRoot parent= (IPackageFragmentRoot)((IPackageFragment)element).getParent();
- return skipProjectPackageFragmentRoot(parent);
- }
- if (element instanceof IJavaScriptElement)
- return ((IJavaScriptElement)element).getParent();
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.java
deleted file mode 100644
index 55a5bf60..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-public final class JavaBrowsingMessages extends NLS {
-
- private static final String BUNDLE_NAME= JavaBrowsingMessages.class.getName();
-
- private JavaBrowsingMessages() {
- // Do not instantiate
- }
-
- public static String JavaBrowsingPart_toolTip;
- public static String JavaBrowsingPart_toolTip2;
- public static String LexicalSortingAction_label;
- public static String LexicalSortingAction_tooltip;
- public static String LexicalSortingAction_description;
- public static String PackagesView_flatLayoutAction_label;
- public static String PackagesView_HierarchicalLayoutAction_label;
- public static String PackagesView_LayoutActionGroup_layout_label;
- public static String StatusBar_concat;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JavaBrowsingMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.properties
deleted file mode 100644
index dfbd8d91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingMessages.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-JavaBrowsingPart_toolTip= Working Set: {0}
-JavaBrowsingPart_toolTip2= {0} - Working Set: {1}
-
-LexicalSortingAction_label= Sort
-LexicalSortingAction_tooltip= Sort
-LexicalSortingAction_description= Enable Sorting
-
-PackagesView_flatLayoutAction_label= &Flat
-PackagesView_HierarchicalLayoutAction_label= &Hierarchical
-PackagesView_LayoutActionGroup_layout_label= &Package Presentation
-
-# the first argument is the string to which the second one is appended
-StatusBar_concat= {0}, {1}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPart.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPart.java
deleted file mode 100644
index 65493b7e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPart.java
+++ /dev/null
@@ -1,1319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.help.IContextProvider;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-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.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-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.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-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.IPartListener2;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.NewWizardsActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.dnd.DelegatingDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.ResourceTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.search.SearchUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.JavaUIHelp;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTableViewer;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.BuildActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.CCPActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.ImportActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenEditorActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-
-abstract class JavaBrowsingPart extends ViewPart implements IMenuListener, ISelectionListener, IViewPartInputProvider {
-
- private static final String TAG_SELECTED_ELEMENTS= "selectedElements"; //$NON-NLS-1$
- private static final String TAG_SELECTED_ELEMENT= "selectedElement"; //$NON-NLS-1$
- private static final String TAG_LOGICAL_PACKAGE= "logicalPackage"; //$NON-NLS-1$
- private static final String TAG_SELECTED_ELEMENT_PATH= "selectedElementPath"; //$NON-NLS-1$
-
- private JavaUILabelProvider fLabelProvider;
- private ILabelProvider fTitleProvider;
- private StructuredViewer fViewer;
- private IMemento fMemento;
- private JavaElementTypeComparator fTypeComparator;
-
- // Actions
- private WorkingSetFilterActionGroup fWorkingSetFilterActionGroup;
- private boolean fHasWorkingSetFilter= true;
- private boolean fHasCustomFilter= true;
- private OpenEditorActionGroup fOpenEditorGroup;
- private CCPActionGroup fCCPActionGroup;
- private BuildActionGroup fBuildActionGroup;
- private ToggleLinkingAction fToggleLinkingAction;
- protected CompositeActionGroup fActionGroups;
-
-
- // Filters
- private CustomFiltersActionGroup fCustomFiltersActionGroup;
-
- protected IWorkbenchPart fPreviousSelectionProvider;
- protected Object fPreviousSelectedElement;
-
- // Linking
- private boolean fLinkingEnabled;
-
- /*
- * Ensure selection changed events being processed only if
- * initiated by user interaction with this part.
- */
- private boolean fProcessSelectionEvents= true;
-
- private IPartListener2 fPartListener= new IPartListener2() {
- public void partActivated(IWorkbenchPartReference ref) {
- }
- public void partBroughtToTop(IWorkbenchPartReference ref) {
- }
- public void partInputChanged(IWorkbenchPartReference ref) {
- }
- public void partClosed(IWorkbenchPartReference ref) {
- }
- public void partDeactivated(IWorkbenchPartReference ref) {
- }
- public void partOpened(IWorkbenchPartReference ref) {
- }
- public void partVisible(IWorkbenchPartReference ref) {
- if (ref != null && ref.getId() == getSite().getId()){
- fProcessSelectionEvents= true;
- IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage();
- if (page != null)
- selectionChanged(page.getActivePart(), page.getSelection());
- }
- }
- public void partHidden(IWorkbenchPartReference ref) {
- if (ref != null && ref.getId() == getSite().getId())
- fProcessSelectionEvents= false;
- }
- };
-
- public JavaBrowsingPart() {
- super();
- initLinkingEnabled();
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void saveState(IMemento memento) {
- if (fViewer == null) {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.saveState(memento);
- if (fHasCustomFilter)
- fCustomFiltersActionGroup.saveState(memento);
- saveSelectionState(memento);
- saveLinkingEnabled(memento);
- }
-
- private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(getLinkToEditorKey(), fLinkingEnabled ? 1 : 0);
- }
-
- private void saveSelectionState(IMemento memento) {
- Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray();
- if (elements.length > 0) {
- IMemento selectionMem= memento.createChild(TAG_SELECTED_ELEMENTS);
- for (int i= 0; i < elements.length; i++) {
- IMemento elementMem= selectionMem.createChild(TAG_SELECTED_ELEMENT);
- Object o= elements[i];
- if (o instanceof IJavaScriptElement)
- elementMem.putString(TAG_SELECTED_ELEMENT_PATH, ((IJavaScriptElement) elements[i]).getHandleIdentifier());
- else if (o instanceof LogicalPackage) {
- IPackageFragment[] packages=((LogicalPackage)o).getFragments();
- for (int j= 0; j < packages.length; j++) {
- IMemento packageMem= elementMem.createChild(TAG_LOGICAL_PACKAGE);
- packageMem.putString(TAG_SELECTED_ELEMENT_PATH, packages[j].getHandleIdentifier());
- }
- }
- }
- }
- }
-
- protected void restoreState(IMemento memento) {
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.restoreState(memento);
- if (fHasCustomFilter)
- fCustomFiltersActionGroup.restoreState(memento);
-
- if (fHasCustomFilter || fHasWorkingSetFilter) {
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
- }
-
- private ISelection restoreSelectionState(IMemento memento) {
- if (memento == null)
- return null;
-
- IMemento childMem;
- childMem= memento.getChild(TAG_SELECTED_ELEMENTS);
- if (childMem != null) {
- ArrayList list= new ArrayList();
- IMemento[] elementMem= childMem.getChildren(TAG_SELECTED_ELEMENT);
- for (int i= 0; i < elementMem.length; i++) {
- String javaElementHandle= elementMem[i].getString(TAG_SELECTED_ELEMENT_PATH);
- if (javaElementHandle == null) {
- // logical package
- IMemento[] packagesMem= elementMem[i].getChildren(TAG_LOGICAL_PACKAGE);
- LogicalPackage lp= null;
- for (int j= 0; j < packagesMem.length; j++) {
- javaElementHandle= packagesMem[j].getString(TAG_SELECTED_ELEMENT_PATH);
- Object pack= JavaScriptCore.create(javaElementHandle);
- if (pack instanceof IPackageFragment && ((IPackageFragment)pack).exists()) {
- if (lp == null)
- lp= new LogicalPackage((IPackageFragment)pack);
- else
- lp.add((IPackageFragment)pack);
- }
- }
- if (lp != null)
- list.add(lp);
- } else {
- IJavaScriptElement element= JavaScriptCore.create(javaElementHandle);
- if (element != null && element.exists())
- list.add(element);
- }
- }
- return new StructuredSelection(list);
- }
- return null;
- }
-
- private void restoreLinkingEnabled(IMemento memento) {
- Integer val= memento.getInteger(getLinkToEditorKey());
- if (val != null) {
- fLinkingEnabled= val.intValue() != 0;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl(Composite parent) {
- Assert.isTrue(fViewer == null);
-
-
- fTypeComparator= new JavaElementTypeComparator();
-
- // Setup viewer
- fViewer= createViewer(parent);
-
- initDragAndDrop();
-
- fLabelProvider= createLabelProvider();
- fViewer.setLabelProvider(createDecoratingLabelProvider(fLabelProvider));
-
- fViewer.setComparator(createJavaElementComparator());
- fViewer.setUseHashlookup(true);
- fTitleProvider= createTitleProvider();
-
- createContextMenu();
- getSite().setSelectionProvider(fViewer);
-
- if (fMemento != null) { // initialize linking state before creating the actions
- restoreLinkingEnabled(fMemento);
- }
-
- createActions(); // call before registering for selection changes
- addKeyListener();
-
- if (fMemento != null)
- restoreState(fMemento);
-
- getSite().setSelectionProvider(fViewer);
-
- // Status line
- IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
- fViewer.addSelectionChangedListener(createStatusBarUpdater(slManager));
-
-
- hookViewerListeners();
-
- // Filters
- addFilters();
-
- // Initialize viewer input
- fViewer.setContentProvider(createContentProvider());
- setInitialInput();
-
- // Initialize selection
- setInitialSelection();
- fMemento= null;
-
- // Listen to page changes
- getViewSite().getPage().addPostSelectionListener(this);
- getViewSite().getPage().addPartListener(fPartListener);
-
- fillActionBars(getViewSite().getActionBars());
-
- setHelp();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- if (key == IContextProvider.class)
- return JavaUIHelp.getHelpContextProvider(this, getHelpContextId());
-
- return super.getAdapter(key);
- }
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- * @return returns the <code>IShowInSource</code>
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
- protected DecoratingJavaLabelProvider createDecoratingLabelProvider(JavaUILabelProvider provider) {
-// XXX: Work in progress for problem decorator being a workbench decorator//
-// return new ExcludingDecoratingLabelProvider(provider, decorationMgr, "org.eclipse.wst.jsdt.ui.problem.decorator"); //$NON-NLS-1$
- return new DecoratingJavaLabelProvider(provider);
- }
-
- protected JavaScriptElementComparator createJavaElementComparator() {
- return new JavaScriptElementComparator();
- }
-
- protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
- return new StatusBarUpdater(slManager);
- }
-
- protected void createContextMenu() {
- MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- menuManager.addMenuListener(this);
- Menu contextMenu= menuManager.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(contextMenu);
- getSite().registerContextMenu(menuManager, fViewer);
- }
-
- protected void initDragAndDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- // drop
- Transfer[] dropTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance()
- };
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fViewer)
- };
- fViewer.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new DelegatingDropAdapter(dropListeners));
-
- // Drag
- Transfer[] dragTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance(),
- ResourceTransfer.getInstance()};
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fViewer),
- new ResourceTransferDragAdapter(fViewer)
- };
- fViewer.addDragSupport(ops, dragTransfers, new JdtViewerDragAdapter(fViewer, dragListeners));
- }
-
- protected void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
-
-
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.fillActionBars(getViewSite().getActionBars());
-
- actionBars.updateActionBars();
-
- fActionGroups.fillActionBars(actionBars);
-
- if (fHasCustomFilter)
- fCustomFiltersActionGroup.fillActionBars(actionBars);
-
- IMenuManager menu= actionBars.getMenuManager();
- menu.add(fToggleLinkingAction);
- }
-
- //---- IWorkbenchPart ------------------------------------------------------
-
-
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- public void dispose() {
- if (fViewer != null) {
- getViewSite().getPage().removePostSelectionListener(this);
- getViewSite().getPage().removePartListener(fPartListener);
- fViewer= null;
- }
- if (fActionGroups != null)
- fActionGroups.dispose();
-
- if (fWorkingSetFilterActionGroup != null) {
- fWorkingSetFilterActionGroup.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * Adds the KeyListener
- */
- protected void addKeyListener() {
- fViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
- });
- }
-
- protected void handleKeyReleased(KeyEvent event) {
- if (event.stateMask != 0)
- return;
-
- int key= event.keyCode;
- if (key == SWT.F5) {
- IAction action= fBuildActionGroup.getRefreshAction();
- if (action.isEnabled())
- action.run();
- }
- }
-
- //---- Adding Action to Toolbar -------------------------------------------
-
- protected void fillToolBar(IToolBarManager tbm) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager menu) {
- JavaScriptPlugin.createStandardGroups(menu);
-
- IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
- int size= selection.size();
- Object element= selection.getFirstElement();
-
- if (size == 1)
- addOpenNewWindowAction(menu, element);
- fActionGroups.setContext(new ActionContext(selection));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
- }
-
- private void addOpenNewWindowAction(IMenuManager menu, Object element) {
- if (element instanceof IJavaScriptElement) {
- element= ((IJavaScriptElement)element).getResource();
- }
- if (!(element instanceof IContainer))
- return;
- menu.appendToGroup(
- IContextMenuConstants.GROUP_OPEN,
- new PatchedOpenInNewWindowAction(getSite().getWorkbenchWindow(), (IContainer)element));
- }
-
- protected void createActions() {
- fActionGroups= new CompositeActionGroup(new ActionGroup[] {
- new NewWizardsActionGroup(this.getSite()),
- fOpenEditorGroup= new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
- fCCPActionGroup= new CCPActionGroup(this),
- new GenerateActionGroup(this),
- new RefactorActionGroup(this),
- new ImportActionGroup(this),
- fBuildActionGroup= new BuildActionGroup(this),
- new JavaSearchActionGroup(this)});
-
-
- if (fHasWorkingSetFilter) {
- String viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doWorkingSetChanged(event);
- }
- };
- fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(getSite(), workingSetListener);
- fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
- }
-
- // Custom filter group
- if (fHasCustomFilter)
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);
-
- fToggleLinkingAction= new ToggleLinkingAction(this);
- }
-
- private void doWorkingSetChanged(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property))
- updateTitle();
- else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- updateTitle();
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
-
- }
-
-
- /**
- * Returns the shell to use for opening dialogs.
- * Used in this class, and in the actions.
- * @return returns the shell
- */
- Shell getShell() {
- return fViewer.getControl().getShell();
- }
-
- protected final Display getDisplay() {
- return fViewer.getControl().getDisplay();
- }
-
- /**
- * Returns the selection provider.
- * @return the selection provider
- */
- ISelectionProvider getSelectionProvider() {
- return fViewer;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <code>true</code> if the given element is a valid input
- */
- abstract protected boolean isValidInput(Object element);
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <code>true</code> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (!(element instanceof IJavaScriptElement)) {
- return false;
- }
- Object input= getViewer().getInput();
- if (input == null)
- return false;
- if (input instanceof Collection)
- return ((Collection)input).contains(element);
- else
- return input.equals(element);
-
- }
-
- private boolean isInputResetBy(Object newInput, Object input, IWorkbenchPart part) {
- if (newInput == null)
- return part == fPreviousSelectionProvider;
-
- if (input instanceof IJavaScriptElement && newInput instanceof IJavaScriptElement)
- return getTypeComparator().compare(newInput, input) > 0;
-
- if((newInput instanceof List) && (part instanceof PackagesView))
- return true;
-
- else
- return false;
- }
-
- private boolean isInputResetBy(IWorkbenchPart part) {
- if (!(part instanceof JavaBrowsingPart))
- return true;
- Object thisInput= getViewer().getInput();
- Object partInput= ((JavaBrowsingPart)part).getViewer().getInput();
-
- if(thisInput instanceof Collection)
- thisInput= ((Collection)thisInput).iterator().next();
-
- if(partInput instanceof Collection)
- partInput= ((Collection)partInput).iterator().next();
-
- if (thisInput instanceof IJavaScriptElement && partInput instanceof IJavaScriptElement)
- return getTypeComparator().compare(partInput, thisInput) > 0;
- else
- return true;
- }
-
- protected boolean isAncestorOf(Object ancestor, Object element) {
- if (element instanceof IJavaScriptElement && ancestor instanceof IJavaScriptElement)
- return !element.equals(ancestor) && internalIsAncestorOf((IJavaScriptElement)ancestor, (IJavaScriptElement)element);
- return false;
- }
-
- private boolean internalIsAncestorOf(IJavaScriptElement ancestor, IJavaScriptElement element) {
- if (element != null)
- return element.equals(ancestor) || internalIsAncestorOf(ancestor, element.getParent());
- else
- return false;
- }
-
- private boolean isSearchResultView(IWorkbenchPart part) {
- return SearchUtil.isSearchPlugInActivated() && part instanceof ISearchResultViewPart;
- }
-
- protected boolean needsToProcessSelectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!fProcessSelectionEvents || part == this || isSearchResultView(part) || part instanceof AbstractInfoView){
- if (part == this)
- fPreviousSelectionProvider= part;
- return false;
- }
- return true;
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!needsToProcessSelectionChanged(part, selection))
- return;
-
- if (fToggleLinkingAction.isChecked() && (part instanceof ITextEditor)) {
- setSelectionFromEditor(part, selection);
- return;
- }
-
- if (!(selection instanceof IStructuredSelection))
- return;
-
- // Set selection
- Object selectedElement= getSingleElementFromSelection(selection);
-
- if (selectedElement != null && (part == null || part.equals(fPreviousSelectionProvider)) && selectedElement.equals(fPreviousSelectedElement))
- return;
-
- fPreviousSelectedElement= selectedElement;
-
- Object currentInput= getViewer().getInput();
- if (selectedElement != null && selectedElement.equals(currentInput)) {
- IJavaScriptElement elementToSelect= findElementToSelect(selectedElement);
- if (elementToSelect != null && getTypeComparator().compare(selectedElement, elementToSelect) < 0)
- setSelection(new StructuredSelection(elementToSelect), true);
- else if (elementToSelect == null && (this instanceof MembersView)) {
- setSelection(StructuredSelection.EMPTY, true);
- fPreviousSelectedElement= StructuredSelection.EMPTY;
- }
- fPreviousSelectionProvider= part;
- return;
- }
-
- // Clear input if needed
- if (part != fPreviousSelectionProvider && selectedElement != null && !selectedElement.equals(currentInput) && isInputResetBy(selectedElement, currentInput, part)) {
- if (!isAncestorOf(selectedElement, currentInput))
- setInput(null);
- fPreviousSelectionProvider= part;
- return;
- } else if (selection.isEmpty() && !isInputResetBy(part)) {
- fPreviousSelectionProvider= part;
- return;
- } else if (selectedElement == null && part == fPreviousSelectionProvider) {
- setInput(null);
- fPreviousSelectionProvider= part;
- return;
- }
- fPreviousSelectionProvider= part;
-
- // Adjust input and set selection and
- adjustInputAndSetSelection(selectedElement);
- }
-
-
- void setHasWorkingSetFilter(boolean state) {
- fHasWorkingSetFilter= state;
- }
-
- void setHasCustomSetFilter(boolean state) {
- fHasCustomFilter= state;
- }
-
- protected Object getInput() {
- return fViewer.getInput();
- }
-
- protected void setInput(Object input) {
- setViewerInput(input);
- updateTitle();
- }
-
- boolean isLinkingEnabled() {
- return fLinkingEnabled;
- }
-
- private void initLinkingEnabled() {
- fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(getLinkToEditorKey());
- }
-
- private void setViewerInput(Object input) {
- fProcessSelectionEvents= false;
- fViewer.setInput(input);
- fProcessSelectionEvents= true;
- }
-
- void updateTitle() {
- setTitleToolTip(getToolTipText(fViewer.getInput()));
- }
-
- /**
- * Returns the tool tip text for the given element.
- * @param element the element
- * @return the tooltip for the element
- */
- String getToolTipText(Object element) {
- String result;
- if (!(element instanceof IResource)) {
- result= JavaScriptElementLabels.getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
- } else {
- IPath path= ((IResource) element).getFullPath();
- if (path.isRoot()) {
- result= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- } else {
- result= path.makeRelative().toString();
- }
- }
-
- if (fWorkingSetFilterActionGroup == null || fWorkingSetFilterActionGroup.getWorkingSet() == null)
- return result;
-
- IWorkingSet ws= fWorkingSetFilterActionGroup.getWorkingSet();
- String wsstr= Messages.format(JavaBrowsingMessages.JavaBrowsingPart_toolTip, new String[] { ws.getLabel() });
- if (result.length() == 0)
- return wsstr;
- return Messages.format(JavaBrowsingMessages.JavaBrowsingPart_toolTip2, new String[] { result, ws.getLabel() });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#getTitleToolTip()
- */
- public String getTitleToolTip() {
- if (fViewer == null)
- return super.getTitleToolTip();
- return getToolTipText(fViewer.getInput());
- }
-
- protected final StructuredViewer getViewer() {
- return fViewer;
- }
-
- protected final void setViewer(StructuredViewer viewer){
- fViewer= viewer;
- }
-
- protected JavaUILabelProvider createLabelProvider() {
- return new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS
- );
- }
-
- protected ILabelProvider createTitleProvider() {
- return new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_BASICS | JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
- protected final ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- protected final ILabelProvider getTitleProvider() {
- return fTitleProvider;
- }
-
- /**
- * Creates the viewer of this part.
- *
- * @param parent the parent for the viewer
- * @return the created viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- return new ProblemTableViewer(parent, SWT.MULTI);
- }
-
- protected int getLabelProviderFlags() {
- return JavaScriptElementLabelProvider.SHOW_BASICS | JavaScriptElementLabelProvider.SHOW_OVERLAY_ICONS |
- JavaScriptElementLabelProvider.SHOW_SMALL_ICONS | JavaScriptElementLabelProvider.SHOW_VARIABLE | JavaScriptElementLabelProvider.SHOW_PARAMETERS;
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- // default is to have no filters
- }
-
- /**
- * Creates the content provider of this part.
- * @return the content provider
- */
- protected IContentProvider createContentProvider() {
- return new JavaBrowsingContentProvider(true, this);
- }
-
- protected void setInitialInput() {
- // Use the selection, if any
- ISelection selection= getSite().getPage().getSelection();
- Object input= getSingleElementFromSelection(selection);
- if (!(input instanceof IJavaScriptElement)) {
- // Use the input of the page
- input= getSite().getPage().getInput();
- if (!(input instanceof IJavaScriptElement) && input instanceof IAdaptable)
- input= ((IAdaptable)input).getAdapter(IJavaScriptElement.class);
- }
- setInput(findInputForJavaElement((IJavaScriptElement)input));
- }
-
- protected void setInitialSelection() {
- // Use the selection, if any
- Object input;
- IWorkbenchPage page= getSite().getPage();
- ISelection selection= null;
- if (page != null)
- selection= page.getSelection();
- if (selection instanceof ITextSelection) {
- Object part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (part instanceof IEditorPart) {
- setSelectionFromEditor((IEditorPart)part);
- if (fViewer.getSelection() != null)
- return;
- }
- }
-
- // Use saved selection from memento
- if (selection == null || selection.isEmpty())
- selection= restoreSelectionState(fMemento);
-
- if (selection == null || selection.isEmpty()) {
- // Use the input of the page
- input= getSite().getPage().getInput();
- if (!(input instanceof IJavaScriptElement)) {
- if (input instanceof IAdaptable)
- input= ((IAdaptable)input).getAdapter(IJavaScriptElement.class);
- else
- return;
- }
- selection= new StructuredSelection(input);
- }
- selectionChanged(null, selection);
- }
-
- protected final void setHelp() {
- JavaUIHelp.setHelp(fViewer, getHelpContextId());
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- abstract protected String getHelpContextId();
-
- /**
- * Returns the preference key for the link to editor setting.
- *
- * @return the string used as key into the preference store
- */
- abstract protected String getLinkToEditorKey();
-
- /**
- * Adds additional listeners to this view.
- * This method can be overridden but should
- * call super.
- */
- protected void hookViewerListeners() {
- fViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!fProcessSelectionEvents)
- return;
-
- fPreviousSelectedElement= getSingleElementFromSelection(event.getSelection());
-
- IWorkbenchPage page= getSite().getPage();
- if (page == null)
- return;
-
- if (page.equals(JavaScriptPlugin.getActivePage()) && JavaBrowsingPart.this.equals(page.getActivePart())) {
- linkToEditor((IStructuredSelection)event.getSelection());
- }
- }
- });
-
- fViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- IAction open= fOpenEditorGroup.getOpenAction();
- if (open.isEnabled()) {
- open.run();
- restoreSelection();
- }
- }
- });
- }
-
- void restoreSelection() {
- // Default is to do nothing
- }
-
- void adjustInputAndSetSelection(Object o) {
- if (!(o instanceof IJavaScriptElement)) {
- if (o == null)
- setInput(null);
- setSelection(StructuredSelection.EMPTY, true);
- return;
- }
-
- IJavaScriptElement je= (IJavaScriptElement)o;
- IJavaScriptElement elementToSelect= findElementToSelect(je);
- IJavaScriptElement newInput= findInputForJavaElement(je);
- IJavaScriptElement oldInput= null;
- if (getInput() instanceof IJavaScriptElement)
- oldInput= (IJavaScriptElement)getInput();
-
- if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(je, oldInput)))
- // Clear input
- setInput(null);
- else if (mustSetNewInput(elementToSelect, oldInput, newInput)) {
- // Adjust input to selection
- setInput(newInput);
- }
-
- if (elementToSelect != null && elementToSelect.exists())
- setSelection(new StructuredSelection(elementToSelect), true);
- else
- setSelection(StructuredSelection.EMPTY, true);
- }
-
- /**
- * Compute if a new input must be set.
- *
- * @param elementToSelect the element to select
- * @param oldInput old input
- * @param newInput new input
- * @return <code>true</code> if the input has to be set
- *
- */
- private boolean mustSetNewInput(IJavaScriptElement elementToSelect, IJavaScriptElement oldInput, IJavaScriptElement newInput) {
- return (newInput == null || !newInput.equals(oldInput))
- && (elementToSelect == null
- || oldInput == null
- || (!((elementToSelect instanceof IPackageDeclaration)
- && (elementToSelect.getParent().equals(oldInput.getParent()))
- && (!isAncestorOf(getViewPartInput(), elementToSelect)))));
- }
-
- /**
- * Finds the closest Java element which can be used as input for
- * this part and has the given Java element as child
- *
- * @param je the Java element for which to search the closest input
- * @return the closest Java element used as input for this part
- */
- protected IJavaScriptElement findInputForJavaElement(IJavaScriptElement je) {
- if (je == null || !je.exists())
- return null;
- if (isValidInput(je))
- return je;
- return findInputForJavaElement(je.getParent());
- }
-
- protected final IJavaScriptElement findElementToSelect(Object obj) {
- if (obj instanceof IJavaScriptElement)
- return findElementToSelect((IJavaScriptElement)obj);
- return null;
- }
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param je the Java element which has the focus
- * @return returns the element to select
- */
- abstract protected IJavaScriptElement findElementToSelect(IJavaScriptElement je);
-
-
- protected final Object getSingleElementFromSelection(ISelection selection) {
- if (!(selection instanceof IStructuredSelection) || selection.isEmpty())
- return null;
-
- Iterator iter= ((IStructuredSelection)selection).iterator();
- Object firstElement= iter.next();
- if (!(firstElement instanceof IJavaScriptElement)) {
- if (firstElement instanceof IMarker)
- firstElement= ((IMarker)firstElement).getResource();
- if (firstElement instanceof IAdaptable) {
- IJavaScriptElement je= (IJavaScriptElement)((IAdaptable)firstElement).getAdapter(IJavaScriptElement.class);
- if (je == null && firstElement instanceof IFile) {
- IContainer parent= ((IFile)firstElement).getParent();
- if (parent != null)
- return parent.getAdapter(IJavaScriptElement.class);
- else return null;
- } else
- return je;
-
- } else
- return firstElement;
- }
- Object currentInput= getViewer().getInput();
- if (currentInput == null || !currentInput.equals(findInputForJavaElement((IJavaScriptElement)firstElement)))
- if (iter.hasNext())
- // multi-selection and view is empty
- return null;
- else
- // OK: single selection and view is empty
- return firstElement;
-
- // be nice to multi-selection
- while (iter.hasNext()) {
- Object element= iter.next();
- if (!(element instanceof IJavaScriptElement))
- return null;
- if (!currentInput.equals(findInputForJavaElement((IJavaScriptElement)element)))
- return null;
- }
- return firstElement;
- }
-
- /**
- * Gets the typeComparator.
- * @return Returns a JavaElementTypeComparator
- */
- protected Comparator getTypeComparator() {
- return fTypeComparator;
- }
-
- /**
- * Links to editor (if option enabled)
- * @param selection the selection
- */
- private void linkToEditor(IStructuredSelection selection) {
- Object obj= selection.getFirstElement();
-
- if (selection.size() == 1) {
- IEditorPart part= EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page= getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof IJavaScriptElement)
- EditorUtility.revealInEditor(part, (IJavaScriptElement) obj);
- }
- }
- }
-
- void setSelectionFromEditor(IWorkbenchPart part) {
- if (!fProcessSelectionEvents || !linkBrowsingViewSelectionToEditor() || !(part instanceof IEditorPart))
- return;
-
- IWorkbenchPartSite site= part.getSite();
- if (site == null)
- return;
- ISelectionProvider provider= site.getSelectionProvider();
- if (provider != null)
- setSelectionFromEditor(part, provider.getSelection());
- }
-
- private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) {
- if (part instanceof IEditorPart) {
- IJavaScriptElement element= null;
- if (selection instanceof IStructuredSelection) {
- Object obj= getSingleElementFromSelection(selection);
- if (obj instanceof IJavaScriptElement)
- element= (IJavaScriptElement)obj;
- }
- IEditorInput ei= ((IEditorPart)part).getEditorInput();
- if (selection instanceof ITextSelection) {
- int offset= ((ITextSelection)selection).getOffset();
- element= getElementAt(ei, offset);
- }
- if (element != null) {
- adjustInputAndSetSelection(element);
- return;
- }
- if (ei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)ei).getFile();
- IJavaScriptElement je= (IJavaScriptElement)file.getAdapter(IJavaScriptElement.class);
- if (je == null) {
- IContainer container= ((IFileEditorInput)ei).getFile().getParent();
- if (container != null)
- je= (IJavaScriptElement)container.getAdapter(IJavaScriptElement.class);
- }
- if (je == null) {
- setSelection(null, false);
- return;
- }
- adjustInputAndSetSelection(je);
- } else if (ei instanceof IClassFileEditorInput) {
- IClassFile cf= ((IClassFileEditorInput)ei).getClassFile();
- adjustInputAndSetSelection(cf);
- }
- }
- }
-
- /**
- * Returns the element contained in the EditorInput
- * @param input the editor input
- * @return the input element
- */
- Object getElementOfInput(IEditorInput input) {
- if (input instanceof IFileEditorInput)
- return ((IFileEditorInput)input).getFile();
- if (input != null)
- return JavaScriptUI.getEditorInputJavaElement(input);
- return null;
- }
-
- void setSelection(ISelection selection, boolean reveal) {
- if (selection != null && selection.equals(fViewer.getSelection()))
- return;
- fProcessSelectionEvents= false;
- fViewer.setSelection(selection, reveal);
- fProcessSelectionEvents= true;
- }
-
- /**
- * @param input the editor input
- * @param offset the offset in the file
- * @return the element at the given offset
- */
- protected IJavaScriptElement getElementAt(IEditorInput input, int offset) {
- if (input instanceof IClassFileEditorInput) {
- try {
- return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset);
- } catch (JavaScriptModelException ex) {
- return null;
- }
- }
-
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- IJavaScriptUnit unit= manager.getWorkingCopy(input);
- if (unit != null)
- try {
- if (unit.isConsistent())
- return unit.getElementAt(offset);
- else {
- /*
- * XXX: We should set the selection later when the
- * CU is reconciled.
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
- */
- }
- } catch (JavaScriptModelException ex) {
- // fall through
- }
- return null;
- }
-
- protected IType getTypeForCU(IJavaScriptUnit cu) {
- // Use primary type if possible
- IType primaryType= cu.findPrimaryType();
- if (primaryType != null)
- return primaryType;
-
- // Use first top-level type
- try {
- IType[] types= cu.getTypes();
- if (types.length > 0)
- return types[0];
- else
- return null;
- } catch (JavaScriptModelException ex) {
- return null;
- }
- }
-
- void setProcessSelectionEvents(boolean state) {
- fProcessSelectionEvents= state;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (fViewer != null) {
- return fViewer.getInput();
- }
- return null;
- }
-
- protected void setActionGroups(CompositeActionGroup actionGroups) {
- fActionGroups= actionGroups;
- }
-
- protected void setBuildActionGroup(BuildActionGroup actionGroup) {
- fBuildActionGroup= actionGroup;
- }
-
- protected void setCCPActionGroup(CCPActionGroup actionGroup) {
- fCCPActionGroup= actionGroup;
- }
-
- protected void setCustomFiltersActionGroup(CustomFiltersActionGroup customFiltersActionGroup) {
- fCustomFiltersActionGroup= customFiltersActionGroup;
- }
-
- protected boolean hasCustomFilter() {
- return fHasCustomFilter;
- }
-
- protected boolean hasWorkingSetFilter() {
- return fHasWorkingSetFilter;
- }
-
- protected void setOpenEditorGroup(OpenEditorActionGroup openEditorGroup) {
- fOpenEditorGroup= openEditorGroup;
- }
-
- protected OpenEditorActionGroup getOpenEditorGroup() {
- return fOpenEditorGroup;
- }
-
- protected BuildActionGroup getBuildActionGroup() {
- return fBuildActionGroup;
- }
-
- protected CCPActionGroup getCCPActionGroup() {
- return fCCPActionGroup;
- }
-
- private boolean linkBrowsingViewSelectionToEditor() {
- return isLinkingEnabled();
- }
-
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- PreferenceConstants.getPreferenceStore().setValue(getLinkToEditorKey(), enabled);
- if (enabled) {
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor != null) {
- setSelectionFromEditor(editor);
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPerspectiveFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPerspectiveFactory.java
deleted file mode 100644
index 55c89f30..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingPerspectiveFactory.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.progress.IProgressConstants;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-public class JavaBrowsingPerspectiveFactory implements IPerspectiveFactory {
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static IJavaScriptElement fgJavaElementFromAction;
-
- /**
- * Constructs a new Default layout engine.
- */
- public JavaBrowsingPerspectiveFactory() {
- super();
- }
-
- public void createInitialLayout(IPageLayout layout) {
- if (stackBrowsingViewsVertically())
- createVerticalLayout(layout);
- else
- createHorizontalLayout(layout);
-
- // action sets
- layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ACTION_SET);
- layout.addActionSet(JavaScriptUI.ID_ELEMENT_CREATION_ACTION_SET);
- layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(JavaScriptUI.ID_TYPE_HIERARCHY);
- layout.addShowViewShortcut(JavaScriptUI.ID_PACKAGES);
- layout.addShowViewShortcut(JavaScriptUI.ID_PROJECTS_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_PACKAGES_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_TYPES_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_MEMBERS_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_SOURCE_VIEW);
- layout.addShowViewShortcut(JavaScriptUI.ID_JAVADOC_VIEW);
-
- // views - search
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
- layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
-
- // new actions - Java project creation wizard
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.JavaProjectWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.wst.jsdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
- }
-
- private void createVerticalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.LEFT;
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(JavaScriptUI.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(JavaScriptUI.ID_PACKAGES);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- if (shouldShowProjectsView()) {
- layout.addView(JavaScriptUI.ID_PROJECTS_VIEW, IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= JavaScriptUI.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- if (shouldShowPackagesView()) {
- layout.addView(JavaScriptUI.ID_PACKAGES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= JavaScriptUI.ID_PACKAGES_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- layout.addView(JavaScriptUI.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(JavaScriptUI.ID_MEMBERS_VIEW, IPageLayout.BOTTOM, (float)0.50, JavaScriptUI.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- placeHolderBottom.addPlaceholder(JavaScriptUI.ID_SOURCE_VIEW);
- placeHolderBottom.addPlaceholder(JavaScriptUI.ID_JAVADOC_VIEW);
- placeHolderBottom.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
- }
-
- private void createHorizontalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.TOP;
-
- if (shouldShowProjectsView()) {
- layout.addView(JavaScriptUI.ID_PROJECTS_VIEW, IPageLayout.TOP, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= JavaScriptUI.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- if (shouldShowPackagesView()) {
- layout.addView(JavaScriptUI.ID_PACKAGES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= JavaScriptUI.ID_PACKAGES_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- layout.addView(JavaScriptUI.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(JavaScriptUI.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, JavaScriptUI.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(JavaScriptUI.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(JavaScriptUI.ID_PACKAGES);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- placeHolderBottom.addPlaceholder(JavaScriptUI.ID_SOURCE_VIEW);
- placeHolderBottom.addPlaceholder(JavaScriptUI.ID_JAVADOC_VIEW);
- placeHolderBottom.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
- }
-
- private boolean shouldShowProjectsView() {
- return fgJavaElementFromAction == null || fgJavaElementFromAction.getElementType() == IJavaScriptElement.JAVASCRIPT_MODEL;
- }
-
- private boolean shouldShowPackagesView() {
- if (fgJavaElementFromAction == null)
- return true;
- int type= fgJavaElementFromAction.getElementType();
- return type == IJavaScriptElement.JAVASCRIPT_MODEL || type == IJavaScriptElement.JAVASCRIPT_PROJECT || type == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT;
- }
-
- private boolean stackBrowsingViewsVertically() {
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.BROWSING_STACK_VERTICALLY);
- }
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static void setInputFromAction(IAdaptable input) {
- if (input instanceof IJavaScriptElement)
- fgJavaElementFromAction= (IJavaScriptElement)input;
- else
- fgJavaElementFromAction= null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java
deleted file mode 100644
index 575bfba7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.Comparator;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-public class JavaElementTypeComparator implements Comparator {
-
-
- /**
- * Compares two Java element types. A type is considered to be
- * greater if it may contain the other.
- *
- * @return an int less than 0 if object1 is less than object2,
- * 0 if they are equal, and > 0 if object1 is greater
- *
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- if (!(o1 instanceof IJavaScriptElement) || !(o2 instanceof IJavaScriptElement))
- throw new ClassCastException();
- return getIdForJavaElement((IJavaScriptElement)o1) - getIdForJavaElement((IJavaScriptElement)o2);
- }
-
- /**
- * Compares two Java element types. A type is considered to be
- * greater if it may contain the other.
- *
- * @return an int < 0 if object1 is less than object2,
- * 0 if they are equal, and > 0 if object1 is greater
- *
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, int elementType) {
- if (!(o1 instanceof IJavaScriptElement))
- throw new ClassCastException();
- return getIdForJavaElement((IJavaScriptElement)o1) - getIdForJavaElementType(elementType);
- }
-
- int getIdForJavaElement(IJavaScriptElement element) {
- return getIdForJavaElementType(element.getElementType());
- }
-
- int getIdForJavaElementType(int elementType) {
- switch (elementType) {
- case IJavaScriptElement.JAVASCRIPT_MODEL:
- return 130;
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- return 120;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- return 110;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- return 100;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return 90;
- case IJavaScriptElement.CLASS_FILE:
- return 80;
- case IJavaScriptElement.TYPE:
- return 70;
- case IJavaScriptElement.FIELD:
- return 60;
- case IJavaScriptElement.METHOD:
- return 50;
- case IJavaScriptElement.INITIALIZER:
- return 40;
- case IJavaScriptElement.PACKAGE_DECLARATION:
- return 30;
- case IJavaScriptElement.IMPORT_CONTAINER:
- return 20;
- case IJavaScriptElement.IMPORT_DECLARATION:
- return 10;
- default :
- return 1;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackage.java
deleted file mode 100644
index 03c3d19a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackage.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * Contains a list of package fragments with the same name
- * but residing in different source folders of a unique Java project.
- */
-public class LogicalPackage extends PlatformObject {
-
- private Set fPackages;
- private String fName;
- private IJavaScriptProject fJavaProject;
-
- public LogicalPackage(IPackageFragment fragment){
- Assert.isNotNull(fragment);
- fPackages= new HashSet();
- fJavaProject= fragment.getJavaScriptProject();
- Assert.isNotNull(fJavaProject);
- add(fragment);
- fName= fragment.getElementName();
- }
-
- public IJavaScriptProject getJavaProject(){
- return fJavaProject;
- }
-
- public IPackageFragment[] getFragments(){
- return (IPackageFragment[]) fPackages.toArray(new IPackageFragment[fPackages.size()]);
- }
-
- public void add(IPackageFragment fragment){
- Assert.isTrue(fragment != null && fJavaProject.equals(fragment.getJavaScriptProject()));
- fPackages.add(fragment);
- }
-
- public void remove(IPackageFragment fragment){
- fPackages.remove(fragment);
- }
-
- public boolean contains(IPackageFragment fragment){
- return fPackages.contains(fragment);
- }
-
- public String getElementName(){
- return fName;
- }
-
- public int size(){
- return fPackages.size();
- }
-
- /**
- * Returns true if the given fragment has the same name and
- * resides inside the same project as the other fragments in
- * the LogicalPackage.
- *
- * @param fragment
- * @return boolean
- */
- public boolean belongs(IPackageFragment fragment) {
-
- if(fragment==null)
- return false;
-
- if(fJavaProject.equals(fragment.getJavaScriptProject())){
- return fName.equals(fragment.getElementName());
- }
-
- return false;
- }
-
- public boolean hasSubpackages() throws JavaScriptModelException {
- for (Iterator iter= fPackages.iterator(); iter.hasNext();) {
- IPackageFragment pack= (IPackageFragment) iter.next();
- if (pack.hasSubpackages()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isDefaultPackage() {
- return fName.length() == 0;
- }
-
- public boolean equals(Object o){
- if (!(o instanceof LogicalPackage))
- return false;
-
- LogicalPackage lp= (LogicalPackage)o;
- if (!fJavaProject.equals(lp.getJavaProject()))
- return false;
-
- IPackageFragment[] fragments= lp.getFragments();
-
- if (fragments.length != getFragments().length)
- return false;
-
- //this works because a LogicalPackage cannot contain the same IPackageFragment twice
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- if(!fPackages.contains(fragment))
- return false;
- }
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- IPackageFragment[] fragments= getFragments();
- return fJavaProject.hashCode() + getHash(fragments, fragments.length-1);
- }
-
- private int getHash(IPackageFragment[] fragments, int index) {
- if (index <= 0)
- return fragments[0].hashCode() * 17;
- else return fragments[index].hashCode() * 17 + getHash(fragments, index-1);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackagesProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackagesProvider.java
deleted file mode 100644
index 5b298f0c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/LogicalPackagesProvider.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElementChangedListener {
-
- protected static final Object[] NO_CHILDREN= new Object[0];
-
- protected Map fMapToLogicalPackage;
- protected Map fMapToPackageFragments;
- protected boolean fCompoundState;
- protected StructuredViewer fViewer;
- protected boolean fInputIsProject;
-
- public LogicalPackagesProvider(StructuredViewer viewer){
- fViewer= viewer;
- fCompoundState= isInCompoundState();
- fInputIsProject= true;
- fMapToLogicalPackage= new HashMap();
- fMapToPackageFragments= new HashMap();
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /**
- * Adds the given fragments to the internal map.
- * Existing fragments will be replaced by the new ones.
- *
- * @param packageFragments the package fragments to add
- */
- protected void addFragmentsToMap(IPackageFragment[] packageFragments) {
- for (int i= 0; i < packageFragments.length; i++) {
- IPackageFragment fragment= packageFragments[i];
- String key= getKey(fragment);
- fMapToPackageFragments.put(key, fragment);
- }
- }
-
- protected String getKey(IPackageFragment fragment) {
- return fragment.getElementName() + fragment.getJavaScriptProject().getElementName();
- }
-
- /**
- * Returns the logical package for the given package fragment
- * or <code>null</code> if it is not grouped by logical package.
- *
- * @param fragment the package fragment
- * @return the logical package
- */
- public LogicalPackage findLogicalPackage(IPackageFragment fragment) {
- Assert.isNotNull(fragment);
- if (isInCompoundState())
- return (LogicalPackage)fMapToLogicalPackage.get(getKey(fragment));
- else
- return null;
- }
-
- /**
- * Combines packages with same names into a logical package which will
- * be added to the resulting array. If a package is not yet in this content
- * provider then the package fragment is added to the resulting array.
- *
- * @param packageFragments the package fragments to combine
- * @return an array with combined (logical) packages and package fragments
- */
- protected Object[] combineSamePackagesIntoLogialPackages(IPackageFragment[] packageFragments) {
-
- if (!fCompoundState)
- return packageFragments;
-
- List newChildren= new ArrayList();
-
- for (int i= 0; i < packageFragments.length; i++) {
- IPackageFragment fragment= packageFragments[i];
-
- if (fragment == null)
- continue;
-
- LogicalPackage lp= findLogicalPackage(fragment);
-
- if (lp != null) {
- if (lp.belongs(fragment)) {
- lp.add(fragment);
- }
- if(!newChildren.contains(lp))
- newChildren.add(lp);
-
- } else {
- String key= getKey(fragment);
- IPackageFragment frag= (IPackageFragment)fMapToPackageFragments.get(key);
- if (frag != null && !fragment.equals(frag)) {
- lp= new LogicalPackage(frag);
- lp.add(fragment);
- newChildren.remove(frag);
- newChildren.add(lp);
- fMapToLogicalPackage.put(key, lp);
- fMapToPackageFragments.remove(frag);
- } else {
- fMapToPackageFragments.put(key, fragment);
- newChildren.add(fragment);
- }
- }
- }
- return newChildren.toArray();
- }
-
- /**
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (fCompoundState == isInCompoundState())
- return;
- else
- fCompoundState= isInCompoundState();
-
- if (!isInCompoundState()) {
- fMapToLogicalPackage.clear();
- fMapToPackageFragments.clear();
- }
-
- if(fViewer instanceof TreeViewer){
- TreeViewer viewer= (TreeViewer) fViewer;
- Object[] expandedObjects= viewer.getExpandedElements();
- viewer.refresh();
- viewer.setExpandedElements(expandedObjects);
- } else
- fViewer.refresh();
- }
-
- protected boolean isInCompoundState() {
- // XXX: for now we don't offer a preference might become a view menu entry
- // return AppearancePreferencePage.logicalPackagesInPackagesView();
- return true;
- }
-
- public void dispose(){
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- fMapToLogicalPackage= null;
- fMapToPackageFragments= null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput != null) {
- JavaScriptCore.addElementChangedListener(this);
- } else {
- JavaScriptCore.removeElementChangedListener(this);
- }
- fInputIsProject= (newInput instanceof IJavaScriptProject);
-
- if(viewer instanceof StructuredViewer)
- fViewer= (StructuredViewer)viewer;
- }
-
- abstract protected void processDelta(IJavaScriptElementDelta delta) throws JavaScriptModelException;
-
- /*
- *
- */
- protected boolean isClassPathChange(IJavaScriptElementDelta delta) {
-
- // need to test the flags only for package fragment roots
- if (delta.getElement().getElementType() != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT)
- return false;
-
- int flags= delta.getFlags();
- return (delta.getKind() == IJavaScriptElementDelta.CHANGED &&
- ((flags & IJavaScriptElementDelta.F_ADDED_TO_CLASSPATH) != 0) ||
- ((flags & IJavaScriptElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) ||
- ((flags & IJavaScriptElementDelta.F_REORDER) != 0));
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.IElementChangedListener#elementChanged(org.eclipse.wst.jsdt.core.ElementChangedEvent)
- */
- public void elementChanged(ElementChangedEvent event) {
- try {
- processDelta(event.getDelta());
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java
deleted file mode 100644
index 6cf0c0f3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IImportContainer;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.CategoryFilterActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.LexicalSortingAction;
-import org.eclipse.wst.jsdt.internal.ui.preferences.MembersOrderPreferenceCache;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.MemberFilterActionGroup;
-
-public class MembersView extends JavaBrowsingPart implements IPropertyChangeListener {
-
- private MemberFilterActionGroup fMemberFilterActionGroup;
- /**
- * Category filter action group.
- *
- */
- private CategoryFilterActionGroup fCategoryFilterActionGroup;
-
-
- public MembersView() {
- setHasWorkingSetFilter(false);
- setHasCustomSetFilter(true);
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected JavaUILabelProvider createLabelProvider() {
- return new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.ALL_CATEGORY,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
- );
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.MEMBERS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.eclipse.swt.widgets.Composite)
- */
- protected StructuredViewer createViewer(Composite parent) {
- ProblemTreeViewer viewer= new ProblemTreeViewer(parent, SWT.MULTI);
- ColoredViewersManager.install(viewer);
- fMemberFilterActionGroup= new MemberFilterActionGroup(viewer, JavaScriptUI.ID_MEMBERS_VIEW);
- return viewer;
- }
-
- protected void fillToolBar(IToolBarManager tbm) {
- tbm.add(new LexicalSortingAction(getViewer(), JavaScriptUI.ID_MEMBERS_VIEW));
- fMemberFilterActionGroup.contributeToToolBar(tbm);
- super.fillToolBar(tbm);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#fillActionBars(org.eclipse.ui.IActionBars)
- *
- */
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- fCategoryFilterActionGroup= new CategoryFilterActionGroup(getViewer(), getViewSite().getId(), getCategoryFilterActionGroupInput());
- fCategoryFilterActionGroup.contributeToViewMenu(actionBars.getMenuManager());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#setInput(java.lang.Object)
- *
- */
- protected void setInput(Object input) {
- super.setInput(input);
- if (fCategoryFilterActionGroup != null)
- fCategoryFilterActionGroup.setInput(getCategoryFilterActionGroupInput());
- }
-
- private IJavaScriptElement[] getCategoryFilterActionGroupInput() {
- Object input= getInput();
- if (input instanceof IJavaScriptElement)
- return new IJavaScriptElement[] { (IJavaScriptElement)input };
- return new IJavaScriptElement[0];
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- if (element instanceof IType) {
- IType type= (IType)element;
- return type.isBinary() || type.getDeclaringType() == null;
- }
- return false;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof IMember)
- return super.isValidElement(((IMember)element).getDeclaringType());
- else if (element instanceof IImportDeclaration)
- return isValidElement(((IJavaScriptElement)element).getParent());
- else if (element instanceof IImportContainer) {
- Object input= getViewer().getInput();
- if (input instanceof IJavaScriptElement) {
- IJavaScriptUnit cu= (IJavaScriptUnit)((IJavaScriptElement)input).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- IJavaScriptUnit importContainerCu= (IJavaScriptUnit)((IJavaScriptElement)element).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- return cu.equals(importContainerCu);
- } else {
- IClassFile cf= (IClassFile)((IJavaScriptElement)input).getAncestor(IJavaScriptElement.CLASS_FILE);
- IClassFile importContainerCf= (IClassFile)((IJavaScriptElement)element).getAncestor(IJavaScriptElement.CLASS_FILE);
- return cf != null && cf.equals(importContainerCf);
- }
- }
- }
- return false;
- }
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param je the Java element which has the focus
- * @return the element to select
- */
- protected IJavaScriptElement findElementToSelect(IJavaScriptElement je) {
- if (je == null)
- return null;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.TYPE:
- if (((IType)je).getDeclaringType() == null)
- return null;
- return je;
- case IJavaScriptElement.METHOD:
- case IJavaScriptElement.INITIALIZER:
- case IJavaScriptElement.FIELD:
- case IJavaScriptElement.PACKAGE_DECLARATION:
- case IJavaScriptElement.IMPORT_CONTAINER:
- return je;
- case IJavaScriptElement.IMPORT_DECLARATION:
- IJavaScriptUnit cu= (IJavaScriptUnit)je.getParent().getParent();
- try {
- if (cu.getImports()[0].equals(je)) {
- Object selectedElement= getSingleElementFromSelection(getViewer().getSelection());
- if (selectedElement instanceof IImportContainer)
- return (IImportContainer)selectedElement;
- }
- } catch (JavaScriptModelException ex) {
- // return je;
- }
- return je;
- }
- return null;
- }
-
- /**
- * Finds the closest Java element which can be used as input for
- * this part and has the given Java element as child.
- *
- * @param je the Java element for which to search the closest input
- * @return the closest Java element used as input for this part, or <code>null</code>
- */
- protected IJavaScriptElement findInputForJavaElement(IJavaScriptElement je) {
- if (je == null || !je.exists() || (je.getJavaScriptProject() != null && !je.getJavaScriptProject().isOnIncludepath(je)))
- return null;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.TYPE:
- IType type= ((IType)je).getDeclaringType();
- if (type == null)
- return je;
- else
- return findInputForJavaElement(type);
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return getTypeForCU((IJavaScriptUnit)je);
- case IJavaScriptElement.CLASS_FILE:
- return findInputForJavaElement(((IClassFile)je).getType());
- case IJavaScriptElement.IMPORT_DECLARATION:
- return findInputForJavaElement(je.getParent());
- case IJavaScriptElement.PACKAGE_DECLARATION:
- case IJavaScriptElement.IMPORT_CONTAINER:
- IJavaScriptElement parent= je.getParent();
- if (parent instanceof IJavaScriptUnit) {
- return getTypeForCU((IJavaScriptUnit)parent);
- }
- else if (parent instanceof IClassFile)
- return findInputForJavaElement(parent);
- return null;
- default:
- if (je instanceof IMember)
- return findInputForJavaElement(((IMember)je).getDeclaringType());
- }
- return null;
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void saveState(IMemento memento) {
- super.saveState(memento);
- fMemberFilterActionGroup.saveState(memento);
- }
-
- protected void restoreState(IMemento memento) {
- super.restoreState(memento);
- fMemberFilterActionGroup.restoreState(memento);
- getViewer().getControl().setRedraw(false);
- getViewer().refresh();
- getViewer().getControl().setRedraw(true);
- }
-
- protected void hookViewerListeners() {
- super.hookViewerListeners();
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TreeViewer viewer= (TreeViewer)getViewer();
- Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- });
- }
-
- boolean isInputAWorkingCopy() {
- Object input= getViewer().getInput();
- if (input instanceof IJavaScriptElement) {
- IJavaScriptUnit cu= (IJavaScriptUnit)((IJavaScriptElement)input).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null)
- return cu.isWorkingCopy();
- }
- return false;
- }
-
- protected void restoreSelection() {
- IEditorPart editor= getViewSite().getPage().getActiveEditor();
- if (editor != null)
- setSelectionFromEditor(editor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
- getViewer().refresh();
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#dispose()
- */
- public void dispose() {
- if (fMemberFilterActionGroup != null) {
- fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
- }
- if (fCategoryFilterActionGroup != null) {
- fCategoryFilterActionGroup.dispose();
- fCategoryFilterActionGroup= null;
- }
- super.dispose();
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackageViewerWrapper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackageViewerWrapper.java
deleted file mode 100644
index 7e810c3b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackageViewerWrapper.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-
-/**
- * Wrapper who transfers listeners and filters and to which clients
- * can refer.
- *
- * @deprecated needs to be replaced by a manager who handles transfer of listeners and filters
- */
-class PackageViewerWrapper extends StructuredViewer {
-
- private StructuredViewer fViewer;
- private ListenerList fListenerList;
- private ListenerList fSelectionChangedListenerList;
- private ListenerList fPostSelectionChangedListenerList;
-
- public PackageViewerWrapper() {
- fListenerList= new ListenerList(ListenerList.IDENTITY);
- fPostSelectionChangedListenerList= new ListenerList(ListenerList.IDENTITY);
- fSelectionChangedListenerList= new ListenerList(ListenerList.IDENTITY);
- }
-
- public void setViewer(StructuredViewer viewer) {
- Assert.isNotNull(viewer);
-
- StructuredViewer oldViewer= fViewer;
- fViewer= viewer;
-
- if (fViewer.getContentProvider() != null)
- super.setContentProvider(fViewer.getContentProvider());
- transferFilters(oldViewer);
- transferListeners();
- }
-
- StructuredViewer getViewer(){
- return fViewer;
- }
-
- private void transferFilters(StructuredViewer oldViewer) {
- //set filters
- if (oldViewer != null) {
- ViewerFilter[] filters= oldViewer.getFilters();
- for (int i= 0; i < filters.length; i++) {
- ViewerFilter filter= filters[i];
- fViewer.addFilter(filter);
- }
- }
- }
-
- private void transferListeners() {
-
- Object[] listeners= fPostSelectionChangedListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- Object object= listeners[i];
- ISelectionChangedListener listener= (ISelectionChangedListener)object;
- fViewer.addPostSelectionChangedListener(listener);
- }
-
- listeners= fSelectionChangedListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- Object object= listeners[i];
- ISelectionChangedListener listener= (ISelectionChangedListener)object;
- fViewer.addSelectionChangedListener(listener);
- }
-
- // Add all other listeners
- listeners= fListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- Object object= listeners[i];
-
- if (object instanceof IOpenListener) {
- IOpenListener listener= (IOpenListener) object;
- addOpenListener(listener);
- } else if (object instanceof HelpListener) {
- HelpListener listener= (HelpListener) object;
- addHelpListener(listener);
- } else if (object instanceof IDoubleClickListener) {
- IDoubleClickListener listener= (IDoubleClickListener) object;
- addDoubleClickListener(listener);
- }
- }
- }
-
- public void setSelection(ISelection selection, boolean reveal) {
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection sel= (IStructuredSelection) selection;
-
- //try and give the two a common super class
- IContentProvider provider= getContentProvider();
- if (provider instanceof LogicalPackagesProvider) {
- LogicalPackagesProvider fprovider= (LogicalPackagesProvider) provider;
-
- Object object= sel.getFirstElement();
- if (object instanceof IPackageFragment) {
- IPackageFragment pkgFragment= (IPackageFragment)object;
- LogicalPackage logicalPkg= fprovider.findLogicalPackage(pkgFragment);
- if (logicalPkg != null)
- object= logicalPkg;
- else
- object= pkgFragment;
- }
- if (object != null)
- fViewer.setSelection(new StructuredSelection(object), reveal);
- else
- fViewer.setSelection(StructuredSelection.EMPTY, reveal);
- }
- } else
- fViewer.setSelection(selection, reveal);
- }
-
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- fPostSelectionChangedListenerList.add(listener);
- fViewer.addPostSelectionChangedListener(listener);
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListenerList.add(listener);
- fViewer.addSelectionChangedListener(listener);
- }
-
- public void addDoubleClickListener(IDoubleClickListener listener) {
- fViewer.addDoubleClickListener(listener);
- fListenerList.add(listener);
- }
-
- public void addOpenListener(IOpenListener listener) {
- fViewer.addOpenListener(listener);
- fListenerList.add(listener);
- }
-
- public void addHelpListener(HelpListener listener) {
- fViewer.addHelpListener(listener);
- fListenerList.add(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fViewer.removeSelectionChangedListener(listener);
- fSelectionChangedListenerList.remove(listener);
- }
-
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- fViewer.removePostSelectionChangedListener(listener);
- fPostSelectionChangedListenerList.remove(listener);
- }
-
- public void removeHelpListener(HelpListener listener) {
- fListenerList.remove(listener);
- fViewer.removeHelpListener(listener);
- }
-
- public void removeDoubleClickListener(IDoubleClickListener listener) {
- fViewer.removeDoubleClickListener(listener);
- fListenerList.remove(listener);
- }
-
- public void removeOpenListener(IOpenListener listener) {
- fViewer.removeOpenListener(listener);
- fListenerList.remove(listener);
- }
-
- // --------- simply delegate to wrapped viewer ---------
- public Control getControl() {
- return fViewer.getControl();
- }
-
- public void addFilter(ViewerFilter filter) {
- fViewer.addFilter(filter);
- }
-
- public void setFilters(ViewerFilter[] filters) {
- fViewer.setFilters(filters);
- }
-
- public void refresh() {
- fViewer.refresh();
- }
-
- public void removeFilter(ViewerFilter filter) {
- fViewer.removeFilter(filter);
- }
-
- public ISelection getSelection() {
- return fViewer.getSelection();
- }
-
- public void refresh(boolean updateLabels) {
- fViewer.refresh(updateLabels);
- }
-
- public void refresh(Object element, boolean updateLabels) {
- fViewer.refresh(element, updateLabels);
- }
-
- public void refresh(Object element) {
- fViewer.refresh(element);
- }
-
- public void resetFilters() {
- fViewer.resetFilters();
- }
-
- public void reveal(Object element) {
- fViewer.reveal(element);
- }
-
- public void setContentProvider(IContentProvider contentProvider) {
- fViewer.setContentProvider(contentProvider);
- }
-
- public void setSorter(ViewerSorter sorter) {
- fViewer.setSorter(sorter);
- }
-
- public void setComparator(ViewerComparator comparator) {
- fViewer.setComparator(comparator);
- }
-
- public void setUseHashlookup(boolean enable) {
- fViewer.setUseHashlookup(enable);
- }
-
- public Widget testFindItem(Object element) {
- return fViewer.testFindItem(element);
- }
-
- public void update(Object element, String[] properties) {
- fViewer.update(element, properties);
- }
-
- public void update(Object[] elements, String[] properties) {
- fViewer.update(elements, properties);
- }
-
- public IContentProvider getContentProvider() {
- return fViewer.getContentProvider();
- }
-
- public Object getInput() {
- return fViewer.getInput();
- }
-
- public IBaseLabelProvider getLabelProvider() {
- return fViewer.getLabelProvider();
- }
-
- public void setLabelProvider(IBaseLabelProvider labelProvider) {
- fViewer.setLabelProvider(labelProvider);
- }
-
- public Object getData(String key) {
- return fViewer.getData(key);
- }
-
- public Item scrollDown(int x, int y) {
- return fViewer.scrollDown(x, y);
- }
-
- public Item scrollUp(int x, int y) {
- return fViewer.scrollUp(x, y);
- }
-
- public void setData(String key, Object value) {
- fViewer.setData(key, value);
- }
-
- public void setSelection(ISelection selection) {
- fViewer.setSelection(selection);
- }
-
- public boolean equals(Object obj) {
- return fViewer.equals(obj);
- }
-
- public int hashCode() {
- return fViewer.hashCode();
- }
-
- public String toString() {
- return fViewer.toString();
- }
-
- public void setViewerInput(Object input){
- fViewer.setInput(input);
- }
-
- // need to provide implementation for abstract methods
- protected Widget doFindInputItem(Object element) {
- return ((IPackagesViewViewer)fViewer).doFindInputItem(element);
- }
-
- protected Widget doFindItem(Object element) {
- return ((IPackagesViewViewer)fViewer).doFindItem(element);
- }
-
- protected void doUpdateItem(Widget item, Object element, boolean fullMap) {
- ((IPackagesViewViewer)fViewer).doUpdateItem(item, element, fullMap);
- }
-
- protected List getSelectionFromWidget() {
- return ((IPackagesViewViewer)fViewer).getSelectionFromWidget();
- }
-
- protected void internalRefresh(Object element) {
- ((IPackagesViewViewer)fViewer).internalRefresh(element);
- }
-
- protected void setSelectionToWidget(List l, boolean reveal) {
- ((IPackagesViewViewer)fViewer).setSelectionToWidget(l, reveal);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesView.java
deleted file mode 100644
index 498c0d62..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesView.java
+++ /dev/null
@@ -1,653 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.Assert;
-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.IContributionItem;
-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.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.actions.MultiActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectAllAction;
-import org.eclipse.wst.jsdt.internal.ui.filters.NonJavaElementFilter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.LibraryFilter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTableViewer;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-public class PackagesView extends JavaBrowsingPart{
-
- private static final String TAG_VIEW_STATE= ".viewState"; //$NON-NLS-1$
- private static final int LIST_VIEW_STATE= 0;
- private static final int TREE_VIEW_STATE= 1;
-
-
- private static class StatusBarUpdater4LogicalPackage extends StatusBarUpdater {
-
- private StatusBarUpdater4LogicalPackage(IStatusLineManager statusLineManager) {
- super(statusLineManager);
- }
-
- protected String formatMessage(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection selection= (IStructuredSelection)sel;
- int nElements= selection.size();
- Object elem= selection.getFirstElement();
- if (nElements == 1 && (elem instanceof LogicalPackage))
- return formatLogicalPackageMessage((LogicalPackage) elem);
- }
- return super.formatMessage(sel);
- }
-
- private String formatLogicalPackageMessage(LogicalPackage logicalPackage) {
- IPackageFragment[] fragments= logicalPackage.getFragments();
- StringBuffer buf= new StringBuffer(logicalPackage.getElementName());
- buf.append(JavaScriptElementLabels.CONCAT_STRING);
- String message= ""; //$NON-NLS-1$
- boolean firstTime= true;
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- IJavaScriptElement element= fragment.getParent();
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) element;
- String label= JavaScriptElementLabels.getElementLabel(root, JavaScriptElementLabels.DEFAULT_QUALIFIED | JavaScriptElementLabels.ROOT_QUALIFIED);
- if (firstTime) {
- buf.append(label);
- firstTime= false;
- }
- else
- message= Messages.format(JavaBrowsingMessages.StatusBar_concat, new String[] {message, label});
- }
- }
- buf.append(message);
- return buf.toString();
- }
- }
-
-
- private SelectAllAction fSelectAllAction;
-
- private int fCurrViewState;
-
- private PackageViewerWrapper fWrappedViewer;
-
- private MultiActionGroup fSwitchActionGroup;
- private boolean fLastInputWasProject;
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(createNonJavaElementFilter());
- getViewer().addFilter(new LibraryFilter());
- }
-
-
- /**
- * Creates new NonJavaElementFilter and overrides method select to allow for
- * LogicalPackages.
- * @return NonJavaElementFilter
- */
- protected NonJavaElementFilter createNonJavaElementFilter() {
- return new NonJavaElementFilter(){
- public boolean select(Viewer viewer, Object parent, Object element){
- return ((element instanceof IJavaScriptElement) || (element instanceof LogicalPackage) || (element instanceof IFolder));
- }
- };
- }
-
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- //this must be created before all actions and filters
- fWrappedViewer= new PackageViewerWrapper();
- restoreLayoutState(memento);
- }
-
- private void restoreLayoutState(IMemento memento) {
- if (memento == null) {
- //read state from the preference store
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- fCurrViewState= store.getInt(this.getViewSite().getId() + TAG_VIEW_STATE);
- } else {
- //restore from memento
- Integer integer= memento.getInteger(this.getViewSite().getId() + TAG_VIEW_STATE);
- if ((integer == null) || !isValidState(integer.intValue())) {
- fCurrViewState= LIST_VIEW_STATE;
- } else fCurrViewState= integer.intValue();
- }
- }
-
- private boolean isValidState(int state) {
- return (state==LIST_VIEW_STATE) || (state==TREE_VIEW_STATE);
- }
-
-
-
- /*
- * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento)
- */
- public void saveState(IMemento memento) {
- super.saveState(memento);
- memento.putInteger(this.getViewSite().getId()+TAG_VIEW_STATE,fCurrViewState);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.eclipse.swt.widgets.Composite)
- */
- protected StructuredViewer createViewer(Composite parent) {
- //Creates the viewer of this part dependent on the current layout.
- StructuredViewer viewer;
- if(isInListState())
- viewer= createTableViewer(parent);
- else
- viewer= createTreeViewer(parent);
-
- fWrappedViewer.setViewer(viewer);
- return fWrappedViewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES, IPageLayout.ID_RES_NAV };
- }
- };
- }
- return super.getAdapter(key);
- }
-
- protected boolean isInListState() {
- return fCurrViewState== LIST_VIEW_STATE;
- }
-
- private ProblemTableViewer createTableViewer(Composite parent) {
- return new PackagesViewTableViewer(parent, SWT.MULTI);
- }
-
- private ProblemTreeViewer createTreeViewer(Composite parent) {
- return new PackagesViewTreeViewer(parent, SWT.MULTI);
- }
-
- /**
- * Overrides the createContentProvider from JavaBrowsingPart
- * Creates the content provider of this part.
- */
- protected IContentProvider createContentProvider() {
- if(isInListState())
- return new PackagesViewFlatContentProvider(fWrappedViewer.getViewer());
- else return new PackagesViewHierarchicalContentProvider(fWrappedViewer.getViewer());
- }
-
- protected JavaUILabelProvider createLabelProvider() {
- if(isInListState())
- return createListLabelProvider();
- else return createTreeLabelProvider();
- }
-
- private JavaUILabelProvider createTreeLabelProvider() {
- return new PackagesViewLabelProvider(PackagesViewLabelProvider.HIERARCHICAL_VIEW_STATE);
- }
-
- private JavaUILabelProvider createListLabelProvider() {
- return new PackagesViewLabelProvider(PackagesViewLabelProvider.FLAT_VIEW_STATE);
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.PACKAGES_BROWSING_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_PACKAGES_TO_EDITOR;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- if (element instanceof IJavaScriptProject || (element instanceof IPackageFragmentRoot && ((IJavaScriptElement)element).getElementName() != IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH))
- try {
- IJavaScriptProject jProject= ((IJavaScriptElement)element).getJavaScriptProject();
- if (jProject != null)
- return jProject.getProject().hasNature(JavaScriptCore.NATURE_ID);
- } catch (CoreException ex) {
- return false;
- }
- return false;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof IPackageFragment) {
- IJavaScriptElement parent= ((IPackageFragment)element).getParent();
- if (parent != null)
- return super.isValidElement(parent) || super.isValidElement(parent.getJavaScriptProject());
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#findElementToSelect(org.eclipse.wst.jsdt.core.IJavaScriptElement)
- */
- protected IJavaScriptElement findElementToSelect(IJavaScriptElement je) {
- if (je == null)
- return null;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- return je;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return ((IJavaScriptUnit)je).getParent();
- case IJavaScriptElement.CLASS_FILE:
- return ((IClassFile)je).getParent();
- case IJavaScriptElement.TYPE:
- return ((IType)je).getPackageFragment();
- default:
- return findElementToSelect(je.getParent());
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#setInput(java.lang.Object)
- */
- protected void setInput(Object input) {
- setViewerWrapperInput(input);
- super.updateTitle();
- }
-
- private void setViewerWrapperInput(Object input) {
- fWrappedViewer.setViewerInput(input);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#fillActionBars(org.eclipse.ui.IActionBars)
- */
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- fSwitchActionGroup.fillActionBars(actionBars);
- }
-
-
-
- private void setUpViewer(StructuredViewer viewer){
- Assert.isTrue(viewer != null);
-
- JavaUILabelProvider labelProvider= createLabelProvider();
- viewer.setLabelProvider(createDecoratingLabelProvider(labelProvider));
-
- viewer.setComparator(createJavaElementComparator());
- viewer.setUseHashlookup(true);
-
- createContextMenu();
-
- //disapears when control disposed
- addKeyListener();
-
- //this methods only adds listeners to the viewer,
- //these listenters disapear when the viewer is disposed
- hookViewerListeners();
-
- // Set content provider
- viewer.setContentProvider(createContentProvider());
- //Disposed when viewer's Control is disposed
- initDragAndDrop();
-
- }
-
- //alter sorter to include LogicalPackages
- protected JavaScriptElementComparator createJavaElementComparator() {
- return new JavaScriptElementComparator(){
- public int category(Object element) {
- if (element instanceof LogicalPackage) {
- LogicalPackage cp= (LogicalPackage) element;
- return super.category(cp.getFragments()[0]);
- } else return super.category(element);
- }
- public int compare(Viewer viewer, Object e1, Object e2){
- if (e1 instanceof LogicalPackage) {
- LogicalPackage cp= (LogicalPackage) e1;
- e1= cp.getFragments()[0];
- }
- if (e2 instanceof LogicalPackage) {
- LogicalPackage cp= (LogicalPackage) e2;
- e2= cp.getFragments()[0];
- }
- return super.compare(viewer, e1, e2);
- }
- };
- }
-
- protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
- return new StatusBarUpdater4LogicalPackage(slManager);
- }
-
- protected void setSiteSelectionProvider(){
- getSite().setSelectionProvider(fWrappedViewer);
- }
-
- void adjustInputAndSetSelection(Object o) {
- if (!(o instanceof LogicalPackage)) {
- super.adjustInputAndSetSelection(o);
- return;
- }
-
- LogicalPackage lp= (LogicalPackage)o;
- if (!lp.getJavaProject().equals(getInput()))
- setInput(lp.getJavaProject());
-
- setSelection(new StructuredSelection(lp), true);
- }
-
- //do the same thing as the JavaBrowsingPart but with wrapper
- protected void createActions() {
- super.createActions();
-
- createSelectAllAction();
-
- //create the switch action group
- fSwitchActionGroup= createSwitchActionGroup();
- }
-
- private MultiActionGroup createSwitchActionGroup(){
-
- LayoutAction switchToFlatViewAction= new LayoutAction(JavaBrowsingMessages.PackagesView_flatLayoutAction_label,LIST_VIEW_STATE);
- LayoutAction switchToHierarchicalViewAction= new LayoutAction(JavaBrowsingMessages.PackagesView_HierarchicalLayoutAction_label, TREE_VIEW_STATE);
- JavaPluginImages.setLocalImageDescriptors(switchToFlatViewAction, "flatLayout.gif"); //$NON-NLS-1$
- JavaPluginImages.setLocalImageDescriptors(switchToHierarchicalViewAction, "hierarchicalLayout.gif"); //$NON-NLS-1$
-
- return new LayoutActionGroup(new IAction[]{switchToFlatViewAction,switchToHierarchicalViewAction}, fCurrViewState);
- }
-
- private static class LayoutActionGroup extends MultiActionGroup {
-
- LayoutActionGroup(IAction[] actions, int index) {
- super(actions, index);
- }
-
- public void fillActionBars(IActionBars actionBars) {
- //create new layout group
- IMenuManager manager= actionBars.getMenuManager();
- final IContributionItem groupMarker= new GroupMarker("layout"); //$NON-NLS-1$
- manager.add(groupMarker);
- IMenuManager newManager= new MenuManager(JavaBrowsingMessages.PackagesView_LayoutActionGroup_layout_label);
- manager.appendToGroup("layout", newManager); //$NON-NLS-1$
- super.addActions(newManager);
- }
- }
-
-
- /**
- * Switches between flat and hierarchical state.
- */
- private class LayoutAction extends Action {
-
- private int fState;
-
- public LayoutAction(String text, int state) {
- super(text, IAction.AS_RADIO_BUTTON);
- fState= state;
- if (state == PackagesView.LIST_VIEW_STATE)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION);
- else
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION);
- }
-
- public int getState() {
- return fState;
- }
-
- public void setRunnable(Runnable runnable) {
- Assert.isNotNull(runnable);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- switchViewer(fState);
- }
- }
-
- private void switchViewer(int state) {
- //Indicate which viewer is to be used
- if (fCurrViewState == state)
- return;
- else {
- fCurrViewState= state;
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
- }
-
- //get the information from the existing viewer
- StructuredViewer viewer= fWrappedViewer.getViewer();
- Object object= viewer.getInput();
- ISelection selection= viewer.getSelection();
-
- // create and set up the new viewer
- Control control= createViewer(fWrappedViewer.getControl().getParent()).getControl();
-
- setUpViewer(fWrappedViewer);
-
- createSelectAllAction();
-
- // add the selection information from old viewer
- fWrappedViewer.setViewerInput(object);
- fWrappedViewer.getControl().setFocus();
- fWrappedViewer.setSelection(selection, true);
-
- // dispose old viewer
- viewer.getContentProvider().dispose();
- viewer.getControl().dispose();
-
- // layout the new viewer
- if (control != null && !control.isDisposed()) {
- control.setVisible(true);
- control.getParent().layout(true);
- }
- }
-
- private void createSelectAllAction() {
- IActionBars actionBars= getViewSite().getActionBars();
- if (isInListState()) {
- fSelectAllAction= new SelectAllAction((TableViewer)fWrappedViewer.getViewer());
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- } else {
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), null);
- fSelectAllAction= null;
- }
- actionBars.updateActionBars();
- }
-
- protected IJavaScriptElement findInputForJavaElement(IJavaScriptElement je) {
- // null check has to take place here as well (not only in
- // findInputForJavaElement(IJavaScriptElement, boolean) since we
- // are accessing the Java element
- if (je == null)
- return null;
- if(je.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT || je.getElementType() == IJavaScriptElement.JAVASCRIPT_PROJECT)
- return findInputForJavaElement(je, true);
- else
- return findInputForJavaElement(je, false);
-
- }
-
- protected IJavaScriptElement findInputForJavaElement(IJavaScriptElement je, boolean canChangeInputType) {
- if (je == null || !je.exists())
- return null;
-
- if (isValidInput(je)) {
-
- //don't update if input must be project (i.e. project is used as source folder)
- if (canChangeInputType)
- fLastInputWasProject= je.getElementType() == IJavaScriptElement.JAVASCRIPT_PROJECT;
- return je;
- } else if (fLastInputWasProject) {
- IPackageFragmentRoot packageFragmentRoot= (IPackageFragmentRoot)je.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (!packageFragmentRoot.isExternal())
- return je.getJavaScriptProject();
- }
-
- return findInputForJavaElement(je.getParent(), canChangeInputType);
- }
-
- /**
- * Override the getText and getImage methods for the DecoratingLabelProvider
- * to handel the decoration of logical packages.
- *
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createDecoratingLabelProvider(JavaUILabelProvider)
- */
- protected DecoratingJavaLabelProvider createDecoratingLabelProvider(JavaUILabelProvider provider) {
- return new DecoratingJavaLabelProvider(provider, false, isInListState()) {
-
- public String getText(Object element){
- if (element instanceof LogicalPackage) {
- LogicalPackage el= (LogicalPackage) element;
- return super.getText(el.getFragments()[0]);
- } else return super.getText(element);
- }
-
- public Image getImage(Object element) {
- if(element instanceof LogicalPackage){
- LogicalPackage el= (LogicalPackage) element;
- ILabelDecorator decorator= getLabelDecorator();
- IPackageFragment[] fragments= el.getFragments();
-
- Image image= super.getImage(el);
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- Image decoratedImage= decorator.decorateImage(image, fragment);
- if(decoratedImage != null)
- image= decoratedImage;
- }
- return image;
- } else return super.getImage(element);
- }
-
- };
- }
-
- /*
- * Overridden from JavaBrowsingPart to handel LogicalPackages and tree
- * structure.
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#adjustInputAndSetSelection(org.eclipse.wst.jsdt.core.IJavaScriptElement)
- */
- void adjustInputAndSetSelection(IJavaScriptElement je) {
-
- IJavaScriptElement jElementToSelect= findElementToSelect(je);
- LogicalPackagesProvider p= (LogicalPackagesProvider) fWrappedViewer.getContentProvider();
-
- Object elementToSelect= jElementToSelect;
- if (jElementToSelect != null && jElementToSelect.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT) {
- IPackageFragment pkgFragment= (IPackageFragment)jElementToSelect;
- elementToSelect= p.findLogicalPackage(pkgFragment);
- if (elementToSelect == null)
- elementToSelect= pkgFragment;
- }
-
- IJavaScriptElement newInput= findInputForJavaElement(je);
- if (elementToSelect == null && !isValidInput(newInput))
- setInput(null);
- else if (elementToSelect == null || getViewer().testFindItem(elementToSelect) == null) {
-
- //optimization, if you are in the same project but expansion hasn't happened
- Object input= getViewer().getInput();
- if (elementToSelect != null && newInput != null) {
- if (newInput.equals(input)) {
- getViewer().reveal(elementToSelect);
- // Adjust input to selection
- } else {
- setInput(newInput);
- getViewer().reveal(elementToSelect);
- }
- } else
- setInput(newInput);
-
- if (elementToSelect instanceof IPackageFragment) {
- IPackageFragment pkgFragment= (IPackageFragment)elementToSelect;
- elementToSelect= p.findLogicalPackage(pkgFragment);
- if (elementToSelect == null)
- elementToSelect= pkgFragment;
- }
- }
-
- ISelection selection;
- if (elementToSelect != null)
- selection= new StructuredSelection(elementToSelect);
- else
- selection= StructuredSelection.EMPTY;
- setSelection(selection, true);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewFlatContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewFlatContentProvider.java
deleted file mode 100644
index 1ff94b3b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewFlatContentProvider.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * Table content provider for the hierarchical layout in the packages view.
- * <p>
- * XXX: The standard Java browsing part content provider needs and calls
- * the browsing part/view. This class currently doesn't need to do so
- * but might be required to later.
- * </p>
- */
-class PackagesViewFlatContentProvider extends LogicalPackagesProvider implements IStructuredContentProvider {
- PackagesViewFlatContentProvider(StructuredViewer viewer) {
- super(viewer);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parentElement) {
-
- if(parentElement instanceof IJavaScriptElement){
- IJavaScriptElement element= (IJavaScriptElement) parentElement;
-
- int type= element.getElementType();
-
- try {
- switch (type) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- IJavaScriptProject project= (IJavaScriptProject) element;
- IPackageFragment[] children= getPackageFragments(project.getPackageFragments());
- if(isInCompoundState()) {
- fMapToLogicalPackage.clear();
- fMapToPackageFragments.clear();
- return combineSamePackagesIntoLogialPackages(children);
- } else
- return children;
-
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- fMapToLogicalPackage.clear();
- fMapToPackageFragments.clear();
- IPackageFragmentRoot root= (IPackageFragmentRoot) element;
- return root.getChildren();
-
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- //no children in flat view
- break;
-
- default :
- //do nothing, empty array returned
- }
- } catch (JavaScriptModelException e) {
- return NO_CHILDREN;
- }
-
- }
- return NO_CHILDREN;
- }
-
- /*
- * Weeds out packageFragments from external jars
- */
- private IPackageFragment[] getPackageFragments(IPackageFragment[] iPackageFragments) {
- List list= new ArrayList();
- for (int i= 0; i < iPackageFragments.length; i++) {
- IPackageFragment fragment= iPackageFragments[i];
- IJavaScriptElement el= fragment.getParent();
- if (el instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) el;
- if(root.isArchive() && root.isExternal())
- continue;
- }
- list.add(fragment);
- }
- return (IPackageFragment[]) list.toArray(new IPackageFragment[list.size()]);
- }
-
- /*
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- protected void processDelta(IJavaScriptElementDelta delta) throws JavaScriptModelException {
-
- int kind= delta.getKind();
- final IJavaScriptElement element= delta.getElement();
-
- if (isClassPathChange(delta)) {
- Object input= fViewer.getInput();
- if (input != null) {
- if (fInputIsProject && input.equals(element.getJavaScriptProject())) {
- postRefresh(input);
- return;
- } else if (!fInputIsProject && input.equals(element)) {
- if (element.exists())
- postRefresh(input);
- else
- postRemove(input);
- return;
- }
- }
- }
-
- if (kind == IJavaScriptElementDelta.REMOVED) {
- Object input= fViewer.getInput();
- if (input != null && input.equals(element)) {
- postRemove(input);
- return;
- }
- }
-
- if (element instanceof IPackageFragment) {
- final IPackageFragment frag= (IPackageFragment) element;
-
- if (kind == IJavaScriptElementDelta.REMOVED) {
- removeElement(frag);
-
- } else if (kind == IJavaScriptElementDelta.ADDED) {
- addElement(frag);
-
- } else if (kind == IJavaScriptElementDelta.CHANGED) {
- //just refresh
- Object toBeRefreshed= element;
-
- IPackageFragment pkgFragment= (IPackageFragment) element;
- LogicalPackage logicalPkg= findLogicalPackage(pkgFragment);
- //deal with packages that have been filtered and are now visible
- if (logicalPkg != null)
- toBeRefreshed= findElementToRefresh(logicalPkg);
- else
- toBeRefreshed= findElementToRefresh(pkgFragment);
-
- postRefresh(toBeRefreshed);
- }
- //in this view there will be no children of PackageFragment to refresh
- return;
- }
- processAffectedChildren(delta);
- }
-
- //test to see if element to be refreshed is being filtered out
- //and if so refresh the viewers input element (JavaProject or PackageFragmentRoot)
- private Object findElementToRefresh(IPackageFragment fragment) {
- if (fViewer.testFindItem(fragment) == null) {
- if(fInputIsProject)
- return fragment.getJavaScriptProject();
- else return fragment.getParent();
- }
- return fragment;
- }
-
- //test to see if element to be refreshed is being filtered out
- //and if so refresh the viewers input element (JavaProject or PackageFragmentRoot)
- private Object findElementToRefresh(LogicalPackage logicalPackage) {
- if (fViewer.testFindItem(logicalPackage) == null) {
- IPackageFragment fragment= logicalPackage.getFragments()[0];
- return fragment.getJavaScriptProject();
- }
- return logicalPackage;
- }
-
-
- private void processAffectedChildren(IJavaScriptElementDelta delta) throws JavaScriptModelException {
- IJavaScriptElementDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
- IJavaScriptElementDelta elementDelta= children[i];
- processDelta(elementDelta);
- }
- }
-
- private void postAdd(final Object child) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ((TableViewer)fViewer).add(child);
- }
- }
- });
- }
-
-
- private void postRemove(final Object object) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ((TableViewer)fViewer).remove(object);
- }
- }
- });
- }
-
- private void postRunnable(final Runnable r) {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- // fBrowsingPart.setProcessSelectionEvents(false);
- try {
- Display currentDisplay= Display.getCurrent();
- if (currentDisplay != null && currentDisplay.equals(ctrl.getDisplay()))
- ctrl.getDisplay().syncExec(r);
- else
- ctrl.getDisplay().asyncExec(r);
- } finally {
- // fBrowsingPart.setProcessSelectionEvents(true);
- }
- }
- }
-
- private void removeElement(IPackageFragment frag) {
- String key= getKey(frag);
- LogicalPackage lp= (LogicalPackage)fMapToLogicalPackage.get(key);
-
- if(lp != null){
- lp.remove(frag);
- //if you need to change the LogicalPackage to a PackageFragment
- if(lp.getFragments().length == 1){
- IPackageFragment fragment= lp.getFragments()[0];
- fMapToLogicalPackage.remove(key);
- fMapToPackageFragments.put(key,fragment);
-
- //@Improve: Should I replace this with a refresh of the parent?
- postRemove(lp);
- postAdd(fragment);
- } return;
- } else {
- fMapToPackageFragments.remove(key);
- postRemove(frag);
- }
- }
-
-
- private void postRefresh(final Object element) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- fViewer.refresh(element);
- }
- }
- });
- }
-
- private void addElement(IPackageFragment frag) {
- String key= getKey(frag);
- LogicalPackage lp= (LogicalPackage)fMapToLogicalPackage.get(key);
-
- if(lp != null && lp.belongs(frag)){
- lp.add(frag);
- return;
- }
-
- IPackageFragment fragment= (IPackageFragment)fMapToPackageFragments.get(key);
- if(fragment != null){
- //must create a new LogicalPackage
- if(!fragment.equals(frag)){
- lp= new LogicalPackage(fragment);
- lp.add(frag);
- fMapToLogicalPackage.put(key, lp);
-
- //@Improve: should I replace this with a refresh?
- postRemove(fragment);
- postAdd(lp);
-
- return;
- }
- }
-
- else {
- fMapToPackageFragments.put(key, frag);
- postAdd(frag);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java
deleted file mode 100644
index 570dbc6c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Tree content provider for the hierarchical layout in the packages view.
- * <p>
- * XXX: The standard Java browsing part content provider needs and calls
- * the browsing part/view. This class currently doesn't need to do so
- * but might be required to later.
- * </p>
- */
-class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider implements ITreeContentProvider {
-
- public PackagesViewHierarchicalContentProvider(StructuredViewer viewer){
- super(viewer);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- try {
- if (parentElement instanceof IJavaScriptElement) {
- IJavaScriptElement iJavaElement= (IJavaScriptElement) parentElement;
- int type= iJavaElement.getElementType();
-
- switch (type) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- {
-
- //create new element mapping
- fMapToLogicalPackage.clear();
- fMapToPackageFragments.clear();
- IJavaScriptProject project= (IJavaScriptProject) parentElement;
-
- IPackageFragment[] topLevelChildren= getTopLevelChildrenByElementName(project.getPackageFragments());
- List list= new ArrayList();
- for (int i= 0; i < topLevelChildren.length; i++) {
- IPackageFragment fragment= topLevelChildren[i];
-
- IJavaScriptElement el= fragment.getParent();
- if (el instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) el;
- if (!root.isArchive() || !root.isExternal())
- list.add(fragment);
- }
- }
-
- IPackageFragmentRoot[] packageFragmentRoots= project.getPackageFragmentRoots();
- List folders= new ArrayList();
- for (int i= 0; i < packageFragmentRoots.length; i++) {
- IPackageFragmentRoot root= packageFragmentRoots[i];
- IResource resource= root.getUnderlyingResource();
- if (resource != null && resource instanceof IFolder) {
- folders.addAll(getFolders(((IFolder)resource).members()));
- }
- }
-
- Object[] logicalPackages= combineSamePackagesIntoLogialPackages((IPackageFragment[]) list.toArray(new IPackageFragment[list.size()]));
- if (folders.size() > 0) {
- if (logicalPackages.length > 0)
- folders.addAll(Arrays.asList(logicalPackages));
- return folders.toArray();
- } else {
- return logicalPackages;
- }
- }
-
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- {
- IPackageFragmentRoot root= (IPackageFragmentRoot) parentElement;
-
- //create new element mapping
- fMapToLogicalPackage.clear();
- fMapToPackageFragments.clear();
- IResource resource= root.getUnderlyingResource();
- if (root.isArchive()) {
- IPackageFragment[] fragments= new IPackageFragment[0];
- IJavaScriptElement[] els= root.getChildren();
- fragments= getTopLevelChildrenByElementName(els);
- addFragmentsToMap(fragments);
- return fragments;
-
- } else if (resource != null && resource instanceof IFolder) {
- List children= getFoldersAndElements(((IFolder)resource).members());
-
- IPackageFragment defaultPackage= root.getPackageFragment(""); //$NON-NLS-1$
- if(defaultPackage.exists())
- children.add(defaultPackage);
-
- addFragmentsToMap(children);
- return children.toArray();
- } else {
- return NO_CHILDREN;
- }
- }
-
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- {
- IPackageFragment packageFragment= (IPackageFragment) parentElement;
- if (packageFragment.isDefaultPackage())
- return NO_CHILDREN;
-
- IPackageFragmentRoot parent= (IPackageFragmentRoot) packageFragment.getParent();
- IPackageFragment[] fragments= findNextLevelChildrenByElementName(parent, packageFragment);
-
- addFragmentsToMap(fragments);
-
- Object[] nonJavaResources= packageFragment.getNonJavaScriptResources();
- if (nonJavaResources.length == 0) {
- return fragments;
- }
- ArrayList combined= new ArrayList();
- combined.addAll(Arrays.asList(fragments));
- for (int i= 0; i < nonJavaResources.length; i++) {
- Object curr= nonJavaResources[i];
- if (curr instanceof IFolder) {
- combined.add(curr);
- }
- }
- return combined.toArray();
- }
- }
-
- //@Improve: rewrite using concatenate
- } else if (parentElement instanceof LogicalPackage) {
-
- List children= new ArrayList();
- LogicalPackage logicalPackage= (LogicalPackage) parentElement;
- IPackageFragment[] elements= logicalPackage.getFragments();
- for (int i= 0; i < elements.length; i++) {
- IPackageFragment fragment= elements[i];
- IPackageFragment[] objects= findNextLevelChildrenByElementName((IPackageFragmentRoot) fragment.getParent(), fragment);
- children.addAll(Arrays.asList(objects));
- }
- return combineSamePackagesIntoLogialPackages((IPackageFragment[]) children.toArray(new IPackageFragment[children.size()]));
- } else if (parentElement instanceof IFolder) {
- IFolder folder= (IFolder)parentElement;
- IResource[] resources= folder.members();
- List children = getFoldersAndElements(resources);
- addFragmentsToMap(children);
- return children.toArray();
- }
-
- } catch (JavaScriptModelException e) {
- return NO_CHILDREN;
- } catch (CoreException e) {
- return NO_CHILDREN;
- }
- return NO_CHILDREN;
- }
-
- private void addFragmentsToMap(List elements) {
- List packageFragments= new ArrayList();
- for (Iterator iter= elements.iterator(); iter.hasNext();) {
- Object elem= iter.next();
- if (elem instanceof IPackageFragment)
- packageFragments.add(elem);
- }
- addFragmentsToMap((IPackageFragment[])packageFragments.toArray(new IPackageFragment[packageFragments.size()]));
- }
-
- private List getFoldersAndElements(IResource[] resources) throws CoreException {
- List list= new ArrayList();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
-
- if (resource instanceof IFolder) {
- IFolder folder= (IFolder) resource;
- IJavaScriptElement element= JavaScriptCore.create(folder);
-
- if (element instanceof IPackageFragment) {
- list.add(element);
- } else {
- list.add(folder);
- }
- }
- }
- return list;
- }
-
- private List getFolders(IResource[] resources) throws CoreException {
- List list= new ArrayList();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
-
- if (resource instanceof IFolder) {
- IFolder folder= (IFolder) resource;
- IJavaScriptElement element= JavaScriptCore.create(folder);
-
- if (element == null) {
- list.add(folder);
- }
- }
- }
- return list;
- }
-
- private IPackageFragment[] findNextLevelChildrenByElementName(IPackageFragmentRoot parent, IPackageFragment fragment) {
- List list= new ArrayList();
- try {
-
- IJavaScriptElement[] children= parent.getChildren();
- String fragmentname= fragment.getElementName();
- for (int i= 0; i < children.length; i++) {
- IJavaScriptElement element= children[i];
- if (element instanceof IPackageFragment) {
- IPackageFragment frag= (IPackageFragment) element;
-
- String name= element.getElementName();
- if (name.length() > fragmentname.length() && name.charAt(fragmentname.length()) == '.' && frag.exists() && !IPackageFragment.DEFAULT_PACKAGE_NAME.equals(fragmentname) && name.startsWith(fragmentname) && !name.equals(fragmentname)) {
- String tail= name.substring(fragmentname.length() + 1);
- if (!IPackageFragment.DEFAULT_PACKAGE_NAME.equals(tail) && tail.indexOf('.') == -1) {
- list.add(frag);
- }
- }
- }
- }
-
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return (IPackageFragment[]) list.toArray(new IPackageFragment[list.size()]);
- }
-
- private IPackageFragment[] getTopLevelChildrenByElementName(IJavaScriptElement[] elements){
- List topLevelElements= new ArrayList();
- for (int i= 0; i < elements.length; i++) {
- IJavaScriptElement iJavaElement= elements[i];
- //if the name of the PackageFragment is the top level package it will contain no "." separators
- if (iJavaElement instanceof IPackageFragment && iJavaElement.getElementName().indexOf('.')==-1){
- topLevelElements.add(iJavaElement);
- }
- }
- return (IPackageFragment[]) topLevelElements.toArray(new IPackageFragment[topLevelElements.size()]);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
-
- try {
- if (element instanceof IPackageFragment) {
- IPackageFragment fragment= (IPackageFragment) element;
- if(!fragment.exists())
- return null;
- Object parent= getHierarchicalParent(fragment);
- if(parent instanceof IPackageFragment) {
- IPackageFragment pkgFragment= (IPackageFragment)parent;
- LogicalPackage logicalPkg= findLogicalPackage(pkgFragment);
- if (logicalPkg != null)
- return logicalPkg;
- else {
- LogicalPackage lp= createLogicalPackage(pkgFragment);
- if(lp == null)
- return pkgFragment;
- else return lp;
- }
- }
- return parent;
-
- } else if(element instanceof LogicalPackage){
- LogicalPackage el= (LogicalPackage) element;
- IPackageFragment fragment= el.getFragments()[0];
- Object parent= getHierarchicalParent(fragment);
-
- if(parent instanceof IPackageFragment){
- IPackageFragment pkgFragment= (IPackageFragment) parent;
- LogicalPackage logicalPkg= findLogicalPackage(pkgFragment);
- if (logicalPkg != null)
- return logicalPkg;
- else {
- LogicalPackage lp= createLogicalPackage(pkgFragment);
- if(lp == null)
- return pkgFragment;
- else return lp;
- }
- } else
- return fragment.getJavaScriptProject();
- } else if (element instanceof IFolder) {
- IFolder folder = (IFolder) element;
- IResource res = folder.getParent();
-
- IJavaScriptElement el = JavaScriptCore.create(res);
- if (el != null) {
- return el;
- } else {
- return res;
- }
- }
-
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return null;
- }
-
- /*
- * Check if the given IPackageFragment should be the member of a
- * LogicalPackage and if so creates the LogicalPackage and adds it to the
- * map.
- */
- private LogicalPackage createLogicalPackage(IPackageFragment pkgFragment) {
- if(!fInputIsProject)
- return null;
-
- List fragments= new ArrayList();
- try {
- IPackageFragmentRoot[] roots= pkgFragment.getJavaScriptProject().getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- IPackageFragment fragment= root.getPackageFragment(pkgFragment.getElementName());
- if(fragment.exists() && !fragment.equals(pkgFragment))
- fragments.add(fragment);
- }
- if(!fragments.isEmpty()) {
- LogicalPackage logicalPackage= new LogicalPackage(pkgFragment);
- fMapToLogicalPackage.put(getKey(pkgFragment), logicalPackage);
- Iterator iter= fragments.iterator();
- while(iter.hasNext()){
- IPackageFragment f= (IPackageFragment)iter.next();
- if(logicalPackage.belongs(f)){
- logicalPackage.add(f);
- fMapToLogicalPackage.put(getKey(f), logicalPackage);
- }
- }
-
- return logicalPackage;
- }
-
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
-
- return null;
- }
-
- private Object getHierarchicalParent(IPackageFragment fragment) throws JavaScriptModelException {
- IJavaScriptElement parent= fragment.getParent();
-
- if ((parent instanceof IPackageFragmentRoot) && parent.exists()) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) parent;
- if (root.isArchive() || !fragment.exists()) {
- return findNextLevelParentByElementName(fragment);
- } else {
- IResource resource= fragment.getUnderlyingResource();
- if ((resource != null) && (resource instanceof IFolder)) {
- IFolder folder= (IFolder) resource;
- IResource res= folder.getParent();
-
- IJavaScriptElement el= JavaScriptCore.create(res);
- if (el != null) {
- return el;
- } else {
- return res;
- }
- }
- }
- }
- return parent;
- }
-
- private Object findNextLevelParentByElementName(IPackageFragment child) {
- String name= child.getElementName();
-
- int index= name.lastIndexOf('.');
- if (index != -1) {
- String realParentName= name.substring(0, index);
- IPackageFragment element= ((IPackageFragmentRoot) child.getParent()).getPackageFragment(realParentName);
- if (element.exists()) {
- return element;
- }
- }
- return child.getParent();
- }
-
-
- /*
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
-
- if (element instanceof IPackageFragment) {
- IPackageFragment fragment= (IPackageFragment) element;
- if(fragment.isDefaultPackage() || !fragment.exists())
- return false;
- }
- return getChildren(element).length > 0;
- }
-
- /*
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- protected void processDelta(IJavaScriptElementDelta delta) throws JavaScriptModelException {
-
- int kind = delta.getKind();
- final IJavaScriptElement element = delta.getElement();
-
- if (isClassPathChange(delta)) {
- Object input= fViewer.getInput();
- if (input != null) {
- if (fInputIsProject && input.equals(element.getJavaScriptProject())) {
- postRefresh(input);
- return;
- } else if (!fInputIsProject && input.equals(element)) {
- if (element.exists())
- postRefresh(input);
- else
- postRemove(input);
- return;
- }
- }
- }
-
- if (kind == IJavaScriptElementDelta.REMOVED) {
- Object input= fViewer.getInput();
- if (input != null && input.equals(element)) {
- postRemove(input);
- return;
- }
- }
-
- if (element instanceof IPackageFragment) {
- final IPackageFragment frag = (IPackageFragment) element;
-
- //if fragment was in LogicalPackage refresh,
- //otherwise just remove
- if (kind == IJavaScriptElementDelta.REMOVED) {
- removeElement(frag);
- return;
-
- } else if (kind == IJavaScriptElementDelta.ADDED) {
-
- Object parent= getParent(frag);
- addElement(frag, parent);
- return;
-
- } else if (kind == IJavaScriptElementDelta.CHANGED) {
- //just refresh
- LogicalPackage logicalPkg= findLogicalPackage(frag);
- //in case changed object is filtered out
- if (logicalPkg != null)
- postRefresh(findElementToRefresh(logicalPkg));
- else
- postRefresh(findElementToRefresh(frag));
- return;
- }
- }
-
- processAffectedChildren(delta);
- }
-
- private Object findElementToRefresh(Object object) {
- Object toBeRefreshed= object;
- if (fViewer.testFindItem(object) == null) {
- Object parent= getParent(object);
- if(parent instanceof IPackageFragmentRoot && fInputIsProject)
- parent= ((IPackageFragmentRoot)parent).getJavaScriptProject();
-
- if(parent != null)
- toBeRefreshed= parent;
- }
- return toBeRefreshed;
- }
-
- private void processAffectedChildren(IJavaScriptElementDelta delta) throws JavaScriptModelException {
- IJavaScriptElementDelta[] affectedChildren = delta.getAffectedChildren();
- for (int i = 0; i < affectedChildren.length; i++) {
- if (!(affectedChildren[i] instanceof IJavaScriptUnit)) {
- processDelta(affectedChildren[i]);
- }
- }
- }
-
- private void postAdd(final Object child, final Object parent) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ((TreeViewer)fViewer).add(parent, child);
- }
- }
- });
- }
-
- private void postRemove(final Object object) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ((TreeViewer)fViewer).remove(object);
- }
- }
- });
- }
-
- private void postRefresh(final Object object) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ((TreeViewer) fViewer).refresh(object);
- }
- }
- });
- }
-
- private void postRunnable(final Runnable r) {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- // fBrowsingPart.setProcessSelectionEvents(false);
- try {
- Display currentDisplay= Display.getCurrent();
- if (currentDisplay != null && currentDisplay.equals(ctrl.getDisplay()))
- ctrl.getDisplay().syncExec(r);
- else
- ctrl.getDisplay().asyncExec(r);
- } finally {
- // fBrowsingPart.setProcessSelectionEvents(true);
- }
- }
- }
-
- private void addElement(IPackageFragment frag, Object parent) {
-
- String key= getKey(frag);
- LogicalPackage lp= (LogicalPackage)fMapToLogicalPackage.get(key);
-
- //if fragment must be added to an existing LogicalPackage
- if (lp != null && lp.belongs(frag)){
- lp.add(frag);
- return;
- }
-
- //if a new LogicalPackage must be created
- IPackageFragment iPackageFragment= (IPackageFragment)fMapToPackageFragments.get(key);
- if (iPackageFragment!= null && !iPackageFragment.equals(frag)){
- lp= new LogicalPackage(iPackageFragment);
- lp.add(frag);
- //add new LogicalPackage to LogicalPackages map
- fMapToLogicalPackage.put(key, lp);
-
- //determine who to refresh
- if (parent instanceof IPackageFragmentRoot){
- IPackageFragmentRoot root= (IPackageFragmentRoot) parent;
- if (fInputIsProject){
- postRefresh(root.getJavaScriptProject());
- } else {
- postRefresh(root);
- }
- } else {
- //@Improve: Should this be replaced by a refresh?
- postAdd(lp, parent);
- postRemove(iPackageFragment);
- }
-
- }
- //if this is a new Package Fragment
- else {
- fMapToPackageFragments.put(key, frag);
-
- //determine who to refresh
- if (parent instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) parent;
- if (fInputIsProject) {
- postAdd(frag, root.getJavaScriptProject());
- } else
- postAdd(frag, root);
- } else {
- postAdd(frag, parent);
- }
- }
- }
-
- private void removeElement(IPackageFragment frag) {
-
- String key= getKey(frag);
- LogicalPackage lp= (LogicalPackage)fMapToLogicalPackage.get(key);
-
- if(lp != null){
- lp.remove(frag);
- //if the LogicalPackage needs to revert back to a PackageFragment
- //remove it from the LogicalPackages map and add the PackageFragment
- //to the PackageFragment map
- if (lp.getFragments().length == 1) {
- IPackageFragment fragment= lp.getFragments()[0];
- fMapToPackageFragments.put(key, fragment);
- fMapToLogicalPackage.remove(key);
-
- //remove the LogicalPackage from viewer
- postRemove(lp);
-
- Object parent= getParent(fragment);
- if (parent instanceof IPackageFragmentRoot) {
- parent= ((IPackageFragmentRoot)parent).getJavaScriptProject();
- }
- postAdd(fragment, parent);
- }
-
- } else {
- //remove the fragment from the fragment map and viewer
- IPackageFragment fragment= (IPackageFragment) fMapToPackageFragments.get(key);
- if (fragment!= null && fragment.equals(frag)) {
- fMapToPackageFragments.remove(key);
- postRemove(frag);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewLabelProvider.java
deleted file mode 100644
index baef2409..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewLabelProvider.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.TreeHierarchyLayoutProblemsDecorator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Label provider for the Packages view.
- */
-class PackagesViewLabelProvider extends AppearanceAwareLabelProvider {
-
- static final int HIERARCHICAL_VIEW_STATE= 0;
- static final int FLAT_VIEW_STATE= 1;
-
- private int fViewState;
-
- private ImageDescriptorRegistry fRegistry;
- private TreeHierarchyLayoutProblemsDecorator fDecorator;
-
- PackagesViewLabelProvider(int state) {
- this(state, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS);
- }
-
- PackagesViewLabelProvider(int state, long textFlags, int imageFlags) {
- super(textFlags, imageFlags);
-
- Assert.isTrue(isValidState(state));
- fViewState= state;
- fRegistry= JavaScriptPlugin.getImageDescriptorRegistry();
-
- fDecorator= new TreeHierarchyLayoutProblemsDecorator(isFlatView());
- addLabelDecorator(fDecorator);
- }
-
- private boolean isValidState(int state) {
- return state == FLAT_VIEW_STATE || state == HIERARCHICAL_VIEW_STATE;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (element instanceof LogicalPackage) {
- LogicalPackage cp= (LogicalPackage) element;
- return getLogicalPackageImage(cp);
- }
- return super.getImage(element);
- }
-
- /*
- * Decoration is only concerned with error ticks
- */
- private Image getLogicalPackageImage(LogicalPackage cp) {
- IPackageFragment[] fragments= cp.getFragments();
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- if(!isEmpty(fragment)) {
- return decorateCompoundElement(JavaPluginImages.DESC_OBJS_LOGICAL_PACKAGE, cp);
- }
- }
- return decorateCompoundElement(JavaPluginImages.DESC_OBJS_EMPTY_LOGICAL_PACKAGE, cp);
- }
-
-
- private Image decorateCompoundElement(ImageDescriptor imageDescriptor, LogicalPackage cp) {
- Image image= fRegistry.get(imageDescriptor);
- return decorateImage(image, cp);
- }
-
- private boolean isEmpty(IPackageFragment fragment) {
- try {
- return (fragment.getJavaScriptUnits().length == 0) && (fragment.getClassFiles().length == 0);
- } catch (JavaScriptModelException e) {
- // ignore
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (element instanceof IPackageFragment)
- return getText((IPackageFragment)element);
- else if (element instanceof LogicalPackage)
- return getText((LogicalPackage)element);
- else
- return super.getText(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider#getRichTextLabel(java.lang.Object)
- */
- public ColoredString getRichTextLabel(Object element) {
- if (element instanceof IPackageFragment || element instanceof LogicalPackage)
- return new ColoredString(getText(element));
- return super.getRichTextLabel(element);
- }
-
-
- private String getText(IPackageFragment fragment) {
- if (isFlatView())
- return getFlatText(fragment);
- else
- return getHierarchicalText(fragment);
- }
-
- private String getText(LogicalPackage logicalPackage) {
- IPackageFragment[] fragments= logicalPackage.getFragments();
- return getText(fragments[0]);
- }
-
- private String getFlatText(IPackageFragment fragment) {
- return super.getText(fragment);
- }
-
- private boolean isFlatView() {
- return fViewState==FLAT_VIEW_STATE;
- }
-
- private String getHierarchicalText(IPackageFragment fragment) {
- if (fragment.isDefaultPackage()) {
- return super.getText(fragment);
- }
- IResource res= fragment.getResource();
- if(res != null && !(res.getType() == IResource.FILE))
- return decorateText(res.getName(), fragment);
- else
- return decorateText(calculateName(fragment), fragment);
- }
-
- private String calculateName(IPackageFragment fragment) {
-
- String name= fragment.getElementName();
- if (name.indexOf(".") != -1) //$NON-NLS-1$
- name= name.substring(name.lastIndexOf(".") + 1); //$NON-NLS-1$
- return name;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTableViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTableViewer.java
deleted file mode 100644
index 48ce472a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTableViewer.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTableViewer;
-
-/**
- * Special problem table viewer to handle logical packages.
- */
-class PackagesViewTableViewer extends ProblemTableViewer implements IPackagesViewViewer {
-
- public PackagesViewTableViewer(Composite parent, int style) {
- super(parent, style);
- ColoredViewersManager.install(this);
- }
-
- public void mapElement(Object element, Widget item) {
- if (element instanceof LogicalPackage && item instanceof Item) {
- LogicalPackage cp= (LogicalPackage) element;
- IPackageFragment[] fragments= cp.getFragments();
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- fResourceToItemsMapper.addToMap(fragment, (Item)item);
- }
- }
- super.mapElement(element, item);
- }
-
- public void unmapElement(Object element, Widget item) {
- if (element instanceof LogicalPackage && item instanceof Item) {
- LogicalPackage cp= (LogicalPackage) element;
- IPackageFragment[] fragments= cp.getFragments();
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- fResourceToItemsMapper.removeFromMap(fragment, (Item)item);
- }
- }
- super.unmapElement(element, item);
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#getFilteredChildren(java.
- * lang.Object)
- */
- protected Object[] getFilteredChildren(Object parent) {
-
- Object[] result= getRawChildren(parent);
- List list= new ArrayList();
- if (result != null) {
- Object[] toBeFiltered= new Object[1];
- for (int i= 0; i < result.length; i++) {
- Object object= result[i];
- if(object instanceof LogicalPackage) {
- if(selectLogicalPackage((LogicalPackage)object))
- list.add(object);
- } else {
- toBeFiltered[0]= object;
- if (filter(toBeFiltered).length == 1)
- list.add(object);
- }
- }
- }
- return list.toArray();
- }
-
- private boolean selectLogicalPackage(LogicalPackage logicalPackage) {
- return filter(logicalPackage.getFragments()).length > 0;
- }
-
- // --------- see: IPackagesViewViewer ----------
-
- public Widget doFindItem(Object element){
- return super.doFindItem(element);
- }
-
- public Widget doFindInputItem(Object element){
- return super.doFindInputItem(element);
- }
-
- public List getSelectionFromWidget(){
- return super.getSelectionFromWidget();
- }
-
- public void doUpdateItem(Widget item, Object element, boolean fullMap){
- super.doUpdateItem(item, element, fullMap);
- }
-
- public void internalRefresh(Object element){
- super.internalRefresh(element);
- }
-
- public void setSelectionToWidget(List l, boolean reveal){
- super.setSelectionToWidget(l, reveal);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTreeViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTreeViewer.java
deleted file mode 100644
index 78e49e9a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PackagesViewTreeViewer.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-
-/**
- * Special problem tree viewer to handle logical packages.
- */
-public class PackagesViewTreeViewer extends ProblemTreeViewer implements IPackagesViewViewer{
-
- public PackagesViewTreeViewer(Composite parent, int style) {
- super(parent, style);
- ColoredViewersManager.install(this);
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#mapElement(java.lang.Object, org.eclipse.swt.widgets.Widget)
- */
- public void mapElement(Object element, Widget item) {
- if (element instanceof LogicalPackage && item instanceof Item) {
- LogicalPackage cp= (LogicalPackage) element;
- IPackageFragment[] fragments= cp.getFragments();
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- fResourceToItemsMapper.addToMap(fragment, (Item) item);
- }
- }
- super.mapElement(element, item);
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#unmapElement(java.lang.Object, org.eclipse.swt.widgets.Widget)
- */
- public void unmapElement(Object element, Widget item) {
-
- if (element instanceof LogicalPackage && item instanceof Item) {
- LogicalPackage cp= (LogicalPackage) element;
- IPackageFragment[] fragments= cp.getFragments();
- for (int i= 0; i < fragments.length; i++) {
- IPackageFragment fragment= fragments[i];
- fResourceToItemsMapper.removeFromMap((Object)fragment, (Item)item);
- }
- }
- super.unmapElement(element, item);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer#isFiltered(java.lang.Object, java.lang.Object, org.eclipse.jface.viewers.ViewerFilter[])
- */
- protected boolean isFiltered(Object object, Object parent, ViewerFilter[] filters) {
- boolean res= super.isFiltered(object, parent, filters);
- if (res && isEssential(object)) {
- return false;
- }
- return res;
- }
-
- private boolean isEssential(Object object) {
- try {
- if (object instanceof IPackageFragment) {
- IPackageFragment fragment = (IPackageFragment) object;
- if (!fragment.isDefaultPackage() && fragment.hasSubpackages()) {
- return hasFilteredChildren(fragment);
- }
- } else if (object instanceof LogicalPackage) {
- LogicalPackage logicalPackage= (LogicalPackage) object;
- if (!logicalPackage.isDefaultPackage() && logicalPackage.hasSubpackages()) {
- return !hasFilteredChildren(object);
- }
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return false;
- }
-
- // --------- see: IPackagesViewViewer ----------
-
- public Widget doFindItem(Object element) {
- return super.doFindItem(element);
- }
-
- public Widget doFindInputItem(Object element) {
- return super.doFindInputItem(element);
- }
-
- public List getSelectionFromWidget() {
- return super.getSelectionFromWidget();
- }
-
- public void doUpdateItem(Widget item, Object element, boolean fullMap){
- super.doUpdateItem(item, element, fullMap);
- }
-
- public void internalRefresh(Object element){
- super.internalRefresh(element);
- }
-
- public void setSelectionToWidget(List l, boolean reveal){
- super.setSelectionToWidget(l, reveal);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PatchedOpenInNewWindowAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PatchedOpenInNewWindowAction.java
deleted file mode 100644
index 3d120a31..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/PatchedOpenInNewWindowAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.OpenInNewWindowAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-/*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- * This class can be removed once the bug is fixed.
- *
- *
- */
-public class PatchedOpenInNewWindowAction extends OpenInNewWindowAction {
-
- private IWorkbenchWindow fWorkbenchWindow;
-
- public PatchedOpenInNewWindowAction(IWorkbenchWindow window, IAdaptable input) {
- super(window, input);
- fWorkbenchWindow= window;
- }
-
- public void run() {
- JavaBrowsingPerspectiveFactory.setInputFromAction(getSelectedJavaElement());
- try {
- super.run();
- } finally {
- JavaBrowsingPerspectiveFactory.setInputFromAction(null);
- }
- }
-
- private IJavaScriptElement getSelectedJavaElement() {
- if (fWorkbenchWindow.getActivePage() != null) {
- ISelection selection= fWorkbenchWindow.getActivePage().getSelection();
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object selectedElement= ((IStructuredSelection)selection).getFirstElement();
- if (selectedElement instanceof IJavaScriptElement)
- return (IJavaScriptElement)selectedElement;
- if (!(selectedElement instanceof IJavaScriptElement) && selectedElement instanceof IAdaptable)
- return (IJavaScriptElement)((IAdaptable)selectedElement).getAdapter(IJavaScriptElement.class);
- else if (selectedElement instanceof IWorkspace)
- return JavaScriptCore.create(((IWorkspace)selectedElement).getRoot());
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectAndSourceFolderContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectAndSourceFolderContentProvider.java
deleted file mode 100644
index 6bf6417f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectAndSourceFolderContentProvider.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-class ProjectAndSourceFolderContentProvider extends JavaBrowsingContentProvider {
-
- ProjectAndSourceFolderContentProvider(JavaBrowsingPart browsingPart) {
- super(false, browsingPart);
- }
-
- /* (non-Javadoc)
- * Method declared on ITreeContentProvider.
- */
- public Object[] getChildren(Object element) {
- if (!exists(element))
- return NO_CHILDREN;
-
- try {
- startReadInDisplayThread();
- if (element instanceof IStructuredSelection) {
- Assert.isLegal(false);
- Object[] result= new Object[0];
- Class clazz= null;
- Iterator iter= ((IStructuredSelection)element).iterator();
- while (iter.hasNext()) {
- Object item= iter.next();
- if (clazz == null)
- clazz= item.getClass();
- if (clazz == item.getClass())
- result= concatenate(result, getChildren(item));
- else
- return NO_CHILDREN;
- }
- return result;
- }
- if (element instanceof IStructuredSelection) {
- Assert.isLegal(false);
- Object[] result= new Object[0];
- Iterator iter= ((IStructuredSelection)element).iterator();
- while (iter.hasNext())
- result= concatenate(result, getChildren(iter.next()));
- return result;
- }
- if (element instanceof IJavaScriptProject)
- return getPackageFragmentRoots((IJavaScriptProject)element);
- if (element instanceof IPackageFragmentRoot)
- return NO_CHILDREN;
-
- return super.getChildren(element);
-
- } catch (JavaScriptModelException e) {
- return NO_CHILDREN;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- protected Object[] getPackageFragmentRoots(IJavaScriptProject project) throws JavaScriptModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- List list= new ArrayList(roots.length);
- // filter out package fragments that correspond to projects and
- // replace them with the package fragments directly
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- if (!isProjectPackageFragmentRoot(root))
- list.add(root);
- }
- return list.toArray();
- }
-
- /*
- *
- * @see ITreeContentProvider
- */
- public boolean hasChildren(Object element) {
- return element instanceof IJavaScriptProject && super.hasChildren(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectsView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectsView.java
deleted file mode 100644
index f7b4d960..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ProjectsView.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.FilterUpdater;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.ProjectActionGroup;
-
-public class ProjectsView extends JavaBrowsingPart {
-
- private FilterUpdater fFilterUpdater;
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.eclipse.swt.widgets.Composite)
- */
- protected StructuredViewer createViewer(Composite parent) {
- ProblemTreeViewer result= new ProblemTreeViewer(parent, SWT.MULTI);
- ColoredViewersManager.install(result);
- fFilterUpdater= new FilterUpdater(result);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#dispose()
- */
- public void dispose() {
- if (fFilterUpdater != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createContentProvider()
- */
- protected IContentProvider createContentProvider() {
- return new ProjectAndSourceFolderContentProvider(this);
- }
-
- /**
- * Returns the context ID for the Help system.
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.PROJECTS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR;
- }
-
-
- /**
- * Adds additional listeners to this view.
- */
- protected void hookViewerListeners() {
- super.hookViewerListeners();
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TreeViewer viewer= (TreeViewer)getViewer();
- Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- });
- }
-
- protected void setInitialInput() {
- IJavaScriptElement root= JavaScriptCore.create(JavaScriptPlugin.getWorkspace().getRoot());
- getViewer().setInput(root);
- updateTitle();
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- return element instanceof IJavaScriptModel;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- return element instanceof IJavaScriptProject || element instanceof IPackageFragmentRoot;
- }
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param je the Java element which has the focus
- * @return the element to select
- */
- protected IJavaScriptElement findElementToSelect(IJavaScriptElement je) {
- if (je == null)
- return null;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_MODEL :
- return null;
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- return je;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- if (je.getElementName().equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH))
- return je.getParent();
- else
- return je;
- default :
- return findElementToSelect(je.getParent());
- }
- }
-
- /*
- * @see JavaBrowsingPart#setInput(Object)
- */
- protected void setInput(Object input) {
- // Don't allow to clear input for this view
- if (input != null)
- super.setInput(input);
- else
- getViewer().setSelection(null);
- }
-
- protected void createActions() {
- super.createActions();
- fActionGroups.addGroup(new ProjectActionGroup(this));
- }
-
- /**
- * Handles selection of LogicalPackage in Packages view.
- *
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- *
- */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!needsToProcessSelectionChanged(part, selection))
- return;
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection sel= (IStructuredSelection)selection;
- Iterator iter= sel.iterator();
- while (iter.hasNext()) {
- Object selectedElement= iter.next();
- if (selectedElement instanceof LogicalPackage) {
- selection= new StructuredSelection(((LogicalPackage)selectedElement).getJavaProject());
- break;
- }
- }
- }
- super.selectionChanged(part, selection);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ToggleLinkingAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ToggleLinkingAction.java
deleted file mode 100644
index 61f385b5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/ToggleLinkingAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.wst.jsdt.internal.ui.actions.AbstractToggleLinkingAction;
-
-
-/**
- * This action toggles whether this package explorer links its selection to the active
- * editor.
- *
- *
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- JavaBrowsingPart fJavaBrowsingPart;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(JavaBrowsingPart part) {
- setChecked(part.isLinkingEnabled());
- fJavaBrowsingPart= part;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- fJavaBrowsingPart.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TopLevelTypeProblemsLabelDecorator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TopLevelTypeProblemsLabelDecorator.java
deleted file mode 100644
index f7011b75..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TopLevelTypeProblemsLabelDecorator.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator;
-
-/**
- * Decorates top-level types with problem markers that
- * are above the first type.
- */
-class TopLevelTypeProblemsLabelDecorator extends ProblemsLabelDecorator {
-
- public TopLevelTypeProblemsLabelDecorator(ImageDescriptorRegistry registry) {
- super(registry);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator#isInside(int, ISourceReference)
- */
- protected boolean isInside(int pos, ISourceReference sourceElement) throws CoreException {
-// XXX: Work in progress for problem decorator being a workbench decorator
-// IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager();
-// if (!decoratorMgr.getEnabled("org.eclipse.wst.jsdt.ui.problem.decorator")) //$NON-NLS-1$
-// return false;
-
- if (!(sourceElement instanceof IType) || ((IType)sourceElement).getDeclaringType() != null)
- return false;
-
- IJavaScriptUnit cu= ((IType)sourceElement).getJavaScriptUnit();
- if (cu == null)
- return false;
- IType[] types= cu.getTypes();
- if (types.length < 1)
- return false;
-
- int firstTypeStartOffset= -1;
- ISourceRange range= types[0].getSourceRange();
- if (range != null)
- firstTypeStartOffset= range.getOffset();
-
- int lastTypeEndOffset= -1;
- range= types[types.length-1].getSourceRange();
- if (range != null)
- lastTypeEndOffset= range.getOffset() + range.getLength() - 1;
-
- return pos < firstTypeStartOffset || pos > lastTypeEndOffset || isInside(pos, sourceElement.getSourceRange());
- }
-
- private boolean isInside(int pos, ISourceRange range) {
- if (range == null)
- return false;
- int offset= range.getOffset();
- return offset <= pos && pos < offset + range.getLength();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java
deleted file mode 100644
index 8a75abae..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.browsing;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectAllAction;
-import org.eclipse.wst.jsdt.internal.ui.filters.NonJavaElementFilter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class TypesView extends JavaBrowsingPart {
-
- private SelectAllAction fSelectAllAction;
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected JavaUILabelProvider createLabelProvider() {
- return new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.T_CATEGORY,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
- }
-
- protected StructuredViewer createViewer(Composite parent) {
- StructuredViewer viewer= super.createViewer(parent);
- ColoredViewersManager.install(viewer);
- return viewer;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new NonJavaElementFilter());
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- return element instanceof IPackageFragment;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof IJavaScriptUnit)
- return super.isValidElement(((IJavaScriptUnit)element).getParent());
- else if (element instanceof IType) {
- IType type= (IType)element;
- return type.getDeclaringType() == null && isValidElement(type.getJavaScriptUnit());
- }
- return false;
- }
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param je the Java element which has the focus
- * @return the element to select
- */
- protected IJavaScriptElement findElementToSelect(IJavaScriptElement je) {
- if (je == null)
- return null;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.TYPE:
- IType type= ((IType)je).getDeclaringType();
- if (type == null)
- type= (IType)je;
- return type;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return getTypeForCU((IJavaScriptUnit)je);
- case IJavaScriptElement.CLASS_FILE:
- return findElementToSelect(((IClassFile)je).getType());
- case IJavaScriptElement.IMPORT_CONTAINER:
- case IJavaScriptElement.IMPORT_DECLARATION:
- case IJavaScriptElement.PACKAGE_DECLARATION:
- return findElementToSelect(je.getParent());
- default:
- if (je instanceof IMember)
- return findElementToSelect(((IMember)je).getDeclaringType());
- return null;
-
- }
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.TYPES_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR;
- }
-
- protected void createActions() {
- super.createActions();
- fSelectAllAction= new SelectAllAction((TableViewer)getViewer());
- }
-
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
-
- // Add selectAll action handlers.
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- }
-
- /**
- * Handles selection of LogicalPackage in Packages view.
- *
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- *
- */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!needsToProcessSelectionChanged(part, selection))
- return;
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection sel= (IStructuredSelection) selection;
- Object selectedElement= sel.getFirstElement();
- if (sel.size() == 1 && (selectedElement instanceof LogicalPackage)) {
- IPackageFragment[] fragments= ((LogicalPackage)selectedElement).getFragments();
- List selectedElements= Arrays.asList(fragments);
- if (selectedElements.size() > 1) {
- adjustInput(part, selectedElements);
- fPreviousSelectedElement= selectedElements;
- fPreviousSelectionProvider= part;
- } else if (selectedElements.size() == 1)
- super.selectionChanged(part, new StructuredSelection(selectedElements.get(0)));
- else
- Assert.isLegal(false);
- return;
- }
- }
- super.selectionChanged(part, selection);
- }
-
- private void adjustInput(IWorkbenchPart part, List selectedElements) {
- Object currentInput= getViewer().getInput();
- if (!selectedElements.equals(currentInput))
- setInput(selectedElements);
- }
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.browsing.JavaBrowsingPart#createDecoratingLabelProvider(org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider)
- */
- protected DecoratingJavaLabelProvider createDecoratingLabelProvider(JavaUILabelProvider provider) {
- DecoratingJavaLabelProvider decoratingLabelProvider= super.createDecoratingLabelProvider(provider);
- provider.addLabelDecorator(new TopLevelTypeProblemsLabelDecorator(null));
- return decoratingLabelProvider;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
deleted file mode 100644
index c53470a8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.progress.DeferredTreeContentManager;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-public class CallHierarchyContentProvider implements ITreeContentProvider {
- private final static Object[] EMPTY_ARRAY = new Object[0];
-
- private DeferredTreeContentManager fManager;
- private CallHierarchyViewPart fPart;
-
- private class MethodWrapperRunnable implements IRunnableWithProgress {
- private MethodWrapper fMethodWrapper;
- private MethodWrapper[] fCalls= null;
-
- MethodWrapperRunnable(MethodWrapper methodWrapper) {
- fMethodWrapper= methodWrapper;
- }
-
- public void run(IProgressMonitor pm) {
- fCalls= fMethodWrapper.getCalls(pm);
- }
-
- MethodWrapper[] getCalls() {
- if (fCalls != null) {
- return fCalls;
- }
- return new MethodWrapper[0];
- }
- }
-
- public CallHierarchyContentProvider(CallHierarchyViewPart part) {
- super();
- fPart= part;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeRoot) {
- TreeRoot dummyRoot = (TreeRoot) parentElement;
-
- return new Object[] { dummyRoot.getRoot() };
- } else if (parentElement instanceof MethodWrapper) {
- MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
-
- if (shouldStopTraversion(methodWrapper)) {
- return EMPTY_ARRAY;
- } else {
- if (fManager != null) {
- Object[] children = fManager.getChildren(new DeferredMethodWrapper(this, methodWrapper));
- if (children != null)
- return children;
- }
- return fetchChildren(methodWrapper);
- }
- }
-
- return EMPTY_ARRAY;
- }
-
- protected Object[] fetchChildren(MethodWrapper methodWrapper) {
- IRunnableContext context= JavaScriptPlugin.getActiveWorkbenchWindow();
- MethodWrapperRunnable runnable= new MethodWrapperRunnable(methodWrapper);
- try {
- context.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, CallHierarchyMessages.CallHierarchyContentProvider_searchError_title, CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);
- return EMPTY_ARRAY;
- } catch (InterruptedException e) {
- return new Object[] { TreeTermination.SEARCH_CANCELED };
- }
-
- return runnable.getCalls();
- }
-
- private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
- return (methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth()) || methodWrapper.isRecursive();
- }
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- if (element instanceof MethodWrapper) {
- return ((MethodWrapper) element).getParent();
- }
-
- return null;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- // Nothing to dispose
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element == TreeRoot.EMPTY_ROOT || element == TreeTermination.SEARCH_CANCELED) {
- return false;
- }
-
- // Only methods can have subelements, so there's no need to fool the
- // user into believing that there is more
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper= (MethodWrapper) element;
- if (methodWrapper.getMember().getElementType() != IJavaScriptElement.METHOD) {
- return false;
- }
- if (shouldStopTraversion(methodWrapper)) {
- return false;
- }
- return true;
- } else if (element instanceof TreeRoot) {
- return true;
- } else if (element instanceof DeferredMethodWrapper) {
- // Err on the safe side by returning true even though
- // we don't know for sure that there are children.
- return true;
- }
-
- return false; // the "Update ..." placeholder has no children
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput instanceof TreeRoot) {
- Object root = ((TreeRoot) oldInput).getRoot();
- if (root instanceof MethodWrapper) {
- cancelJobs((MethodWrapper) root);
- }
- }
- if (viewer instanceof AbstractTreeViewer) {
- fManager = new DeferredTreeContentManager(this, (AbstractTreeViewer) viewer, fPart.getSite());
- }
- }
-
- /**
- * Cancel all current jobs.
- */
- void cancelJobs(MethodWrapper wrapper) {
- if (fManager != null && wrapper != null) {
- fManager.cancel(wrapper);
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
- }
-
- /**
- *
- */
- public void doneFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
-
- /**
- *
- */
- public void startFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java
deleted file mode 100644
index 4808ef7b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Action group to add the filter action to a view part's toolbar
- * menu.
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- */
-public class CallHierarchyFiltersActionGroup extends ActionGroup {
-
- class ShowFilterDialogAction extends Action {
- ShowFilterDialogAction() {
- setText(CallHierarchyMessages.ShowFilterDialogAction_text);
- setImageDescriptor(JavaPluginImages.DESC_ELCL_FILTER);
- setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_FILTER);
- }
-
- public void run() {
- openDialog();
- }
- }
-
- private IViewPart fPart;
-
- /**
- * Creates a new <code>CustomFiltersActionGroup</code>.
- *
- * @param part the view part that owns this action group
- * @param viewer the viewer to be filtered
- */
- public CallHierarchyFiltersActionGroup(IViewPart part, StructuredViewer viewer) {
- Assert.isNotNull(part);
- Assert.isNotNull(viewer);
- fPart= part;
- }
-
- /* (non-Javadoc)
- * Method declared on ActionGroup.
- */
- public void fillActionBars(IActionBars actionBars) {
- fillViewMenu(actionBars.getMenuManager());
- }
-
- private void fillViewMenu(IMenuManager viewMenu) {
- viewMenu.add(new Separator("filters")); //$NON-NLS-1$
- viewMenu.add(new ShowFilterDialogAction());
- }
-
- /* (non-Javadoc)
- * Method declared on ActionGroup.
- */
- public void dispose() {
- super.dispose();
- }
-
- // ---------- dialog related code ----------
-
- private void openDialog() {
- FiltersDialog dialog= new FiltersDialog(
- fPart.getViewSite().getShell());
-
- dialog.open();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyImageDescriptor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyImageDescriptor.java
deleted file mode 100644
index b0b37122..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyImageDescriptor.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-
-public class CallHierarchyImageDescriptor extends CompositeImageDescriptor {
-
- /** Flag to render the recursive adornment */
- public final static int RECURSIVE= 0x001;
-
- /** Flag to render the callee adornment */
- public final static int MAX_LEVEL= 0x002;
-
- private ImageDescriptor fBaseImage;
- private int fFlags;
- private Point fSize;
-
- /**
- * Creates a new CallHierarchyImageDescriptor.
- *
- * @param baseImage an image descriptor used as the base image
- * @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code>
- * for valid values.
- * @param size the size of the resulting image
- * @see #setAdornments(int)
- */
- public CallHierarchyImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
- fBaseImage= baseImage;
- Assert.isNotNull(fBaseImage);
- fFlags= flags;
- Assert.isTrue(fFlags >= 0);
- fSize= size;
- Assert.isNotNull(fSize);
- }
-
- /**
- * Sets the descriptors adornments. Valid values are: <code>RECURSIVE</code>, <code>CALLER</code>,
- * <code>CALLEE</code>, <code>MAX_LEVEL</code>, or any combination of those.
- *
- * @param adornments the image descritpors adornments
- */
- public void setAdornments(int adornments) {
- Assert.isTrue(adornments >= 0);
- fFlags= adornments;
- }
-
- /**
- * Returns the current adornments.
- *
- * @return the current adornments
- */
- public int getAdronments() {
- return fFlags;
- }
-
- /**
- * Sets the size of the image created by calling <code>createImage()</code>.
- *
- * @param size the size of the image returned from calling <code>createImage()</code>
- * @see ImageDescriptor#createImage()
- */
- public void setImageSize(Point size) {
- Assert.isNotNull(size);
- Assert.isTrue(size.x >= 0 && size.y >= 0);
- fSize= size;
- }
-
- /**
- * Returns the size of the image created by calling <code>createImage()</code>.
- *
- * @return the size of the image created by calling <code>createImage()</code>
- * @see ImageDescriptor#createImage()
- */
- public Point getImageSize() {
- return new Point(fSize.x, fSize.y);
- }
-
- /* (non-Javadoc)
- * Method declared in CompositeImageDescriptor
- */
- protected Point getSize() {
- return fSize;
- }
-
- /* (non-Javadoc)
- * Method declared on Object.
- */
- public boolean equals(Object object) {
- if (object == null || !CallHierarchyImageDescriptor.class.equals(object.getClass()))
- return false;
-
- CallHierarchyImageDescriptor other= (CallHierarchyImageDescriptor)object;
- return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
- }
-
- /* (non-Javadoc)
- * Method declared on Object.
- */
- public int hashCode() {
- return fBaseImage.hashCode() | fFlags | fSize.hashCode();
- }
-
- /* (non-Javadoc)
- * Method declared in CompositeImageDescriptor
- */
- protected void drawCompositeImage(int width, int height) {
- ImageData bg= getImageData(fBaseImage);
-
- drawImage(bg, 0, 0);
- drawBottomLeft();
- }
-
- private ImageData getImageData(ImageDescriptor descriptor) {
- ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
- if (data == null) {
- data= DEFAULT_IMAGE_DATA;
- JavaScriptPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
- }
- return data;
- }
-
- private void drawBottomLeft() {
- Point size= getSize();
- int x= 0;
- ImageData data= null;
- if ((fFlags & RECURSIVE) != 0) {
- data= getImageData(JavaPluginImages.DESC_OVR_RECURSIVE);
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- if ((fFlags & MAX_LEVEL) != 0) {
- data= getImageData(JavaPluginImages.DESC_OVR_MAX_LEVEL);
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelDecorator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelDecorator.java
deleted file mode 100644
index 54a2181b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelDecorator.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageImageDescriptor;
-
-/**
- * LabelDecorator that decorates an method's image with recursion overlays.
- * The viewer using this decorator is responsible for updating the images on element changes.
- */
-public class CallHierarchyLabelDecorator implements ILabelDecorator {
-
- /**
- * Creates a decorator. The decorator creates an own image registry to cache
- * images.
- */
- public CallHierarchyLabelDecorator() {
- // Do nothing
- }
-
- /* (non-Javadoc)
- * @see ILabelDecorator#decorateText(String, Object)
- */
- public String decorateText(String text, Object element) {
- return text;
- }
-
- /* (non-Javadoc)
- * @see ILabelDecorator#decorateImage(Image, Object)
- */
- public Image decorateImage(Image image, Object element) {
- int adornmentFlags= computeAdornmentFlags(element);
- if (adornmentFlags != 0) {
- ImageDescriptor baseImage= new ImageImageDescriptor(image);
- Rectangle bounds= image.getBounds();
- return JavaScriptPlugin.getImageDescriptorRegistry().get(new CallHierarchyImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height)));
- }
- return image;
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- */
- private int computeAdornmentFlags(Object element) {
- int flags= 0;
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper= (MethodWrapper) element;
- if (methodWrapper.isRecursive()) {
- flags= CallHierarchyImageDescriptor.RECURSIVE;
- }
- if (isMaxCallDepthExceeded(methodWrapper)) {
- flags|= CallHierarchyImageDescriptor.MAX_LEVEL;
- }
- }
- return flags;
- }
-
- private boolean isMaxCallDepthExceeded(MethodWrapper methodWrapper) {
- return methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth();
- }
-
- /* (non-Javadoc)
- * @see IBaseLabelProvider#addListener(ILabelProviderListener)
- */
- public void addListener(ILabelProviderListener listener) {
- // Do nothing
- }
-
- /* (non-Javadoc)
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- // Nothing to dispose
- }
-
- /* (non-Javadoc)
- * @see IBaseLabelProvider#isLabelProperty(Object, String)
- */
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- /* (non-Javadoc)
- * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
- */
- public void removeListener(ILabelProviderListener listener) {
- // Do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
deleted file mode 100644
index 75772572..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.Collection;
-
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredJavaElementLabels;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-class CallHierarchyLabelProvider extends AppearanceAwareLabelProvider {
- private static final long TEXTFLAGS= DEFAULT_TEXTFLAGS | JavaScriptElementLabels.ALL_POST_QUALIFIED | JavaScriptElementLabels.P_COMPRESSED;
- private static final int IMAGEFLAGS= DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS;
-
- private ILabelDecorator fDecorator;
-
- CallHierarchyLabelProvider() {
- super(TEXTFLAGS, IMAGEFLAGS);
- fDecorator= new CallHierarchyLabelDecorator();
- }
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- Image result= null;
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) element;
-
- if (methodWrapper.getMember() != null) {
- result= fDecorator.decorateImage(super.getImage(methodWrapper.getMember()), methodWrapper);
- }
- } else if (isPendingUpdate(element)) {
- return null;
- } else {
- result= super.getImage(element);
- }
-
- return result;
- }
-
- /*
- * @see ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
- if (element instanceof MethodWrapper && ((MethodWrapper) element).getMember() != null) {
- return getElementLabel((MethodWrapper) element);
- }
- return getSpecialLabel(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider#getRichTextLabel(java.lang.Object)
- */
- public ColoredString getRichTextLabel(Object element) {
- if (element instanceof MethodWrapper && ((MethodWrapper) element).getMember() != null) {
- MethodWrapper wrapper= (MethodWrapper) element;
- String decorated= getElementLabel(wrapper);
- ColoredString text= super.getRichTextLabel(wrapper.getMember());
- return ColoredJavaElementLabels.decorateColoredString(text, decorated, ColoredJavaElementLabels.COUNTER_STYLE);
- }
- return new ColoredString(getSpecialLabel(element));
- }
-
- private String getSpecialLabel(Object element) {
- if (element instanceof MethodWrapper) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_root;
- } else if (element == TreeTermination.SEARCH_CANCELED) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_searchCanceled;
- } else if (isPendingUpdate(element)) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_updatePending;
- }
- return CallHierarchyMessages.CallHierarchyLabelProvider_noMethodSelected;
- }
-
- private boolean isPendingUpdate(Object element) {
- return element instanceof IWorkbenchAdapter;
- }
-
- private String getElementLabel(MethodWrapper methodWrapper) {
- String label = super.getText(methodWrapper.getMember());
-
- Collection callLocations = methodWrapper.getMethodCall().getCallLocations();
-
- if ((callLocations != null) && (callLocations.size() > 1)) {
- return Messages.format(CallHierarchyMessages.CallHierarchyLabelProvider_matches, new String[]{label, String.valueOf(callLocations.size())});
- }
-
- return label;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.java
deleted file mode 100644
index c1bb1589..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class CallHierarchyMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.callhierarchy.CallHierarchyMessages";//$NON-NLS-1$
-
- private CallHierarchyMessages() {
- // Do not instantiate
- }
-
- public static String HistoryDropDownAction_clearhistory_label;
- public static String LocationCopyAction_copy;
- public static String ToggleCallModeAction_callers_label;
- public static String ToggleCallModeAction_callers_tooltip;
- public static String ToggleCallModeAction_callers_description;
- public static String ToggleCallModeAction_callees_label;
- public static String ToggleCallModeAction_callees_tooltip;
- public static String ToggleCallModeAction_callees_description;
- public static String HistoryDropDownAction_tooltip;
- public static String HistoryAction_description;
- public static String HistoryAction_tooltip;
- public static String HistoryListDialog_title;
- public static String HistoryListDialog_label;
- public static String HistoryListDialog_remove_button;
- public static String HistoryListAction_label;
- public static String ToggleOrientationAction_vertical_label;
- public static String ToggleOrientationAction_vertical_description;
- public static String ToggleOrientationAction_vertical_tooltip;
- public static String ToggleOrientationAction_horizontal_label;
- public static String ToggleOrientationAction_horizontal_tooltip;
- public static String ToggleOrientationAction_horizontal_description;
- public static String ToggleOrientationAction_automatic_label;
- public static String ToggleOrientationAction_automatic_tooltip;
- public static String ToggleOrientationAction_automatic_description;
- public static String ToggleOrientationAction_single_label;
- public static String ToggleOrientationAction_single_tooltip;
- public static String ToggleOrientationAction_single_description;
- public static String ShowFilterDialogAction_text;
- public static String FiltersDialog_filter;
- public static String FiltersDialog_filterOnNames;
- public static String FiltersDialog_filterOnNamesSubCaption;
- public static String FiltersDialog_maxCallDepth;
- public static String FiltersDialog_messageMaxCallDepthInvalid;
- public static String CallHierarchyContentProvider_searchError_title;
- public static String CallHierarchyContentProvider_searchError_message;
- public static String CallHierarchyLabelProvider_root;
- public static String CallHierarchyLabelProvider_searchCanceled;
- public static String CallHierarchyLabelProvider_noMethodSelected;
- public static String CallHierarchyLabelProvider_updatePending;
- public static String CallHierarchyLabelProvider_matches;
- public static String CallHierarchyViewPart_empty;
- public static String CallHierarchyViewPart_callsToMethod;
- public static String CallHierarchyViewPart_callsFromMethod;
- public static String FocusOnSelectionAction_focusOnSelection_text;
- public static String FocusOnSelectionAction_focusOnSelection_description;
- public static String FocusOnSelectionAction_focusOnSelection_tooltip;
- public static String FocusOnSelectionAction_focusOn_text;
- public static String RefreshAction_text;
- public static String RefreshAction_tooltip;
- public static String SearchScopeActionGroup_searchScope;
- public static String SearchScopeActionGroup_hierarchy_text;
- public static String SearchScopeActionGroup_hierarchy_tooltip;
- public static String SearchScopeActionGroup_project_text;
- public static String SearchScopeActionGroup_project_tooltip;
- public static String SearchScopeActionGroup_workingset_tooltip;
- public static String SearchScopeActionGroup_workspace_text;
- public static String SearchScopeActionGroup_workspace_tooltip;
- public static String SearchScopeActionGroup_workingset_select_text;
- public static String SearchScopeActionGroup_workingset_select_tooltip;
- public static String WorkingSetScope;
- public static String SearchUtil_workingSetConcatenation;
- public static String SelectWorkingSetAction_error_title;
- public static String SelectWorkingSetAction_error_message;
- public static String OpenLocationAction_error_title;
- public static String CallHierarchyUI_open_in_editor_error_message;
- public static String CallHierarchyUI_open_in_editor_error_messageArgs;
- public static String CallHierarchyUI_error_open_view;
- public static String CopyCallHierarchyAction_label;
- public static String CopyCallHierarchyAction_problem;
- public static String CopyCallHierarchyAction_clipboard_busy;
- public static String OpenCallHierarchyAction_label;
- public static String OpenCallHierarchyAction_tooltip;
- public static String OpenCallHierarchyAction_description;
- public static String OpenCallHierarchyAction_messages_no_java_element;
- public static String OpenCallHierarchyAction_messages_no_valid_java_element;
- public static String OpenCallHierarchyAction_messages_title;
- public static String OpenCallHierarchyAction_dialog_title;
- public static String CancelSearchAction_label;
- public static String CancelSearchAction_tooltip;
- public static String CallHierarchyUI_selectionDialog_title;
- public static String CallHierarchyUI_selectionDialog_message;
- public static String OpenLocationAction_label;
- public static String OpenLocationAction_tooltip;
- public static String LocationViewer_ColumnIcon_header;
- public static String LocationViewer_ColumnLine_header;
- public static String LocationViewer_ColumnInfo_header;
- public static String LocationLabelProvider_unknown;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class);
- }
-
- public static String CallHierarchyViewPart_layout_menu;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.properties
deleted file mode 100644
index 27a9c25b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyMessages.properties
+++ /dev/null
@@ -1,116 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
-# (report 36180: Callers/Callees view)
-# Michael Fraenkel (fraenkel@us.ibm.com) - patch
-# (report 60714: Call Hierarchy: display search scope in view title)
-###############################################################################
-
-ToggleCallModeAction_callers_label=&Caller Hierarchy
-ToggleCallModeAction_callers_tooltip=Show Caller Hierarchy
-ToggleCallModeAction_callers_description=Show the Caller Hierarchy
-ToggleCallModeAction_callees_label=C&allee Hierarchy
-ToggleCallModeAction_callees_tooltip=Show Callee Hierarchy
-ToggleCallModeAction_callees_description=Show the Callee Hierarchy
-
-HistoryDropDownAction_tooltip=Show History List
-HistoryDropDownAction_clearhistory_label=Clear History
-HistoryAction_description=Open ''{0}'' in Hierarchy
-HistoryAction_tooltip=Open ''{0}'' in Hierarchy
-
-HistoryListDialog_title=Call Hierarchy History
-HistoryListDialog_label=&Select the element to open in the call hierarchy:
-HistoryListDialog_remove_button=&Remove
-
-HistoryListAction_label=History...
-
-ToggleOrientationAction_vertical_label=&Vertical View Orientation
-ToggleOrientationAction_vertical_description=Vertical View Orientation
-ToggleOrientationAction_vertical_tooltip=Vertical View Orientation
-ToggleOrientationAction_horizontal_label=&Horizontal View Orientation
-ToggleOrientationAction_horizontal_tooltip=Horizontal View Orientation
-ToggleOrientationAction_horizontal_description=Horizontal View Orientation
-ToggleOrientationAction_automatic_label=&Automatic View Orientation
-ToggleOrientationAction_automatic_tooltip=Automatic View Orientation
-ToggleOrientationAction_automatic_description=Automatic View Orientation
-ToggleOrientationAction_single_label=Hierarchy View &Only
-ToggleOrientationAction_single_tooltip=Hierarchy View Only
-ToggleOrientationAction_single_description=Hierarchy View Only
-
-ShowFilterDialogAction_text= &Filters...
-FiltersDialog_filter= Filter Calls
-FiltersDialog_filterOnNames= &Name filter patterns (matching names will be hidden):
-FiltersDialog_filterOnNamesSubCaption= Patterns are separated by commas (* = any string, ? = any character)
-FiltersDialog_maxCallDepth= &Max call depth:
-FiltersDialog_messageMaxCallDepthInvalid= The max call depth must be in range [1..99]
-CallHierarchyContentProvider_searchError_title=Exception
-CallHierarchyContentProvider_searchError_message=Unexpected exception.
-CallHierarchyLabelProvider_root=Root
-CallHierarchyLabelProvider_searchCanceled=The search was cancelled
-CallHierarchyLabelProvider_noMethodSelected=- no function selected -
-CallHierarchyLabelProvider_updatePending=...
-CallHierarchyLabelProvider_matches={0} ({1} matches)
-CallHierarchyViewPart_empty=To display the call hierarchy, select a function (for example in the outline view or in the editor), and select the \'Open Call Hierarchy\' menu option. Alternatively, you can drag and drop a function onto this view.
-CallHierarchyViewPart_callsToMethod=Members calling ''{0}'' - in {1}
-CallHierarchyViewPart_layout_menu=Layout
-CallHierarchyViewPart_callsFromMethod=Calls from method ''{0}'' - in {1}
-FocusOnSelectionAction_focusOnSelection_text=Fo&cus On Selection
-FocusOnSelectionAction_focusOnSelection_description=Focus On Selection
-FocusOnSelectionAction_focusOnSelection_tooltip=Focus On Selection
-FocusOnSelectionAction_focusOn_text=Fo&cus On ''{0}''
-
-RefreshAction_text=Re&fresh
-RefreshAction_tooltip=Refresh
-SearchScopeActionGroup_searchScope=&Search Scope
-SearchScopeActionGroup_hierarchy_text=&Hierarchy
-SearchScopeActionGroup_hierarchy_tooltip=Search for Calls in Hierarchy
-SearchScopeActionGroup_project_text=&Project
-SearchScopeActionGroup_project_tooltip=Search for Calls in Project
-SearchScopeActionGroup_workingset_tooltip=Search for Calls in Working Set
-SearchScopeActionGroup_workspace_text=&Workspace
-SearchScopeActionGroup_workspace_tooltip=Search for Calls in Workspace
-SearchScopeActionGroup_workingset_select_text=Working &Set...
-SearchScopeActionGroup_workingset_select_tooltip=Select Working Set
-WorkingSetScope= Working Set - {0}
-
-SearchUtil_workingSetConcatenation= {0}, {1}
-
-SelectWorkingSetAction_error_title=Select Working Sets Error
-SelectWorkingSetAction_error_message=An error occurred while selecting the working sets.
-OpenLocationAction_error_title=Show Call Location
-CallHierarchyUI_open_in_editor_error_message=An error occurred while opening the editor.
-CallHierarchyUI_open_in_editor_error_messageArgs=An error occurred while opening the editor for ''{0}'': ''{1}''.
-CallHierarchyUI_error_open_view=An error occurred while opening the call hierarchy view.
-
-CopyCallHierarchyAction_label=Copy E&xpanded Hierarchy
-CopyCallHierarchyAction_problem=Problem Copying Hierarchy to Clipboard
-CopyCallHierarchyAction_clipboard_busy=There was a problem when accessing the system clipboard. Retry?
-OpenCallHierarchyAction_label=Open Call &Hierarchy
-OpenCallHierarchyAction_tooltip=Open a Call Hierarchy on the Selected Element
-OpenCallHierarchyAction_description=Open a call hierarchy on the selected element
-OpenCallHierarchyAction_messages_no_java_element=A JavaScript element must be selected.
-OpenCallHierarchyAction_messages_no_valid_java_element=A function must be selected.
-OpenCallHierarchyAction_messages_title= Cannot create call hierarchy
-OpenCallHierarchyAction_dialog_title=Open Call Hierarchy
-
-CancelSearchAction_label=Cancel
-CancelSearchAction_tooltip=Cancel Current Search
-
-CallHierarchyUI_selectionDialog_title=Open In Call Hierarchy
-CallHierarchyUI_selectionDialog_message=&Select the method to be shown in the Call Hierarchy:
-
-OpenLocationAction_label=&Open
-OpenLocationAction_tooltip=Open Location
-
-LocationViewer_ColumnIcon_header=
-LocationViewer_ColumnLine_header=Line
-LocationViewer_ColumnInfo_header=Call
-
-LocationLabelProvider_unknown=?
-LocationCopyAction_copy=&Copy
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java
deleted file mode 100644
index 8abad4f8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-
-class CallHierarchyTransferDropAdapter extends SelectionTransferDropAdapter {
-
- private static final int OPERATION = DND.DROP_LINK;
- private CallHierarchyViewPart fCallHierarchyViewPart;
-
- public CallHierarchyTransferDropAdapter(CallHierarchyViewPart viewPart, StructuredViewer viewer) {
- super(viewer);
- setFullWidthMatchesItem(false);
- fCallHierarchyViewPart= viewPart;
- }
-
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
- initializeSelection();
- if (target != null){
- super.validateDrop(target, event, operation);
- return;
- }
- if (getInputElement(getSelection()) != null)
- event.detail= OPERATION;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDropAdapter#isEnabled(org.eclipse.swt.dnd.DropTargetEvent)
- */
- public boolean isEnabled(DropTargetEvent event) {
- return true;
- }
-
- public void drop(Object target, DropTargetEvent event) {
- if (target != null || event.detail != OPERATION){
- super.drop(target, event);
- return;
- }
- IFunction input= getInputElement(getSelection());
- fCallHierarchyViewPart.setMethod(input);
- }
-
- private static IFunction getInputElement(ISelection selection) {
- Object single= SelectionUtil.getSingleElement(selection);
- if (single == null)
- return null;
- return getCandidate(single);
- }
-
- /**
- * Converts the input to a possible input candidates
- */
- public static IFunction getCandidate(Object input) {
- if (!(input instanceof IFunction)) {
- return null;
- }
- return (IFunction) input;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyUI.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyUI.java
deleted file mode 100644
index 569e72d0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyUI.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallHierarchy;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallLocation;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class CallHierarchyUI {
- private static final int DEFAULT_MAX_CALL_DEPTH= 10;
- private static final String PREF_MAX_CALL_DEPTH = "PREF_MAX_CALL_DEPTH"; //$NON-NLS-1$
-
- private static CallHierarchyUI fgInstance;
-
- private CallHierarchyUI() {
- // Do nothing
- }
-
- public static CallHierarchyUI getDefault() {
- if (fgInstance == null) {
- fgInstance = new CallHierarchyUI();
- }
-
- return fgInstance;
- }
-
- /**
- * Returns the maximum tree level allowed
- * @return int
- */
- public int getMaxCallDepth() {
- int maxCallDepth;
-
- IPreferenceStore settings = JavaScriptPlugin.getDefault().getPreferenceStore();
- maxCallDepth = settings.getInt(PREF_MAX_CALL_DEPTH);
- if (maxCallDepth < 1 || maxCallDepth > 99) {
- maxCallDepth= DEFAULT_MAX_CALL_DEPTH;
- }
-
- return maxCallDepth;
- }
-
- public void setMaxCallDepth(int maxCallDepth) {
- IPreferenceStore settings = JavaScriptPlugin.getDefault().getPreferenceStore();
- settings.setValue(PREF_MAX_CALL_DEPTH, maxCallDepth);
- }
-
- public static void jumpToMember(IJavaScriptElement element) {
- if (element != null) {
- try {
- JavaScriptUI.openInEditor(element, true, true);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- } catch (PartInitException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- public static void jumpToLocation(CallLocation callLocation) {
- try {
- IEditorPart methodEditor = JavaScriptUI.openInEditor(callLocation.getMember(), false, false);
- if (methodEditor instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) methodEditor;
- editor.selectAndReveal(callLocation.getStart(),
- (callLocation.getEnd() - callLocation.getStart()));
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- } catch (PartInitException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- /**
- * @return <code>true</code> iff no error occurred while trying to
- * open the editor, <code>false</code> iff an error dialog was raised.
- */
- public static boolean openInEditor(Object element, Shell shell, String title) {
- CallLocation callLocation= CallHierarchy.getCallLocation(element);
-
- try {
- IMember enclosingMember;
- int selectionStart;
- int selectionLength;
-
- if (callLocation != null) {
- enclosingMember= callLocation.getMember();
- selectionStart= callLocation.getStart();
- selectionLength= callLocation.getEnd() - selectionStart;
- } else if (element instanceof MethodWrapper) {
- enclosingMember= ((MethodWrapper) element).getMember();
- if(enclosingMember.isVirtual()) {
- selectionStart = 0;
- selectionLength = 0;
-
- }else {
- ISourceRange selectionRange= enclosingMember.getNameRange();
- if (selectionRange == null)
- selectionRange= enclosingMember.getSourceRange();
- if (selectionRange == null)
- return true;
- selectionStart= selectionRange.getOffset();
- selectionLength= selectionRange.getLength();
- }
- } else {
- return true;
- }
-
- boolean activateOnOpen = OpenStrategy.activateOnOpen();
-
- IEditorPart methodEditor = JavaScriptUI.openInEditor(enclosingMember, activateOnOpen, false);
- if (methodEditor instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) methodEditor;
- editor.selectAndReveal(selectionStart, selectionLength);
- }
- return true;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(),
- IJavaStatusConstants.INTERNAL_ERROR,
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message, e));
-
- ErrorDialog.openError(shell, title,
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message,
- e.getStatus());
- return false;
- } catch (PartInitException x) {
- String name;
- if (callLocation != null)
- name= callLocation.getCalledMember().getElementName();
- else if (element instanceof MethodWrapper)
- name= ((MethodWrapper) element).getName();
- else
- name= ""; //$NON-NLS-1$
- MessageDialog.openError(shell, title,
- Messages.format(
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_messageArgs,
- new String[] { name, x.getMessage() }));
- return false;
- }
- }
-
- public static IEditorPart isOpenInEditor(Object elem) {
- IJavaScriptElement javaElement= null;
- if (elem instanceof MethodWrapper) {
- javaElement= ((MethodWrapper) elem).getMember();
- } else if (elem instanceof CallLocation) {
- javaElement= ((CallLocation) elem).getCalledMember();
- }
- if (javaElement != null) {
- return EditorUtility.isOpenInEditor(javaElement);
- }
- return null;
- }
-
- /**
- * Converts the input to a possible input candidates
- */
- public static IJavaScriptElement[] getCandidates(Object input) {
- if (!(input instanceof IJavaScriptElement)) {
- return null;
- }
- IJavaScriptElement elem= (IJavaScriptElement) input;
- if (elem.getElementType() == IJavaScriptElement.METHOD) {
- return new IJavaScriptElement[] { elem };
- }
- return null;
- }
-
- public static CallHierarchyViewPart open(IJavaScriptElement[] candidates, IWorkbenchWindow window) {
- Assert.isTrue(candidates != null && candidates.length != 0);
-
- IJavaScriptElement input= null;
- if (candidates.length > 1) {
- String title= CallHierarchyMessages.CallHierarchyUI_selectionDialog_title;
- String message= CallHierarchyMessages.CallHierarchyUI_selectionDialog_message;
- input= SelectionConverter.selectJavaElement(candidates, window.getShell(), title, message);
- } else {
- input= candidates[0];
- }
- if (input == null)
- return null;
-
- return openInViewPart(window, input);
- }
-
- private static CallHierarchyViewPart openInViewPart(IWorkbenchWindow window, IJavaScriptElement input) {
- IWorkbenchPage page= window.getActivePage();
- try {
- CallHierarchyViewPart result= (CallHierarchyViewPart)page.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
- result.setMethod((IFunction)input);
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CallHierarchyMessages.CallHierarchyUI_error_open_view, e.getMessage());
- }
- return null;
- }
-
- /**
- * Converts an ISelection (containing MethodWrapper instances) to an ISelection
- * with the MethodWrapper's replaced by their corresponding IMembers. If the selection
- * contains elements which are not MethodWrapper instances or not already IMember instances
- * they are discarded.
- * @param selection The selection to convert.
- * @return An ISelection containing IMember's in place of MethodWrapper instances.
- */
- static ISelection convertSelection(ISelection selection) {
- if (selection.isEmpty()) {
- return selection;
- }
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) selection;
- List javaElements= new ArrayList();
- for (Iterator iter= structuredSelection.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof MethodWrapper) {
- IMember member= ((MethodWrapper)element).getMember();
- if (member != null) {
- javaElements.add(member);
- }
- } else if (element instanceof IMember) {
- javaElements.add(element);
- } else if (element instanceof CallLocation) {
- IMember member = ((CallLocation) element).getMember();
- javaElements.add(member);
- }
- }
- return new StructuredSelection(javaElements);
- }
- return StructuredSelection.EMPTY;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewPart.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
deleted file mode 100644
index eeb7cfa4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
+++ /dev/null
@@ -1,948 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.help.IContextProvider;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallHierarchy;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallLocation;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.dnd.DelegatingDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.ResourceTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.JavaUIHelp;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionProviderMediator;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.actions.CCPActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenEditorActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-/**
- * This is the main view for the callers plugin. It builds a tree of callers/callees
- * and allows the user to double click an entry to go to the selected method.
- *
- */
-public class CallHierarchyViewPart extends ViewPart implements ICallHierarchyViewPart,
- ISelectionChangedListener {
-
- private class CallHierarchySelectionProvider extends SelectionProviderMediator {
-
- public CallHierarchySelectionProvider(StructuredViewer[] viewers) {
- super(viewers, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.typehierarchy.SelectionProviderMediator#getSelection()
- */
- public ISelection getSelection() {
- ISelection selection= super.getSelection();
- if (!selection.isEmpty()) {
- return CallHierarchyUI.convertSelection(selection);
- }
- return selection;
- }
- }
-
- private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$
- private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$
- /**
- * The key to be used is <code>DIALOGSTORE_RATIO + fCurrentOrientation</code>.
- */
- private static final String DIALOGSTORE_RATIO= "CallHierarchyViewPart.ratio"; //$NON-NLS-1$
-
- static final int VIEW_ORIENTATION_VERTICAL = 0;
- static final int VIEW_ORIENTATION_HORIZONTAL = 1;
- static final int VIEW_ORIENTATION_SINGLE = 2;
- static final int VIEW_ORIENTATION_AUTOMATIC = 3;
- static final int CALL_MODE_CALLERS = 0;
- static final int CALL_MODE_CALLEES = 1;
- static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$
- static final String ID_CALL_HIERARCHY = "org.eclipse.wst.jsdt.callhierarchy.view"; //$NON-NLS-1$
- private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$
- private static final int PAGE_EMPTY = 0;
- private static final int PAGE_VIEWER = 1;
- private Label fNoHierarchyShownLabel;
- private PageBook fPagebook;
- private IDialogSettings fDialogSettings;
- private int fCurrentOrientation;
- int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
- private int fCurrentCallMode;
- private MethodWrapper fCalleeRoot;
- private MethodWrapper fCallerRoot;
- private IMemento fMemento;
- private IFunction fShownMethod;
- private CallHierarchySelectionProvider fSelectionProviderMediator;
- private List fMethodHistory;
- private LocationViewer fLocationViewer;
- private SashForm fHierarchyLocationSplitter;
- private Clipboard fClipboard;
- private SearchScopeActionGroup fSearchScopeActions;
- private ToggleOrientationAction[] fToggleOrientationActions;
- private ToggleCallModeAction[] fToggleCallModeActions;
- private CallHierarchyFiltersActionGroup fFiltersActionGroup;
- private HistoryDropDownAction fHistoryDropDownAction;
- private RefreshAction fRefreshAction;
- private OpenLocationAction fOpenLocationAction;
- private LocationCopyAction fLocationCopyAction;
- private FocusOnSelectionAction fFocusOnSelectionAction;
- private CopyCallHierarchyAction fCopyAction;
- private CancelSearchAction fCancelSearchAction;
- private CompositeActionGroup fActionGroups;
- private CallHierarchyViewer fCallHierarchyViewer;
- private boolean fShowCallDetails;
- protected Composite fParent;
- private IPartListener2 fPartListener;
-
- public CallHierarchyViewPart() {
- super();
-
- fDialogSettings = JavaScriptPlugin.getDefault().getDialogSettings();
-
- fMethodHistory = new ArrayList();
- }
-
- public void setFocus() {
- fPagebook.setFocus();
- }
-
- /**
- * Sets the history entries
- */
- public void setHistoryEntries(IFunction[] elems) {
- fMethodHistory.clear();
-
- for (int i = 0; i < elems.length; i++) {
- fMethodHistory.add(elems[i]);
- }
-
- updateHistoryEntries();
- }
-
- /**
- * Gets all history entries.
- */
- public IFunction[] getHistoryEntries() {
- if (fMethodHistory.size() > 0) {
- updateHistoryEntries();
- }
-
- return (IFunction[]) fMethodHistory.toArray(new IFunction[fMethodHistory.size()]);
- }
-
- /**
- * Method setMethod.
- * @param method
- */
- public void setMethod(IFunction method) {
- if (method == null) {
- showPage(PAGE_EMPTY);
-
- return;
- }
- if (! method.equals(fShownMethod)) {
- addHistoryEntry(method);
- }
-
- this.fShownMethod = method;
-
- refresh();
- }
-
- public IFunction getMethod() {
- return fShownMethod;
- }
-
- public MethodWrapper getCurrentMethodWrapper() {
- if (fCurrentCallMode == CALL_MODE_CALLERS) {
- return fCallerRoot;
- } else {
- return fCalleeRoot;
- }
- }
-
- /**
- * called from ToggleOrientationAction.
- * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
- */
- void setOrientation(int orientation) {
- if (fCurrentOrientation != orientation) {
- if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() &&
- (fHierarchyLocationSplitter != null) &&
- !fHierarchyLocationSplitter.isDisposed()) {
- if (orientation == VIEW_ORIENTATION_SINGLE) {
- setShowCallDetails(false);
- } else {
- if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
- setShowCallDetails(true);
- }
-
- boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL;
- fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL
- : SWT.VERTICAL);
- }
-
- fHierarchyLocationSplitter.layout();
- }
-
- updateCheckedState();
-
- fCurrentOrientation = orientation;
-
- restoreSplitterRatio();
- }
- }
-
- private void updateCheckedState() {
- for (int i= 0; i < fToggleOrientationActions.length; i++) {
- fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
- }
- }
-
- /**
- * called from ToggleCallModeAction.
- * @param mode CALL_MODE_CALLERS or CALL_MODE_CALLEES
- */
- void setCallMode(int mode) {
- if (fCurrentCallMode != mode) {
- for (int i = 0; i < fToggleCallModeActions.length; i++) {
- fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode());
- }
-
- fCurrentCallMode = mode;
- fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode);
-
- updateView();
- }
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- return fSearchScopeActions.getSearchScope();
- }
-
- public void setShowCallDetails(boolean show) {
- fShowCallDetails = show;
- showOrHideCallDetailsView();
- }
-
- private void initDragAndDrop() {
- addDragAdapters(fCallHierarchyViewer);
- addDropAdapters(fCallHierarchyViewer);
- addDropAdapters(fLocationViewer);
-
- //dnd on empty hierarchy
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() });
- dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer));
- }
-
- private void addDropAdapters(StructuredViewer viewer) {
- Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
- int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
-
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new CallHierarchyTransferDropAdapter(this, viewer)
- };
- viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
- }
-
- private void addDragAdapters(StructuredViewer viewer) {
- int ops= DND.DROP_COPY | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance()};
-
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(viewer),
- new ResourceTransferDragAdapter(viewer)
- };
- viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners));
- }
-
- public void createPartControl(Composite parent) {
- fParent= parent;
- addResizeListener(parent);
- fPagebook = new PageBook(parent, SWT.NONE);
-
- // Page 1: Viewers
- createHierarchyLocationSplitter(fPagebook);
- createCallHierarchyViewer(fHierarchyLocationSplitter);
- createLocationViewer(fHierarchyLocationSplitter);
-
- // Page 2: Nothing selected
- fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
- fNoHierarchyShownLabel.setText(CallHierarchyMessages.CallHierarchyViewPart_empty); //
-
- initDragAndDrop();
-
- showPage(PAGE_EMPTY);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW);
-
- fSelectionProviderMediator = new CallHierarchySelectionProvider(new StructuredViewer[] {
- fCallHierarchyViewer, fLocationViewer
- });
-
- IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager();
- fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
- getSite().setSelectionProvider(fSelectionProviderMediator);
-
- fCallHierarchyViewer.initContextMenu(
- new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillCallHierarchyViewerContextMenu(menu);
- }
- }, getSite(), fSelectionProviderMediator);
-
-
- fClipboard= new Clipboard(parent.getDisplay());
-
- makeActions();
- fillViewMenu();
- fillActionBars();
-
- initOrientation();
- initCallMode();
-
- if (fMemento != null) {
- restoreState(fMemento);
- }
- restoreSplitterRatio();
- addPartListener();
- }
-
- private void restoreSplitterRatio() {
- String ratio= fDialogSettings.get(DIALOGSTORE_RATIO + fCurrentOrientation);
- if (ratio == null)
- return;
- int intRatio= Integer.parseInt(ratio);
- fHierarchyLocationSplitter.setWeights(new int[] {intRatio, 1000 - intRatio});
- }
-
- private void saveSplitterRatio() {
- if (fHierarchyLocationSplitter != null && ! fHierarchyLocationSplitter.isDisposed()) {
- int[] weigths = fHierarchyLocationSplitter.getWeights();
- int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]);
- String key= DIALOGSTORE_RATIO + fCurrentOrientation;
- fDialogSettings.put(key, ratio);
- }
- }
-
- private void addPartListener() {
- fPartListener= new IPartListener2() {
- public void partActivated(IWorkbenchPartReference partRef) { }
- public void partBroughtToTop(IWorkbenchPartReference partRef) { }
- public void partClosed(IWorkbenchPartReference partRef) {
- if (ID_CALL_HIERARCHY.equals(partRef.getId()))
- saveViewSettings();
- }
- public void partDeactivated(IWorkbenchPartReference partRef) {
- if (ID_CALL_HIERARCHY.equals(partRef.getId()))
- saveViewSettings();
- }
- public void partOpened(IWorkbenchPartReference partRef) { }
- public void partHidden(IWorkbenchPartReference partRef) { }
- public void partVisible(IWorkbenchPartReference partRef) { }
- public void partInputChanged(IWorkbenchPartReference partRef) { }
- };
- getViewSite().getPage().addPartListener(fPartListener);
- }
-
- protected void saveViewSettings() {
- saveSplitterRatio();
- fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, fOrientation);
- }
-
- private void addResizeListener(Composite parent) {
- parent.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent e) {
- }
- public void controlResized(ControlEvent e) {
- computeOrientation();
- }
- });
- }
-
- void computeOrientation() {
- saveSplitterRatio();
- fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, fOrientation);
- if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
- setOrientation(fOrientation);
- }
- else {
- if (fOrientation == VIEW_ORIENTATION_SINGLE)
- return;
- Point size= fParent.getSize();
- if (size.x != 0 && size.y != 0) {
- if (size.x > size.y)
- setOrientation(VIEW_ORIENTATION_HORIZONTAL);
- else
- setOrientation(VIEW_ORIENTATION_VERTICAL);
- }
- }
- }
-
- private void showPage(int page) {
- if (page == PAGE_EMPTY) {
- fPagebook.showPage(fNoHierarchyShownLabel);
- } else {
- fPagebook.showPage(fHierarchyLocationSplitter);
- }
- }
-
- /**
- * Restores the type hierarchy settings from a memento.
- */
- private void restoreState(IMemento memento) {
- fSearchScopeActions.restoreState(memento);
- }
-
- private void initCallMode() {
- int mode;
-
- try {
- mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE);
-
- if ((mode < 0) || (mode > 1)) {
- mode = CALL_MODE_CALLERS;
- }
- } catch (NumberFormatException e) {
- mode = CALL_MODE_CALLERS;
- }
-
- // force the update
- fCurrentCallMode = -1;
-
- // will fill the main tool bar
- setCallMode(mode);
- }
-
- private void initOrientation() {
-
- try {
- fOrientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION);
-
- if ((fOrientation < 0) || (fOrientation > 3)) {
- fOrientation = VIEW_ORIENTATION_AUTOMATIC;
- }
- } catch (NumberFormatException e) {
- fOrientation = VIEW_ORIENTATION_AUTOMATIC;
- }
-
- // force the update
- fCurrentOrientation = -1;
- setOrientation(fOrientation);
- }
-
- private void fillViewMenu() {
- IActionBars actionBars = getViewSite().getActionBars();
- IMenuManager viewMenu = actionBars.getMenuManager();
- viewMenu.add(new Separator());
-
- for (int i = 0; i < fToggleCallModeActions.length; i++) {
- viewMenu.add(fToggleCallModeActions[i]);
- }
-
- viewMenu.add(new Separator());
-
- MenuManager layoutSubMenu= new MenuManager(CallHierarchyMessages.CallHierarchyViewPart_layout_menu);
- for (int i = 0; i < fToggleOrientationActions.length; i++) {
- layoutSubMenu.add(fToggleOrientationActions[i]);
- }
- viewMenu.add(layoutSubMenu);
- }
-
- /**
- *
- */
- public void dispose() {
- if (fActionGroups != null)
- fActionGroups.dispose();
-
- if (fClipboard != null)
- fClipboard.dispose();
-
- if (fPartListener != null) {
- getViewSite().getPage().removePartListener(fPartListener);
- fPartListener= null;
- }
-
- super.dispose();
- }
-
- /**
- * Goes to the selected entry, without updating the order of history entries.
- */
- public void gotoHistoryEntry(IFunction entry) {
- if (fMethodHistory.contains(entry)) {
- setMethod(entry);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IViewPart.
- */
- public void init(IViewSite site, IMemento memento)
- throws PartInitException {
- super.init(site, memento);
- fMemento = memento;
- }
-
- /**
- *
- */
- public void refresh() {
- setCalleeRoot(null);
- setCallerRoot(null);
-
- updateView();
- }
-
- public void saveState(IMemento memento) {
- if (fPagebook == null) {
- // part has not been created
- if (fMemento != null) { //Keep the old state;
- memento.putMemento(fMemento);
- }
-
- return;
- }
-
- fSearchScopeActions.saveState(memento);
- }
-
- public void selectionChanged(SelectionChangedEvent e) {
- if (e.getSelectionProvider() == fCallHierarchyViewer) {
- methodSelectionChanged(e.getSelection());
- }
- }
-
- /**
- * @param selection
- */
- private void methodSelectionChanged(ISelection selection) {
- if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
- Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
-
- if (selectedElement instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) selectedElement;
-
- revealElementInEditor(methodWrapper, fCallHierarchyViewer);
- updateLocationsView(methodWrapper);
- } else {
- updateLocationsView(null);
- }
- } else {
- updateLocationsView(null);
- }
- }
-
- private void revealElementInEditor(Object elem, Viewer originViewer) {
- // only allow revealing when the type hierarchy is the active pagae
- // no revealing after selection events due to model changes
- if (getSite().getPage().getActivePart() != this) {
- return;
- }
-
- if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
- return;
- }
-
- if (elem instanceof MethodWrapper) {
- CallLocation callLocation = CallHierarchy.getCallLocation(elem);
-
- if (callLocation != null) {
- IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation);
-
- if (editorPart != null) {
- getSite().getPage().bringToTop(editorPart);
-
- if (editorPart instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) editorPart;
- editor.selectAndReveal(callLocation.getStart(),
- (callLocation.getEnd() - callLocation.getStart()));
- }
- }
- } else {
- IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem);
- getSite().getPage().bringToTop(editorPart);
- EditorUtility.revealInEditor(editorPart,
- ((MethodWrapper) elem).getMember());
- }
- } else if (elem instanceof IJavaScriptElement) {
- IEditorPart editorPart = EditorUtility.isOpenInEditor(elem);
-
- if (editorPart != null) {
- // getSite().getPage().removePartListener(fPartListener);
- getSite().getPage().bringToTop(editorPart);
- EditorUtility.revealInEditor(editorPart, (IJavaScriptElement) elem);
-
- // getSite().getPage().addPartListener(fPartListener);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IContextProvider.class) {
- return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.CALL_HIERARCHY_VIEW);
- }
- if (adapter == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES, IPageLayout.ID_RES_NAV };
- }
- };
- }
- return super.getAdapter(adapter);
- }
-
- /**
- * Returns the current selection.
- */
- protected ISelection getSelection() {
- StructuredViewer viewerInFocus= fSelectionProviderMediator.getViewerInFocus();
- if (viewerInFocus != null) {
- return viewerInFocus.getSelection();
- }
- return StructuredSelection.EMPTY;
- }
-
- protected void fillLocationViewerContextMenu(IMenuManager menu) {
- JavaScriptPlugin.createStandardGroups(menu);
-
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenLocationAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fLocationCopyAction);
- }
-
- protected void handleKeyEvent(KeyEvent event) {
- if (event.stateMask == 0) {
- if (event.keyCode == SWT.F5) {
- if ((fRefreshAction != null) && fRefreshAction.isEnabled()) {
- fRefreshAction.run();
-
- return;
- }
- }
- }
- }
-
- private IActionBars getActionBars() {
- return getViewSite().getActionBars();
- }
-
- private void setCalleeRoot(MethodWrapper calleeRoot) {
- this.fCalleeRoot = calleeRoot;
- }
-
- private MethodWrapper getCalleeRoot() {
- if (fCalleeRoot == null) {
- fCalleeRoot = CallHierarchy.getDefault().getCalleeRoot(fShownMethod);
- }
-
- return fCalleeRoot;
- }
-
- private void setCallerRoot(MethodWrapper callerRoot) {
- this.fCallerRoot = callerRoot;
- }
-
- private MethodWrapper getCallerRoot() {
- if (fCallerRoot == null) {
- fCallerRoot = CallHierarchy.getDefault().getCallerRoot(fShownMethod);
- }
-
- return fCallerRoot;
- }
-
- /**
- * Adds the entry if new. Inserted at the beginning of the history entries list.
- */
- private void addHistoryEntry(IJavaScriptElement entry) {
- if (fMethodHistory.contains(entry)) {
- fMethodHistory.remove(entry);
- }
-
- fMethodHistory.add(0, entry);
- fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty());
- }
-
- /**
- * @param parent
- */
- private void createLocationViewer(Composite parent) {
- fLocationViewer= new LocationViewer(parent);
-
- fLocationViewer.getControl().addKeyListener(createKeyListener());
-
- fLocationViewer.initContextMenu(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillLocationViewerContextMenu(menu);
- }
- }, ID_CALL_HIERARCHY, getSite());
- }
-
- private void createHierarchyLocationSplitter(Composite parent) {
- fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE);
-
- fHierarchyLocationSplitter.addKeyListener(createKeyListener());
- }
-
- private void createCallHierarchyViewer(Composite parent) {
- fCallHierarchyViewer = new CallHierarchyViewer(parent, this);
-
- fCallHierarchyViewer.addKeyListener(createKeyListener());
- fCallHierarchyViewer.addSelectionChangedListener(this);
- }
-
- /**
- * @param menu
- */
- protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) {
- JavaScriptPlugin.createStandardGroups(menu);
-
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS));
-
- if (fFocusOnSelectionAction.canActionBeAdded()) {
- menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction);
- }
- if (fCopyAction.canActionBeAdded()) {
- menu.appendToGroup(GROUP_FOCUS, fCopyAction);
- }
-
- fActionGroups.setContext(new ActionContext(getSelection()));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
- }
-
- private void fillActionBars() {
- IActionBars actionBars = getActionBars();
- IToolBarManager toolBar = actionBars.getToolBarManager();
-
- fActionGroups.fillActionBars(actionBars);
-
- toolBar.add(fCancelSearchAction);
- for (int i = 0; i < fToggleCallModeActions.length; i++) {
- toolBar.add(fToggleCallModeActions[i]);
- }
- toolBar.add(fHistoryDropDownAction);
- }
-
- private KeyListener createKeyListener() {
- KeyListener keyListener = new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- handleKeyEvent(event);
- }
- };
-
- return keyListener;
- }
-
- /**
- *
- */
- private void makeActions() {
- fRefreshAction = new RefreshAction(this);
-
- fOpenLocationAction = new OpenLocationAction(this, getSite());
- fLocationViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- fOpenLocationAction.run();
- }
- });
-
- fLocationCopyAction= fLocationViewer.initCopyAction(getViewSite(), fClipboard);
-
- fFocusOnSelectionAction = new FocusOnSelectionAction(this);
- fCopyAction= new CopyCallHierarchyAction(this, fClipboard, fCallHierarchyViewer);
- fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
- fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
- fCallHierarchyViewer);
- fHistoryDropDownAction = new HistoryDropDownAction(this);
- fHistoryDropDownAction.setEnabled(false);
- fCancelSearchAction = new CancelSearchAction(this);
- setCancelEnabled(false);
- fToggleOrientationActions = new ToggleOrientationAction[] {
- new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
- };
- fToggleCallModeActions = new ToggleCallModeAction[] {
- new ToggleCallModeAction(this, CALL_MODE_CALLERS),
- new ToggleCallModeAction(this, CALL_MODE_CALLEES)
- };
- fActionGroups = new CompositeActionGroup(new ActionGroup[] {
- new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
- new CCPActionGroup(this),
- new GenerateActionGroup(this),
- new RefactorActionGroup(this),
- new JavaSearchActionGroup(this),
- fSearchScopeActions, fFiltersActionGroup
- });
- }
-
- private void showOrHideCallDetailsView() {
- if (fShowCallDetails) {
- fHierarchyLocationSplitter.setMaximizedControl(null);
- } else {
- fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl());
- }
- }
-
- private void updateLocationsView(MethodWrapper methodWrapper) {
- if (methodWrapper != null && methodWrapper.getMethodCall().hasCallLocations()) {
- fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations());
- } else {
- fLocationViewer.clearViewer();
- }
- }
-
- private void updateHistoryEntries() {
- for (int i = fMethodHistory.size() - 1; i >= 0; i--) {
- IFunction method = (IFunction) fMethodHistory.get(i);
-
- if (!method.exists()) {
- fMethodHistory.remove(i);
- }
- }
-
- fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty());
- }
-
- /**
- * Method updateView.
- */
- private void updateView() {
- if ( (fShownMethod != null)) {
- showPage(PAGE_VIEWER);
-
- CallHierarchy.getDefault().setSearchScope(getSearchScope());
-
- String elementName= JavaScriptElementLabels.getElementLabel(fShownMethod, JavaScriptElementLabels.ALL_DEFAULT);
- String scopeDescription= fSearchScopeActions.getFullDescription();
- String[] args= new String[] { elementName, scopeDescription };
- // set input to null so that setSorter does not cause a refresh on the old contents:
- fCallHierarchyViewer.setInput(null);
- if (fCurrentCallMode == CALL_MODE_CALLERS) {
- setContentDescription(Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMethod, args));
- fCallHierarchyViewer.setComparator(new ViewerComparator()); // bug 111423: sort caller hierarchy alphabetically
- fCallHierarchyViewer.setMethodWrapper(getCallerRoot());
- } else {
- setContentDescription(Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod, args));
- fCallHierarchyViewer.setComparator(null);
- fCallHierarchyViewer.setMethodWrapper(getCalleeRoot());
- }
- }
- }
-
- static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) {
- IWorkbenchPage workbenchPage = site.getPage();
- CallHierarchyViewPart callersView = null;
-
- try {
- callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
- } catch (PartInitException e) {
- JavaScriptPlugin.log(e);
- }
-
- return callersView;
- }
-
- /**
- * Cancels the caller/callee search jobs that are currently running.
- */
- void cancelJobs() {
- fCallHierarchyViewer.cancelJobs();
- }
-
- /**
- * Sets the enablement state of the cancel button.
- * @param enabled
- */
- void setCancelEnabled(boolean enabled) {
- fCancelSearchAction.setEnabled(enabled);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewer.java
deleted file mode 100644
index 9769dbdc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CallHierarchyViewer.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-
-class CallHierarchyViewer extends TreeViewer {
- private CallHierarchyViewPart fPart;
-
- private OpenLocationAction fOpen;
-
- private CallHierarchyContentProvider fContentProvider;
-
- /**
- * @param parent the parent composite
- * @param part the call hierarchy view part
- */
- CallHierarchyViewer(Composite parent, CallHierarchyViewPart part) {
- super(new Tree(parent, SWT.MULTI));
-
- fPart = part;
-
- getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- setUseHashlookup(true);
- setAutoExpandLevel(2);
- fContentProvider = new CallHierarchyContentProvider(fPart);
- setContentProvider(fContentProvider);
- setLabelProvider(new CallHierarchyLabelProvider());
-
- fOpen= new OpenLocationAction(part, part.getSite());
- addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- fOpen.run();
- }
- });
-
- ColoredViewersManager.install(this);
-
- clearViewer();
- }
-
- /**
- * @param wrapper
- */
- void setMethodWrapper(MethodWrapper wrapper) {
- setInput(getTreeRoot(wrapper));
-
- setFocus();
- setSelection(new StructuredSelection(wrapper), true);
- }
-
- CallHierarchyViewPart getPart() {
- return fPart;
- }
-
- /**
- *
- */
- void setFocus() {
- getControl().setFocus();
- }
-
- boolean isInFocus() {
- return getControl().isFocusControl();
- }
-
- /**
- * @param keyListener
- */
- void addKeyListener(KeyListener keyListener) {
- getControl().addKeyListener(keyListener);
- }
-
- /**
- * Wraps the root of a MethodWrapper tree in a dummy root in order to show
- * it in the tree.
- *
- * @param root The root of the MethodWrapper tree.
- * @return A new MethodWrapper which is a dummy root above the specified root.
- */
- private TreeRoot getTreeRoot(MethodWrapper root) {
- TreeRoot dummyRoot = new TreeRoot(root);
-
- return dummyRoot;
- }
-
- /**
- * Attaches a contextmenu listener to the tree
- * @param menuListener the menu listener
- * @param viewSite the view site
- * @param selectionProvider the selection provider
- */
- void initContextMenu(IMenuListener menuListener, IWorkbenchPartSite viewSite, ISelectionProvider selectionProvider) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getTree());
- getTree().setMenu(menu);
- viewSite.registerContextMenu(menuMgr, selectionProvider);
- }
-
- /**
- *
- */
- void clearViewer() {
- setInput(TreeRoot.EMPTY_ROOT);
- }
-
- void cancelJobs() {
- if (fPart == null)
- return;
- fContentProvider.cancelJobs(fPart.getCurrentMethodWrapper());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CancelSearchAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CancelSearchAction.java
deleted file mode 100644
index 7fda702d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CancelSearchAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * This class is copied from the org.eclipse.search2.internal.ui.CancelSearchAction class.
- */
-public class CancelSearchAction extends Action {
-
- private CallHierarchyViewPart fView;
-
- public CancelSearchAction(CallHierarchyViewPart view) {
- super(CallHierarchyMessages.CancelSearchAction_label);
- fView= view;
- setToolTipText(CallHierarchyMessages.CancelSearchAction_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "ch_cancel.gif"); //$NON-NLS-1$
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_CANCEL_SEARCH_ACTION);
-}
-
- public void run() {
- fView.cancelJobs();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CopyCallHierarchyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CopyCallHierarchyAction.java
deleted file mode 100644
index b2dd2eec..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/CopyCallHierarchyAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-
-class CopyCallHierarchyAction extends Action {
- private static final char INDENTATION= '\t';
-
- private CallHierarchyViewPart fView;
- private CallHierarchyViewer fViewer;
-
- private final Clipboard fClipboard;
-
- public CopyCallHierarchyAction(CallHierarchyViewPart view, Clipboard clipboard, CallHierarchyViewer viewer) {
- super(CallHierarchyMessages.CopyCallHierarchyAction_label);
- Assert.isNotNull(clipboard);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_COPY_ACTION);
- fView= view;
- fClipboard= clipboard;
- fViewer= viewer;
- }
-
- public boolean canActionBeAdded() {
- Object element = SelectionUtil.getSingleElement(getSelection());
- return element != null;
- }
-
- private ISelection getSelection() {
- ISelectionProvider provider = fView.getSite().getSelectionProvider();
-
- if (provider != null) {
- return provider.getSelection();
- }
-
- return null;
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- StringBuffer buf= new StringBuffer();
- addCalls(fViewer.getTree().getSelection()[0], 0, buf);
-
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- try{
- fClipboard.setContents(
- new String[]{ convertLineTerminators(buf.toString()) },
- new Transfer[]{ plainTextTransfer });
- } catch (SWTError e){
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw e;
- if (MessageDialog.openQuestion(fView.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
- run();
- }
- }
-
- /**
- * Adds the specified TreeItem's text to the StringBuffer
- *
- * @param item
- * @param buf
- */
- private void addCalls(TreeItem item, int indent, StringBuffer buf) {
- for (int i= 0; i < indent; i++) {
- buf.append(INDENTATION);
- }
-
- buf.append(item.getText());
- buf.append('\n');
-
- if (item.getExpanded()) {
- TreeItem[] items= item.getItems();
- for (int i= 0; i < items.length; i++) {
- addCalls(items[i], indent + 1, buf);
- }
- }
- }
-
- static String convertLineTerminators(String in) {
- StringWriter stringWriter= new StringWriter();
- PrintWriter printWriter= new PrintWriter(stringWriter);
- StringReader stringReader= new StringReader(in);
- BufferedReader bufferedReader= new BufferedReader(stringReader);
- try {
- String line= bufferedReader.readLine();
- while (line != null) {
- printWriter.print(line);
- line= bufferedReader.readLine();
- if (line != null && line.length() != 0)
- printWriter.println();
-
- }
- } catch (IOException e) {
- return in; // return the call hierarchy unfiltered
- }
- return stringWriter.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/DeferredMethodWrapper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/DeferredMethodWrapper.java
deleted file mode 100644
index 0b8cc4a9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/DeferredMethodWrapper.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-public class DeferredMethodWrapper extends MethodWrapperWorkbenchAdapter implements IDeferredWorkbenchAdapter {
- private final CallHierarchyContentProvider fProvider;
-
- /**
- * A simple job scheduling rule for serializing jobs that shouldn't be run
- * concurrently.
- */
- private class BatchSimilarSchedulingRule implements ISchedulingRule {
- public String id;
-
- public BatchSimilarSchedulingRule(String id) {
- this.id = id;
- }
-
- /*
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- public boolean isConflicting(ISchedulingRule rule) {
- if (rule instanceof BatchSimilarSchedulingRule) {
- return ((BatchSimilarSchedulingRule) rule).id.equals(id);
- }
- return false;
- }
-
- /*
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- public boolean contains(ISchedulingRule rule) {
- return this == rule;
- }
- }
-
- DeferredMethodWrapper(CallHierarchyContentProvider provider, MethodWrapper methodWrapper) {
- super(methodWrapper);
- this.fProvider = provider;
- }
-
- private Object getCalls(IProgressMonitor monitor) {
- return getMethodWrapper().getCalls(monitor);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object,
- * org.eclipse.jface.progress.IElementCollector,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
- try {
- fProvider.startFetching();
- DeferredMethodWrapper methodWrapper = (DeferredMethodWrapper) object;
- collector.add((Object[]) methodWrapper.getCalls(monitor), monitor);
- collector.done();
- } catch (OperationCanceledException e) {
- collector.add(new Object[] { TreeTermination.SEARCH_CANCELED }, monitor);
- } catch (Exception e) {
- JavaScriptPlugin.log(e);
- } finally {
- fProvider.doneFetching();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer()
- */
- public boolean isContainer() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule()
- */
- public ISchedulingRule getRule(Object o) {
- return new BatchSimilarSchedulingRule("org.eclipse.wst.jsdt.ui.callhierarchy.methodwrapper"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object o) {
- return this.fProvider.fetchChildren(((DeferredMethodWrapper) o).getMethodWrapper());
- }
-
- /**
- * Returns an object which is an instance of the given class associated
- * with this object. Returns <code>null</code> if no such object can be
- * found.
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IDeferredWorkbenchAdapter.class)
- return this;
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FiltersDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FiltersDialog.java
deleted file mode 100644
index f09c94ec..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FiltersDialog.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallHierarchy;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-
-class FiltersDialog extends StatusDialog {
- private Label fNamesHelpText;
- private Button fFilterOnNames;
- private Text fNames;
- private Text fMaxCallDepth;
-
- /**
- * @param parentShell
- */
- protected FiltersDialog(Shell parentShell) {
- super(parentShell);
- }
-
- /* (non-Javadoc)
- * Method declared on Window.
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(CallHierarchyMessages.FiltersDialog_filter);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_FILTERS_DIALOG);
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected Control createDialogArea(Composite parent) {
- Composite superComposite = (Composite) super.createDialogArea(parent);
-
- Composite composite = new Composite(superComposite, SWT.NONE);
- composite.setFont(superComposite.getFont());
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout layout = new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
-
- createNamesArea(composite);
- new Label(composite, SWT.NONE); // Filler
- createMaxCallDepthArea(composite);
-
- updateUIFromFilter();
-
- return composite;
- }
-
- private void createMaxCallDepthArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
-
- Label label= new Label(composite, SWT.NONE);
- label.setFont(composite.getFont());
- label.setText(CallHierarchyMessages.FiltersDialog_maxCallDepth);
-
- fMaxCallDepth = new Text(composite, SWT.SINGLE | SWT.BORDER);
- fMaxCallDepth.setFont(composite.getFont());
- fMaxCallDepth.setTextLimit(6);
- fMaxCallDepth.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
- });
-
- GridData gridData = new GridData();
- gridData.widthHint = convertWidthInCharsToPixels(10);
- fMaxCallDepth.setLayoutData(gridData);
- }
-
- private void createNamesArea(Composite parent) {
- fFilterOnNames = createCheckbox(parent,
- CallHierarchyMessages.FiltersDialog_filterOnNames, true);
-
- fNames= new Text(parent, SWT.SINGLE | SWT.BORDER);
- fNames.setFont(parent.getFont());
- fNames.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
- });
-
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- gridData.widthHint = convertWidthInCharsToPixels(60);
- fNames.setLayoutData(gridData);
-
- fNamesHelpText= new Label(parent, SWT.LEFT);
- fNamesHelpText.setFont(parent.getFont());
- fNamesHelpText.setText(CallHierarchyMessages.FiltersDialog_filterOnNamesSubCaption);
- }
-
- /**
- * Creates a check box button with the given parent and text.
- *
- * @param parent the parent composite
- * @param text the text for the check box
- * @param grabRow <code>true</code>to grab the remaining horizontal space,
- * <code>false</code> otherwise
- *
- * @return the check box button
- */
- private Button createCheckbox(Composite parent, String text, boolean grabRow) {
- Button button = new Button(parent, SWT.CHECK);
- button.setFont(parent.getFont());
-
- if (grabRow) {
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- button.setLayoutData(gridData);
- }
-
- button.setText(text);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- validateInput();
- updateEnabledState();
- }
- });
-
- return button;
- }
-
- /**
- * Updates the enabled state of the widgetry.
- */
- private void updateEnabledState() {
- fNames.setEnabled(fFilterOnNames.getSelection());
- fNamesHelpText.setEnabled(fFilterOnNames.getSelection());
- }
-
- /**
- * Updates the given filter from the UI state.
- */
- private void updateFilterFromUI() {
- int maxCallDepth = Integer.parseInt(this.fMaxCallDepth.getText());
-
- CallHierarchyUI.getDefault().setMaxCallDepth(maxCallDepth);
- CallHierarchy.getDefault().setFilters(fNames.getText());
- CallHierarchy.getDefault().setFilterEnabled(fFilterOnNames.getSelection());
- }
-
- /**
- * Updates the UI state from the given filter.
- */
- private void updateUIFromFilter() {
- fMaxCallDepth.setText(String.valueOf(CallHierarchyUI.getDefault().getMaxCallDepth()));
- fNames.setText(CallHierarchy.getDefault().getFilters());
- fFilterOnNames.setSelection(CallHierarchy.getDefault().isFilterEnabled());
- updateEnabledState();
- }
-
- /**
- * Updates the filter from the UI state.
- * Must be done here rather than by extending open()
- * because after super.open() is called, the widgetry is disposed.
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- if (!isMaxCallDepthValid()) {
- if (fMaxCallDepth.forceFocus()) {
- fMaxCallDepth.setSelection(0, fMaxCallDepth.getCharCount());
- fMaxCallDepth.showSelection();
- }
- }
-
- updateFilterFromUI();
- super.okPressed();
- }
-
- private boolean isMaxCallDepthValid() {
- String text= fMaxCallDepth.getText();
- if (text.length() == 0)
- return false;
-
- try {
- int maxCallDepth= Integer.parseInt(text);
-
- return (maxCallDepth >= 1 && maxCallDepth <= 99);
- } catch (NumberFormatException e) {
- return false;
- }
- }
-
- private void validateInput() {
- StatusInfo status= new StatusInfo();
- if (!isMaxCallDepthValid()) {
- status.setError(CallHierarchyMessages.FiltersDialog_messageMaxCallDepthInvalid);
- }
- updateStatus(status);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FocusOnSelectionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FocusOnSelectionAction.java
deleted file mode 100644
index 84873d3c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/FocusOnSelectionAction.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-
-class FocusOnSelectionAction extends Action {
- private CallHierarchyViewPart fPart;
-
- public FocusOnSelectionAction(CallHierarchyViewPart part) {
- super(CallHierarchyMessages.FocusOnSelectionAction_focusOnSelection_text);
- fPart= part;
- setDescription(CallHierarchyMessages.FocusOnSelectionAction_focusOnSelection_description);
- setToolTipText(CallHierarchyMessages.FocusOnSelectionAction_focusOnSelection_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_FOCUS_ON_SELECTION_ACTION);
- }
-
- public boolean canActionBeAdded() {
- Object element = SelectionUtil.getSingleElement(getSelection());
-
- IFunction method = getSelectedMethod(element);
-
- if (method != null) {
- setText(Messages.format(CallHierarchyMessages.FocusOnSelectionAction_focusOn_text, method.getElementName()));
-
- return true;
- }
-
- return false;
- }
-
- private IFunction getSelectedMethod(Object element) {
- IFunction method = null;
-
- if (element instanceof IFunction) {
- method= (IFunction) element;
- } else if (element instanceof MethodWrapper) {
- IMember member= ((MethodWrapper) element).getMember();
- if (member.getElementType() == IJavaScriptElement.METHOD) {
- method= (IFunction) member;
- }
- }
- return method;
- }
-
- /*
- * @see Action#run
- */
- public void run() {
- Object element = SelectionUtil.getSingleElement(getSelection());
-
- IFunction method= getSelectedMethod(element);
- if (method != null) {
- fPart.setMethod(method);
- }
- }
-
- private ISelection getSelection() {
- ISelectionProvider provider = fPart.getSite().getSelectionProvider();
-
- if (provider != null) {
- return provider.getSelection();
- }
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryAction.java
deleted file mode 100644
index a68a1958..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-/**
- * Action used for the type hierarchy forward / backward buttons
- */
-class HistoryAction extends Action {
- private static JavaScriptElementLabelProvider fLabelProvider = new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_POST_QUALIFIED |
- JavaScriptElementLabelProvider.SHOW_PARAMETERS |
- JavaScriptElementLabelProvider.SHOW_RETURN_TYPE);
- private CallHierarchyViewPart fView;
- private IFunction fMethod;
-
- public HistoryAction(CallHierarchyViewPart viewPart, IFunction element) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fView = viewPart;
- fMethod = element;
-
- String elementName = getElementLabel(element);
- setText(elementName);
- setImageDescriptor(getImageDescriptor(element));
-
- setDescription(Messages.format(CallHierarchyMessages.HistoryAction_description, elementName));
- setToolTipText(Messages.format(CallHierarchyMessages.HistoryAction_tooltip, elementName));
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_ACTION);
- }
-
- private ImageDescriptor getImageDescriptor(IJavaScriptElement elem) {
- JavaElementImageProvider imageProvider = new JavaElementImageProvider();
- ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0);
- imageProvider.dispose();
-
- return desc;
- }
-
- /*
- * @see Action#run()
- */
- public void run() {
- fView.gotoHistoryEntry(fMethod);
- }
-
- /**
- * @param element
- * @return String
- */
- private String getElementLabel(IJavaScriptElement element) {
- Assert.isNotNull(element);
- return fLabelProvider.getText(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryDropDownAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryDropDownAction.java
deleted file mode 100644
index cb995d91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryDropDownAction.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-
-class HistoryDropDownAction extends Action implements IMenuCreator {
-
- private static class ClearHistoryAction extends Action {
-
- private CallHierarchyViewPart fView;
-
- public ClearHistoryAction(CallHierarchyViewPart view) {
- super(CallHierarchyMessages.HistoryDropDownAction_clearhistory_label);
- fView= view;
- }
-
- public void run() {
- fView.setHistoryEntries(new IFunction[0]);
- fView.setMethod(null);
- }
- }
-
- public static final int RESULTS_IN_DROP_DOWN = 10;
- private CallHierarchyViewPart fView;
- private Menu fMenu;
-
- public HistoryDropDownAction(CallHierarchyViewPart view) {
- fView = view;
- fMenu = null;
- setToolTipText(CallHierarchyMessages.HistoryDropDownAction_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "history_list.gif"); //$NON-NLS-1$
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_DROP_DOWN_ACTION);
-
- setMenuCreator(this);
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu= new Menu(parent);
- IFunction[] elements= fView.getHistoryEntries();
- addEntries(fMenu, elements);
- new MenuItem(fMenu, SWT.SEPARATOR);
- addActionToMenu(fMenu, new HistoryListAction(fView));
- addActionToMenu(fMenu, new ClearHistoryAction(fView));
- return fMenu;
- }
-
- public void dispose() {
- fView = null;
-
- if (fMenu != null) {
- fMenu.dispose();
- fMenu = null;
- }
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item = new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- private boolean addEntries(Menu menu, IFunction[] elements) {
- boolean checked = false;
-
- int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN);
-
- for (int i = 0; i < min; i++) {
- HistoryAction action = new HistoryAction(fView, elements[i]);
- action.setChecked(elements[i].equals(fView.getMethod()));
- checked = checked || action.isChecked();
- addActionToMenu(menu, action);
- }
-
- return checked;
- }
-
- public void run() {
- (new HistoryListAction(fView)).run();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryListAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryListAction.java
deleted file mode 100644
index 44d25cc9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/HistoryListAction.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-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.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class HistoryListAction extends Action {
-
- private class HistoryListDialog extends StatusDialog {
-
- private ListDialogField fHistoryList;
- private IStatus fHistoryStatus;
- private IFunction fResult;
-
- private HistoryListDialog(Shell shell, IFunction[] elements) {
- super(shell);
- setTitle(CallHierarchyMessages.HistoryListDialog_title);
-
- String[] buttonLabels= new String[] {
- CallHierarchyMessages.HistoryListDialog_remove_button,
- };
-
- IListAdapter adapter= new IListAdapter() {
- public void customButtonPressed(ListDialogField field, int index) {
- doCustomButtonPressed();
- }
- public void selectionChanged(ListDialogField field) {
- doSelectionChanged();
- }
-
- public void doubleClicked(ListDialogField field) {
- doDoubleClicked();
- }
- };
-
- JavaScriptElementLabelProvider labelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_QUALIFIED | JavaScriptElementLabelProvider.SHOW_ROOT);
-
- fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(CallHierarchyMessages.HistoryListDialog_label);
- fHistoryList.setElements(Arrays.asList(elements));
-
- ISelection sel;
- if (elements.length > 0) {
- sel= new StructuredSelection(elements[0]);
- } else {
- sel= new StructuredSelection();
- }
-
- fHistoryList.selectElements(sel);
- }
-
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- inner.setFont(composite.getFont());
-
- LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
- LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
- LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null));
-
- applyDialogFont(composite);
- return composite;
- }
-
- /**
- * Method doCustomButtonPressed.
- */
- private void doCustomButtonPressed() {
- fHistoryList.removeElements(fHistoryList.getSelectedElements());
- }
-
- private void doDoubleClicked() {
- if (fHistoryStatus.isOK()) {
- okPressed();
- }
- }
-
-
- private void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List selected= fHistoryList.getSelectedElements();
- if (selected.size() != 1) {
- status.setError(""); //$NON-NLS-1$
- fResult= null;
- } else {
- fResult= (IFunction) selected.get(0);
- }
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
- }
-
- public IFunction getResult() {
- return fResult;
- }
-
- public IFunction[] getRemaining() {
- List elems= fHistoryList.getElements();
- return (IFunction[]) elems.toArray(new IFunction[elems.size()]);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.HISTORY_LIST_DIALOG);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#create()
- */
- public void create() {
- setShellStyle(getShellStyle() | SWT.RESIZE);
- super.create();
- }
-
- }
-
- private CallHierarchyViewPart fView;
-
- public HistoryListAction(CallHierarchyViewPart view) {
- fView= view;
- setText(CallHierarchyMessages.HistoryListAction_label);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.HISTORY_LIST_ACTION);
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- IFunction[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(JavaScriptPlugin.getActiveWorkbenchShell(), historyEntries);
- if (dialog.open() == Window.OK) {
- fView.setHistoryEntries(dialog.getRemaining());
- fView.setMethod(dialog.getResult());
- }
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java
deleted file mode 100644
index f4b7bff0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-/**
- * Marker interface for the call hierarchy view to be used outside.
- */
-public interface ICallHierarchyViewPart {
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationCopyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationCopyAction.java
deleted file mode 100644
index 0d57bc40..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationCopyAction.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallLocation;
-
-/**
- * Copies the selection from the location viewer.
- */
-class LocationCopyAction extends Action {
- private final Clipboard fClipboard;
- private final IViewSite fViewSite;
- private final LocationViewer fLocationViewer;
-
- LocationCopyAction(IViewSite viewSite, Clipboard clipboard, LocationViewer locationViewer) {
- fClipboard= clipboard;
- fViewSite= viewSite;
- fLocationViewer= locationViewer;
-
- setText(CallHierarchyMessages.LocationCopyAction_copy);
- setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
-
- locationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- setEnabled(! event.getSelection().isEmpty());
- }
- });
- }
-
- public void run() {
- IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
- StringBuffer buf= new StringBuffer();
- for (Iterator iterator= selection.iterator(); iterator.hasNext();) {
- CallLocation location= (CallLocation) iterator.next();
- buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
- buf.append('\n');
- }
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- try {
- fClipboard.setContents(
- new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
- new Transfer[]{ plainTextTransfer });
- } catch (SWTError e){
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw e;
- if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
- run();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationLabelProvider.java
deleted file mode 100644
index ded7b84f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationLabelProvider.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallLocation;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-class LocationLabelProvider extends LabelProvider implements ITableLabelProvider {
- private static final int COLUMN_ICON= 0;
- private static final int COLUMN_LINE= 1;
- private static final int COLUMN_INFO= 2;
-
- LocationLabelProvider() {
- // Do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return getColumnText(element, COLUMN_INFO);
- }
-
- public Image getImage(Object element) {
- return getColumnImage(element, COLUMN_ICON);
- }
-
- private String removeWhitespaceOutsideStringLiterals(CallLocation callLocation) {
- StringBuffer buf = new StringBuffer();
- boolean withinString = false;
-
- String s= callLocation.getCallText();
- for (int i = 0; i < s.length(); i++) {
- char ch = s.charAt(i);
-
- if (ch == '"') {
- withinString = !withinString;
- }
-
- if (withinString) {
- buf.append(ch);
- } else if (Character.isWhitespace(ch)) {
- if ((buf.length() == 0) ||
- !Character.isWhitespace(buf.charAt(buf.length() - 1))) {
- if (ch != ' ') {
- ch = ' ';
- }
-
- buf.append(ch);
- }
- } else {
- buf.append(ch);
- }
- }
-
- return buf.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == COLUMN_ICON) {
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof CallLocation) {
- CallLocation callLocation= (CallLocation) element;
-
- switch (columnIndex) {
- case COLUMN_LINE:
- int lineNumber= callLocation.getLineNumber();
- if (lineNumber == CallLocation.UNKNOWN_LINE_NUMBER) {
- return CallHierarchyMessages.LocationLabelProvider_unknown;
- } else {
- return String.valueOf(lineNumber);
- }
- case COLUMN_INFO:
- return removeWhitespaceOutsideStringLiterals(callLocation);
- }
- }
-
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationViewer.java
deleted file mode 100644
index f6660a37..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/LocationViewer.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.actions.ActionFactory;
-
-
-
-class LocationViewer extends TableViewer {
- private final String columnHeaders[] = {
- CallHierarchyMessages.LocationViewer_ColumnIcon_header,
- CallHierarchyMessages.LocationViewer_ColumnLine_header,
- CallHierarchyMessages.LocationViewer_ColumnInfo_header};
-
- private ColumnLayoutData columnLayouts[] = {
- new ColumnPixelData(18, false, true),
- new ColumnWeightData(60),
- new ColumnWeightData(300)};
-
-
- LocationViewer(Composite parent) {
- super(createTable(parent));
-
- setContentProvider(new ArrayContentProvider());
- setLabelProvider(new LocationLabelProvider());
- setInput(new ArrayList());
-
- createColumns();
- }
-
- /**
- * Creates the table control.
- */
- private static Table createTable(Composite parent) {
- return new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
- }
-
- private void createColumns() {
- TableLayout layout = new TableLayout();
- getTable().setLayout(layout);
- getTable().setHeaderVisible(true);
- for (int i = 0; i < columnHeaders.length; i++) {
- layout.addColumnData(columnLayouts[i]);
- TableColumn tc = new TableColumn(getTable(), SWT.NONE,i);
- tc.setResizable(columnLayouts[i].resizable);
- tc.setText(columnHeaders[i]);
- }
- }
-
- /**
- * Attaches a contextmenu listener to the tree
- */
- void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getControl());
- getControl().setMenu(menu);
- viewSite.registerContextMenu(popupId, menuMgr, this);
- }
-
- /**
- * Initializes and returns the Copy action for the location viewer.
- */
- LocationCopyAction initCopyAction(final IViewSite viewSite, final Clipboard clipboard) {
- final LocationCopyAction copyAction= new LocationCopyAction(viewSite, clipboard, this);
-
- getTable().addFocusListener(new FocusListener() {
- IAction fViewCopyHandler;
- public void focusLost(FocusEvent e) {
- if (fViewCopyHandler != null) {
- IActionBars actionBars= viewSite.getActionBars();
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fViewCopyHandler);
- actionBars.updateActionBars();
- fViewCopyHandler= null;
- }
- }
-
- public void focusGained(FocusEvent e) {
- IActionBars actionBars= viewSite.getActionBars();
- fViewCopyHandler= actionBars.getGlobalActionHandler(ActionFactory.COPY.getId());
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
- actionBars.updateActionBars();
- }
- });
-
- return copyAction;
- }
-
- /**
- *
- */
- void clearViewer() {
- setInput(""); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/MethodWrapperWorkbenchAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/MethodWrapperWorkbenchAdapter.java
deleted file mode 100644
index 2c2a90cb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/MethodWrapperWorkbenchAdapter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-
-public class MethodWrapperWorkbenchAdapter implements IWorkbenchAdapter {
-
- private final MethodWrapper fMethodWrapper;
-
- public MethodWrapperWorkbenchAdapter(MethodWrapper methodWrapper) {
- Assert.isNotNull(methodWrapper);
- fMethodWrapper= methodWrapper;
- }
-
- public MethodWrapper getMethodWrapper() {
- return fMethodWrapper;
- }
-
- public Object[] getChildren(Object o) { //should not be called
- return new Object[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- public String getLabel(Object o) {
- return fMethodWrapper.getMember().getElementName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object o) {
- return fMethodWrapper.getParent();
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- //Note: A MethodWrapperWorkbenchAdapter is equal to its MethodWrapper and vice versa (bug 101677).
- return fMethodWrapper.equals(obj);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- //Note: A MethodWrapperWorkbenchAdapter is equal to its MethodWrapper and vice versa (bug 101677).
- return fMethodWrapper.hashCode();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
deleted file mode 100644
index e072511b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-/**
- * This action opens a call hierarchy on the selected method.
- * <p>
- * The action is applicable to selections containing elements of type
- * <code>IFunction</code>.
- */
-public class OpenCallHierarchyAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- /**
- * Creates a new <code>OpenCallHierarchyAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- */
- public OpenCallHierarchyAction(IWorkbenchSite site) {
- super(site);
- setText(CallHierarchyMessages.OpenCallHierarchyAction_label);
- setToolTipText(CallHierarchyMessages.OpenCallHierarchyAction_tooltip);
- setDescription(CallHierarchyMessages.OpenCallHierarchyAction_description);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_OPEN_ACTION);
-
- }
-
- /**
- * Creates a new <code>OpenCallHierarchyAction</code>. The action requires
- * that the selection provided by the given selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- * @param provider a special selection provider which is used instead
- * of the site's selection provider or <code>null</code> to use the site's
- * selection provider
- *
- *
- * @deprecated Use {@link #setSpecialSelectionProvider(ISelectionProvider)} instead. This API will be
- * removed after 3.2 M5.
- */
- public OpenCallHierarchyAction(IWorkbenchSite site, ISelectionProvider provider) {
- this(site);
- setSpecialSelectionProvider(provider);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- */
- public OpenCallHierarchyAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(ITextSelection selection) {
- // Do nothing
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(isEnabled(selection));
- }
-
- private boolean isEnabled(IStructuredSelection selection) {
- if (selection.size() != 1)
- return false;
- Object input= selection.getFirstElement();
- if (!(input instanceof IJavaScriptElement))
- return false;
- switch (((IJavaScriptElement)input).getElementType()) {
- case IJavaScriptElement.METHOD:
- return true;
- default:
- return false;
- }
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(ITextSelection selection) {
- IJavaScriptElement input= SelectionConverter.getInput(fEditor);
- if (!ActionUtil.isProcessable(getShell(), input))
- return;
-
- try {
- IJavaScriptElement[] elements= SelectionConverter.codeResolveOrInputForked(fEditor);
- if (elements == null)
- return;
- List candidates= new ArrayList(elements.length);
- for (int i= 0; i < elements.length; i++) {
- IJavaScriptElement[] resolvedElements= CallHierarchyUI.getCandidates(elements[i]);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
- }
- if (candidates.isEmpty()) {
- IJavaScriptElement enclosingMethod= getEnclosingMethod(input, selection);
- if (enclosingMethod != null) {
- candidates.add(enclosingMethod);
- }
- }
- run((IJavaScriptElement[])candidates.toArray(new IJavaScriptElement[candidates.size()]));
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), getErrorDialogTitle(), ActionMessages.SelectionConverter_codeResolve_failed);
- } catch (InterruptedException e) {
- // cancelled
- }
- }
-
- private IJavaScriptElement getEnclosingMethod(IJavaScriptElement input, ITextSelection selection) {
- IJavaScriptElement enclosingElement= null;
- try {
- switch (input.getElementType()) {
- case IJavaScriptElement.CLASS_FILE :
- IClassFile classFile= (IClassFile) input.getAncestor(IJavaScriptElement.CLASS_FILE);
- if (classFile != null) {
- enclosingElement= classFile.getElementAt(selection.getOffset());
- }
- break;
- case IJavaScriptElement.JAVASCRIPT_UNIT :
- IJavaScriptUnit cu= (IJavaScriptUnit) input.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- enclosingElement= cu.getElementAt(selection.getOffset());
- }
- break;
- }
- if (enclosingElement != null && enclosingElement.getElementType() == IJavaScriptElement.METHOD) {
- return enclosingElement;
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(IStructuredSelection selection) {
- if (selection.size() != 1)
- return;
- Object input= selection.getFirstElement();
-
- if (!(input instanceof IJavaScriptElement)) {
- IStatus status= createStatus(CallHierarchyMessages.OpenCallHierarchyAction_messages_no_java_element);
- openErrorDialog(status);
- return;
- }
- IJavaScriptElement element= (IJavaScriptElement) input;
- if (!ActionUtil.isProcessable(getShell(), element))
- return;
-
- List result= new ArrayList(1);
- IStatus status= compileCandidates(result, element);
- if (status.isOK()) {
- run((IJavaScriptElement[]) result.toArray(new IJavaScriptElement[result.size()]));
- } else {
- openErrorDialog(status);
- }
- }
-
- private int openErrorDialog(IStatus status) {
- String message= CallHierarchyMessages.OpenCallHierarchyAction_messages_title;
- String dialogTitle= getErrorDialogTitle();
- return ErrorDialog.openError(getShell(), dialogTitle, message, status);
- }
-
- private static String getErrorDialogTitle() {
- return CallHierarchyMessages.OpenCallHierarchyAction_dialog_title;
- }
-
- public void run(IJavaScriptElement[] elements) {
- if (elements.length == 0) {
- getShell().getDisplay().beep();
- return;
- }
- CallHierarchyUI.open(elements, getSite().getWorkbenchWindow());
- }
-
- private static IStatus compileCandidates(List result, IJavaScriptElement elem) {
- IStatus ok= new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
- switch (elem.getElementType()) {
- case IJavaScriptElement.METHOD:
- result.add(elem);
- return ok;
- }
- return createStatus(CallHierarchyMessages.OpenCallHierarchyAction_messages_no_valid_java_element);
- }
-
- private static IStatus createStatus(String message) {
- return new Status(IStatus.INFO, JavaScriptPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenDeclarationAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenDeclarationAction.java
deleted file mode 100644
index b93a94f6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenDeclarationAction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-import org.eclipse.wst.jsdt.ui.actions.OpenAction;
-
-/**
- * This class is used for opening the declaration of an element from the call hierarchy view.
- */
-class OpenDeclarationAction extends OpenAction {
- public OpenDeclarationAction(IWorkbenchSite site) {
- super(site);
- }
-
- public boolean canActionBeAdded() {
- // It is safe to cast to IMember since the selection has already been converted
- IMember member = (IMember) SelectionUtil.getSingleElement(getSelection());
-
- if (member != null) {
- return true;
- }
-
- return false;
- }
-
- public ISelection getSelection() {
- return CallHierarchyUI.convertSelection(getSelectionProvider().getSelection());
- }
-
- public Object getElementToOpen(Object object) {
- if (object instanceof MethodWrapper) {
- return ((MethodWrapper) object).getMember();
- }
- return object;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenLocationAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenLocationAction.java
deleted file mode 100644
index 11d5c28c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/OpenLocationAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.CallLocation;
-import org.eclipse.wst.jsdt.internal.corext.callhierarchy.MethodWrapper;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-class OpenLocationAction extends SelectionDispatchAction {
- private CallHierarchyViewPart fPart;
-
- public OpenLocationAction(CallHierarchyViewPart part, IWorkbenchSite site) {
- super(site);
- fPart= part;
- setText(CallHierarchyMessages.OpenLocationAction_label);
- setToolTipText(CallHierarchyMessages.OpenLocationAction_tooltip);
- }
-
- private boolean checkEnabled(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- return false;
- }
-
- for (Iterator iter = selection.iterator(); iter.hasNext();) {
- Object element = iter.next();
-
- if (element instanceof MethodWrapper) {
- continue;
- } else if (element instanceof CallLocation) {
- continue;
- }
-
- return false;
- }
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#getSelection()
- */
- public ISelection getSelection() {
- return fPart.getSelection();
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(IStructuredSelection selection) {
- if (!checkEnabled(selection)) {
- return;
- }
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- boolean noError= CallHierarchyUI.openInEditor(iter.next(), getShell(), getDialogTitle());
- if (! noError)
- return;
- }
- }
-
- private String getDialogTitle() {
- return CallHierarchyMessages.OpenLocationAction_error_title;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/RefreshAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/RefreshAction.java
deleted file mode 100644
index 728129d6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/RefreshAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-class RefreshAction extends Action {
- private CallHierarchyViewPart fPart;
-
- public RefreshAction(CallHierarchyViewPart part) {
- fPart= part;
- setText(CallHierarchyMessages.RefreshAction_text);
- setToolTipText(CallHierarchyMessages.RefreshAction_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "refresh_nav.gif");//$NON-NLS-1$
- setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_REFRESH_ACTION);
- }
-
- /**
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- fPart.refresh();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeAction.java
deleted file mode 100644
index b3fa2312..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-
-
-abstract class SearchScopeAction extends Action {
- private final SearchScopeActionGroup fGroup;
-
- public SearchScopeAction(SearchScopeActionGroup group, String text) {
- super(text, AS_RADIO_BUTTON);
- this.fGroup = group;
- }
-
- public abstract IJavaScriptSearchScope getSearchScope();
-
- public abstract int getSearchScopeType();
-
- public void run() {
- this.fGroup.setSelected(this, true);
- }
-
- public abstract String getFullDescription();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
deleted file mode 100644
index aae31fc0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jface.action.Action;
-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.dialogs.IDialogSettings;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-
-class SearchScopeActionGroup extends ActionGroup {
- private static final String TAG_SEARCH_SCOPE_TYPE= "search_scope_type"; //$NON-NLS-1$
- private static final String TAG_SELECTED_WORKING_SET= "working_set"; //$NON-NLS-1$
- private static final String TAG_WORKING_SET_COUNT = "working_set_count"; //$NON-NLS-1$
-
- private static final String DIALOGSTORE_SCOPE_TYPE= "SearchScopeActionGroup.search_scope_type"; //$NON-NLS-1$
- private static final String DIALOGSTORE_SELECTED_WORKING_SET= "SearchScopeActionGroup.working_set"; //$NON-NLS-1$
-
- static final int SEARCH_SCOPE_TYPE_WORKSPACE= 1;
- static final int SEARCH_SCOPE_TYPE_PROJECT= 2;
- static final int SEARCH_SCOPE_TYPE_HIERARCHY= 3;
- static final int SEARCH_SCOPE_TYPE_WORKING_SET= 4;
-
- private SearchScopeAction fSelectedAction = null;
- private String[] fSelectedWorkingSetNames = null;
- private CallHierarchyViewPart fView;
- private IDialogSettings fDialogSettings;
- private SearchScopeHierarchyAction fSearchScopeHierarchyAction;
- private SearchScopeProjectAction fSearchScopeProjectAction;
- private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction;
- private SelectWorkingSetAction fSelectWorkingSetAction;
-
- public SearchScopeActionGroup(CallHierarchyViewPart view, IDialogSettings dialogSettings) {
- this.fView= view;
- this.fDialogSettings= dialogSettings;
- createActions();
- }
-
- /**
- * @return IJavaScriptSearchScope
- */
- public IJavaScriptSearchScope getSearchScope() {
- if (fSelectedAction != null) {
- return fSelectedAction.getSearchScope();
- }
-
- return null;
- }
-
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- fillContextMenu(actionBars.getMenuManager());
- }
-
- protected void setActiveWorkingSets(IWorkingSet[] sets) {
- if (sets != null) {
- fSelectedWorkingSetNames = getWorkingSetNames(sets);
- fSelectedAction = new SearchScopeWorkingSetAction(this, sets, getScopeDescription(sets));
- } else {
- fSelectedWorkingSetNames = null;
- fSelectedAction = null;
- }
- }
-
- private String[] getWorkingSetNames(IWorkingSet[] sets) {
- String[] result= new String[sets.length];
- for (int i = 0; i < sets.length; i++) {
- result[i]= sets[i].getName();
- }
- return result;
- }
-
- protected IWorkingSet[] getActiveWorkingSets() {
- if (fSelectedWorkingSetNames != null) {
- return getWorkingSets(fSelectedWorkingSetNames);
- }
-
- return null;
- }
-
- private IWorkingSet[] getWorkingSets(String[] workingSetNames) {
- if (workingSetNames == null) {
- return null;
- }
- Set workingSets= new HashSet(2);
- for (int j= 0; j < workingSetNames.length; j++) {
- IWorkingSet workingSet= getWorkingSetManager().getWorkingSet(workingSetNames[j]);
- if (workingSet != null) {
- workingSets.add(workingSet);
- }
- }
-
- return (IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]);
- }
-
- /**
- * Sets the new search scope type.
- *
- * @param newSelection New action which should be the checked one
- * @param ignoreUnchecked Ignores actions which are unchecked (necessary since both the old and the new action fires).
- */
- protected void setSelected(SearchScopeAction newSelection, boolean ignoreUnchecked) {
- if (!ignoreUnchecked || newSelection.isChecked()) {
- if (newSelection instanceof SearchScopeWorkingSetAction) {
- fSelectedWorkingSetNames = getWorkingSetNames(((SearchScopeWorkingSetAction) newSelection).getWorkingSets());
- } else {
- fSelectedWorkingSetNames = null;
- }
-
- if (newSelection != null) {
- fSelectedAction= newSelection;
- } else {
- fSelectedAction= fSearchScopeWorkspaceAction;
- }
-
- fDialogSettings.put(DIALOGSTORE_SCOPE_TYPE, getSearchScopeType());
- fDialogSettings.put(DIALOGSTORE_SELECTED_WORKING_SET, fSelectedWorkingSetNames);
- }
- }
-
- protected CallHierarchyViewPart getView() {
- return fView;
- }
-
- protected IWorkingSetManager getWorkingSetManager() {
- IWorkingSetManager workingSetManager = PlatformUI.getWorkbench()
- .getWorkingSetManager();
-
- return workingSetManager;
- }
-
- protected void fillSearchActions(IMenuManager javaSearchMM) {
- Action[] actions = getActions();
-
- for (int i = 0; i < actions.length; i++) {
- Action action = actions[i];
-
- if (action.isEnabled()) {
- javaSearchMM.add(action);
- }
- }
-
- javaSearchMM.setVisible(!javaSearchMM.isEmpty());
- }
-
- public void fillContextMenu(IMenuManager menu) {
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
-
- MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.SearchScopeActionGroup_searchScope,
- IContextMenuConstants.GROUP_SEARCH);
- javaSearchMM.setRemoveAllWhenShown(true);
-
- javaSearchMM.addMenuListener(new IMenuListener() {
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager) {
- fillSearchActions(manager);
- }
- });
-
- fillSearchActions(javaSearchMM);
- menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM);
- }
-
- private Action[] getActions() {
- List actions = new ArrayList(SearchUtil.LRU_WORKINGSET_LIST_SIZE + 4);
- addAction(actions, fSearchScopeWorkspaceAction);
- addAction(actions, fSearchScopeProjectAction);
- addAction(actions, fSearchScopeHierarchyAction);
- addAction(actions, fSelectWorkingSetAction);
-
- Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
- while (iter.hasNext()) {
- IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
- String description = SearchUtil.toString(workingSets);
- SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(this, workingSets, description);
-
- if (isSelectedWorkingSet(workingSets)) {
- workingSetAction.setChecked(true);
- }
-
- actions.add(workingSetAction);
- }
-
- Action[] result = (Action[]) actions.toArray(new Action[actions.size()]);
-
- ensureExactlyOneCheckedAction(result);
- return result;
- }
-
- private void ensureExactlyOneCheckedAction(Action[] result) {
- int checked = getCheckedActionCount(result);
- if (checked != 1) {
- if (checked > 1) {
- for (int i = 0; i < result.length; i++) {
- Action action = result[i];
- action.setChecked(false);
- }
- }
- fSearchScopeWorkspaceAction.setChecked(true);
- }
- }
-
- private int getCheckedActionCount(Action[] result) {
- // Ensure that exactly one action is selected
- int checked= 0;
- for (int i = 0; i < result.length; i++) {
- Action action = result[i];
- if (action.isChecked()) {
- checked++;
- }
- }
- return checked;
- }
-
- private void addAction(List actions, Action action) {
- if (action == fSelectedAction) {
- action.setChecked(true);
- } else {
- action.setChecked(false);
- }
-
- actions.add(action);
- }
-
- private void createActions() {
- fSearchScopeWorkspaceAction = new SearchScopeWorkspaceAction(this);
- fSelectWorkingSetAction = new SelectWorkingSetAction(this);
- fSearchScopeHierarchyAction = new SearchScopeHierarchyAction(this);
- fSearchScopeProjectAction = new SearchScopeProjectAction(this);
-
- int searchScopeType;
- try {
- searchScopeType= fDialogSettings.getInt(DIALOGSTORE_SCOPE_TYPE);
- } catch (NumberFormatException e) {
- searchScopeType= SEARCH_SCOPE_TYPE_WORKSPACE;
- }
- String[] workingSetNames= fDialogSettings.getArray(DIALOGSTORE_SELECTED_WORKING_SET);
- setSelected(getSearchScopeAction(searchScopeType, workingSetNames), false);
- }
-
- public void saveState(IMemento memento) {
- int type= getSearchScopeType();
- memento.putInteger(TAG_SEARCH_SCOPE_TYPE, type);
- if (type == SEARCH_SCOPE_TYPE_WORKING_SET) {
- memento.putInteger(TAG_WORKING_SET_COUNT, fSelectedWorkingSetNames.length);
- for (int i = 0; i < fSelectedWorkingSetNames.length; i++) {
- String workingSetName = fSelectedWorkingSetNames[i];
- memento.putString(TAG_SELECTED_WORKING_SET+i, workingSetName);
- }
- }
- }
-
- public void restoreState(IMemento memento) {
- String[] workingSetNames= null;
- Integer scopeType= memento.getInteger(TAG_SEARCH_SCOPE_TYPE);
- if (scopeType != null) {
- if (scopeType.intValue() == SEARCH_SCOPE_TYPE_WORKING_SET) {
- Integer workingSetCount= memento.getInteger(TAG_WORKING_SET_COUNT);
- if (workingSetCount != null) {
- workingSetNames = new String[workingSetCount.intValue()];
- for (int i = 0; i < workingSetCount.intValue(); i++) {
- workingSetNames[i]= memento.getString(TAG_SELECTED_WORKING_SET+i);
- }
- }
- }
- setSelected(getSearchScopeAction(scopeType.intValue(), workingSetNames), false);
- }
- }
-
- private SearchScopeAction getSearchScopeAction(int searchScopeType, String[] workingSetNames) {
- switch (searchScopeType) {
- case SEARCH_SCOPE_TYPE_WORKSPACE:
- return fSearchScopeWorkspaceAction;
- case SEARCH_SCOPE_TYPE_PROJECT:
- return fSearchScopeProjectAction;
- case SEARCH_SCOPE_TYPE_HIERARCHY:
- return fSearchScopeHierarchyAction;
- case SEARCH_SCOPE_TYPE_WORKING_SET:
- IWorkingSet[] workingSets= getWorkingSets(workingSetNames);
- if (workingSets != null && workingSets.length > 0) {
- return new SearchScopeWorkingSetAction(this, workingSets, getScopeDescription(workingSets));
- }
- return null;
- }
- return null;
- }
-
- private int getSearchScopeType() {
- if (fSelectedAction != null) {
- return fSelectedAction.getSearchScopeType();
- }
- return 0;
- }
-
- private String getScopeDescription(IWorkingSet[] workingSets) {
- return Messages.format(CallHierarchyMessages.WorkingSetScope, new String[] {SearchUtil.toString(workingSets)});
- }
-
- /**
- * Determines whether the specified working sets correspond to the currently selected working sets.
- * @param workingSets
- * @return Returns true if the specified working sets correspond to the currently selected working sets
- */
- private boolean isSelectedWorkingSet(IWorkingSet[] workingSets) {
- if (fSelectedWorkingSetNames != null && fSelectedWorkingSetNames.length == workingSets.length) {
- Set workingSetNames= new HashSet(workingSets.length);
- for (int i = 0; i < workingSets.length; i++) {
- workingSetNames.add(workingSets[i].getName());
- }
- for (int i = 0; i < fSelectedWorkingSetNames.length; i++) {
- if (!workingSetNames.contains(fSelectedWorkingSetNames[i])) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- public String getFullDescription() {
- if (fSelectedAction != null)
- return fSelectedAction.getFullDescription();
- return null;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
deleted file mode 100644
index 4130eda6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-
-
-class SearchScopeHierarchyAction extends SearchScopeAction {
- private final SearchScopeActionGroup fGroup;
-
- public SearchScopeHierarchyAction(SearchScopeActionGroup group) {
- super(group, CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
- this.fGroup = group;
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- try {
- IFunction method = this.fGroup.getView().getMethod();
-
- if (method != null) {
- return SearchEngine.createHierarchyScope(method.getDeclaringType());
- } else {
- return null;
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
- */
- public int getSearchScopeType() {
- return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_HIERARCHY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeAction#getFullDescription()
- */
- public String getFullDescription() {
- IFunction method = this.fGroup.getView().getMethod();
- return JavaSearchScopeFactory.getInstance().getHierarchyScopeDescription(method.getDeclaringType());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeProjectAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeProjectAction.java
deleted file mode 100644
index 25bdc72d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeProjectAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-
-
-class SearchScopeProjectAction extends SearchScopeAction {
- private final SearchScopeActionGroup fGroup;
-
- public SearchScopeProjectAction(SearchScopeActionGroup group) {
- super(group, CallHierarchyMessages.SearchScopeActionGroup_project_text);
- this.fGroup = group;
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_project_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- IFunction method = this.fGroup.getView().getMethod();
- if (method == null) {
- return null;
- }
-
- JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
- return factory.createJavaProjectSearchScope(method.getJavaScriptProject(), true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
- */
- public int getSearchScopeType() {
- return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_PROJECT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeAction#getFullDescription()
- */
- public String getFullDescription() {
- IFunction method = this.fGroup.getView().getMethod();
- if (method != null) {
- JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
- return factory.getProjectScopeDescription(method.getJavaScriptProject(), true);
- }
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java
deleted file mode 100644
index 334b2ad2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-
-
-class SearchScopeWorkingSetAction extends SearchScopeAction {
- private IWorkingSet[] fWorkingSets;
-
- public SearchScopeWorkingSetAction(SearchScopeActionGroup group, IWorkingSet[] workingSets, String name) {
- super(group, name);
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_workingset_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
-
- this.fWorkingSets = workingSets;
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- return JavaSearchScopeFactory.getInstance().createJavaSearchScope(fWorkingSets, true);
- }
-
- /**
- *
- */
- public IWorkingSet[] getWorkingSets() {
- return fWorkingSets;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
- */
- public int getSearchScopeType() {
- return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_WORKING_SET;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeAction#getFullDescription()
- */
- public String getFullDescription() {
- return JavaSearchScopeFactory.getInstance().getWorkingSetScopeDescription(fWorkingSets, true);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java
deleted file mode 100644
index 97db3004..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- * Michael Fraenkel (fraenkel@us.ibm.com) - patch
- * (report 60714: Call Hierarchy: display search scope in view title)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-
-
-class SearchScopeWorkspaceAction extends SearchScopeAction {
- public SearchScopeWorkspaceAction(SearchScopeActionGroup group) {
- super(group, CallHierarchyMessages.SearchScopeActionGroup_workspace_text);
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_workspace_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- return SearchEngine.createWorkspaceScope();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
- */
- public int getSearchScopeType() {
- return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_WORKSPACE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.callhierarchy.SearchScopeAction#getFullDescription()
- */
- public String getFullDescription() {
- JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
- return factory.getWorkspaceScopeDescription(true);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchUtil.java
deleted file mode 100644
index 44d020e6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SearchUtil.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.search.LRUWorkingSetsList;
-import org.eclipse.wst.jsdt.internal.ui.search.WorkingSetComparator;
-
-public class SearchUtil {
-
- // LRU working sets
- public static int LRU_WORKINGSET_LIST_SIZE= 3;
- private static LRUWorkingSetsList fgLRUWorkingSets;
- // Settings store
- private static final String DIALOG_SETTINGS_KEY= "CallHierarchySearchScope"; //$NON-NLS-1$
- private static final String STORE_LRU_WORKING_SET_NAMES= "lastUsedWorkingSetNames"; //$NON-NLS-1$
- private static IDialogSettings fgSettingsStore;
-
- /**
- * Updates the LRU list of working sets.
- *
- * @param workingSets the workings sets to be added to the LRU list
- */
- public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
- if (workingSets == null || workingSets.length < 1)
- return;
-
- SearchUtil.getLRUWorkingSets().add(workingSets);
- SearchUtil.saveState();
- }
-
- private static void saveState() {
- IWorkingSet[] workingSets;
- Iterator iter= SearchUtil.fgLRUWorkingSets.iterator();
- int i= 0;
- while (iter.hasNext()) {
- workingSets= (IWorkingSet[])iter.next();
- String[] names= new String[workingSets.length];
- for (int j= 0; j < workingSets.length; j++)
- names[j]= workingSets[j].getName();
- SearchUtil.fgSettingsStore.put(SearchUtil.STORE_LRU_WORKING_SET_NAMES + i, names);
- i++;
- }
- }
-
- public static LRUWorkingSetsList getLRUWorkingSets() {
- if (SearchUtil.fgLRUWorkingSets == null) {
- restoreState();
- }
- return SearchUtil.fgLRUWorkingSets;
- }
-
- static void restoreState() {
- SearchUtil.fgLRUWorkingSets= new LRUWorkingSetsList(SearchUtil.LRU_WORKINGSET_LIST_SIZE);
- SearchUtil.fgSettingsStore= JavaScriptPlugin.getDefault().getDialogSettings().getSection(SearchUtil.DIALOG_SETTINGS_KEY);
- if (SearchUtil.fgSettingsStore == null)
- SearchUtil.fgSettingsStore= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(SearchUtil.DIALOG_SETTINGS_KEY);
-
- boolean foundLRU= false;
- for (int i= SearchUtil.LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) {
- String[] lruWorkingSetNames= SearchUtil.fgSettingsStore.getArray(SearchUtil.STORE_LRU_WORKING_SET_NAMES + i);
- if (lruWorkingSetNames != null) {
- Set workingSets= new HashSet(2);
- for (int j= 0; j < lruWorkingSetNames.length; j++) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[j]);
- if (workingSet != null) {
- workingSets.add(workingSet);
- }
- }
- foundLRU= true;
- if (!workingSets.isEmpty())
- SearchUtil.fgLRUWorkingSets.add((IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]));
- }
- }
- if (!foundLRU)
- // try old preference format
- restoreFromOldFormat();
- }
-
- private static void restoreFromOldFormat() {
- SearchUtil.fgLRUWorkingSets= new LRUWorkingSetsList(SearchUtil.LRU_WORKINGSET_LIST_SIZE);
- SearchUtil.fgSettingsStore= JavaScriptPlugin.getDefault().getDialogSettings().getSection(SearchUtil.DIALOG_SETTINGS_KEY);
- if (SearchUtil.fgSettingsStore == null)
- SearchUtil.fgSettingsStore= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(SearchUtil.DIALOG_SETTINGS_KEY);
-
- boolean foundLRU= false;
- String[] lruWorkingSetNames= SearchUtil.fgSettingsStore.getArray(SearchUtil.STORE_LRU_WORKING_SET_NAMES);
- if (lruWorkingSetNames != null) {
- for (int i= lruWorkingSetNames.length - 1; i >= 0; i--) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[i]);
- if (workingSet != null) {
- foundLRU= true;
- SearchUtil.fgLRUWorkingSets.add(new IWorkingSet[]{workingSet});
- }
- }
- }
- if (foundLRU)
- // save in new format
- saveState();
- }
-
- public static String toString(IWorkingSet[] workingSets) {
- Arrays.sort(workingSets, new WorkingSetComparator());
- String result= ""; //$NON-NLS-1$
- if (workingSets != null && workingSets.length > 0) {
- boolean firstFound= false;
- for (int i= 0; i < workingSets.length; i++) {
- String workingSetName= workingSets[i].getLabel();
- if (firstFound)
- result= Messages.format(CallHierarchyMessages.SearchUtil_workingSetConcatenation, new String[] {result, workingSetName});
- else {
- result= workingSetName;
- firstFound= true;
- }
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SelectWorkingSetAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SelectWorkingSetAction.java
deleted file mode 100644
index aa6b1061..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/SelectWorkingSetAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-class SelectWorkingSetAction extends Action {
- private final SearchScopeActionGroup fGroup;
-
- public SelectWorkingSetAction(SearchScopeActionGroup group) {
- super(CallHierarchyMessages.SearchScopeActionGroup_workingset_select_text);
- this.fGroup = group;
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_workingset_select_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- try {
- IWorkingSet[] workingSets;
- workingSets = JavaSearchScopeFactory.getInstance().queryWorkingSets();
- if (workingSets != null) {
- this.fGroup.setActiveWorkingSets(workingSets);
- SearchUtil.updateLRUWorkingSets(workingSets);
- } else {
- this.fGroup.setActiveWorkingSets(null);
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, JavaScriptPlugin.getActiveWorkbenchShell(),
- CallHierarchyMessages.SelectWorkingSetAction_error_title,
- CallHierarchyMessages.SelectWorkingSetAction_error_message);
- } catch (InterruptedException e) {
- // cancel pressed
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleCallModeAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleCallModeAction.java
deleted file mode 100644
index 7c9ffd50..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleCallModeAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Toggles the call direction of the call hierarchy (i.e. toggles between showing callers and callees.)
- */
-class ToggleCallModeAction extends Action {
-
- private CallHierarchyViewPart fView;
- private int fMode;
-
- public ToggleCallModeAction(CallHierarchyViewPart v, int mode) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- if (mode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
- setText(CallHierarchyMessages.ToggleCallModeAction_callers_label);
- setDescription(CallHierarchyMessages.ToggleCallModeAction_callers_description);
- setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callers_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "ch_callers.gif"); //$NON-NLS-1$
- } else if (mode == CallHierarchyViewPart.CALL_MODE_CALLEES) {
- setText(CallHierarchyMessages.ToggleCallModeAction_callees_label);
- setDescription(CallHierarchyMessages.ToggleCallModeAction_callees_description);
- setToolTipText(CallHierarchyMessages.ToggleCallModeAction_callees_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "ch_callees.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
- fView= v;
- fMode= mode;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
- }
-
- public int getMode() {
- return fMode;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- fView.setCallMode(fMode); // will toggle the checked state
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleOrientationAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleOrientationAction.java
deleted file mode 100644
index 43ee5083..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/ToggleOrientationAction.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Toggles the orientationof the layout of the call hierarchy
- */
-class ToggleOrientationAction extends Action {
-
- private CallHierarchyViewPart fView;
- private int fActionOrientation;
-
- public ToggleOrientationAction(CallHierarchyViewPart v, int orientation) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) {
- setText(CallHierarchyMessages.ToggleOrientationAction_horizontal_label);
- setDescription(CallHierarchyMessages.ToggleOrientationAction_horizontal_description);
- setToolTipText(CallHierarchyMessages.ToggleOrientationAction_horizontal_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$
- } else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) {
- setText(CallHierarchyMessages.ToggleOrientationAction_vertical_label);
- setDescription(CallHierarchyMessages.ToggleOrientationAction_vertical_description);
- setToolTipText(CallHierarchyMessages.ToggleOrientationAction_vertical_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$
- } else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
- setText(CallHierarchyMessages.ToggleOrientationAction_automatic_label);
- setDescription(CallHierarchyMessages.ToggleOrientationAction_automatic_description);
- setToolTipText(CallHierarchyMessages.ToggleOrientationAction_automatic_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "th_automatic.gif"); //$NON-NLS-1$
- } else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
- setText(CallHierarchyMessages.ToggleOrientationAction_single_label);
- setDescription(CallHierarchyMessages.ToggleOrientationAction_single_description);
- setToolTipText(CallHierarchyMessages.ToggleOrientationAction_single_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
- fView= v;
- fActionOrientation= orientation;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_ORIENTATION_ACTION);
- }
-
- public int getOrientation() {
- return fActionOrientation;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- if (isChecked()) {
- fView.fOrientation= fActionOrientation;
- fView.computeOrientation();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeRoot.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeRoot.java
deleted file mode 100644
index 7daa0f08..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeRoot.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-public class TreeRoot {
- public static final Object EMPTY_ROOT = new Object();
- private Object fRoot;
-
- /**
- * Constructor for TreeRoot.
- */
- public TreeRoot(Object root) {
- this.fRoot = root;
- }
-
- Object getRoot() {
- return fRoot;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeTermination.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeTermination.java
deleted file mode 100644
index 1e77217a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/callhierarchy/TreeTermination.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * (report 36180: Callers/Callees view)
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.callhierarchy;
-
-
-final class TreeTermination {
- public static final Object SEARCH_CANCELED = new Object();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/JavaElementReferenceConverter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/JavaElementReferenceConverter.java
deleted file mode 100644
index e6f8190c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/JavaElementReferenceConverter.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.commands;
-
-import org.eclipse.core.commands.AbstractParameterValueConverter;
-import org.eclipse.core.commands.ParameterValueConversionException;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-/**
- * A command parameter value converter to convert between Java elements and
- * String references that identify them.
- * <p>
- * References can be made to Java types, methods and fields. The reference
- * identifies the project to use as a search scope as well as the java element
- * information. Note that non-source elements may be referenced (such as
- * java.lang.Object), but they must be resolved within the scope of some
- * project.
- * </p>
- * <p>
- * References take the form:
- *
- * <pre>
- * elementRef := typeRef | fieldRef | methodRef
- * typeRef := projectName '/' fullyQualifiedTypeName
- * fieldRef := typeRef '#' fieldName
- * methodRef := typeRef '#' methodName '(' parameterSignatures ')'
- * </pre>
- *
- * where <code>parameterSignatures</code> uses the signature format documented
- * in the {@link org.eclipse.wst.jsdt.core.Signature Signature} class.
- * </p>
- *
- *
- */
-public class JavaElementReferenceConverter extends AbstractParameterValueConverter {
-
- private static final char PROJECT_END_CHAR= '/';
-
- private static final char TYPE_END_CHAR= '#';
-
- private static final char PARAM_START_CHAR= Signature.C_PARAM_START;
-
- private static final char PARAM_END_CHAR= Signature.C_PARAM_END;
-
- public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
-
- assertWellFormed(parameterValue != null);
-
- final int projectEndPosition= parameterValue.indexOf(PROJECT_END_CHAR);
- assertWellFormed(projectEndPosition != -1);
-
- String projectName= parameterValue.substring(0, projectEndPosition);
- String javaElementRef= parameterValue.substring(projectEndPosition + 1);
-
- IJavaScriptModel javaModel= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- assertExists(javaModel);
-
- IJavaScriptProject javaProject= javaModel.getJavaScriptProject(projectName);
- assertExists(javaProject);
-
- final int typeEndPosition= javaElementRef.indexOf(TYPE_END_CHAR);
- String typeName;
- if (typeEndPosition == -1) {
- typeName= javaElementRef;
- } else {
- typeName= javaElementRef.substring(0, typeEndPosition);
- }
-
- if (Util.isJavaLikeFileName(typeName))
- {
- ITypeRoot typeRoot=null;
- try {
- typeRoot=javaProject.findTypeRoot(typeName);
- } catch (JavaScriptModelException e) { }
- assertExists(typeRoot);
- if (typeEndPosition == -1) {
- return typeRoot;
- }
- String memberRef= javaElementRef.substring(typeEndPosition + 1);
-
- final int paramStartPosition= memberRef.indexOf(PARAM_START_CHAR);
- if (paramStartPosition == -1) {
- IField field= typeRoot.getField(memberRef);
- assertExists(field);
- return field;
- }
- String methodName= memberRef.substring(0, paramStartPosition);
- String signature= memberRef.substring(paramStartPosition);
- String[] parameterTypes= null;
- try {
- parameterTypes= Signature.getParameterTypes(signature);
- } catch (IllegalArgumentException ex) {
- // parameterTypes == null
- }
- assertWellFormed(parameterTypes != null);
- IFunction method= typeRoot.getFunction(methodName, parameterTypes);
- assertExists(method);
- return method;
- }
-
- IType type= null;
- try {
- type= javaProject.findType(typeName);
- } catch (JavaScriptModelException ex) {
- // type == null
- }
- assertExists(type);
-
- if (typeEndPosition == -1) {
- return type;
- }
-
- String memberRef= javaElementRef.substring(typeEndPosition + 1);
-
- final int paramStartPosition= memberRef.indexOf(PARAM_START_CHAR);
- if (paramStartPosition == -1) {
- IField field= type.getField(memberRef);
- assertExists(field);
- return field;
- }
- String methodName= memberRef.substring(0, paramStartPosition);
- String signature= memberRef.substring(paramStartPosition);
- String[] parameterTypes= null;
- try {
- parameterTypes= Signature.getParameterTypes(signature);
- } catch (IllegalArgumentException ex) {
- // parameterTypes == null
- }
- assertWellFormed(parameterTypes != null);
- IFunction method= type.getFunction(methodName, parameterTypes);
- assertExists(method);
- return method;
- }
-
- /**
- * Throws a <code>ParameterValueConversionException</code> if the java
- * element reference string does not meet some well-formedness condition.
- *
- * @param assertion
- * a boolean check for well-formedness
- * @throws ParameterValueConversionException
- */
- private void assertWellFormed(boolean assertion) throws ParameterValueConversionException {
- if (!assertion) {
- throw new ParameterValueConversionException("Malformed parameterValue"); //$NON-NLS-1$
- }
- }
-
- /**
- * Throws a <code>ParameterValueConversionException</code> if the java
- * element reference string identifies an element that does not exist.
- *
- * @param javaElement
- * an element to check for existence
- * @throws ParameterValueConversionException
- */
- private void assertExists(IJavaScriptElement javaElement) throws ParameterValueConversionException {
- if ((javaElement == null) || (!javaElement.exists())) {
- throw new ParameterValueConversionException("parameterValue must reference an existing IJavaScriptElement"); //$NON-NLS-1$
- }
- }
-
- public String convertToString(Object parameterValue) throws ParameterValueConversionException {
-
- if (!(parameterValue instanceof IJavaScriptElement)) {
- throw new ParameterValueConversionException("parameterValue must be an IJavaScriptElement"); //$NON-NLS-1$
- }
-
- IJavaScriptElement javaElement= (IJavaScriptElement) parameterValue;
-
- IJavaScriptProject javaProject= javaElement.getJavaScriptProject();
- if (javaProject == null) {
- throw new ParameterValueConversionException("Could not get IJavaScriptProject for element"); //$NON-NLS-1$
- }
-
- StringBuffer buffer;
-
- if (javaElement instanceof IType) {
- IType type= (IType) javaElement;
- buffer= composeTypeReference(type);
- } else
- if (javaElement instanceof IFunction) {
- IFunction method= (IFunction) javaElement;
- buffer= composeTypeReference(method.getDeclaringType());
- buffer.append(TYPE_END_CHAR);
- buffer.append(method.getElementName());
- String[] parameterTypes= method.getParameterTypes();
- buffer.append(PARAM_START_CHAR);
- for (int i= 0; i < parameterTypes.length; i++) {
- buffer.append(parameterTypes[i]);
- }
- buffer.append(PARAM_END_CHAR);
- } else
- if (javaElement instanceof IField) {
- IField field= (IField) javaElement;
- buffer= composeTypeReference(field.getDeclaringType());
- buffer.append(TYPE_END_CHAR);
- buffer.append(field.getElementName());
- } else {
- throw new ParameterValueConversionException("Unsupported IJavaScriptElement type"); //$NON-NLS-1$
- }
-
- return buffer.toString();
- }
-
- private StringBuffer composeTypeReference(IType type) {
- StringBuffer buffer= new StringBuffer();
- buffer.append(type.getJavaScriptProject().getElementName());
- buffer.append(PROJECT_END_CHAR);
- buffer.append(type.getFullyQualifiedName());
- return buffer;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/OpenElementInEditorHandler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/OpenElementInEditorHandler.java
deleted file mode 100644
index 2f236210..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/OpenElementInEditorHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * A command handler to open a java element in its editor.
- *
- *
- */
-public class OpenElementInEditorHandler extends AbstractHandler {
-
- private static final String PARAM_ID_ELEMENT_REF= "elementRef"; //$NON-NLS-1$
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IJavaScriptElement javaElement= (IJavaScriptElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF);
-
- try {
- IEditorPart editorPart= JavaScriptUI.openInEditor(javaElement);
- JavaScriptUI.revealInEditor(editorPart, javaElement);
- } catch (JavaScriptModelException ex) {
- throw new ExecutionException("Error opening java element in editor", ex); //$NON-NLS-1$
- } catch (PartInitException ex) {
- throw new ExecutionException("Error opening java element in editor", ex); //$NON-NLS-1$
- }
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInPackageViewHandler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInPackageViewHandler.java
deleted file mode 100644
index fa060ea5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInPackageViewHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart;
-
-/**
- * A command handler to show a java element in the package view.
- *
- *
- */
-public class ShowElementInPackageViewHandler extends AbstractHandler {
-
- private static final String PARAM_ID_ELEMENT_REF= "elementRef"; //$NON-NLS-1$
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IJavaScriptElement javaElement= (IJavaScriptElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF);
-
- PackageExplorerPart view= PackageExplorerPart.openInActivePerspective();
- view.tryToReveal(javaElement);
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java
deleted file mode 100644
index 3d8bf18a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.OpenTypeHierarchyUtil;
-
-/**
- * A command handler to show a java element in the type hierarchy view.
- *
- *
- */
-public class ShowElementInTypeHierarchyViewHandler extends AbstractHandler {
-
- private static final String PARAM_ID_ELEMENT_REF= "elementRef"; //$NON-NLS-1$
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window= JavaScriptPlugin.getActiveWorkbenchWindow();
- if (window == null)
- return null;
-
- IJavaScriptElement javaElement= (IJavaScriptElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF);
-
- OpenTypeHierarchyUtil.open(javaElement, window);
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/AddFromHistoryAction.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/AddFromHistoryAction.properties
deleted file mode 100644
index a2e79a11..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/AddFromHistoryAction.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-title= Restore JavaScript Element from Local History
-width= 800
-height= 600
-
-treeTitleFormat= Local History of ''{0}''
-
-treeFormat= {0}
-workspaceTreeFormat= {0} (Workspace File)
-
-editionLabel= Local History ({0})
-workspaceEditionLabel= Workspace File
-
-targetLabel= Editor Buffer
-workspaceEditionLabel= Workspace File
-
-todayFormat= Today ({0})
-yesterdayFormat= Yesterday ({0})
-dayFormat= {0}
-
-buttonLabel= Restore
-
-memberPaneTitle= Available JavaScript Elements
-treeTitleFormat= Local History of ''{0}''
-noAdditionalMembersMessage= No additional members found in local history.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareAction.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareAction.properties
deleted file mode 100644
index 24ca1da8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareAction.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-title= Compare JavaScript Elements
-width= 800
-height= 600
-
-buttonLabel= Close
-
-errorTitle= Compare JavaScript Element Error
-errorFormat= Cannot locate source for ''{0}''.
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareDialog.java
deleted file mode 100644
index 8143e1eb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareDialog.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-class CompareDialog extends ResizableDialog {
-
- class ViewerSwitchingPane extends CompareViewerSwitchingPane {
-
- ViewerSwitchingPane(Composite parent, int style) {
- super(parent, style, false);
- }
-
- protected Viewer getViewer(Viewer oldViewer, Object input) {
- if (input instanceof ICompareInput)
- return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration);
- return null;
- }
-
- public void setImage(Image image) {
- // don't show icon
- }
- }
-
- private CompareViewerSwitchingPane fContentPane;
- private CompareConfiguration fCompareConfiguration;
- private ICompareInput fInput;
-
-
- CompareDialog(Shell parent, ResourceBundle bundle) {
- super(parent, bundle);
-
- fCompareConfiguration= new CompareConfiguration();
- fCompareConfiguration.setLeftEditable(false);
- fCompareConfiguration.setRightEditable(false);
- }
-
- void compare(ICompareInput input) {
-
- fInput= input;
-
- fCompareConfiguration.setLeftLabel(fInput.getLeft().getName());
- fCompareConfiguration.setLeftImage(fInput.getLeft().getImage());
-
- fCompareConfiguration.setRightLabel(fInput.getRight().getName());
- fCompareConfiguration.setRightImage(fInput.getRight().getImage());
-
- if (fContentPane != null)
- fContentPane.setInput(fInput);
-
- open();
- }
-
- /* (non Javadoc)
- * Creates SWT control tree.
- */
- protected synchronized Control createDialogArea(Composite parent2) {
-
- Composite parent= (Composite) super.createDialogArea(parent2);
-
- getShell().setText(JavaCompareUtilities.getString(fBundle, "title")); //$NON-NLS-1$
-
- fContentPane= new ViewerSwitchingPane(parent, SWT.BORDER | SWT.FLAT);
- fContentPane.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
- | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
-
- if (fInput != null)
- fContentPane.setInput(fInput);
-
- applyDialogFont(parent);
- return parent;
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected void createButtonsForButtonBar(Composite parent) {
- String buttonLabel= JavaCompareUtilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$
- createButton(parent, IDialogConstants.CANCEL_ID, buttonLabel, false);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.COMPARE_DIALOG);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java
deleted file mode 100644
index 2991f498..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class CompareMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.compare.CompareMessages";//$NON-NLS-1$
-
- private CompareMessages() {
- // Do not instantiate
- }
-
- public static String JavaCompareWithEditionActionImpl_0;
- public static String JavaMergeViewer_title;
- public static String JavaReplaceWithEditionActionImpl_0;
- public static String PropertiesFileMergeViewer_title;
- public static String JavaStructureViewer_title;
- public static String JavaNode_compilationUnit;
- public static String JavaNode_importDeclarations;
- public static String JavaNode_initializer;
- public static String JavaNode_packageDeclaration;
- public static String PropertiesStructureCreator_error_occurred;
- public static String PropertyCompareViewer_title;
- public static String PropertyCompareViewer_malformedEncoding;
- public static String CompareWithHistory_title;
- public static String CompareWithHistory_internalErrorMessage;
- public static String CompareWithHistory_invalidSelectionMessage;
- public static String ReplaceFromHistory_title;
- public static String ReplaceFromHistory_internalErrorMessage;
- public static String ReplaceFromHistory_invalidSelectionMessage;
- public static String ReplaceFromHistory_parsingErrorMessage;
- public static String AddFromHistory_title;
- public static String AddFromHistory_internalErrorMessage;
- public static String AddFromHistory_invalidSelectionMessage;
- public static String Editor_Buffer;
- public static String Workspace_File;
- public static String LocalHistoryActionGroup_menu_local_history;
- public static String LocalHistoryActionGroup_action_compare_with;
- public static String LocalHistoryActionGroup_action_compare_with_title;
- public static String LocalHistoryActionGroup_action_compare_with_message;
- public static String LocalHistoryActionGroup_action_replace_with_previous;
- public static String LocalHistoryActionGroup_action_replace_with_previous_title;
- public static String LocalHistoryActionGroup_action_replace_with_previous_message;
- public static String LocalHistoryActionGroup_action_replace_with;
- public static String LocalHistoryActionGroup_action_replace_with_title;
- public static String LocalHistoryActionGroup_action_replace_with_message;
- public static String LocalHistoryActionGroup_action_add;
- public static String LocalHistoryActionGroup_action_add_title;
- public static String LocalHistoryActionGroup_action_add_message;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties
deleted file mode 100644
index 71cd7b80..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties
+++ /dev/null
@@ -1,89 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-#
-# Title of Java source compare viewer
-#
-JavaMergeViewer_title= JavaScript Source Compare
-
-#
-# Title of Java properties file compare viewer
-#
-PropertiesFileMergeViewer_title= JavaScript Properties Compare
-
-#
-# Title of Java structure ceator (shown in diff structure viewer)
-#
-JavaStructureViewer_title= JavaScript Structure Compare
-JavaNode_compilationUnit= JavaScript file
-JavaNode_importDeclarations= Import Declarations
-JavaNode_initializer= {...}
-JavaNode_packageDeclaration= Package Declaration
-
-#
-# Property file compare viewer
-#
-PropertyCompareViewer_title= Property Compare
-PropertyCompareViewer_malformedEncoding=Malformed encoding.
-PropertiesStructureCreator_error_occurred=An error occurred while creating the input structure.
-
-#
-# Compare with Local History action
-#
-CompareWithHistory_title= Compare with Local History
-CompareWithHistory_internalErrorMessage= Internal error.
-CompareWithHistory_invalidSelectionMessage= Selection is no longer valid.
-
-#
-# Replace from Local History action
-#
-ReplaceFromHistory_title= Replace from Local History
-ReplaceFromHistory_internalErrorMessage= Internal error.
-ReplaceFromHistory_invalidSelectionMessage= Selection is no longer valid.
-ReplaceFromHistory_parsingErrorMessage= Could not parse previous entry in local history.\nUse \'Replace with Element from Local History\'.
-
-#
-# Restore from Local History action
-#
-AddFromHistory_title= Restore from Local History
-AddFromHistory_internalErrorMessage= Internal error.
-AddFromHistory_invalidSelectionMessage= Selection is no longer valid.
-
-#
-# Title of left pane in Compare/Replace/Restore from local History dialog
-#
-Editor_Buffer= Editor Buffer
-Workspace_File= Workspace File
-
-#
-# Local history action group for compilation unit editor
-#
-LocalHistoryActionGroup_menu_local_history=Local &History
-
-LocalHistoryActionGroup_action_compare_with=Comp&are With...
-LocalHistoryActionGroup_action_compare_with_title=Compare With
-LocalHistoryActionGroup_action_compare_with_message=Operation not applicable to current text selection. Please select a type, method or field.
-
-LocalHistoryActionGroup_action_replace_with_previous=Replace with &Previous
-LocalHistoryActionGroup_action_replace_with_previous_title=Replace with Previous
-LocalHistoryActionGroup_action_replace_with_previous_message=Operation not applicable to current text selection. Please select a type, function or field.
-
-LocalHistoryActionGroup_action_replace_with=Replace &With...
-LocalHistoryActionGroup_action_replace_with_title=Replace With
-LocalHistoryActionGroup_action_replace_with_message=Operation not applicable to current text selection. Please select a type, function or field.
-
-LocalHistoryActionGroup_action_add=&Restore From...
-LocalHistoryActionGroup_action_add_title=Restore From
-LocalHistoryActionGroup_action_add_message=Operation not applicable to current text selection. Please select a type, function or field.
-
-JavaCompareWithEditionActionImpl_0=Compare JavaScript Element with Local History
-JavaReplaceWithEditionActionImpl_0=Replace with JavaScript Element from Local History
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareWithEditionAction.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareWithEditionAction.properties
deleted file mode 100644
index 884cdaeb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareWithEditionAction.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-title= Compare JavaScript Element with Local History
-width= 800
-height= 600
-
-treeTitleFormat= Local History of ''{0}''
-
-treeFormat= {0}
-workspaceTreeFormat= {0} (Workspace File)
-parseErrorFormat= {0} (Parsing Error; No Structured Compare Available)
-
-editionLabel= Local History ({0})
-workspaceEditionLabel= Workspace File
-
-targetLabel= {0}
-
-todayFormat= Today ({0})
-yesterdayFormat= Yesterday ({0})
-dayFormat= {0}
-
-buttonLabel= Close
-
-notFoundInLocalHistoryMessage= No differing versions of selected JavaScript element found in local history.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/EclipsePreferencesAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/EclipsePreferencesAdapter.java
deleted file mode 100644
index a74b060c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/EclipsePreferencesAdapter.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Adapts an options {@link IEclipsePreferences} to {@link org.eclipse.jface.preference.IPreferenceStore}.
- * <p>
- * This preference store is read-only i.e. write access
- * throws an {@link java.lang.UnsupportedOperationException}.
- * </p>
- *
- *
- */
-class EclipsePreferencesAdapter implements IPreferenceStore {
-
- /**
- * Preference change listener. Listens for events preferences
- * fires a {@link org.eclipse.jface.util.PropertyChangeEvent}
- * on this adapter with arguments from the received event.
- */
- private class PreferenceChangeListener implements IEclipsePreferences.IPreferenceChangeListener {
-
- /**
- * {@inheritDoc}
- */
- public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
- if (Display.getCurrent() == null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
- }
- });
- } else {
- firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
- }
- }
- }
-
- /** Listeners on on this adapter */
- private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
-
- /** Listener on the node */
- private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
-
- /** wrapped node */
- private final IScopeContext fContext;
- private final String fQualifier;
-
- /**
- * Initialize with the node to wrap
- *
- * @param context The context to access
- */
- public EclipsePreferencesAdapter(IScopeContext context, String qualifier) {
- fContext= context;
- fQualifier= qualifier;
- }
-
- private IEclipsePreferences getNode() {
- return fContext.getNode(fQualifier);
- }
-
- /**
- * {@inheritDoc}
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if (fListeners.size() == 0)
- getNode().addPreferenceChangeListener(fListener);
- fListeners.add(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fListeners.remove(listener);
- if (fListeners.size() == 0) {
- getNode().removePreferenceChangeListener(fListener);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean contains(String name) {
- return getNode().get(name, null) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++)
- ((IPropertyChangeListener) listeners[i]).propertyChange(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getBoolean(String name) {
- return getNode().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getDefaultBoolean(String name) {
- return BOOLEAN_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDefaultDouble(String name) {
- return DOUBLE_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public float getDefaultFloat(String name) {
- return FLOAT_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getDefaultInt(String name) {
- return INT_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public long getDefaultLong(String name) {
- return LONG_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDefaultString(String name) {
- return STRING_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDouble(String name) {
- return getNode().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public float getFloat(String name) {
- return getNode().getFloat(name, FLOAT_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public int getInt(String name) {
- return getNode().getInt(name, INT_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public long getLong(String name) {
- return getNode().getLong(name, LONG_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getString(String name) {
- return getNode().get(name, STRING_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDefault(String name) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean needsSaving() {
- try {
- return getNode().keys().length > 0;
- } catch (BackingStoreException e) {
- // ignore
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void putValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, String defaultObject) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setToDefault(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistory.java
deleted file mode 100644
index cae3a0c4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistory.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-
-public class JavaAddElementFromHistory extends JavaHistoryAction {
-
- public JavaAddElementFromHistory() {
- }
-
- protected JavaHistoryActionImpl createDelegate() {
- return new JavaAddElementFromHistoryImpl();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistoryImpl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistoryImpl.java
deleted file mode 100644
index 02143327..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaAddElementFromHistoryImpl.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.EditionSelectionDialog;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ListRewrite;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.util.Resources;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-
-
-class JavaAddElementFromHistoryImpl extends JavaHistoryActionImpl {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.compare.AddFromHistoryAction"; //$NON-NLS-1$
-
- JavaAddElementFromHistoryImpl() {
- super(true);
- }
-
- public void run(ISelection selection) {
-
- String errorTitle= CompareMessages.AddFromHistory_title;
- String errorMessage= CompareMessages.AddFromHistory_internalErrorMessage;
- Shell shell= getShell();
-
- IJavaScriptUnit cu= null;
- IParent parent= null;
- IMember input= null;
-
- // analyze selection
- if (selection.isEmpty()) {
- // no selection: we try to use the editor's input
- JavaEditor editor= getEditor();
- if (editor != null) {
- IEditorInput editorInput= editor.getEditorInput();
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- if (manager != null) {
- cu= manager.getWorkingCopy(editorInput);
- parent= cu;
- }
- }
- } else {
- input= getEditionElement(selection);
- if (input != null) {
- cu= input.getJavaScriptUnit();
- parent= input;
- input= null;
-
- } else {
- if (selection instanceof IStructuredSelection) {
- Object o= ((IStructuredSelection)selection).getFirstElement();
- if (o instanceof IJavaScriptUnit) {
- cu= (IJavaScriptUnit) o;
- parent= cu;
- }
- }
- }
- }
-
- if (parent == null || cu == null) {
- String invalidSelectionMessage= CompareMessages.AddFromHistory_invalidSelectionMessage;
- MessageDialog.openInformation(shell, errorTitle, invalidSelectionMessage);
- return;
- }
-
- IFile file= getFile(parent);
- if (file == null) {
- MessageDialog.openError(shell, errorTitle, errorMessage);
- return;
- }
-
- boolean inEditor= beingEdited(file);
-
- IStatus status= Resources.makeCommittable(file, shell);
- if (!status.isOK()) {
- return;
- }
-
- // get the document where to insert the text
- IPath path= file.getFullPath();
- ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager();
- ITextFileBuffer textFileBuffer= null;
- try {
- bufferManager.connect(path, LocationKind.IFILE, null);
- textFileBuffer= bufferManager.getTextFileBuffer(path, LocationKind.IFILE);
- IDocument document= textFileBuffer.getDocument();
-
- // configure EditionSelectionDialog and let user select an edition
- ITypedElement target= new JavaTextBufferNode(file, document, inEditor);
- ITypedElement[] editions= buildEditions(target, file);
-
- ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
- EditionSelectionDialog d= new EditionSelectionDialog(shell, bundle);
- d.setAddMode(true);
- d.setHelpContextId(IJavaHelpContextIds.ADD_ELEMENT_FROM_HISTORY_DIALOG);
- ITypedElement selected= d.selectEdition(target, editions, parent);
- if (selected == null)
- return; // user cancel
-
- IJavaScriptUnit cu2= cu;
- if (parent instanceof IMember)
- cu2= ((IMember)parent).getJavaScriptUnit();
-
- JavaScriptUnit root= parsePartialCompilationUnit(cu2);
- ASTRewrite rewriter= ASTRewrite.create(root.getAST());
-
- ITypedElement[] results= d.getSelection();
- for (int i= 0; i < results.length; i++) {
-
- // create an AST node
- ASTNode newNode= createASTNode(rewriter, results[i], TextUtilities.getDefaultLineDelimiter(document), cu.getJavaScriptProject());
- if (newNode == null) {
- MessageDialog.openError(shell, errorTitle, errorMessage);
- return;
- }
-
- // now determine where to put the new node
- if (newNode instanceof PackageDeclaration) {
- rewriter.set(root, JavaScriptUnit.PACKAGE_PROPERTY, newNode, null);
-
- } else if (newNode instanceof ImportDeclaration) {
- ListRewrite lw= rewriter.getListRewrite(root, JavaScriptUnit.IMPORTS_PROPERTY);
- lw.insertFirst(newNode, null);
-
- } else { // class, interface, enum, annotation, method, field
-
- if (parent instanceof IJavaScriptUnit) { // top level
- ListRewrite lw= rewriter.getListRewrite(root, JavaScriptUnit.TYPES_PROPERTY);
- int index= ASTNodes.getInsertionIndex((BodyDeclaration)newNode, root.types());
- lw.insertAt(newNode, index, null);
-
- } else if (parent instanceof IType) {
- ASTNode declaration= getBodyContainer(root, (IType)parent);
- if (declaration instanceof TypeDeclaration) {
- List container= ASTNodes.getBodyDeclarations(declaration);
- int index= ASTNodes.getInsertionIndex((BodyDeclaration)newNode, container);
- ListRewrite lw= rewriter.getListRewrite(declaration, ASTNodes.getBodyDeclarationsProperty(declaration));
- lw.insertAt(newNode, index, null);
- }
- } else {
- JavaScriptPlugin.logErrorMessage("JavaAddElementFromHistoryImpl: unknown container " + parent); //$NON-NLS-1$
- }
-
- }
- }
-
- Map options= null;
- IJavaScriptProject javaProject= cu2.getJavaScriptProject();
- if (javaProject != null)
- options= javaProject.getOptions(true);
- applyChanges(rewriter, document, textFileBuffer, shell, inEditor, options);
-
- } catch(InvocationTargetException ex) {
- ExceptionHandler.handle(ex, shell, errorTitle, errorMessage);
-
- } catch(InterruptedException ex) {
- // shouldn't be called because is not cancelable
- Assert.isTrue(false);
-
- } catch(CoreException ex) {
- ExceptionHandler.handle(ex, shell, errorTitle, errorMessage);
-
- } finally {
- try {
- if (textFileBuffer != null)
- bufferManager.disconnect(path, LocationKind.IFILE, null);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /**
- * Creates a place holder ASTNode for the given element.
- * @param rewriter
- * @param element
- * @param delimiter the line delimiter
- * @param project
- * @return a ASTNode or null
- * @throws CoreException
- */
- private ASTNode createASTNode(ASTRewrite rewriter, ITypedElement element, String delimiter, IJavaScriptProject project) throws CoreException {
- if (element instanceof IStreamContentAccessor) {
- String content= JavaCompareUtilities.readString((IStreamContentAccessor)element);
- if (content != null) {
- content= trimTextBlock(content, delimiter, project);
- if (content != null) {
- int type= getPlaceHolderType(element);
- if (type != -1)
- return rewriter.createStringPlaceholder(content, type);
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the corresponding place holder type for the given element.
- * @return a place holder type (see ASTRewrite) or -1 if there is no corresponding placeholder
- */
- private int getPlaceHolderType(ITypedElement element) {
-
- if (element instanceof DocumentRangeNode) {
- JavaNode jn= (JavaNode) element;
- switch (jn.getTypeCode()) {
-
- case JavaNode.PACKAGE:
- return ASTNode.PACKAGE_DECLARATION;
-
- case JavaNode.CLASS:
- case JavaNode.INTERFACE:
- return ASTNode.TYPE_DECLARATION;
-
- case JavaNode.CONSTRUCTOR:
- case JavaNode.METHOD:
- return ASTNode.FUNCTION_DECLARATION;
-
- case JavaNode.FIELD:
- return ASTNode.FIELD_DECLARATION;
-
- case JavaNode.INIT:
- return ASTNode.INITIALIZER;
-
- case JavaNode.IMPORT:
- case JavaNode.IMPORT_CONTAINER:
- return ASTNode.IMPORT_DECLARATION;
-
- case JavaNode.CU:
- return ASTNode.JAVASCRIPT_UNIT;
- }
- }
- return -1;
- }
-
- protected boolean isEnabled(ISelection selection) {
-
- if (selection.isEmpty()) {
- JavaEditor editor= getEditor();
- if (editor != null) {
- // we check whether editor shows JavaScriptUnit
- IEditorInput editorInput= editor.getEditorInput();
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- return manager.getWorkingCopy(editorInput) != null;
- }
- return false;
- }
-
- if (selection instanceof IStructuredSelection) {
- Object o= ((IStructuredSelection)selection).getFirstElement();
- if (o instanceof IJavaScriptUnit)
- return true;
- }
-
- return super.isEnabled(selection);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareAction.java
deleted file mode 100644
index 0d58f8b8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareAction.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class JavaCompareAction implements IActionDelegate {
-
- class TypedElement implements ITypedElement, IEncodedStreamContentAccessor {
-
- private ISourceReference fSource;
- private String fContents;
-
- TypedElement(ISourceReference s, String contents) {
- fSource= s;
- fContents= contents;
- }
-
- public String getName() {
- return fJavaElementLabelProvider.getText(fSource);
- }
-
- public String getType() {
- return "JAVA"; //$NON-NLS-1$
- }
-
- public Image getImage() {
- return fJavaElementLabelProvider.getImage(fSource);
- }
-
- public InputStream getContents() throws CoreException {
- byte[] bytes;
- try {
- bytes= fContents.getBytes("UTF-16"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- bytes= fContents.getBytes();
- }
- return new ByteArrayInputStream(bytes);
- }
-
- public String getCharset() {
- return "UTF-16"; //$NON-NLS-1$
- }
- }
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.compare.CompareAction"; //$NON-NLS-1$
-
- private ISourceReference fLeft;
- private ISourceReference fRight;
-
- private JavaScriptElementLabelProvider fJavaElementLabelProvider;
-
-
- public void selectionChanged(IAction action, ISelection selection) {
- action.setEnabled(isEnabled(selection));
- }
-
- public void run(IAction action) {
- Shell shell= JavaScriptPlugin.getActiveWorkbenchShell();
- ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
- CompareDialog d= new CompareDialog(shell, bundle);
-
-
- String left= null;
- String right= null;
-
- try {
- left= getExtendedSource(fLeft);
- } catch (JavaScriptModelException ex) {
- JavaScriptPlugin.log(ex);
- }
-
- try {
- right= getExtendedSource(fRight);
- } catch (JavaScriptModelException ex) {
- JavaScriptPlugin.log(ex);
- }
-
- fJavaElementLabelProvider= new JavaScriptElementLabelProvider(
- JavaScriptElementLabelProvider.SHOW_PARAMETERS |
- JavaScriptElementLabelProvider.SHOW_OVERLAY_ICONS |
- JavaScriptElementLabelProvider.SHOW_ROOT);
-
- if (left == null || right == null) {
- String errorTitle= JavaCompareUtilities.getString(bundle, "errorTitle"); //$NON-NLS-1$
- String errorFormat= JavaCompareUtilities.getString(bundle, "errorFormat"); //$NON-NLS-1$
-
- Object element= null;
- if (left == null)
- element= fLeft;
- else
- element= fRight;
-
- String message= Messages.format(errorFormat, new String[] { fJavaElementLabelProvider.getText(element) } );
-
- MessageDialog.openError(shell, errorTitle, message);
- return;
- }
-
- d.compare(new DiffNode(new TypedElement(fLeft, left), new TypedElement(fRight, right)));
-
- fJavaElementLabelProvider.dispose();
- fJavaElementLabelProvider= null;
- }
-
- protected boolean isEnabled(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- Object[] sel= ((IStructuredSelection) selection).toArray();
- if (sel.length == 2) {
- for (int i= 0; i < 2; i++) {
- Object o= sel[i];
- if (!(o instanceof ISourceReference))
- return false;
- }
- fLeft= (ISourceReference) sel[0];
- fRight= (ISourceReference) sel[1];
- return true;
- }
- }
- return false;
- }
-
- private String getExtendedSource(ISourceReference ref) throws JavaScriptModelException {
-
- // get parent
- if (ref instanceof IJavaScriptElement) {
- IJavaScriptElement parent= ((IJavaScriptElement) ref).getParent();
- if (parent instanceof ISourceReference) {
- ISourceReference sr= (ISourceReference) parent;
- String parentContent= sr.getSource();
- if (parentContent != null) {
- ISourceRange parentRange= sr.getSourceRange();
- ISourceRange childRange= ref.getSourceRange();
-
- int start= childRange.getOffset() - parentRange.getOffset();
- int end= start + childRange.getLength();
-
- // search backwards for beginning of line
- while (start > 0) {
- char c= parentContent.charAt(start-1);
- if (c == '\n' || c == '\r')
- break;
- start--;
- }
-
- return parentContent.substring(start, end);
- }
- }
- }
-
- return ref.getSource();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java
deleted file mode 100644
index 3ec02136..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-class JavaCompareUtilities {
-
- private static final char PACKAGEDECLARATION= '%';
- private static final char IMPORTDECLARATION= '#';
- private static final char IMPORT_CONTAINER= '<';
- private static final char FIELD= '^';
- private static final char METHOD= '~';
- private static final char INITIALIZER= '|';
- private static final char COMPILATIONUNIT= '{';
- private static final char TYPE= '[';
-
- static String getString(ResourceBundle bundle, String key, String dfltValue) {
-
- if (bundle != null) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException x) {
- // NeedWork
- }
- }
- return dfltValue;
- }
-
- static String getString(ResourceBundle bundle, String key) {
- return getString(bundle, key, key);
- }
-
- static int getInteger(ResourceBundle bundle, String key, int dfltValue) {
-
- if (bundle != null) {
- try {
- String s= bundle.getString(key);
- if (s != null)
- return Integer.parseInt(s);
- } catch (NumberFormatException x) {
- // NeedWork
- } catch (MissingResourceException x) {
- // NeedWork
- }
- }
- return dfltValue;
- }
-
- static ImageDescriptor getImageDescriptor(int type) {
- switch (type) {
- case IJavaScriptElement.INITIALIZER:
- case IJavaScriptElement.METHOD:
- return getImageDescriptor("obj16/compare_method.gif"); //$NON-NLS-1$
- case IJavaScriptElement.FIELD:
- return getImageDescriptor("obj16/compare_field.gif"); //$NON-NLS-1$
- case IJavaScriptElement.PACKAGE_DECLARATION:
- return JavaPluginImages.DESC_OBJS_PACKDECL;
- case IJavaScriptElement.IMPORT_DECLARATION:
- return JavaPluginImages.DESC_OBJS_IMPDECL;
- case IJavaScriptElement.IMPORT_CONTAINER:
- return JavaPluginImages.DESC_OBJS_IMPCONT;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return JavaPluginImages.DESC_OBJS_CUNIT;
- }
- return ImageDescriptor.getMissingImageDescriptor();
- }
-
- static ImageDescriptor getTypeImageDescriptor(boolean isClass) {
- if (isClass)
- return JavaPluginImages.DESC_OBJS_CLASS;
- return JavaPluginImages.DESC_OBJS_INTERFACE;
- }
-
- static ImageDescriptor getEnumImageDescriptor() {
- return JavaPluginImages.DESC_OBJS_ENUM;
- }
-
- static ImageDescriptor getAnnotationImageDescriptor() {
- return JavaPluginImages.DESC_OBJS_ANNOTATION;
- }
-
- static ImageDescriptor getImageDescriptor(IMember element) {
- int t= element.getElementType();
- if (t == IJavaScriptElement.TYPE) {
- IType type= (IType) element;
- try {
- return getTypeImageDescriptor(type.isClass());
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return JavaPluginImages.DESC_OBJS_GHOST;
- }
- }
- return getImageDescriptor(t);
- }
-
- /**
- * Returns a name for the given Java element that uses the same conventions
- * as the JavaNode name of a corresponding element.
- */
- static String getJavaElementID(IJavaScriptElement je) {
-
- if (je instanceof IMember && ((IMember)je).isBinary())
- return null;
-
- StringBuffer sb= new StringBuffer();
-
- switch (je.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- sb.append(COMPILATIONUNIT);
- break;
- case IJavaScriptElement.TYPE:
- sb.append(TYPE);
- sb.append(je.getElementName());
- break;
- case IJavaScriptElement.FIELD:
- sb.append(FIELD);
- sb.append(je.getElementName());
- break;
- case IJavaScriptElement.METHOD:
- sb.append(METHOD);
- sb.append(JavaScriptElementLabels.getElementLabel(je, JavaScriptElementLabels.M_PARAMETER_TYPES));
- break;
- case IJavaScriptElement.INITIALIZER:
- String id= je.getHandleIdentifier();
- int pos= id.lastIndexOf(INITIALIZER);
- if (pos >= 0)
- sb.append(id.substring(pos));
- break;
- case IJavaScriptElement.PACKAGE_DECLARATION:
- sb.append(PACKAGEDECLARATION);
- break;
- case IJavaScriptElement.IMPORT_CONTAINER:
- sb.append(IMPORT_CONTAINER);
- break;
- case IJavaScriptElement.IMPORT_DECLARATION:
- sb.append(IMPORTDECLARATION);
- sb.append(je.getElementName());
- break;
- default:
- return null;
- }
- return sb.toString();
- }
-
- /**
- * Returns a name which identifies the given typed name.
- * The type is encoded as a single character at the beginning of the string.
- */
- static String buildID(int type, String name) {
- StringBuffer sb= new StringBuffer();
- switch (type) {
- case JavaNode.CU:
- sb.append(COMPILATIONUNIT);
- break;
- case JavaNode.CLASS:
- case JavaNode.INTERFACE:
- case JavaNode.ENUM:
- case JavaNode.ANNOTATION:
- sb.append(TYPE);
- sb.append(name);
- break;
- case JavaNode.FIELD:
- sb.append(FIELD);
- sb.append(name);
- break;
- case JavaNode.CONSTRUCTOR:
- case JavaNode.METHOD:
- sb.append(METHOD);
- sb.append(name);
- break;
- case JavaNode.INIT:
- sb.append(INITIALIZER);
- sb.append(name);
- break;
- case JavaNode.PACKAGE:
- sb.append(PACKAGEDECLARATION);
- break;
- case JavaNode.IMPORT:
- sb.append(IMPORTDECLARATION);
- sb.append(name);
- break;
- case JavaNode.IMPORT_CONTAINER:
- sb.append(IMPORT_CONTAINER);
- break;
- default:
- Assert.isTrue(false);
- break;
- }
- return sb.toString();
- }
-
- static ImageDescriptor getImageDescriptor(String relativePath) {
- IPath path= JavaPluginImages.ICONS_PATH.append(relativePath);
- return JavaPluginImages.createImageDescriptor(JavaScriptPlugin.getDefault().getBundle(), path, true);
- }
-
- static boolean getBoolean(CompareConfiguration cc, String key, boolean dflt) {
- if (cc != null) {
- Object value= cc.getProperty(key);
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- }
- return dflt;
- }
-
- static Image getImage(IMember member) {
- ImageDescriptor id= getImageDescriptor(member);
- return id.createImage();
- }
-
- static JavaScriptTextTools getJavaTextTools() {
- JavaScriptPlugin plugin= JavaScriptPlugin.getDefault();
- if (plugin != null)
- return plugin.getJavaTextTools();
- return null;
- }
-
- static IDocumentPartitioner createJavaPartitioner() {
- JavaScriptTextTools tools= getJavaTextTools();
- if (tools != null)
- return tools.createDocumentPartitioner();
- return null;
- }
-
- static void setupDocument(IDocument document) {
- JavaScriptTextTools tools= getJavaTextTools();
- if (tools != null)
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- }
-//
-// static void setupPropertiesFileDocument(IDocument document) {
-// PropertiesFileDocumentSetupParticipant.setupDocument(document);
-// }
-
- /**
- * Reads the contents of the given input stream into a string.
- * The function assumes that the input stream uses the platform's default encoding
- * (<code>ResourcesPlugin.getEncoding()</code>).
- * Returns null if an error occurred.
- */
- private static String readString(InputStream is, String encoding) {
- 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, encoding));
-
- while ((read= reader.read(part)) != -1)
- buffer.append(part, 0, read);
-
- return buffer.toString();
-
- } catch (IOException ex) {
- // NeedWork
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ex) {
- // silently ignored
- }
- }
- }
- return null;
- }
-
- public static String readString(IStreamContentAccessor sa) throws CoreException {
- InputStream is= sa.getContents();
- if (is != null) {
- String encoding= null;
- if (sa instanceof IEncodedStreamContentAccessor) {
- try {
- encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
- } catch (Exception e) {
- }
- }
- if (encoding == null)
- encoding= ResourcesPlugin.getEncoding();
- return readString(is, encoding);
- }
- return null;
- }
-
- /**
- * Returns the contents of the given string as an array of bytes
- * in the platform's default encoding.
- */
- static byte[] getBytes(String s, String encoding) {
- try {
- return s.getBytes(encoding);
- } catch (UnsupportedEncodingException e) {
- return s.getBytes();
- }
- }
-
- /**
- * Breaks the contents of the given input stream into an array of strings.
- * The function assumes that the input stream uses the platform's default encoding
- * (<code>ResourcesPlugin.getEncoding()</code>).
- * Returns null if an error occurred.
- */
- static String[] readLines(InputStream is2, String encoding) {
-
- BufferedReader reader= null;
- try {
- reader= new BufferedReader(new InputStreamReader(is2, encoding));
- StringBuffer sb= new StringBuffer();
- List list= new ArrayList();
- while (true) {
- int c= reader.read();
- if (c == -1)
- break;
- sb.append((char)c);
- if (c == '\r') { // single CR or a CR followed by LF
- c= reader.read();
- if (c == -1)
- break;
- sb.append((char)c);
- if (c == '\n') {
- list.add(sb.toString());
- sb= new StringBuffer();
- }
- } else if (c == '\n') { // a single LF
- list.add(sb.toString());
- sb= new StringBuffer();
- }
- }
- if (sb.length() > 0)
- list.add(sb.toString());
- return (String[]) list.toArray(new String[list.size()]);
-
- } catch (IOException ex) {
- return null;
-
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ex) {
- // silently ignored
- }
- }
- }
- }
-
- /*
- * Initialize the given Action from a ResourceBundle.
- */
- static void initAction(IAction a, ResourceBundle bundle, String prefix) {
-
- String labelKey= "label"; //$NON-NLS-1$
- String tooltipKey= "tooltip"; //$NON-NLS-1$
- String imageKey= "image"; //$NON-NLS-1$
- String descriptionKey= "description"; //$NON-NLS-1$
-
- if (prefix != null && prefix.length() > 0) {
- labelKey= prefix + labelKey;
- tooltipKey= prefix + tooltipKey;
- imageKey= prefix + imageKey;
- descriptionKey= prefix + descriptionKey;
- }
-
- a.setText(getString(bundle, labelKey, labelKey));
- a.setToolTipText(getString(bundle, tooltipKey, null));
- a.setDescription(getString(bundle, descriptionKey, null));
-
- String relPath= getString(bundle, imageKey, null);
- if (relPath != null && relPath.trim().length() > 0) {
-
- String dPath;
- String ePath;
-
- if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
- String path= relPath.substring(1);
- dPath= 'd' + path;
- ePath= 'e' + path;
- } else {
- dPath= "dlcl16/" + relPath; //$NON-NLS-1$
- ePath= "elcl16/" + relPath; //$NON-NLS-1$
- }
-
- ImageDescriptor id= JavaCompareUtilities.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87)
- if (id != null)
- a.setDisabledImageDescriptor(id);
- id= JavaCompareUtilities.getImageDescriptor(ePath);
- if (id != null) {
- a.setImageDescriptor(id);
- a.setHoverImageDescriptor(id);
- }
- }
- }
-
- static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) {
-
- String tooltip= null;
- if (checked)
- tooltip= getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$
- else
- tooltip= getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$
- if (tooltip == null)
- tooltip= getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$
-
- if (tooltip != null)
- a.setToolTipText(tooltip);
-
- String description= null;
- if (checked)
- description= getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$
- else
- description= getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$
- if (description == null)
- description= getString(bundle, prefix + "description", null); //$NON-NLS-1$
-
- if (description != null)
- a.setDescription(description);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionAction.java
deleted file mode 100644
index 5bc68c14..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionAction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-/**
- * Provides "Replace from local history" for Java elements.
- */
-public class JavaCompareWithEditionAction extends JavaHistoryAction {
-
- public JavaCompareWithEditionAction() {
- }
-
- protected JavaHistoryActionImpl createDelegate() {
- return new JavaCompareWithEditionActionImpl();
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java
deleted file mode 100644
index 4f3d1866..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.history.HistoryPageCompareEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-/**
- * Provides "Replace from local history" for Java elements.
- */
-class JavaCompareWithEditionActionImpl extends JavaHistoryActionImpl {
-
- private static boolean USE_MODAL_COMPARE = false;
-
- JavaCompareWithEditionActionImpl() {
- super(false);
- }
-
- public void run(ISelection selection) {
-
- IMember input= getEditionElement(selection);
- if (input == null) {
- MessageDialog.openInformation(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_invalidSelectionMessage);
- return;
- }
-
- JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
- final IFile file= pageSource.getFile(input);
- if (file == null) {
- MessageDialog.openError(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_internalErrorMessage);
- return;
- }
-
- if (USE_MODAL_COMPARE) {
- CompareConfiguration cc = new CompareConfiguration();
- cc.setLeftEditable(false);
- cc.setRightEditable(false);
- HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input);
- ci.setTitle(CompareMessages.JavaCompareWithEditionActionImpl_0);
- ci.setHelpContextId(IJavaHelpContextIds.COMPARE_ELEMENT_WITH_HISTORY_DIALOG);
- CompareUI.openCompareDialog(ci);
- } else {
- TeamUI.showHistoryFor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, pageSource);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaContentViewerCreator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaContentViewerCreator.java
deleted file mode 100644
index 30275f66..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaContentViewerCreator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-
-/**
- * Required when creating a JavaMergeViewer from the plugin.xml file.
- */
-public class JavaContentViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new JavaMergeViewer(parent, SWT.NULL, mp);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java
deleted file mode 100644
index 76226a44..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.team.ui.history.ElementLocalHistoryPageSource;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-
-public class JavaElementHistoryPageSource extends ElementLocalHistoryPageSource {
-
- private static JavaElementHistoryPageSource instance;
-
- public static JavaElementHistoryPageSource getInstance() {
- if (instance == null)
- instance = new JavaElementHistoryPageSource();
- return instance;
- }
-
- /**
- * Returns true if the given IJavaScriptElement maps to a JavaNode.
- * The JavaHistoryAction uses this function to determine whether
- * a selected Java element can be replaced by some piece of
- * code from the local history.
- */
- public static boolean hasEdition(IJavaScriptElement je) {
-
- if (je instanceof IMember && ((IMember)je).isBinary())
- return false;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- case IJavaScriptElement.TYPE:
- case IJavaScriptElement.FIELD:
- case IJavaScriptElement.METHOD:
- case IJavaScriptElement.INITIALIZER:
- case IJavaScriptElement.PACKAGE_DECLARATION:
- case IJavaScriptElement.IMPORT_CONTAINER:
- case IJavaScriptElement.IMPORT_DECLARATION:
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.history.ElementLocalHistoryPageSource#getFile(java.lang.Object)
- */
- public IFile getFile(Object input) {
- // extract CU from input
- IJavaScriptUnit cu= null;
- if (input instanceof IJavaScriptUnit)
- cu= (IJavaScriptUnit) input;
- else if (input instanceof IMember)
- cu= ((IMember)input).getJavaScriptUnit();
-
- if (cu == null || !cu.exists())
- return null;
-
- // get to original CU
- cu= cu.getPrimary();
-
- // find underlying file
- IFile file= (IFile) cu.getResource();
- if (file != null && file.exists())
- return file;
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryAction.java
deleted file mode 100644
index 62a89d2a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryAction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-/**
- * A delegate for JavaHistoryActionImpls.
- */
-public abstract class JavaHistoryAction extends Action implements IActionDelegate {
-
- private JavaHistoryActionImpl fDelegate;
- private JavaEditor fEditor;
- private String fTitle;
- private String fMessage;
-
- JavaHistoryAction() {
- }
-
- private JavaHistoryActionImpl getDelegate() {
- if (fDelegate == null) {
- fDelegate= createDelegate();
- if (fEditor != null && fTitle != null && fMessage != null)
- fDelegate.init(fEditor, fTitle, fMessage);
- }
- return fDelegate;
- }
-
- protected abstract JavaHistoryActionImpl createDelegate();
-
- final void init(JavaEditor editor, String text, String title, String message) {
- Assert.isNotNull(editor);
- Assert.isNotNull(title);
- Assert.isNotNull(message);
- fEditor= editor;
- fTitle= title;
- fMessage= message;
- //getDelegate().init(editor, text, title, message);
- setText(text);
- //setEnabled(getDelegate().checkEnabled());
- }
-
- /**
- * Executes this action with the given selection.
- */
- public final void run(ISelection selection) {
- getDelegate().run(selection);
- }
-
- public final void run() {
- getDelegate().runFromEditor(this);
- }
-
- final void update() {
- getDelegate().update(this);
- }
-
- //---- IActionDelegate
-
- public final void selectionChanged(IAction uiProxy, ISelection selection) {
- getDelegate().selectionChanged(uiProxy, selection);
- }
-
- public final void run(IAction action) {
- getDelegate().run(action);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryActionImpl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryActionImpl.java
deleted file mode 100644
index 2d35a42f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaHistoryActionImpl.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-import org.eclipse.compare.HistoryItem;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.ResourceNode;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFileState;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.RewriteSessionEditProcessor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTParser;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-/**
- * Base class for the "Replace with local history"
- * and "Add from local history" actions.
- */
-abstract class JavaHistoryActionImpl /* extends Action implements IActionDelegate*/ {
-
- private boolean fModifiesFile;
- private ISelection fSelection;
-
- JavaHistoryActionImpl(boolean modifiesFile) {
- fModifiesFile= modifiesFile;
- }
-
- ISelection getSelection() {
- return fSelection;
- }
-
- final IFile getFile(Object input) {
- return JavaElementHistoryPageSource.getInstance().getFile(input);
- }
-
- final ITypedElement[] buildEditions(ITypedElement target, IFile file) {
-
- // setup array of editions
- IFileState[] states= null;
- // add available editions
- try {
- states= file.getHistory(null);
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- }
-
- int count= 1;
- if (states != null)
- count+= states.length;
-
- ITypedElement[] editions= new ITypedElement[count];
- editions[0]= new ResourceNode(file);
- if (states != null)
- for (int i= 0; i < states.length; i++)
- editions[i+1]= new HistoryItem(target, states[i]);
- return editions;
- }
-
- final Shell getShell() {
- if (fEditor != null)
- return fEditor.getEditorSite().getShell();
- return JavaScriptPlugin.getActiveWorkbenchShell();
- }
-
- /**
- * Tries to find the given element in a working copy.
- */
- final IJavaScriptElement getWorkingCopy(IJavaScriptElement input) {
- // TODO: With new working copy story: original == working copy.
- // Note that the previous code could result in a reconcile as side effect. Should check if that
- // is still required.
- return input;
- }
-
- final ASTNode getBodyContainer(JavaScriptUnit root, IMember parent) throws JavaScriptModelException {
- ISourceRange sourceRange= parent.getNameRange();
- ASTNode parentNode= NodeFinder.perform(root, sourceRange);
- do {
- if (parentNode instanceof TypeDeclaration )
- return parentNode;
- parentNode= parentNode.getParent();
- } while (parentNode != null);
- return null;
- }
-
- /**
- * Returns true if the given file is open in an editor.
- */
- final boolean beingEdited(IFile file) {
- IDocumentProvider dp= JavaScriptPlugin.getDefault().getCompilationUnitDocumentProvider();
- FileEditorInput input= new FileEditorInput(file);
- return dp.getDocument(input) != null;
- }
-
- /**
- * Returns an IMember or null.
- */
- final IMember getEditionElement(ISelection selection) {
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- if (ss.size() == 1) {
- Object o= ss.getFirstElement();
- if (o instanceof IMember) {
- IMember m= (IMember) o;
- if (m.exists() && !m.isBinary() && JavaStructureCreator.hasEdition(m))
- return m;
- }
- }
- }
- return null;
- }
-
- final boolean isEnabled(IFile file) {
- if (file == null || ! file.exists())
- return false;
- if (fModifiesFile) {
- // without validate/edit we would do this:
- // return !file.isReadOnly();
- // with validate/edit we have to return true
- return true;
- }
- return true;
- }
-
- boolean isEnabled(ISelection selection) {
- IMember m= getEditionElement(selection);
- if (m == null)
- return false;
- IFile file= getFile(m);
- if (!isEnabled(file))
- return false;
- return true;
- }
-
- void applyChanges(ASTRewrite rewriter, final IDocument document, final ITextFileBuffer textFileBuffer, Shell shell, boolean inEditor, Map options)
- throws CoreException, InvocationTargetException, InterruptedException {
-
-
- MultiTextEdit edit= new MultiTextEdit();
- try {
- TextEdit res= rewriter.rewriteAST(document, options);
- edit.addChildren(res.removeChildren());
- } catch (IllegalArgumentException e) {
- JavaScriptPlugin.log(e);
- }
-
- try {
- new RewriteSessionEditProcessor(document, edit, TextEdit.UPDATE_REGIONS).performEdits();
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
-
- IRunnableWithProgress r= new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InvocationTargetException {
- try {
- textFileBuffer.commit(pm, false);
- } catch (CoreException ex) {
- throw new InvocationTargetException(ex);
- }
- }
- };
-
- if (inEditor) {
- // we don't show progress
- r.run(new NullProgressMonitor());
- } else {
- PlatformUI.getWorkbench().getProgressService().run(true, false, r);
- }
- }
-
- static String trimTextBlock(String content, String delimiter, IJavaScriptProject currentProject) {
- if (content != null) {
- String[] lines= Strings.convertIntoLines(content);
- if (lines != null) {
- Strings.trimIndentation(lines, currentProject);
- return Strings.concatenate(lines, delimiter);
- }
- }
- return null;
- }
-
- final JavaEditor getEditor(IFile file) {
- FileEditorInput fei= new FileEditorInput(file);
- IWorkbench workbench= JavaScriptPlugin.getDefault().getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int x= 0; x < pages.length; x++) {
- IEditorPart[] editors= pages[x].getDirtyEditors();
- for (int z= 0; z < editors.length; z++) {
- IEditorPart ep= editors[z];
- if (ep instanceof JavaEditor) {
- JavaEditor je= (JavaEditor) ep;
- if (fei.equals(je.getEditorInput()))
- return (JavaEditor) ep;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Executes this action with the given selection.
- */
- public abstract void run(ISelection selection);
-
- //---- Action
-
- private JavaEditor fEditor;
- private String fTitle;
- private String fMessage;
-
- void init(JavaEditor editor, String title, String message) {
- fEditor= editor;
- fTitle= title;
- fMessage= message;
- }
-
- final JavaEditor getEditor() {
- return fEditor;
- }
-
- final public void runFromEditor(IAction uiProxy) {
-
- // this run is called from Editor
- IJavaScriptElement element= null;
- try {
- element= SelectionConverter.getElementAtOffset(fEditor);
- } catch (JavaScriptModelException e) {
- // ignored
- }
-
- fSelection= element != null
- ? new StructuredSelection(element)
- : StructuredSelection.EMPTY;
- boolean isEnabled= isEnabled(fSelection);
- uiProxy.setEnabled(isEnabled);
-
- if (!isEnabled) {
- MessageDialog.openInformation(getShell(), fTitle, fMessage);
- return;
- }
- run(fSelection);
- }
-
- boolean checkEnabled() {
- IJavaScriptUnit unit= SelectionConverter.getInputAsCompilationUnit(fEditor);
- IFile file= getFile(unit);
- return isEnabled(file);
- }
-
- final public void update(IAction uiProxy) {
- uiProxy.setEnabled(checkEnabled());
- }
-
- //---- IActionDelegate
-
- final public void selectionChanged(IAction uiProxy, ISelection selection) {
- fSelection= selection;
- uiProxy.setEnabled(isEnabled(selection));
- }
-
- final public void run(IAction action) {
- run(fSelection);
- }
-
- static JavaScriptUnit parsePartialCompilationUnit(IJavaScriptUnit unit) {
-
- if (unit == null) {
- throw new IllegalArgumentException();
- }
- try {
- ASTParser c= ASTParser.newParser(AST.JLS3);
- c.setSource(unit);
- c.setFocalPosition(0);
- c.setResolveBindings(false);
- c.setWorkingCopyOwner(null);
- ASTNode result= c.createAST(null);
- return (JavaScriptUnit) result;
- } catch (IllegalStateException e) {
- // convert ASTParser's complaints into old form
- throw new IllegalArgumentException();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaMergeViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaMergeViewer.java
deleted file mode 100644
index d148a62a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaMergeViewer.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IResourceProvider;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.contentmergeviewer.ITokenComparator;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextViewer;
-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.events.DisposeEvent;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.compare.JavaTokenComparator.ITokenComparatorFactory;
-import org.eclipse.wst.jsdt.internal.ui.text.PreferencesAdapter;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptColorConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public class JavaMergeViewer extends TextMergeViewer {
-
- private IPropertyChangeListener fPreferenceChangeListener;
- private IPreferenceStore fPreferenceStore;
- private boolean fUseSystemColors;
- private JavaScriptSourceViewerConfiguration fSourceViewerConfiguration;
- private ArrayList fSourceViewer;
-
-
- public JavaMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
- super(parent, styles | SWT.LEFT_TO_RIGHT, mp);
-
- getPreferenceStore();
-
- fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- if (! fUseSystemColors) {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- RGB fg= createColor(fPreferenceStore, IJavaScriptColorConstants.JAVA_DEFAULT);
- setForegroundColor(fg);
- }
- }
-
- private IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null)
- setPreferenceStore(createChainedPreferenceStore(null));
- return fPreferenceStore;
- }
-
- protected void handleDispose(DisposeEvent event) {
- setPreferenceStore(null);
- fSourceViewer= null;
- super.handleDispose(event);
- }
-
- public IJavaScriptProject getJavaProject(ICompareInput input) {
-
- if (input == null)
- return null;
-
- IResourceProvider rp= null;
- ITypedElement te= input.getLeft();
- if (te instanceof IResourceProvider)
- rp= (IResourceProvider) te;
- if (rp == null) {
- te= input.getRight();
- if (te instanceof IResourceProvider)
- rp= (IResourceProvider) te;
- }
- if (rp == null) {
- te= input.getAncestor();
- if (te instanceof IResourceProvider)
- rp= (IResourceProvider) te;
- }
- if (rp != null) {
- IResource resource= rp.getResource();
- if (resource != null) {
- IJavaScriptElement element= JavaScriptCore.create(resource);
- if (element != null)
- return element.getJavaScriptProject();
- }
- }
- return null;
- }
-
- public void setInput(Object input) {
-
- if (input instanceof ICompareInput) {
- IJavaScriptProject project= getJavaProject((ICompareInput)input);
- if (project != null) {
- setPreferenceStore(createChainedPreferenceStore(project));
- if (fSourceViewer != null) {
- Iterator iterator= fSourceViewer.iterator();
- while (iterator.hasNext()) {
- SourceViewer sourceViewer= (SourceViewer) iterator.next();
- sourceViewer.unconfigure();
- sourceViewer.configure(getSourceViewerConfiguration());
- }
- }
- }
- }
-
- super.setInput(input);
- }
-
- private ChainedPreferenceStore createChainedPreferenceStore(IJavaScriptProject project) {
- ArrayList stores= new ArrayList(4);
- if (project != null)
- stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), JavaScriptCore.PLUGIN_ID));
- stores.add(JavaScriptPlugin.getDefault().getPreferenceStore());
- stores.add(new PreferencesAdapter(JavaScriptCore.getPlugin().getPluginPreferences()));
- stores.add(EditorsUI.getPreferenceStore());
- return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
- }
-
- private void handlePropertyChange(PropertyChangeEvent event) {
-
- String key= event.getProperty();
-
- if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
-
- if (!fUseSystemColors) {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- }
-
- } else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
-
- fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- if (fUseSystemColors) {
- setBackgroundColor(null);
- setForegroundColor(null);
- } else {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- RGB fg= createColor(fPreferenceStore, IJavaScriptColorConstants.JAVA_DEFAULT);
- setForegroundColor(fg);
- }
- } else if (key.equals(IJavaScriptColorConstants.JAVA_DEFAULT)) {
-
- if (!fUseSystemColors) {
- RGB fg= createColor(fPreferenceStore, IJavaScriptColorConstants.JAVA_DEFAULT);
- setForegroundColor(fg);
- }
- }
-
- if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
- fSourceViewerConfiguration.handlePropertyChangeEvent(event);
- invalidateTextPresentation();
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- * @param store preference store
- * @param key preference key
- * @return the color or <code>null</code>
- */
- private static RGB createColor(IPreferenceStore store, String key) {
- if (!store.contains(key))
- return null;
- if (store.isDefault(key))
- return PreferenceConverter.getDefaultColor(store, key);
- return PreferenceConverter.getColor(store, key);
- }
-
- public String getTitle() {
- return CompareMessages.JavaMergeViewer_title;
- }
-
- public ITokenComparator createTokenComparator(String s) {
- return new JavaTokenComparator(s, new ITokenComparatorFactory() {
- public ITokenComparator createTokenComparator(String text) {
- return JavaMergeViewer.super.createTokenComparator(text);
- }
- });
- }
-
- protected IDocumentPartitioner getDocumentPartitioner() {
- return JavaCompareUtilities.createJavaPartitioner();
- }
-
- protected String getDocumentPartitioning() {
- return IJavaScriptPartitions.JAVA_PARTITIONING;
- }
-
- protected void configureTextViewer(TextViewer textViewer) {
- if (textViewer instanceof SourceViewer) {
- if (fSourceViewer == null)
- fSourceViewer= new ArrayList();
- fSourceViewer.add(textViewer);
- JavaScriptTextTools tools= JavaCompareUtilities.getJavaTextTools();
- if (tools != null)
- ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
- }
- }
-
- private JavaScriptSourceViewerConfiguration getSourceViewerConfiguration() {
- if (fSourceViewerConfiguration == null)
- getPreferenceStore();
- return fSourceViewerConfiguration;
- }
-
- protected int findInsertionPosition(char type, ICompareInput input) {
-
- int pos= super.findInsertionPosition(type, input);
- if (pos != 0)
- return pos;
-
- if (input instanceof IDiffElement) {
-
- // find the other (not deleted) element
- JavaNode otherJavaElement= null;
- ITypedElement otherElement= null;
- switch (type) {
- case 'L':
- otherElement= input.getRight();
- break;
- case 'R':
- otherElement= input.getLeft();
- break;
- }
- if (otherElement instanceof JavaNode)
- otherJavaElement= (JavaNode) otherElement;
-
- // find the parent of the deleted elements
- JavaNode javaContainer= null;
- IDiffElement diffElement= (IDiffElement) input;
- IDiffContainer container= diffElement.getParent();
- if (container instanceof ICompareInput) {
-
- ICompareInput parent= (ICompareInput) container;
- ITypedElement element= null;
-
- switch (type) {
- case 'L':
- element= parent.getLeft();
- break;
- case 'R':
- element= parent.getRight();
- break;
- }
-
- if (element instanceof JavaNode)
- javaContainer= (JavaNode) element;
- }
-
- if (otherJavaElement != null && javaContainer != null) {
-
- Object[] children;
- Position p;
-
- switch (otherJavaElement.getTypeCode()) {
-
- case JavaNode.PACKAGE:
- return 0;
-
- case JavaNode.IMPORT_CONTAINER:
- // we have to find the place after the package declaration
- children= javaContainer.getChildren();
- if (children.length > 0) {
- JavaNode packageDecl= null;
- for (int i= 0; i < children.length; i++) {
- JavaNode child= (JavaNode) children[i];
- switch (child.getTypeCode()) {
- case JavaNode.PACKAGE:
- packageDecl= child;
- break;
- case JavaNode.CLASS:
- return child.getRange().getOffset();
- }
- }
- if (packageDecl != null) {
- p= packageDecl.getRange();
- return p.getOffset() + p.getLength();
- }
- }
- return javaContainer.getRange().getOffset();
-
- case JavaNode.IMPORT:
- // append after last import
- p= javaContainer.getRange();
- return p.getOffset() + p.getLength();
-
- case JavaNode.CLASS:
- // append after last class
- children= javaContainer.getChildren();
- if (children.length > 0) {
- for (int i= children.length-1; i >= 0; i--) {
- JavaNode child= (JavaNode) children[i];
- switch (child.getTypeCode()) {
- case JavaNode.CLASS:
- case JavaNode.IMPORT_CONTAINER:
- case JavaNode.PACKAGE:
- case JavaNode.FIELD:
- p= child.getRange();
- return p.getOffset() + p.getLength();
- }
- }
- }
- return javaContainer.getAppendPosition().getOffset();
-
- case JavaNode.METHOD:
- // append in next line after last child
- children= javaContainer.getChildren();
- if (children.length > 0) {
- JavaNode child= (JavaNode) children[children.length-1];
- p= child.getRange();
- return findEndOfLine(javaContainer, p.getOffset() + p.getLength());
- }
- // otherwise use position from parser
- return javaContainer.getAppendPosition().getOffset();
-
- case JavaNode.FIELD:
- // append after last field
- children= javaContainer.getChildren();
- if (children.length > 0) {
- JavaNode method= null;
- for (int i= children.length-1; i >= 0; i--) {
- JavaNode child= (JavaNode) children[i];
- switch (child.getTypeCode()) {
- case JavaNode.METHOD:
- method= child;
- break;
- case JavaNode.FIELD:
- p= child.getRange();
- return p.getOffset() + p.getLength();
- }
- }
- if (method != null)
- return method.getRange().getOffset();
- }
- return javaContainer.getAppendPosition().getOffset();
- }
- }
-
- if (javaContainer != null) {
- // return end of container
- Position p= javaContainer.getRange();
- return p.getOffset() + p.getLength();
- }
- }
-
- // we give up
- return 0;
- }
-
- private int findEndOfLine(JavaNode container, int pos) {
- int line;
- IDocument doc= container.getDocument();
- try {
- line= doc.getLineOfOffset(pos);
- pos= doc.getLineOffset(line+1);
- } catch (BadLocationException ex) {
- // silently ignored
- }
-
- // ensure that position is within container range
- Position containerRange= container.getRange();
- int start= containerRange.getOffset();
- int end= containerRange.getOffset() + containerRange.getLength();
- if (pos < start)
- return start;
- if (pos >= end)
- return end-1;
-
- return pos;
- }
-
- private void setPreferenceStore(IPreferenceStore ps) {
- if (fPreferenceChangeListener != null) {
- if (fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
- fPreferenceChangeListener= null;
- }
- fPreferenceStore= ps;
- if (fPreferenceStore != null) {
- JavaScriptTextTools tools= JavaCompareUtilities.getJavaTextTools();
- fSourceViewerConfiguration= new JavaScriptSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, getDocumentPartitioning());
- fPreferenceChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- handlePropertyChange(event);
- }
- };
- fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java
deleted file mode 100644
index a63fe1d1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-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;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Comparable Java elements are represented as JavaNodes.
- * Extends the DocumentRangeNode with method signature information.
- */
-public class JavaNode extends DocumentRangeNode implements ITypedElement {
-
- public static final int CU= 0;
- public static final int PACKAGE= 1;
- public static final int IMPORT_CONTAINER= 2;
- public static final int IMPORT= 3;
- public static final int INTERFACE= 4;
- public static final int CLASS= 5;
- public static final int ENUM= 6;
- public static final int ANNOTATION= 7;
- public static final int FIELD= 8;
- public static final int INIT= 9;
- public static final int CONSTRUCTOR= 10;
- public static final int METHOD= 11;
-
- private int fInitializerCount= 1;
-
- /**
- * Creates a JavaNode under the given parent.
- * @param parent the parent node
- * @param type the Java elements type. Legal values are from the range CU to METHOD of this class.
- * @param name the name of the Java element
- * @param start the starting position of the java element in the underlying document
- * @param length the number of characters of the java element in the underlying document
- */
- public JavaNode(JavaNode parent, int type, String name, int start, int length) {
- super(parent, type, JavaCompareUtilities.buildID(type, name), parent.getDocument(), start, length);
- parent.addChild(this);
- }
-
- /**
- * Creates a JavaNode for a CU. It represents the root of a
- * JavaNode tree, so its parent is null.
- * @param document the document which contains the Java element
- */
- public JavaNode(IDocument document) {
- super(CU, JavaCompareUtilities.buildID(CU, "root"), document, 0, document.getLength()); //$NON-NLS-1$
- }
-
- public String getInitializerCount() {
- return Integer.toString(fInitializerCount++);
- }
-
- /**
- * Extracts the method name from the signature.
- * Used for smart matching.
- */
- public String extractMethodName() {
- String id= getId();
- int pos= id.indexOf('(');
- if (pos > 0)
- return id.substring(1, pos);
- return id.substring(1);
- }
-
- /**
- * Extracts the method's arguments name the signature.
- * Used for smart matching.
- */
- public String extractArgumentList() {
- String id= getId();
- int pos= id.indexOf('(');
- if (pos >= 0)
- return id.substring(pos+1);
- return id.substring(1);
- }
-
- /**
- * Returns a name which is presented in the UI.
- * @see ITypedElement#getName()
- */
- public String getName() {
-
- switch (getTypeCode()) {
- case INIT:
- return CompareMessages.JavaNode_initializer;
- case IMPORT_CONTAINER:
- return CompareMessages.JavaNode_importDeclarations;
- case CU:
- return CompareMessages.JavaNode_compilationUnit;
- case PACKAGE:
- return CompareMessages.JavaNode_packageDeclaration;
- }
- return getId().substring(1); // we strip away the type character
- }
-
- /*
- * @see ITypedElement#getType()
- */
- public String getType() {
- return "java2"; //$NON-NLS-1$
- }
-
- /**
- * Returns a shared image for this Java element.
- *
- * see ITypedInput.getImage
- */
- public Image getImage() {
-
- ImageDescriptor id= null;
-
- switch (getTypeCode()) {
- case CU:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.JAVASCRIPT_UNIT);
- break;
- case PACKAGE:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.PACKAGE_DECLARATION);
- break;
- case IMPORT:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.IMPORT_DECLARATION);
- break;
- case IMPORT_CONTAINER:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.IMPORT_CONTAINER);
- break;
- case CLASS:
- id= JavaCompareUtilities.getTypeImageDescriptor(true);
- break;
- case INTERFACE:
- id= JavaCompareUtilities.getTypeImageDescriptor(false);
- break;
- case INIT:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.INITIALIZER);
- break;
- case CONSTRUCTOR:
- case METHOD:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.METHOD);
- break;
- case FIELD:
- id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.FIELD);
- break;
- case ENUM:
- id= JavaCompareUtilities.getEnumImageDescriptor();
- break;
- case ANNOTATION:
- id= JavaCompareUtilities.getAnnotationImageDescriptor();
- break;
- }
- return JavaScriptPlugin.getImageDescriptorRegistry().get(id);
- }
-
- /*
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getType() + ": " + getName() //$NON-NLS-1$
- + "[" + getRange().offset + "+" + getRange().length + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaParseTreeBuilder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaParseTreeBuilder.java
deleted file mode 100644
index 64a25ef0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaParseTreeBuilder.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.Iterator;
-import java.util.Stack;
-
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Initializer;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
-
-
-class JavaParseTreeBuilder extends ASTVisitor {
-
- private char[] fBuffer;
- private Stack fStack= new Stack();
- private JavaNode fImportContainer;
- private boolean fShowCU;
-
- /*
- * Parsing is performed on the given buffer and the resulting tree (if any)
- * hangs below the given root.
- */
- JavaParseTreeBuilder(JavaNode root, char[] buffer, boolean showCU) {
- fBuffer= buffer;
- fShowCU= showCU;
- fStack.clear();
- fStack.push(root);
- }
-
- public boolean visit(PackageDeclaration node) {
- new JavaNode(getCurrentContainer(), JavaNode.PACKAGE, null, node.getStartPosition(), node.getLength());
- return false;
- }
-
- public boolean visit(JavaScriptUnit node) {
- if (fShowCU)
- push(JavaNode.CU, null, node.getStartPosition(), node.getLength());
- return true;
- }
-
- public void endVisit(JavaScriptUnit node) {
- if (fShowCU)
- pop();
- }
-
- public boolean visit(TypeDeclaration node) {
- push(node.isInterface() ? JavaNode.INTERFACE : JavaNode.CLASS, node.getName().toString(), node.getStartPosition(), node.getLength());
- return true;
- }
-
- public void endVisit(TypeDeclaration node) {
- pop();
- }
-
-
-
-
-
- public boolean visit(FunctionDeclaration node) {
- String signature= getSignature(node);
- push(node.isConstructor() ? JavaNode.CONSTRUCTOR : JavaNode.METHOD, signature, node.getStartPosition(), node.getLength());
- return false;
- }
-
- public void endVisit(FunctionDeclaration node) {
- pop();
- }
-
- public boolean visit(Initializer node) {
- push(JavaNode.INIT, getCurrentContainer().getInitializerCount(), node.getStartPosition(), node.getLength());
- return false;
- }
-
- public void endVisit(Initializer node) {
- pop();
- }
-
- public boolean visit(ImportDeclaration node) {
- int s= node.getStartPosition();
- int l= node.getLength();
- int declarationEnd= s + l;
- if (fImportContainer == null)
- fImportContainer= new JavaNode(getCurrentContainer(), JavaNode.IMPORT_CONTAINER, null, s, l);
- String nm= node.getName().toString();
- if (node.isOnDemand())
- nm+= ".*"; //$NON-NLS-1$
- new JavaNode(fImportContainer, JavaNode.IMPORT, nm, s, l);
- fImportContainer.setLength(declarationEnd - fImportContainer.getRange().getOffset() + 1);
- fImportContainer.setAppendPosition(declarationEnd + 2); // FIXME
- return false;
- }
-
- public boolean visit(VariableDeclarationFragment node) {
- String name= getFieldName(node);
- ASTNode parent= node.getParent();
- push(JavaNode.FIELD, name, parent.getStartPosition(), parent.getLength());
- return false;
- }
-
- public void endVisit(VariableDeclarationFragment node) {
- pop();
- }
-
- // private stuff
-
- /**
- * Adds a new JavaNode with the given type and name to the current
- * container.
- */
- private void push(int type, String name, int declarationStart, int length) {
-
- while (declarationStart > 0) {
- char c= fBuffer[declarationStart - 1];
- if (c != ' ' && c != '\t')
- break;
- declarationStart--;
- length++;
- }
-
- JavaNode node= new JavaNode(getCurrentContainer(), type, name, declarationStart, length);
- if (type == JavaNode.CU)
- node.setAppendPosition(declarationStart + length + 1);
- else
- node.setAppendPosition(declarationStart + length);
-
- fStack.push(node);
- }
-
- /**
- * Closes the current Java node by setting its end position and pops it off
- * the stack.
- */
- private void pop() {
- fStack.pop();
- }
-
- private JavaNode getCurrentContainer() {
- return (JavaNode) fStack.peek();
- }
-
- private String getFieldName(VariableDeclarationFragment node) {
- StringBuffer buffer= new StringBuffer();
- buffer.append(node.getName().toString());
- ASTNode parent= node.getParent();
- if (parent instanceof FieldDeclaration) {
- FieldDeclaration fd= (FieldDeclaration) parent;
- buffer.append(" : "); //$NON-NLS-1$
- buffer.append(getType(fd.getType()));
- }
- return buffer.toString();
- }
-
- private String getSignature(FunctionDeclaration node) {
- StringBuffer buffer= new StringBuffer();
- SimpleName name = node.getName();
- if (name!=null)
- buffer.append(name.toString());
-
- buffer.append('(');
- boolean first= true;
- Iterator iterator= node.parameters().iterator();
- while (iterator.hasNext()) {
- Object parameterDecl= iterator.next();
- if (parameterDecl instanceof SingleVariableDeclaration) {
- SingleVariableDeclaration svd= (SingleVariableDeclaration) parameterDecl;
- if (!first)
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(getType(svd.getType()));
- if (svd.isVarargs())
- buffer.append("..."); //$NON-NLS-1$
- first= false;
- }
- }
- buffer.append(')');
- return buffer.toString();
- }
-
-
- private String getType(Type type) {
- String name= type.toString();
- int pos= name.lastIndexOf('.');
- if (pos >= 0)
- name= name.substring(pos + 1);
- return name;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionAction.java
deleted file mode 100644
index ad083b55..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-/**
- * Provides "Replace from local history" for Java elements.
- */
-public class JavaReplaceWithEditionAction extends JavaHistoryAction {
-
- public JavaReplaceWithEditionAction() {
- }
-
- protected JavaHistoryActionImpl createDelegate() {
- return new JavaReplaceWithEditionActionImpl(false);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionActionImpl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionActionImpl.java
deleted file mode 100644
index 74c56050..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithEditionActionImpl.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.ui.history.ElementLocalHistoryPageSource;
-import org.eclipse.team.ui.history.HistoryPageCompareEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.wst.jsdt.internal.corext.SourceRange;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.util.Resources;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-
-/**
- * Provides "Replace from local history" for Java elements.
- */
-class JavaReplaceWithEditionActionImpl extends JavaHistoryActionImpl {
-
- protected boolean fPrevious= false;
-
- JavaReplaceWithEditionActionImpl(boolean previous) {
- super(true);
- fPrevious= previous;
- }
-
- public void run(ISelection selection) {
-
- Shell shell= getShell();
-
- final IMember input= getEditionElement(selection);
- if (input == null) {
- MessageDialog.openInformation(shell, CompareMessages.ReplaceFromHistory_title, CompareMessages.ReplaceFromHistory_invalidSelectionMessage);
- return;
- }
-
- final IFile file= getFile(input);
- if (file == null) {
- showError();
- return;
- }
-
- IStatus status= Resources.makeCommittable(file, shell);
- if (!status.isOK()) {
- return;
- }
-
- if (fPrevious) {
- String errorTitle= CompareMessages.ReplaceFromHistory_title;
- String errorMessage= CompareMessages.ReplaceFromHistory_internalErrorMessage;
- try {
- ITypedElement ti = ElementLocalHistoryPageSource.getPreviousEdition(file, input);
- if (ti == null) {
- MessageDialog.openInformation(shell, errorTitle, CompareMessages.ReplaceFromHistory_parsingErrorMessage);
- return;
- }
- replace(input, file, ti);
- } catch (TeamException e) {
- ExceptionHandler.handle(e, shell, errorTitle, errorMessage);
- }
- } else {
- JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
- CompareConfiguration cc = new CompareConfiguration();
- cc.setLeftEditable(false);
- cc.setRightEditable(false);
- HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input) {
- protected void performReplace(Object selectedElement) {
- if (selectedElement instanceof ITypedElement) {
- JavaReplaceWithEditionActionImpl.this.replace(input, file, (ITypedElement)selectedElement);
- }
- }
- };
- ci.setReplace(true);
- ci.setTitle(CompareMessages.JavaReplaceWithEditionActionImpl_0);
- ci.setHelpContextId(IJavaHelpContextIds.REPLACE_ELEMENT_WITH_HISTORY_DIALOG);
- CompareUI.openCompareDialog(ci);
- }
- }
-
- public void replace(IMember input, IFile file, ITypedElement element) {
-
- Shell shell= getShell();
-
- String errorTitle= CompareMessages.ReplaceFromHistory_title;
- String errorMessage= CompareMessages.ReplaceFromHistory_internalErrorMessage;
-
- // get the document where to insert the text
- IPath path= file.getFullPath();
- ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager();
- ITextFileBuffer textFileBuffer= null;
- try {
- bufferManager.connect(path, LocationKind.IFILE, null);
- textFileBuffer= bufferManager.getTextFileBuffer(path, LocationKind.IFILE);
- IDocument document= textFileBuffer.getDocument();
- performReplace(input, file, textFileBuffer, document, element);
- } catch(InvocationTargetException ex) {
- ExceptionHandler.handle(ex, shell, errorTitle, errorMessage);
-
- } catch(InterruptedException ex) {
- // shouldn't be called because is not cancelable
- Assert.isTrue(false);
-
- } catch(CoreException ex) {
- ExceptionHandler.handle(ex, shell, errorTitle, errorMessage);
-
- } finally {
- try {
- if (textFileBuffer != null)
- bufferManager.disconnect(path, LocationKind.IFILE, null);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- private void performReplace(IMember input, IFile file,
- ITextFileBuffer textFileBuffer, IDocument document, ITypedElement ti)
- throws CoreException, JavaScriptModelException,
- InvocationTargetException, InterruptedException {
-
- if (ti instanceof IStreamContentAccessor) {
-
- boolean inEditor= beingEdited(file);
-
- String content= JavaCompareUtilities.readString((IStreamContentAccessor)ti);
- String newContent= trimTextBlock(content, TextUtilities.getDefaultLineDelimiter(document), input.getJavaScriptProject());
- if (newContent == null) {
- showError();
- return;
- }
-
- IJavaScriptUnit compilationUnit= input.getJavaScriptUnit();
- JavaScriptUnit root= parsePartialCompilationUnit(compilationUnit);
-
-
- final ISourceRange nameRange= input.getNameRange();
- // workaround for bug in getNameRange(): for AnnotationMembers length is negative
- int length= nameRange.getLength();
- if (length < 0)
- length= 1;
- ASTNode node2= NodeFinder.perform(root, new SourceRange(nameRange.getOffset(), length));
- ASTNode node= ASTNodes.getParent(node2, BodyDeclaration.class);
-
- //ASTNode node= getBodyContainer(root, input);
- if (node == null) {
- showError();
- return;
- }
-
- ASTRewrite rewriter= ASTRewrite.create(root.getAST());
- rewriter.replace(node, rewriter.createStringPlaceholder(newContent, node.getNodeType()), null);
-
- if (inEditor) {
- JavaEditor je= getEditor(file);
- if (je != null)
- je.setFocus();
- }
-
- Map options= null;
- IJavaScriptProject javaProject= compilationUnit.getJavaScriptProject();
- if (javaProject != null)
- options= javaProject.getOptions(true);
- applyChanges(rewriter, document, textFileBuffer, getShell(), inEditor, options);
-
- }
- }
-
- private void showError() {
- MessageDialog.openError(getShell(), CompareMessages.ReplaceFromHistory_title, CompareMessages.ReplaceFromHistory_internalErrorMessage);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithPreviousEditionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithPreviousEditionAction.java
deleted file mode 100644
index e11639a0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaReplaceWithPreviousEditionAction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-/**
- * Provides "Replace from local history" for Java elements.
- */
-public class JavaReplaceWithPreviousEditionAction extends JavaHistoryAction {
-
- public JavaReplaceWithPreviousEditionAction() {
- }
-
- protected JavaHistoryActionImpl createDelegate() {
- return new JavaReplaceWithEditionActionImpl(true);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureCreator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureCreator.java
deleted file mode 100644
index 0bd482dd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureCreator.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.IEditableContent;
-import org.eclipse.compare.IEditableContentExtension;
-import org.eclipse.compare.IResourceProvider;
-import org.eclipse.compare.ISharedDocumentAdapter;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.StructureCreator;
-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.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.services.IDisposable;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTParser;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-public class JavaStructureCreator extends StructureCreator {
-
- private Map fDefaultCompilerOptions;
-
- /**
- * A root node for the structure. It is similar to {@link org.eclipse.compare.structuremergeviewer.StructureRootNode} but needed
- * to be a subclass of {@link JavaNode} because of the code used to build the structure.
- */
- private final class RootJavaNode extends JavaNode implements IDisposable {
-
- private final Object fInput;
- private final boolean fEditable;
- private final ISharedDocumentAdapter fAdapter;
-
- private RootJavaNode(IDocument document, boolean editable, Object input, ISharedDocumentAdapter adapter) {
- super(document);
- this.fEditable = editable;
- fInput= input;
- fAdapter= adapter;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#isEditable()
- */
- public boolean isEditable() {
- return fEditable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#nodeChanged(org.eclipse.compare.structuremergeviewer.DocumentRangeNode)
- */
- protected void nodeChanged(DocumentRangeNode node) {
- save(this, fInput);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.services.IDisposable#dispose()
- */
- public void dispose() {
- if (fAdapter != null) {
- fAdapter.disconnect(fInput);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter == ISharedDocumentAdapter.class) {
- return fAdapter;
- }
- return super.getAdapter(adapter);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#isReadOnly()
- */
- public boolean isReadOnly() {
- if (fInput instanceof IEditableContentExtension) {
- IEditableContentExtension ext = (IEditableContentExtension) fInput;
- return ext.isReadOnly();
- }
- return super.isReadOnly();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#validateEdit(org.eclipse.swt.widgets.Shell)
- */
- public IStatus validateEdit(Shell shell) {
- if (fInput instanceof IEditableContentExtension) {
- IEditableContentExtension ext = (IEditableContentExtension) fInput;
- return ext.validateEdit(shell);
- }
- return super.validateEdit(shell);
- }
- }
-
- /**
- * RewriteInfos are used temporarily when rewriting the diff tree
- * in order to combine similar diff nodes ("smart folding").
- */
- static class RewriteInfo {
-
- boolean fIsOut= false;
-
- JavaNode fAncestor= null;
- JavaNode fLeft= null;
- JavaNode fRight= null;
-
- ArrayList fChildren= new ArrayList();
-
- void add(IDiffElement diff) {
- fChildren.add(diff);
- }
-
- void setDiff(ICompareInput diff) {
- if (fIsOut)
- return;
-
- fIsOut= true;
-
- JavaNode a= (JavaNode) diff.getAncestor();
- JavaNode y= (JavaNode) diff.getLeft();
- JavaNode m= (JavaNode) diff.getRight();
-
- if (a != null) {
- if (fAncestor != null)
- return;
- fAncestor= a;
- }
- if (y != null) {
- if (fLeft != null)
- return;
- fLeft= y;
- }
- if (m != null) {
- if (fRight != null)
- return;
- fRight= m;
- }
-
- fIsOut= false;
- }
-
- /**
- * @return true if some nodes could be successfully combined into one
- */
- boolean matches() {
- return !fIsOut && fAncestor != null && fLeft != null && fRight != null;
- }
- }
-
- public JavaStructureCreator() {
- }
-
- void setDefaultCompilerOptions(Map compilerSettings) {
- fDefaultCompilerOptions= compilerSettings;
- }
-
- /**
- * @return the name that appears in the enclosing pane title bar
- */
- public String getName() {
- return CompareMessages.JavaStructureViewer_title;
- }
-
- /**
- * @param input implement the IStreamContentAccessor interface
- * @return a tree of JavaNodes for the given input.
- * In case of error null is returned.
- */
- public IStructureComparator getStructure(final Object input) {
- String contents= null;
- char[] buffer= null;
- IDocument doc= CompareUI.getDocument(input);
- if (doc == null) {
- if (input instanceof IStreamContentAccessor) {
- IStreamContentAccessor sca= (IStreamContentAccessor) input;
- try {
- contents= JavaCompareUtilities.readString(sca);
- } catch (CoreException ex) {
- // return null indicates the error.
- return null;
- }
- }
-
- if (contents != null) {
- int n= contents.length();
- buffer= new char[n];
- contents.getChars(0, n, buffer, 0);
-
- doc= new Document(contents);
- setupDocument(doc);
- }
- }
-
- return createStructureComparator(input, buffer, doc, null, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.StructureCreator#createStructureComparator(java.lang.Object, org.eclipse.jface.text.IDocument, org.eclipse.compare.ISharedDocumentAdapter, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStructureComparator createStructureComparator(Object element,
- IDocument document, ISharedDocumentAdapter sharedDocumentAdapter,
- IProgressMonitor monitor) throws CoreException {
- return createStructureComparator(element, null, document, sharedDocumentAdapter, monitor);
- }
-
- private IStructureComparator createStructureComparator(final Object input, char[] buffer, IDocument doc, ISharedDocumentAdapter adapter, IProgressMonitor monitor) {
- String contents;
- Map compilerOptions= null;
-
- if (input instanceof IResourceProvider) {
- IResource resource= ((IResourceProvider) input).getResource();
- if (resource != null) {
- IJavaScriptElement element= JavaScriptCore.create(resource);
- if (element != null) {
- IJavaScriptProject javaProject= element.getJavaScriptProject();
- if (javaProject != null)
- compilerOptions= javaProject.getOptions(true);
- }
- }
- }
- if (compilerOptions == null)
- compilerOptions= fDefaultCompilerOptions;
-
- if (doc != null) {
- boolean isEditable= false;
- if (input instanceof IEditableContent)
- isEditable= ((IEditableContent) input).isEditable();
-
- // we hook into the root node to intercept all node changes
- JavaNode root= new RootJavaNode(doc, isEditable, input, adapter);
-
- if (buffer == null) {
- contents= doc.get();
- int n= contents.length();
- buffer= new char[n];
- contents.getChars(0, n, buffer, 0);
- }
-
- ASTParser parser= ASTParser.newParser(AST.JLS3);
- if (compilerOptions != null)
- parser.setCompilerOptions(compilerOptions);
- parser.setSource(buffer);
- parser.setFocalPosition(0);
- JavaScriptUnit cu= (JavaScriptUnit) parser.createAST(monitor);
- cu.accept(new JavaParseTreeBuilder(root, buffer, true));
-
- return root;
- }
- return null;
- }
-
- /**
- * Returns the contents of the given node as a string.
- * This string is used to test the content of a Java element
- * for equality. Is is never shown in the UI, so any string representing
- * the content will do.
- * @param node must implement the IStreamContentAccessor interface
- * @param ignoreWhiteSpace if true all Java white space (including comments) is removed from the contents.
- * @return contents for equality test
- */
- public String getContents(Object node, boolean ignoreWhiteSpace) {
-
- if (! (node instanceof IStreamContentAccessor))
- return null;
-
- IStreamContentAccessor sca= (IStreamContentAccessor) node;
- String content= null;
- try {
- content= JavaCompareUtilities.readString(sca);
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- return null;
- }
-
- if (ignoreWhiteSpace) { // we return everything but Java whitespace
-
- // replace comments and whitespace by a single blank
- StringBuffer buf= new StringBuffer();
- char[] b= content.toCharArray();
-
- // to avoid the trouble when dealing with Unicode
- // we use the Java scanner to extract non-whitespace and non-comment tokens
- IScanner scanner= ToolFactory.createScanner(true, true, false, false); // however we request Whitespace and Comments
- scanner.setSource(b);
- try {
- int token;
- while ((token= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) {
- switch (token) {
- case ITerminalSymbols.TokenNameWHITESPACE:
- int l= buf.length();
- if (l > 0 && buf.charAt(l-1) != ' ')
- buf.append(' ');
- break;
- default:
- buf.append(scanner.getCurrentTokenSource());
- buf.append(' ');
- break;
- }
- }
- content= buf.toString(); // success!
- } catch (InvalidInputException ex) {
- // NeedWork
- }
- }
- return content;
- }
-
- /**
- * @return true since this IStructureCreator can rewrite the diff tree
- * in order to fold certain combinations of additions and deletions.
- */
- public boolean canRewriteTree() {
- return true;
- }
-
- /**
- * Tries to detect certain combinations of additions and deletions
- * as renames or signature changes and folders them into a single node.
- * @param differencer
- * @param root
- */
- public void rewriteTree(Differencer differencer, IDiffContainer root) {
-
- HashMap map= new HashMap(10);
-
- Object[] children= root.getChildren();
- for (int i= 0; i < children.length; i++) {
- DiffNode diff= (DiffNode) children[i];
- JavaNode jn= (JavaNode) diff.getId();
-
- if (jn == null)
- continue;
- int type= jn.getTypeCode();
-
- // we can only combine methods or constructors
- if (type == JavaNode.METHOD || type == JavaNode.CONSTRUCTOR) {
-
- // find or create a RewriteInfo for all methods with the same name
- String name= jn.extractMethodName();
- RewriteInfo nameInfo= (RewriteInfo) map.get(name);
- if (nameInfo == null) {
- nameInfo= new RewriteInfo();
- map.put(name, nameInfo);
- }
- nameInfo.add(diff);
-
- // find or create a RewriteInfo for all methods with the same
- // (non-empty) argument list
- String argList= jn.extractArgumentList();
- RewriteInfo argInfo= null;
- if (argList != null && !argList.equals("()")) { //$NON-NLS-1$
- argInfo= (RewriteInfo) map.get(argList);
- if (argInfo == null) {
- argInfo= new RewriteInfo();
- map.put(argList, argInfo);
- }
- argInfo.add(diff);
- }
-
- switch (diff.getKind() & Differencer.CHANGE_TYPE_MASK) {
- case Differencer.ADDITION:
- case Differencer.DELETION:
- // we only consider addition and deletions
- // since a rename or argument list change looks
- // like a pair of addition and deletions
- if (type != JavaNode.CONSTRUCTOR)
- nameInfo.setDiff(diff);
-
- if (argInfo != null)
- argInfo.setDiff(diff);
- break;
- default:
- break;
- }
- }
-
- // recurse
- rewriteTree(differencer, diff);
- }
-
- // now we have to rebuild the diff tree according to the combined
- // changes
- Iterator it= map.keySet().iterator();
- while (it.hasNext()) {
- String name= (String) it.next();
- RewriteInfo i= (RewriteInfo) map.get(name);
- if (i.matches()) { // we found a RewriteInfo that could be successfully combined
-
- // we have to find the differences of the newly combined node
- // (because in the first pass we only got a deletion and an addition)
- DiffNode d= (DiffNode) differencer.findDifferences(true, null, root, i.fAncestor, i.fLeft, i.fRight);
- if (d != null) {// there better should be a difference
- d.setDontExpand(true);
- Iterator it2= i.fChildren.iterator();
- while (it2.hasNext()) {
- IDiffElement rd= (IDiffElement) it2.next();
- root.removeToRoot(rd);
- d.add(rd);
- }
- }
- }
- }
- }
-
- /**
- * The JavaHistoryAction uses this function to determine whether
- * a selected Java element can be replaced by some piece of
- * code from the local history.
- * @param je Java element
- * @return true if the given IJavaScriptElement maps to a JavaNode
- */
- static boolean hasEdition(IJavaScriptElement je) {
- return JavaElementHistoryPageSource.hasEdition(je);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioner()
- */
- protected IDocumentPartitioner getDocumentPartitioner() {
- return JavaCompareUtilities.createJavaPartitioner();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioning()
- */
- protected String getDocumentPartitioning() {
- return IJavaScriptPartitions.JAVA_PARTITIONING;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.StructureCreator#getPath(java.lang.Object, java.lang.Object)
- */
- protected String[] getPath(Object element, Object input) {
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement je = (IJavaScriptElement) element;
- // build a path starting at the given Java element and walk
- // up the parent chain until we reach a IWorkingCopy or IJavaScriptUnit
- List args= new ArrayList();
- while (je != null) {
- // each path component has a name that uses the same
- // conventions as a JavaNode name
- String name= JavaCompareUtilities.getJavaElementID(je);
- if (name == null)
- return null;
- args.add(name);
- if (je instanceof IJavaScriptUnit)
- break;
- je= je.getParent();
- }
-
- // revert the path
- int n= args.size();
- String[] path= new String[n];
- for (int i= 0; i < n; i++)
- path[i]= (String) args.get(n-1-i);
-
- return path;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewer.java
deleted file mode 100644
index 00c3aa12..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewer.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareViewerPane;
-import org.eclipse.compare.IResourceProvider;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-class JavaStructureDiffViewer extends StructureDiffViewer {
-
- /**
- * Toggles a boolean property of an <code>CompareConfiguration</code>.
- */
- static class ChangePropertyAction extends Action {
-
- private CompareConfiguration fCompareConfiguration;
- private String fPropertyKey;
- private ResourceBundle fBundle;
- private String fPrefix;
-
-
- public ChangePropertyAction(ResourceBundle bundle, CompareConfiguration cc, String rkey, String pkey) {
- fPropertyKey= pkey;
- fBundle= bundle;
- fPrefix= rkey;
- JavaCompareUtilities.initAction(this, fBundle, fPrefix);
- setCompareConfiguration(cc);
- }
-
- public void run() {
- boolean b= !JavaCompareUtilities.getBoolean(fCompareConfiguration, fPropertyKey, false);
- setChecked(b);
- if (fCompareConfiguration != null)
- fCompareConfiguration.setProperty(fPropertyKey, new Boolean(b));
- }
-
- public void setChecked(boolean state) {
- super.setChecked(state);
- JavaCompareUtilities.initToggleAction(this, fBundle, fPrefix, state);
- }
-
- public void setCompareConfiguration(CompareConfiguration cc) {
- fCompareConfiguration= cc;
- setChecked(JavaCompareUtilities.getBoolean(fCompareConfiguration, fPropertyKey, false));
- }
- }
-
- private static final String SMART= "SMART"; //$NON-NLS-1$
-
- private ActionContributionItem fSmartActionItem;
- private JavaStructureCreator fStructureCreator;
- private boolean fThreeWay;
-
- public JavaStructureDiffViewer(Composite parent, CompareConfiguration configuration) {
- super(parent, configuration);
- fStructureCreator= new JavaStructureCreator();
- setStructureCreator(fStructureCreator);
- }
-
- /**
- * Overridden to find and expand the first class.
- */
- protected void initialSelection() {
- Object firstClass= null;
- Object o= getRoot();
- if (o != null) {
- Object[] children= getSortedChildren(o);
- if (children != null && children.length > 0) {
- for (int i= 0; i < children.length; i++) {
- o= children[i];
- Object[] sortedChildren= getSortedChildren(o);
- if (sortedChildren != null && sortedChildren.length > 0) {
- for (int j= 0; j < sortedChildren.length; j++) {
- o= sortedChildren[j];
- if (o instanceof DiffNode) {
- DiffNode dn= (DiffNode) o;
- ITypedElement e= dn.getId();
- if (e instanceof JavaNode) {
- JavaNode jn= (JavaNode) e;
- int tc= jn.getTypeCode();
- if (tc == JavaNode.CLASS || tc == JavaNode.INTERFACE) {
- firstClass= dn;
- }
- }
- }
- }
- }
- }
- }
- }
- if (firstClass != null)
- expandToLevel(firstClass, 1);
- else
- expandToLevel(2);
- }
-
- protected void compareInputChanged(ICompareInput input) {
-
- fThreeWay= input != null ? input.getAncestor() != null
- : false;
- setSmartButtonVisible(fThreeWay);
-
- if (input != null) {
- Map compilerOptions= getCompilerOptions(input.getAncestor());
- if (compilerOptions == null)
- compilerOptions= getCompilerOptions(input.getLeft());
- if (compilerOptions == null)
- compilerOptions= getCompilerOptions(input.getRight());
- if (compilerOptions != null)
- fStructureCreator.setDefaultCompilerOptions(compilerOptions);
- }
-
- super.compareInputChanged(input);
- }
-
- private Map getCompilerOptions(ITypedElement input) {
- if (input instanceof IResourceProvider) {
- IResource resource= ((IResourceProvider) input).getResource();
- if (resource != null) {
- IJavaScriptElement element= JavaScriptCore.create(resource);
- if (element != null) {
- IJavaScriptProject javaProject= element.getJavaScriptProject();
- if (javaProject != null)
- return javaProject.getOptions(true);
- }
- }
- }
- return null;
- }
-
- /**
- * Overriden to create a "smart" button in the viewer's pane control bar.
- * <p>
- * Clients can override this method and are free to decide whether they want to call
- * the inherited method.
- *
- * @param toolBarManager the toolbar manager for which to add the buttons
- */
- protected void createToolItems(ToolBarManager toolBarManager) {
-
- super.createToolItems(toolBarManager);
-
- IAction a= new ChangePropertyAction(getBundle(), getCompareConfiguration(), "action.Smart.", SMART); //$NON-NLS-1$
- fSmartActionItem= new ActionContributionItem(a);
- fSmartActionItem.setVisible(fThreeWay);
- toolBarManager.appendToGroup("modes", fSmartActionItem); //$NON-NLS-1$
- }
-
- protected void postDiffHook(Differencer differencer, IDiffContainer root, IProgressMonitor monitor) {
- if (fStructureCreator.canRewriteTree()) {
- boolean smart= JavaCompareUtilities.getBoolean(getCompareConfiguration(), SMART, false);
- if (smart && root != null)
- fStructureCreator.rewriteTree(differencer, root);
- }
- }
-
- /**
- * Tracks property changes of the configuration object.
- * Clients may override to track their own property changes.
- * In this case they must call the inherited method.
- */
- protected void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(SMART))
- diff();
- else
- super.propertyChange(event);
- }
-
- private void setSmartButtonVisible(boolean visible) {
- if (fSmartActionItem == null)
- return;
- Control c= getControl();
- if (c == null || c.isDisposed())
- return;
-
- fSmartActionItem.setVisible(visible);
- ToolBarManager tbm= CompareViewerPane.getToolBarManager(c.getParent());
- if (tbm != null) {
- tbm.update(true);
- ToolBar tb= tbm.getControl();
- if (!tb.isDisposed())
- tb.getParent().layout(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewerCreator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewerCreator.java
deleted file mode 100644
index bf367eda..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaStructureDiffViewerCreator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A factory object for the <code>JavaStructureDiffViewer</code>.
- * This indirection is necessary because only objects with a default
- * constructor can be created via an extension point
- * (this precludes Viewers).
- */
-public class JavaStructureDiffViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration cc) {
- return new JavaStructureDiffViewer(parent, cc);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextBufferNode.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextBufferNode.java
deleted file mode 100644
index 8c107528..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextBufferNode.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.eclipse.compare.HistoryItem;
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.IResourceProvider;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.ResourceNode;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFileState;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Implements the IStreamContentAccessor and ITypedElement protocols
- * for a TextBuffer.
- */
-class JavaTextBufferNode implements ITypedElement, IEncodedStreamContentAccessor, IResourceProvider {
-
- private IFile fFile;
- private IDocument fDocument;
- private boolean fInEditor;
-
- JavaTextBufferNode(IFile file, IDocument document, boolean inEditor) {
- fFile= file;
- fDocument= document;
- fInEditor= inEditor;
- }
-
- public String getName() {
- if (fInEditor)
- return CompareMessages.Editor_Buffer;
- return CompareMessages.Workspace_File;
- }
-
- public String getType() {
- return "java"; //$NON-NLS-1$
- }
-
- public Image getImage() {
- return null;
- }
-
- public InputStream getContents() {
- return new ByteArrayInputStream(JavaCompareUtilities.getBytes(fDocument.get(), "UTF-16")); //$NON-NLS-1$
- }
-
- public String getCharset() {
- return "UTF-16"; //$NON-NLS-1$
- }
-
- public IResource getResource() {
- return fFile;
- }
-
- static final ITypedElement[] buildEditions(ITypedElement target, IFile file) {
-
- // setup array of editions
- IFileState[] states= null;
- // add available editions
- try {
- states= file.getHistory(null);
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- }
-
- int count= 1;
- if (states != null)
- count+= states.length;
-
- ITypedElement[] editions= new ITypedElement[count];
- editions[0]= new ResourceNode(file);
- if (states != null)
- for (int i= 0; i < states.length; i++)
- editions[i+1]= new HistoryItem(target, states[i]);
- return editions;
- }
-
- /**
- * Returns the corresponding place holder type for the given element.
- * @return a place holder type (see ASTRewrite) or -1 if there is no corresponding placeholder
- */
- static final int getPlaceHolderType(ITypedElement element) {
-
- if (element instanceof DocumentRangeNode) {
- JavaNode jn= (JavaNode) element;
- switch (jn.getTypeCode()) {
-
- case JavaNode.PACKAGE:
- return ASTNode.PACKAGE_DECLARATION;
-
- case JavaNode.CLASS:
- case JavaNode.INTERFACE:
- return ASTNode.TYPE_DECLARATION;
-
-
- case JavaNode.CONSTRUCTOR:
- case JavaNode.METHOD:
- return ASTNode.FUNCTION_DECLARATION;
-
- case JavaNode.FIELD:
- return ASTNode.FIELD_DECLARATION;
-
- case JavaNode.INIT:
- return ASTNode.INITIALIZER;
-
- case JavaNode.IMPORT:
- case JavaNode.IMPORT_CONTAINER:
- return ASTNode.IMPORT_DECLARATION;
-
- case JavaNode.CU:
- return ASTNode.JAVASCRIPT_UNIT;
- }
- }
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewer.java
deleted file mode 100644
index 29e26579..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public class JavaTextViewer extends Viewer {
-
- private SourceViewer fSourceViewer;
- private Object fInput;
-
-
- JavaTextViewer(Composite parent) {
- fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
- JavaScriptTextTools tools= JavaCompareUtilities.getJavaTextTools();
- if (tools != null) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSourceViewer.configure(new JavaScriptSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING));
- }
-
- fSourceViewer.setEditable(false);
-
- String symbolicFontName= JavaMergeViewer.class.getName();
- Font font= JFaceResources.getFont(symbolicFontName);
- if (font != null)
- fSourceViewer.getTextWidget().setFont(font);
-
- }
-
- public Control getControl() {
- return fSourceViewer.getControl();
- }
-
- public void setInput(Object input) {
- if (input instanceof IStreamContentAccessor) {
- Document document= new Document(getString(input));
- JavaCompareUtilities.setupDocument(document);
- fSourceViewer.setDocument(document);
- }
- fInput= input;
- }
-
- public Object getInput() {
- return fInput;
- }
-
- public ISelection getSelection() {
- return null;
- }
-
- public void setSelection(ISelection s, boolean reveal) {
- }
-
- public void refresh() {
- }
-
- /**
- * A helper method to retrieve the contents of the given object
- * if it implements the IStreamContentAccessor interface.
- */
- private static String getString(Object input) {
-
- if (input instanceof IStreamContentAccessor) {
- IStreamContentAccessor sca= (IStreamContentAccessor) input;
- try {
- return JavaCompareUtilities.readString(sca);
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- }
- }
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewerCreator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewerCreator.java
deleted file mode 100644
index 2f2b98a3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTextViewerCreator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Composite;
-
-
-/**
- * A factory object for the <code>JavaTextViewer</code>.
- * This indirection is necessary because only objects with a default
- * constructor can be created via an extension point
- * (this precludes Viewers).
- */
-public class JavaTextViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new JavaTextViewer(parent);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTokenComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTokenComparator.java
deleted file mode 100644
index 340fb536..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaTokenComparator.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.contentmergeviewer.ITokenComparator;
-import org.eclipse.compare.rangedifferencer.IRangeComparator;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.internal.corext.dom.TokenScanner;
-
-
-/**
- * A comparator for Java tokens.
- */
-public class JavaTokenComparator implements ITokenComparator {
-
- /**
- * Factory to create text token comparators.
- * This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=183224 .
- */
- public static interface ITokenComparatorFactory {
- /**
- * @param text text to be tokenized
- * @return a token comparator
- */
- public ITokenComparator createTokenComparator(String text);
- }
-
- private static final boolean DEBUG= false;
-
- private final String fText;
- private final ITokenComparatorFactory fTextTokenComparatorFactory;
- private int fCount;
- private int[] fStarts;
- private int[] fLengths;
-
- /**
- * Creates a token comparator for the given string.
- *
- * @param text the text to be tokenized
- */
- public JavaTokenComparator(String text) {
- this(text, null);
- }
-
- /**
- * Creates a token comparator for the given string.
- *
- * @param text the text to be tokenized
- * @param textTokenComparatorFactory a factory to create text token comparators
- */
- public JavaTokenComparator(String text, ITokenComparatorFactory textTokenComparatorFactory) {
-
- fTextTokenComparatorFactory= textTokenComparatorFactory;
- Assert.isLegal(text != null);
-
- fText= text;
-
- int length= fText.length();
- fStarts= new int[length];
- fLengths= new int[length];
- fCount= 0;
-
- IScanner scanner= ToolFactory.createScanner(true, true, false, false); // returns comments & whitespace
- scanner.setSource(fText.toCharArray());
- int endPos= 0;
- try {
- int tokenType;
- while ((tokenType= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) {
- int start= scanner.getCurrentTokenStartPosition();
- int end= scanner.getCurrentTokenEndPosition()+1;
- // Comments are treated as a single token (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=78063)
- if (TokenScanner.isComment(tokenType) || tokenType == ITerminalSymbols.TokenNameStringLiteral) {
- int dl= fTextTokenComparatorFactory == null ? getCommentStartTokenLength(tokenType) : 0;
- recordTokenRange(start, dl);
- parseText(start + dl, text.substring(start + dl, end));
- } else {
- recordTokenRange(start, end - start);
- }
- endPos= end;
- }
- } catch (InvalidInputException ex) {
- // We couldn't parse part of the input. Fall through and make the rest a single token
- }
- // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=13907
- if (endPos < length) {
- recordTokenRange(endPos, length - endPos);
- }
- }
-
- /**
- * Records the given token range.
- *
- * @param start of the token
- * @param length length of the token
- *
- */
- private void recordTokenRange(int start, int length) {
- fStarts[fCount]= start;
- fLengths[fCount]= length;
- fCount++;
- if (DEBUG)
- System.out.println(fText.substring(start, start + length));
- }
-
- private void parseText(int start, String text) {
- ITokenComparator subTokenizer= fTextTokenComparatorFactory == null
- ? new JavaTokenComparator(text)
- : fTextTokenComparatorFactory.createTokenComparator(text);
- int count= subTokenizer.getRangeCount();
- for (int i= 0; i < count; i++) {
- int subStart= subTokenizer.getTokenStart(i);
- int subLength= subTokenizer.getTokenLength(i);
- recordTokenRange(start + subStart, subLength);
- }
- }
-
- /**
- * Returns the length of the token that
- * initiates the given comment type.
- *
- * @param tokenType
- * @return the length of the token that start a comment
- *
- */
- private static int getCommentStartTokenLength(int tokenType) {
- if (tokenType == ITerminalSymbols.TokenNameCOMMENT_JAVADOC) {
- return 3;
- } else if (tokenType == ITerminalSymbols.TokenNameStringLiteral) {
- return 1;
- } else {
- return 2;
- }
- }
-
- /**
- * Returns the number of tokens in the string.
- *
- * @return number of token in the string
- */
- public int getRangeCount() {
- return fCount;
- }
-
- /* (non Javadoc)
- * see ITokenComparator.getTokenStart
- */
- public int getTokenStart(int index) {
- if (index >= 0 && index < fCount)
- return fStarts[index];
- if (fCount > 0)
- return fStarts[fCount-1] + fLengths[fCount-1];
- return 0;
- }
-
- /* (non Javadoc)
- * see ITokenComparator.getTokenLength
- */
- public int getTokenLength(int index) {
- if (index < fCount)
- return fLengths[index];
- return 0;
- }
-
- /**
- * Returns <code>true</code> if a token given by the first index
- * matches a token specified by the other <code>IRangeComparator</code> and index.
- *
- * @param thisIndex the number of the token within this range comparator
- * @param other the range comparator to compare this with
- * @param otherIndex the number of the token within the other comparator
- * @return <code>true</code> if the token are equal
- */
- public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
- if (other != null && getClass() == other.getClass()) {
- JavaTokenComparator tc= (JavaTokenComparator) other; // safe cast
- int thisLen= getTokenLength(thisIndex);
- int otherLen= tc.getTokenLength(otherIndex);
- if (thisLen == otherLen)
- return fText.regionMatches(false, getTokenStart(thisIndex), tc.fText, tc.getTokenStart(otherIndex), thisLen);
- }
- return false;
- }
-
- /**
- * Aborts the comparison if the number of tokens is too large.
- *
- * @param length a number on which to base the decision whether to return
- * <code>true</code> or <code>false</code>
- * @param maxLength another number on which to base the decision whether to return
- * <code>true</code> or <code>false</code>
- * @param other the other <code>IRangeComparator</code> to compare with
- * @return <code>true</code> to abort a token comparison
- */
- public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
-
- if (getRangeCount() < 50 || other.getRangeCount() < 50)
- return false;
-
- if (maxLength < 100)
- return false;
-
- if (length < 100)
- return false;
-
- if (maxLength > 800)
- return true;
-
- if (length < maxLength / 4)
- return false;
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/LocalHistoryActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/LocalHistoryActionGroup.java
deleted file mode 100644
index a6463736..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/LocalHistoryActionGroup.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-
-public class LocalHistoryActionGroup extends ActionGroup {
-
- private String fGroupName;
-
- private JavaHistoryAction fCompareWith;
- private JavaHistoryAction fReplaceWithPrevious;
- private JavaHistoryAction fReplaceWith;
- private JavaHistoryAction fAddFrom;
-
- public LocalHistoryActionGroup(CompilationUnitEditor editor, String groupName) {
- Assert.isNotNull(groupName);
- fGroupName= groupName;
- fCompareWith= new JavaCompareWithEditionAction();
- fCompareWith.init(editor,
- CompareMessages.LocalHistoryActionGroup_action_compare_with,
- CompareMessages.LocalHistoryActionGroup_action_compare_with_title,
- CompareMessages.LocalHistoryActionGroup_action_compare_with_message);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fCompareWith, IJavaHelpContextIds.COMPARE_WITH_HISTORY_ACTION);
-
- fReplaceWithPrevious= new JavaReplaceWithPreviousEditionAction();
- fReplaceWithPrevious.init(editor,
- CompareMessages.LocalHistoryActionGroup_action_replace_with_previous,
- CompareMessages.LocalHistoryActionGroup_action_replace_with_previous_title,
- CompareMessages.LocalHistoryActionGroup_action_replace_with_previous_message);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fReplaceWithPrevious, IJavaHelpContextIds.REPLACE_WITH_PREVIOUS_FROM_HISTORY_ACTION);
-
- fReplaceWith= new JavaReplaceWithEditionAction();
- fReplaceWith.init(editor,
- CompareMessages.LocalHistoryActionGroup_action_replace_with,
- CompareMessages.LocalHistoryActionGroup_action_replace_with_title,
- CompareMessages.LocalHistoryActionGroup_action_replace_with_message);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fReplaceWith, IJavaHelpContextIds.REPLACE_WITH_HISTORY_ACTION);
-
- fAddFrom= new JavaAddElementFromHistory();
- fAddFrom.init(editor,
- CompareMessages.LocalHistoryActionGroup_action_add,
- CompareMessages.LocalHistoryActionGroup_action_add_title,
- CompareMessages.LocalHistoryActionGroup_action_add_message);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fAddFrom, IJavaHelpContextIds.ADD_FROM_HISTORY_ACTION);
- }
-
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- IMenuManager localMenu= new MenuManager(CompareMessages.LocalHistoryActionGroup_menu_local_history);
- int added= 0;
- added+= addAction(localMenu, fCompareWith);
- added+= addAction(localMenu, fReplaceWithPrevious);
- added+= addAction(localMenu, fReplaceWith);
- added+= addAction(localMenu, fAddFrom);
- if (added > 0)
- menu.appendToGroup(fGroupName, localMenu);
- }
-
- private int addAction(IMenuManager menu, JavaHistoryAction action) {
- action.update();
- if (action.isEnabled()) {
- menu.add(action);
- return 1;
- }
- return 0;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ReplaceWithEditionAction.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ReplaceWithEditionAction.properties
deleted file mode 100644
index 911b6d20..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ReplaceWithEditionAction.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-title= Replace JavaScript Element from Local History
-width= 800
-height= 600
-
-treeTitleFormat= Local History of ''{0}''
-
-treeFormat= {0}
-workspaceTreeFormat= {0} (Workspace File)
-parseErrorFormat= {0} (Parsing Error; No Structured Replace Available)
-
-editionLabel= Local History ({0})
-workspaceEditionLabel= Workspace File
-
-targetLabel= {0}
-
-todayFormat= Today ({0})
-yesterdayFormat= Yesterday ({0})
-dayFormat= {0}
-
-buttonLabel= Replace
-
-notFoundInLocalHistoryMessage= No differing versions of selected JavaScript element found in local history.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ResizableDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ResizableDialog.java
deleted file mode 100644
index 2bb0bb69..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/ResizableDialog.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.TrayDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Base class for resizable Dialogs with persistent window bounds.
- */
-public abstract class ResizableDialog extends TrayDialog {
-
- // dialog store id constants
- private final static String DIALOG_BOUNDS_KEY= "ResizableDialogBounds"; //$NON-NLS-1$
- private static final String X= "x"; //$NON-NLS-1$
- private static final String Y= "y"; //$NON-NLS-1$
- private static final String WIDTH= "width"; //$NON-NLS-1$
- private static final String HEIGHT= "height"; //$NON-NLS-1$
-
- protected ResourceBundle fBundle;
- private Rectangle fNewBounds;
- private IDialogSettings fSettings;
-
- public ResizableDialog(Shell parent, ResourceBundle bundle) {
- super(parent);
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
-
- fBundle= bundle;
-
- fSettings= CompareUI.getPlugin().getDialogSettings();
- }
-
- protected Point getInitialSize() {
-
- int width= 0;
- int height= 0;
-
- final Shell s= getShell();
- if (s != null) {
- s.addControlListener(
- new ControlListener() {
- public void controlMoved(ControlEvent arg0) {
- fNewBounds= s.getBounds();
- }
- public void controlResized(ControlEvent arg0) {
- fNewBounds= s.getBounds();
- }
- }
- );
- }
-
- IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY);
- if (bounds == null) {
- if (fBundle != null) {
- width= JavaCompareUtilities.getInteger(fBundle, WIDTH, 0);
- height= JavaCompareUtilities.getInteger(fBundle, HEIGHT, 0);
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- if (width <= 0)
- width= parentSize.x-300;
- if (height <= 0)
- height= parentSize.y-200;
- }
- } else {
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- width= parentSize.x-100;
- height= parentSize.y-100;
- }
- }
- if (width < 700)
- width= 700;
- if (height < 500)
- height= 500;
- } else {
- try {
- width= bounds.getInt(WIDTH);
- } catch (NumberFormatException e) {
- width= 700;
- }
- try {
- height= bounds.getInt(HEIGHT);
- } catch (NumberFormatException e) {
- height= 500;
- }
- }
-
- return new Point(width, height);
- }
-
- protected Point getInitialLocation(Point initialSize) {
- Point loc= super.getInitialLocation(initialSize);
-
- IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY);
- if (bounds != null) {
- try {
- loc.x= bounds.getInt(X);
- } catch (NumberFormatException e) {
- // silently ignored
- }
- try {
- loc.y= bounds.getInt(Y);
- } catch (NumberFormatException e) {
- // silently ignored
- }
- }
- return loc;
- }
-
- public boolean close() {
- boolean closed= super.close();
- if (closed && fNewBounds != null)
- saveBounds(fNewBounds);
- return closed;
- }
-
- private void saveBounds(Rectangle bounds) {
- IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY);
- if (dialogBounds == null) {
- dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY);
- fSettings.addSection(dialogBounds);
- }
- dialogBounds.put(X, bounds.x);
- dialogBounds.put(Y, bounds.y);
- dialogBounds.put(WIDTH, bounds.width);
- dialogBounds.put(HEIGHT, bounds.height);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/TextMergeViewerCreator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/TextMergeViewerCreator.java
deleted file mode 100644
index bd3bebf7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/TextMergeViewerCreator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A factory object for the <code>TextMergeViewer</code>.
- * This indirection is necessary because only objects with a default
- * constructor can be created via an extension point
- * (this precludes Viewers).
- */
-public class TextMergeViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new TextMergeViewer(parent, mp);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.java
deleted file mode 100644
index abf8ae66..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- */
-public class DialogsMessages extends NLS {
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
- private DialogsMessages() {
- }
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, DialogsMessages.class);
- }
- public static String SortMembersMessageDialog_dialog_title;
- public static String SortMembersMessageDialog_description;
- public static String SortMembersMessageDialog_link_tooltip;
- public static String SortMembersMessageDialog_do_not_sort_fields_label;
- public static String SortMembersMessageDialog_sort_all_label;
- public static String SortMembersMessageDialog_sort_warning_label;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.properties
deleted file mode 100644
index 8684258e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/DialogsMessages.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Sebastian Davids <sdavids@gmx.de> - Bug 114276
-###############################################################################
-
-SortMembersMessageDialog_dialog_title=Sort Members
-SortMembersMessageDialog_description=The order of the sort may be configured on the <a>Members Sort Order</a> preference page.
-SortMembersMessageDialog_link_tooltip=Show the members sort order preferences.
-SortMembersMessageDialog_do_not_sort_fields_label=Do not sort vars and initializers
-SortMembersMessageDialog_sort_all_label=&Sort all members
-SortMembersMessageDialog_sort_warning_label=Reordering of vars and initializers can result in semantic and runtime changes due to different initialization and persistence order.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java
deleted file mode 100644
index 294635a5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java
+++ /dev/null
@@ -1,1663 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-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.Item;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.dialogs.SearchPattern;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatch;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatchRequestor;
-import org.eclipse.wst.jsdt.core.search.TypeNameRequestor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.OpenTypeHistory;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeFilter;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeInfoRequestorAdapter;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.preferences.TypeFilterPreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.TypeNameMatchLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredJavaElementLabels;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.OwnerDrawSupport;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.wst.jsdt.launching.IVMInstall;
-import org.eclipse.wst.jsdt.launching.IVMInstallType;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-import org.eclipse.wst.jsdt.launching.LibraryLocation;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeInfoFilterExtension;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeInfoImageProvider;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeSelectionComponent;
-import org.eclipse.wst.jsdt.ui.dialogs.TypeSelectionExtension;
-
-/**
- * Shows a list of Java types to the user with a text entry field for a string
- * pattern used to filter the list of types.
- *
- *
- */
-public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog implements ITypeSelectionComponent {
-
- /**
- * Disabled "Show Container for Duplicates because of
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=184693 .
- */
- private static final boolean BUG_184693= true;
-
- private static final String DIALOG_SETTINGS= "org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog"; //$NON-NLS-1$
-
- private static final String SHOW_CONTAINER_FOR_DUPLICATES= "ShowContainerForDuplicates"; //$NON-NLS-1$
-
- private static final String WORKINGS_SET_SETTINGS= "WorkingSet"; //$NON-NLS-1$
-
- private WorkingSetFilterActionGroup fFilterActionGroup;
-
- private final TypeItemLabelProvider fTypeInfoLabelProvider;
-
- private String fTitle;
-
- private ShowContainerForDuplicatesAction fShowContainerForDuplicatesAction;
-
- private IJavaScriptSearchScope fSearchScope;
-
- private boolean fAllowScopeSwitching;
-
- private final int fElementKinds;
-
- private final ITypeInfoFilterExtension fFilterExtension;
-
- private final TypeSelectionExtension fExtension;
-
- private ISelectionStatusValidator fValidator;
-
- private final TypeInfoUtil fTypeInfoUtil;
-
- private static boolean fgFirstTime= true;
-
- private final TypeItemsComparator fTypeItemsComparator;
-
- private int fTypeFilterVersion= 0;
-
- /**
- * Creates new FilteredTypesSelectionDialog instance
- *
- * @param parent
- * shell to parent the dialog on
- * @param multi
- * <code>true</code> if multiple selection is allowed
- * @param context
- * context used to execute long-running operations associated
- * with this dialog
- * @param scope
- * scope used when searching for types
- * @param elementKinds
- * flags defining nature of searched elements; the only valid
- * values are: <code>IJavaScriptSearchConstants.TYPE</code>
- * <code>IJavaScriptSearchConstants.ANNOTATION_TYPE</code>
- * <code>IJavaScriptSearchConstants.INTERFACE</code>
- * <code>IJavaScriptSearchConstants.ENUM</code>
- * <code>IJavaScriptSearchConstants.CLASS_AND_INTERFACE</code>
- * <code>IJavaScriptSearchConstants.CLASS_AND_ENUM</code>.
- * Please note that the bitwise OR combination of the elementary
- * constants is not supported.
- */
- public FilteredTypesSelectionDialog(Shell parent, boolean multi, IRunnableContext context, IJavaScriptSearchScope scope, int elementKinds) {
- this(parent, multi, context, scope, elementKinds, null);
- }
-
- /**
- * Creates new FilteredTypesSelectionDialog instance.
- *
- * @param shell
- * shell to parent the dialog on
- * @param multi
- * <code>true</code> if multiple selection is allowed
- * @param context
- * context used to execute long-running operations associated
- * with this dialog
- * @param scope
- * scope used when searching for types. If the scope is <code>null</code>,
- * then workspace is scope is used as default, and the user can
- * choose a working set as scope.
- * @param elementKinds
- * flags defining nature of searched elements; the only valid
- * values are: <code>IJavaScriptSearchConstants.TYPE</code>
- * <code>IJavaScriptSearchConstants.ANNOTATION_TYPE</code>
- * <code>IJavaScriptSearchConstants.INTERFACE</code>
- * <code>IJavaScriptSearchConstants.ENUM</code>
- * <code>IJavaScriptSearchConstants.CLASS_AND_INTERFACE</code>
- * <code>IJavaScriptSearchConstants.CLASS_AND_ENUM</code>.
- * Please note that the bitwise OR combination of the elementary
- * constants is not supported.
- * @param extension
- * an extension of the standard type selection dialog; See
- * {@link TypeSelectionExtension}
- */
- public FilteredTypesSelectionDialog(Shell shell, boolean multi, IRunnableContext context, IJavaScriptSearchScope scope, int elementKinds, TypeSelectionExtension extension) {
- super(shell, multi);
-
- setSelectionHistory(new TypeSelectionHistory());
-
- if (scope == null) {
- fAllowScopeSwitching= true;
- scope= SearchEngine.createWorkspaceScope();
- }
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IJavaHelpContextIds.TYPE_SELECTION_DIALOG2);
-
- fElementKinds= elementKinds;
- fExtension= extension;
- fFilterExtension= (extension == null) ? null : extension.getFilterExtension();
- fSearchScope= scope;
-
- if (extension != null) {
- fValidator= extension.getSelectionValidator();
- }
-
- fTypeInfoUtil= new TypeInfoUtil(extension != null ? extension.getImageProvider() : null);
-
- fTypeInfoLabelProvider= new TypeItemLabelProvider();
-
- setListLabelProvider(fTypeInfoLabelProvider);
- setListSelectionLabelDecorator(fTypeInfoLabelProvider);
- setDetailsLabelProvider(new TypeItemDetailsLabelProvider(fTypeInfoUtil));
-
- fTypeItemsComparator= new TypeItemsComparator();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SelectionDialog#setTitle(java.lang.String)
- */
- public void setTitle(String title) {
- super.setTitle(title);
- fTitle= title;
- }
-
- /**
- * Adds or replaces subtitle of the dialog
- *
- * @param text
- * the new subtitle for this dialog
- */
- private void setSubtitle(String text) {
- if (text == null || text.length() == 0) {
- getShell().setText(fTitle);
- } else {
- getShell().setText(Messages.format(JavaUIMessages.FilteredTypeSelectionDialog_titleFormat, new String[] { fTitle, text }));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.AbstractSearchDialog#getDialogSettings()
- */
- protected IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS);
-
- if (settings == null) {
- settings= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS);
- }
-
- return settings;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.AbstractSearchDialog#storeDialog(org.eclipse.jface.dialogs.IDialogSettings)
- */
- protected void storeDialog(IDialogSettings settings) {
- super.storeDialog(settings);
-
- if (! BUG_184693) {
- settings.put(SHOW_CONTAINER_FOR_DUPLICATES, fShowContainerForDuplicatesAction.isChecked());
- }
-
- if (fFilterActionGroup != null) {
- XMLMemento memento= XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$
- fFilterActionGroup.saveState(memento);
- fFilterActionGroup.dispose();
- StringWriter writer= new StringWriter();
- try {
- memento.save(writer);
- settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString());
- } catch (IOException e) {
- // don't do anything. Simply don't store the settings
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.AbstractSearchDialog#restoreDialog(org.eclipse.jface.dialogs.IDialogSettings)
- */
- protected void restoreDialog(IDialogSettings settings) {
- super.restoreDialog(settings);
-
- if (! BUG_184693) {
- boolean showContainer= settings.getBoolean(SHOW_CONTAINER_FOR_DUPLICATES);
- fShowContainerForDuplicatesAction.setChecked(showContainer);
- fTypeInfoLabelProvider.setContainerInfo(showContainer);
- } else {
- fTypeInfoLabelProvider.setContainerInfo(true);
- }
-
- if (fAllowScopeSwitching) {
- String setting= settings.get(WORKINGS_SET_SETTINGS);
- if (setting != null) {
- try {
- IMemento memento= XMLMemento.createReadRoot(new StringReader(setting));
- fFilterActionGroup.restoreState(memento);
- } catch (WorkbenchException e) {
- // don't do anything. Simply don't restore the settings
- JavaScriptPlugin.log(e);
- }
- }
- IWorkingSet ws= fFilterActionGroup.getWorkingSet();
- if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
- setSearchScope(SearchEngine.createWorkspaceScope());
- setSubtitle(null);
- } else {
- setSearchScope(JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true));
- setSubtitle(ws.getLabel());
- }
- }
-
- // TypeNameMatch[] types = OpenTypeHistory.getInstance().getTypeInfos();
- //
- // for (int i = 0; i < types.length; i++) {
- // TypeNameMatch type = types[i];
- // accessedHistoryItem(type);
- // }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.AbstractSearchDialog#fillViewMenu(org.eclipse.jface.action.IMenuManager)
- */
- protected void fillViewMenu(IMenuManager menuManager) {
- super.fillViewMenu(menuManager);
-
- if (! BUG_184693) {
- fShowContainerForDuplicatesAction= new ShowContainerForDuplicatesAction();
- menuManager.add(fShowContainerForDuplicatesAction);
- }
- if (fAllowScopeSwitching) {
- fFilterActionGroup= new WorkingSetFilterActionGroup(getShell(), JavaScriptPlugin.getActivePage(), new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- IWorkingSet ws= (IWorkingSet) event.getNewValue();
- if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
- setSearchScope(SearchEngine.createWorkspaceScope());
- setSubtitle(null);
- } else {
- setSearchScope(JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true));
- setSubtitle(ws.getLabel());
- }
-
- applyFilter();
- }
- });
- fFilterActionGroup.fillViewMenu(menuManager);
- }
-
- menuManager.add(new Separator());
- menuManager.add(new TypeFiltersPreferencesAction());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createExtendedContentArea(Composite parent) {
- Control addition= null;
-
- if (fExtension != null) {
-
- addition= fExtension.createContentArea(parent);
- if (addition != null) {
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- addition.setLayoutData(gd);
-
- }
-
- fExtension.initialize(this);
- }
-
- return addition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SelectionDialog#setResult(java.util.List)
- */
- protected void setResult(List newResult) {
-
- List resultToReturn= new ArrayList();
-
- for (int i= 0; i < newResult.size(); i++) {
- if (newResult.get(i) instanceof TypeNameMatch) {
- IType type= ((TypeNameMatch) newResult.get(i)).getType();
- if (type.exists()) {
- // items are added to history in the
- // org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#computeResult()
- // method
- resultToReturn.add(type);
- } else {
- TypeNameMatch typeInfo= (TypeNameMatch) newResult.get(i);
- IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
- String containerName= JavaScriptElementLabels.getElementLabel(root, JavaScriptElementLabels.ROOT_QUALIFIED);
- String message= Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName });
- MessageDialog.openError(getShell(), fTitle, message);
- getSelectionHistory().remove(typeInfo);
- }
- }
- }
-
- super.setResult(resultToReturn);
- }
-
- /*
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#create()
- */
- public void create() {
- super.create();
- Control patternControl= getPatternControl();
- if (patternControl instanceof Text) {
- TextFieldNavigationHandler.install((Text) patternControl);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open() {
- if (getInitialPattern() == null) {
- IWorkbenchWindow window= JavaScriptPlugin.getActiveWorkbenchWindow();
- if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
- if (selection instanceof ITextSelection) {
- String text= ((ITextSelection) selection).getText();
- if (text != null) {
- text= text.trim();
- if (text.length() > 0 && JavaScriptConventions.validateJavaScriptTypeName(text, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3).isOK()) {
- setInitialPattern(text, FULL_SELECTION);
- }
- }
- }
- }
- }
- return super.open();
- }
-
- /**
- * Sets a new validator.
- *
- * @param validator
- * the new validator
- */
- public void setValidator(ISelectionStatusValidator validator) {
- fValidator= validator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
- */
- protected ItemsFilter createFilter() {
- return new TypeItemsFilter(fSearchScope, fElementKinds, fFilterExtension);
- }
-
- protected Control createContents(Composite parent) {
- Control contents= super.createContents(parent);
- if (ColoredViewersManager.showColoredLabels()) {
- if (contents instanceof Composite) {
- Table listControl= findTableControl((Composite) contents);
- if (listControl != null) {
- installOwnerDraw(listControl);
- }
- }
- }
- return contents;
- }
-
- private void installOwnerDraw(Table tableControl) {
- new OwnerDrawSupport(tableControl) { // installs the owner draw listeners
- public ColoredString getColoredLabel(Item item) {
- String text= item.getText();
- ColoredString str= new ColoredString(text);
- int index= text.indexOf('-');
- if (index != -1) {
- str.colorize(index, str.length() - index, ColoredJavaElementLabels.QUALIFIER_STYLE);
- }
- return str;
- }
-
- public Color getColor(String foregroundColorName, Display display) {
- return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(foregroundColorName);
- }
- };
- }
-
- private Table findTableControl(Composite composite) {
- Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- Control curr= children[i];
- if (curr instanceof Table) {
- return (Table) curr;
- } else if (curr instanceof Composite) {
- Table res= findTableControl((Composite) curr);
- if (res != null) {
- return res;
- }
- }
- }
- return null;
- }
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider,
- * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void fillContentProvider(AbstractContentProvider provider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
- TypeItemsFilter typeSearchFilter= (TypeItemsFilter) itemsFilter;
- TypeSearchRequestor requestor= new TypeSearchRequestor(provider, typeSearchFilter);
- SearchEngine engine= new SearchEngine((WorkingCopyOwner) null);
- String packPattern= typeSearchFilter.getPackagePattern();
- progressMonitor.setTaskName(JavaUIMessages.FilteredTypesSelectionDialog_searchJob_taskName);
-
- /*
- * Setting the filter into match everything mode avoids filtering twice
- * by the same pattern (the search engine only provides filtered
- * matches). For the case when the pattern is a camel case pattern with
- * a terminator, the filter is not set to match everything mode because
- * jdt.core's SearchPattern does not support that case.
- */
- String typePattern= itemsFilter.getPattern();
- int matchRule= typeSearchFilter.getMatchRule();
- if (matchRule == SearchPattern.RULE_CAMELCASE_MATCH) {
- // If the pattern is empty, the RULE_BLANK_MATCH will be chosen, so we don't have to check the pattern length
- char lastChar= typePattern.charAt(typePattern.length() - 1);
-
- if (lastChar == '<' || lastChar == ' ') {
- typePattern= typePattern.substring(0, typePattern.length() - 1);
- } else {
- typeSearchFilter.setMatchEverythingMode(true);
- }
- } else {
- typeSearchFilter.setMatchEverythingMode(true);
- }
-
- try {
- engine.searchAllTypeNames(packPattern == null ? null : packPattern.toCharArray(),
- typeSearchFilter.getPackageFlags(), //TODO: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176017
- typePattern.toCharArray(),
- matchRule, //TODO: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176017
- typeSearchFilter.getElementKind(),
- typeSearchFilter.getSearchScope(),
- requestor,
- IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- progressMonitor);
- } finally {
- typeSearchFilter.setMatchEverythingMode(false);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getItemsComparator()
- */
- protected Comparator getItemsComparator() {
- return fTypeItemsComparator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.lang.Object)
- */
- public String getElementName(Object item) {
- TypeNameMatch type= (TypeNameMatch) item;
- return fTypeInfoUtil.getText(type);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
- */
- protected IStatus validateItem(Object item) {
-
- if (item == null)
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, "", null); //$NON-NLS-1$
-
- if (fValidator != null) {
- IType type= ((TypeNameMatch) item).getType();
- if (!type.exists())
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_error_type_doesnot_exist, ((TypeNameMatch) item).getFullyQualifiedName()), null);
- Object[] elements= { type };
- return fValidator.validate(elements);
- } else
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
-
- /**
- * Sets search scope used when searching for types.
- *
- * @param scope
- * the new scope
- */
- private void setSearchScope(IJavaScriptSearchScope scope) {
- fSearchScope= scope;
- }
-
- /*
- * We only have to ensure history consistency here since the search engine
- * takes care of working copies.
- */
- private static class ConsistencyRunnable implements IRunnableWithProgress {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- if (fgFirstTime) {
- // Join the initialize after load job.
- IJobManager manager= Job.getJobManager();
- manager.join(JavaScriptUI.ID_PLUGIN, monitor);
- }
- OpenTypeHistory history= OpenTypeHistory.getInstance();
- if (fgFirstTime || history.isEmpty()) {
- if (history.needConsistencyCheck()) {
- monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100);
- refreshSearchIndices(new SubProgressMonitor(monitor, 90));
- history.checkConsistency(new SubProgressMonitor(monitor, 10));
- } else {
- refreshSearchIndices(monitor);
- }
- monitor.done();
- fgFirstTime= false;
- } else {
- history.checkConsistency(monitor);
- }
- }
- public static boolean needsExecution() {
- OpenTypeHistory history= OpenTypeHistory.getInstance();
- return fgFirstTime || history.isEmpty() || history.needConsistencyCheck();
- }
- private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- new SearchEngine().searchAllTypeNames(
- null,
- 0,
- // make sure we search a concrete name. This is faster according to Kent
- "_______________".toCharArray(), //$NON-NLS-1$
- SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_CASE_SENSITIVE,
- IJavaScriptSearchConstants.ENUM,
- SearchEngine.createWorkspaceScope(),
- new TypeNameRequestor() {},
- IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- monitor);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#reloadCache(boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void reloadCache(boolean checkDuplicates, IProgressMonitor monitor) {
- IProgressMonitor remainingMonitor;
- if (ConsistencyRunnable.needsExecution()) {
- monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 10);
- try {
- ConsistencyRunnable runnable= new ConsistencyRunnable();
- runnable.run(new SubProgressMonitor(monitor, 1));
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message);
- close();
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- close();
- return;
- }
- remainingMonitor= new SubProgressMonitor(monitor, 9);
- } else {
- remainingMonitor= monitor;
- }
- super.reloadCache(checkDuplicates, remainingMonitor);
- monitor.done();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.dialogs.ITypeSelectionComponent#triggerSearch()
- */
- public void triggerSearch() {
- fTypeFilterVersion++;
- applyFilter();
- }
-
- /**
- * The <code>ShowContainerForDuplicatesAction</code> provides means to
- * show/hide container information for duplicate elements.
- */
- private class ShowContainerForDuplicatesAction extends Action {
-
- /**
- * Creates a new instance of the class
- */
- public ShowContainerForDuplicatesAction() {
- super(JavaUIMessages.FilteredTypeSelectionDialog_showContainerForDuplicatesAction, IAction.AS_CHECK_BOX);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- fTypeInfoLabelProvider.setContainerInfo(isChecked());
- }
- }
-
- private class TypeFiltersPreferencesAction extends Action {
-
- public TypeFiltersPreferencesAction() {
- super(JavaUIMessages.FilteredTypesSelectionDialog_TypeFiltersPreferencesAction_label);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- String typeFilterID= TypeFilterPreferencePage.TYPE_FILTER_PREF_PAGE_ID;
- PreferencesUtil.createPreferenceDialogOn(getShell(), typeFilterID, new String[] { typeFilterID }, null).open();
- triggerSearch();
- }
- }
-
- /**
- * A <code>LabelProvider</code> for (the table of) types.
- */
- private class TypeItemLabelProvider extends LabelProvider implements ILabelDecorator {
-
- private boolean fContainerInfo;
-
-
- /**
- * Construct a new <code>TypeItemLabelProvider</code>. F
- */
- public TypeItemLabelProvider() {
-
- }
-
- public void setContainerInfo(boolean containerInfo) {
- fContainerInfo= containerInfo;
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
- }
-
- private boolean isInnerType(TypeNameMatch match) {
- return match.getTypeQualifiedName().indexOf('.') != -1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (!(element instanceof TypeNameMatch)) {
- return super.getImage(element);
- }
-
- TypeNameMatch type= (TypeNameMatch) element;
-
- ImageDescriptor iD= JavaElementImageProvider.getTypeImageDescriptor(isInnerType(type), false, type.getModifiers(), false);
-
- return JavaScriptPlugin.getImageDescriptorRegistry().get(iD);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (!(element instanceof TypeNameMatch)) {
- return super.getText(element);
- }
-
- if (fContainerInfo && isDuplicateElement(element)) {
- return fTypeInfoUtil.getFullyQualifiedText((TypeNameMatch) element);
- }
-
- if (!fContainerInfo && isDuplicateElement(element)) {
- return fTypeInfoUtil.getQualifiedText((TypeNameMatch) element);
- }
-
- return fTypeInfoUtil.getText(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image,
- * java.lang.Object)
- */
- public Image decorateImage(Image image, Object element) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String,
- * java.lang.Object)
- */
- public String decorateText(String text, Object element) {
- if (!(element instanceof TypeNameMatch)) {
- return null;
- }
-
- if (fContainerInfo && isDuplicateElement(element)) {
- return fTypeInfoUtil.getFullyQualifiedText((TypeNameMatch) element);
- }
-
- return fTypeInfoUtil.getQualifiedText((TypeNameMatch) element);
- }
-
- }
-
- /**
- * A <code>LabelProvider</code> for the label showing type details.
- */
- private static class TypeItemDetailsLabelProvider extends LabelProvider {
-
- private final TypeNameMatchLabelProvider fLabelProvider= new TypeNameMatchLabelProvider(TypeNameMatchLabelProvider.SHOW_TYPE_CONTAINER_ONLY + TypeNameMatchLabelProvider.SHOW_ROOT_POSTFIX);
-
- private final TypeInfoUtil fTypeInfoUtil;
-
- public TypeItemDetailsLabelProvider(TypeInfoUtil typeInfoUtil) {
- fTypeInfoUtil= typeInfoUtil;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (element instanceof TypeNameMatch) {
- return fLabelProvider.getImage((element));
- }
-
- return super.getImage(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (element instanceof TypeNameMatch) {
- return fTypeInfoUtil.getQualificationText((TypeNameMatch) element);
- }
-
- return super.getText(element);
- }
- }
-
- private static class TypeInfoUtil {
-
- private final ITypeInfoImageProvider fProviderExtension;
-
- private final TypeInfoRequestorAdapter fAdapter= new TypeInfoRequestorAdapter();
-
- private final Map fLib2Name= new HashMap();
-
- private final String[] fInstallLocations;
-
- private final String[] fVMNames;
-
- private boolean fFullyQualifyDuplicates;
-
- public TypeInfoUtil(ITypeInfoImageProvider extension) {
- fProviderExtension= extension;
- List locations= new ArrayList();
- List labels= new ArrayList();
- IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
- for (int i= 0; i < installs.length; i++) {
- processVMInstallType(installs[i], locations, labels);
- }
- fInstallLocations= (String[]) locations.toArray(new String[locations.size()]);
- fVMNames= (String[]) labels.toArray(new String[labels.size()]);
-
- }
-
- public void setFullyQualifyDuplicates(boolean value) {
- fFullyQualifyDuplicates= value;
- }
-
- private void processVMInstallType(IVMInstallType installType, List locations, List labels) {
- if (installType != null) {
- IVMInstall[] installs= installType.getVMInstalls();
- boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
- final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$
- for (int i= 0; i < installs.length; i++) {
- String label= getFormattedLabel(installs[i].getName());
- LibraryLocation[] libLocations= installs[i].getLibraryLocations();
- if (libLocations != null) {
- processLibraryLocation(libLocations, label);
- } else {
- String filePath= installs[i].getInstallLocation().getAbsolutePath();
- // on MacOS X install locations end in an additional
- // "/Home" segment; remove it
- if (isMac && filePath.endsWith(HOME_SUFFIX))
- filePath= filePath.substring(0, filePath.length() - HOME_SUFFIX.length() + 1);
- locations.add(filePath);
- labels.add(label);
- }
- }
- }
- }
-
- private void processLibraryLocation(LibraryLocation[] libLocations, String label) {
- for (int l= 0; l < libLocations.length; l++) {
- LibraryLocation location= libLocations[l];
- fLib2Name.put(location.getSystemLibraryPath().toOSString(), label);
- }
- }
-
- private String getFormattedLabel(String name) {
- return Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_library_name_format, name);
- }
-
- public String getText(Object element) {
-
- return ((TypeNameMatch) element).getQualifiedName();
- }
-
- public String getQualifiedText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- result.append(type.getQualifiedName());
- String containerName= type.getTypeContainerName();
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- if (containerName.length() > 0) {
- result.append(containerName);
- } else {
- result.append(JavaUIMessages.FilteredTypesSelectionDialog_default_package);
- }
- return result.toString();
- }
-
- public String getFullyQualifiedText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- result.append(type.getSimpleTypeName());
- String containerName= type.getTypeContainerName();
- if (containerName.length() > 0) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(containerName);
- }
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(type));
- return result.toString();
- }
-
- public String getText(TypeNameMatch last, TypeNameMatch current, TypeNameMatch next) {
- StringBuffer result= new StringBuffer();
- int qualifications= 0;
- String currentTN= current.getSimpleTypeName();
- result.append(currentTN);
- String currentTCN= getTypeContainerName(current);
- if (last != null) {
- String lastTN= last.getSimpleTypeName();
- String lastTCN= getTypeContainerName(last);
- if (currentTCN.equals(lastTCN)) {
- if (currentTN.equals(lastTN)) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- return result.toString();
- }
- } else if (currentTN.equals(lastTN)) {
- qualifications= 1;
- }
- }
- if (next != null) {
- String nextTN= next.getSimpleTypeName();
- String nextTCN= getTypeContainerName(next);
- if (currentTCN.equals(nextTCN)) {
- if (currentTN.equals(nextTN)) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- return result.toString();
- }
- } else if (currentTN.equals(nextTN)) {
- qualifications= 1;
- }
- }
- if (qualifications > 0) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- if (fFullyQualifyDuplicates) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- }
- }
- return result.toString();
- }
-
- public String getQualificationText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- String containerName= type.getTypeContainerName();
- if (containerName.length() > 0) {
- result.append(containerName);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- }
- result.append(getContainerName(type));
- return result.toString();
- }
-
- private boolean isInnerType(TypeNameMatch match) {
- return match.getTypeQualifiedName().indexOf('.') != -1;
- }
-
- public ImageDescriptor getImageDescriptor(Object element) {
- TypeNameMatch type= (TypeNameMatch) element;
- if (fProviderExtension != null) {
- fAdapter.setMatch(type);
- ImageDescriptor descriptor= fProviderExtension.getImageDescriptor(fAdapter);
- if (descriptor != null)
- return descriptor;
- }
- return JavaElementImageProvider.getTypeImageDescriptor(isInnerType(type), false, type.getModifiers(), false);
- }
-
- private String getTypeContainerName(TypeNameMatch info) {
- String result= info.getTypeContainerName();
- if (result.length() > 0)
- return result;
- return JavaUIMessages.FilteredTypesSelectionDialog_default_package;
- }
-
- private String getContainerName(TypeNameMatch type) {
- IPackageFragmentRoot root= type.getPackageFragmentRoot();
- if (root.isExternal()) {
- String name= root.getPath().toOSString();
- for (int i= 0; i < fInstallLocations.length; i++) {
- if (name.startsWith(fInstallLocations[i])) {
- return fVMNames[i];
- }
- }
- String lib= (String) fLib2Name.get(name);
- if (lib != null)
- return lib;
- }
- StringBuffer buf= new StringBuffer();
- JavaScriptElementLabels.getPackageFragmentRootLabel(root, JavaScriptElementLabels.ROOT_QUALIFIED | JavaScriptElementLabels.ROOT_VARIABLE, buf);
- return buf.toString();
- }
- }
-
- /**
- * Filters types using pattern, scope, element kind and filter extension.
- */
- private class TypeItemsFilter extends ItemsFilter {
-
- private static final int TYPE_MODIFIERS= Flags.AccEnum | Flags.AccAnnotation | Flags.AccInterface;
-
- private final IJavaScriptSearchScope fScope;
-
- private final boolean fIsWorkspaceScope;
-
- private final int fElemKind;
-
- private final ITypeInfoFilterExtension fFilterExt;
-
- private final TypeInfoRequestorAdapter fAdapter= new TypeInfoRequestorAdapter();
-
- private SearchPattern fPackageMatcher;
-
- private boolean fMatchEverything= false;
-
- private final int fMyTypeFilterVersion= fTypeFilterVersion;
-
- /**
- * Creates instance of TypeItemsFilter
- *
- * @param scope
- * @param elementKind
- * @param extension
- */
- public TypeItemsFilter(IJavaScriptSearchScope scope, int elementKind, ITypeInfoFilterExtension extension) {
- super(new TypeSearchPattern());
- fScope= scope;
- fIsWorkspaceScope= scope == null ? false : scope.equals(SearchEngine.createWorkspaceScope());
- fElemKind= elementKind;
- fFilterExt= extension;
- String stringPackage= ((TypeSearchPattern) patternMatcher).getPackagePattern();
- if (stringPackage != null) {
- fPackageMatcher= new SearchPattern();
- fPackageMatcher.setPattern(stringPackage);
- } else {
- fPackageMatcher= null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter#isSubFilter(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter)
- */
- public boolean isSubFilter(ItemsFilter filter) {
- if (!super.isSubFilter(filter))
- return false;
- TypeItemsFilter typeItemsFilter= (TypeItemsFilter) filter;
- if (fScope != typeItemsFilter.getSearchScope())
- return false;
- if (fMyTypeFilterVersion != typeItemsFilter.getMyTypeFilterVersion())
- return false;
- return getPattern().indexOf('.', filter.getPattern().length()) == -1;
- }
-
- public boolean equalsFilter(ItemsFilter iFilter) {
- if (!super.equalsFilter(iFilter))
- return false;
- if (!(iFilter instanceof TypeItemsFilter))
- return false;
- TypeItemsFilter typeItemsFilter= (TypeItemsFilter) iFilter;
- if (fScope != typeItemsFilter.getSearchScope())
- return false;
- if (fMyTypeFilterVersion != typeItemsFilter.getMyTypeFilterVersion())
- return false;
- return true;
- }
-
- public int getElementKind() {
- return fElemKind;
- }
-
- public ITypeInfoFilterExtension getFilterExtension() {
- return fFilterExt;
- }
-
- public IJavaScriptSearchScope getSearchScope() {
- return fScope;
- }
-
- public int getMyTypeFilterVersion() {
- return fMyTypeFilterVersion;
- }
-
- public String getPackagePattern() {
- if (fPackageMatcher == null)
- return null;
- return fPackageMatcher.getPattern();
- }
-
- public int getPackageFlags() {
- if (fPackageMatcher == null)
- return SearchPattern.RULE_PREFIX_MATCH;
-
- return fPackageMatcher.getMatchRule();
- }
-
- public boolean matchesRawNamePattern(TypeNameMatch type) {
- return Strings.startsWithIgnoreCase(type.getSimpleTypeName(), getPattern());
- }
-
- public boolean matchesCachedResult(TypeNameMatch type) {
- if (!(matchesPackage(type) && matchesFilterExtension(type)))
- return false;
- return matchesName(type);
- }
-
- public boolean matchesHistoryElement(TypeNameMatch type) {
- if (!(matchesPackage(type) && matchesModifiers(type) && matchesScope(type) && matchesFilterExtension(type)))
- return false;
- return matchesName(type);
- }
-
- public boolean matchesFilterExtension(TypeNameMatch type) {
- if (fFilterExt == null)
- return true;
- fAdapter.setMatch(type);
- return fFilterExt.select(fAdapter);
- }
-
- private boolean matchesName(TypeNameMatch type) {
- return matches(type.getSimpleTypeName());
- }
-
- private boolean matchesPackage(TypeNameMatch type) {
- if (fPackageMatcher == null)
- return true;
- return fPackageMatcher.matches(type.getPackageName());
- }
-
- private boolean matchesScope(TypeNameMatch type) {
- if (fIsWorkspaceScope)
- return true;
- return fScope.encloses(type.getType());
-
- }
-
- private boolean matchesModifiers(TypeNameMatch type) {
- if (fElemKind == IJavaScriptSearchConstants.TYPE)
- return true;
- int modifiers= type.getModifiers() & TYPE_MODIFIERS;
- switch (fElemKind) {
- case IJavaScriptSearchConstants.CLASS:
- return modifiers == 0;
- case IJavaScriptSearchConstants.ANNOTATION_TYPE:
- return Flags.isAnnotation(modifiers);
- case IJavaScriptSearchConstants.INTERFACE:
- return Flags.isInterface(modifiers);
- case IJavaScriptSearchConstants.ENUM:
- return Flags.isEnum(modifiers);
- case IJavaScriptSearchConstants.CLASS_AND_INTERFACE:
- return modifiers == 0 || Flags.isInterface(modifiers);
- case IJavaScriptSearchConstants.CLASS_AND_ENUM:
- return modifiers == 0 || Flags.isEnum(modifiers);
- }
- return false;
- }
-
- /**
- * Set filter to "match everything" mode.
- *
- * @param matchEverything if <code>true</code>, {@link #matchItem(Object)} always returns true.
- * If <code>false</code>, the filter is enabled.
- */
- public void setMatchEverythingMode(boolean matchEverything) {
- this.fMatchEverything= matchEverything;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter#isConsistentItem(java.lang.Object)
- */
- public boolean isConsistentItem(Object item) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter#matchItem(java.lang.Object)
- */
- public boolean matchItem(Object item) {
-
- if (fMatchEverything)
- return true;
-
- TypeNameMatch type= (TypeNameMatch) item;
- if (!(matchesPackage(type) && matchesModifiers(type) && matchesScope(type) && matchesFilterExtension(type)))
- return false;
- return matchesName(type);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter#matchesRawNamePattern(java.lang.Object)
- */
- public boolean matchesRawNamePattern(Object item) {
- TypeNameMatch type= (TypeNameMatch) item;
- return matchesRawNamePattern(type);
- }
-
- }
-
- /**
- * Extends functionality of SearchPatterns
- */
- private static class TypeSearchPattern extends SearchPattern {
-
- private String packagePattern;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SearchPattern#setPattern(java.lang.String)
- */
- public void setPattern(String stringPattern) {
- String pattern= stringPattern;
- String packPattern= null;
- int index= stringPattern.lastIndexOf("."); //$NON-NLS-1$
- if (index != -1) {
- packPattern= evaluatePackagePattern(stringPattern.substring(0, index));
- pattern= stringPattern.substring(index + 1);
- if (pattern.length() == 0)
- pattern= "**"; //$NON-NLS-1$
- }
- super.setPattern(pattern);
- packagePattern= packPattern;
- }
-
- /*
- * Transforms o.e.j to o*.e*.j*
- */
- private String evaluatePackagePattern(String s) {
- StringBuffer buf= new StringBuffer();
- boolean hasWildCard= false;
- for (int i= 0; i < s.length(); i++) {
- char ch= s.charAt(i);
- if (ch == '.') {
- if (!hasWildCard) {
- buf.append('*');
- }
- hasWildCard= false;
- } else if (ch == '*' || ch == '?') {
- hasWildCard= true;
- }
- buf.append(ch);
- }
- if (!hasWildCard) {
- buf.append('*');
- }
- return buf.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SearchPattern#isNameCharAllowed(char)
- */
- protected boolean isNameCharAllowed(char nameChar) {
- return super.isNameCharAllowed(nameChar);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SearchPattern#isPatternCharAllowed(char)
- */
- protected boolean isPatternCharAllowed(char patternChar) {
- return super.isPatternCharAllowed(patternChar);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SearchPattern#isValidCamelCaseChar(char)
- */
- protected boolean isValidCamelCaseChar(char ch) {
- return super.isValidCamelCaseChar(ch);
- }
-
- /**
- * @return the packagePattern
- */
- public String getPackagePattern() {
- return packagePattern;
- }
-
- }
-
- /**
- * A <code>TypeSearchRequestor</code> collects matches filtered using
- * <code>TypeItemsFilter</code>. The attached content provider is filled
- * on the basis of the collected entries (instances of
- * <code>TypeNameMatch</code>).
- */
- private static class TypeSearchRequestor extends TypeNameMatchRequestor {
- private volatile boolean fStop;
-
- private final AbstractContentProvider fContentProvider;
-
- private final TypeItemsFilter fTypeItemsFilter;
-
- public TypeSearchRequestor(AbstractContentProvider contentProvider, TypeItemsFilter typeItemsFilter) {
- super();
- fContentProvider= contentProvider;
- fTypeItemsFilter= typeItemsFilter;
- }
-
- public void cancel() {
- fStop= true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.jsdt.core.search.TypeNameMatchRequestor#acceptTypeNameMatch(org.eclipse.wst.jsdt.core.search.TypeNameMatch)
- */
- public void acceptTypeNameMatch(TypeNameMatch match) {
- if (fStop)
- return;
- if (TypeFilter.isFiltered(match))
- return;
- if (fTypeItemsFilter.matchesFilterExtension(match))
- fContentProvider.add(match, fTypeItemsFilter);
- }
-
- }
-
- /**
- * Compares TypeItems is used during sorting
- */
- private static class TypeItemsComparator implements Comparator {
-
- private final Map fLib2Name= new HashMap();
-
- private final String[] fInstallLocations;
-
- private final String[] fVMNames;
-
- /**
- * Creates new instance of TypeItemsComparator
- */
- public TypeItemsComparator() {
- List locations= new ArrayList();
- List labels= new ArrayList();
- IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
- for (int i= 0; i < installs.length; i++) {
- processVMInstallType(installs[i], locations, labels);
- }
- fInstallLocations= (String[]) locations.toArray(new String[locations.size()]);
- fVMNames= (String[]) labels.toArray(new String[labels.size()]);
- }
-
- private void processVMInstallType(IVMInstallType installType, List locations, List labels) {
- if (installType != null) {
- IVMInstall[] installs= installType.getVMInstalls();
- boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
- final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$
- for (int i= 0; i < installs.length; i++) {
- String label= getFormattedLabel(installs[i].getName());
- LibraryLocation[] libLocations= installs[i].getLibraryLocations();
- if (libLocations != null) {
- processLibraryLocation(libLocations, label);
- } else {
- String filePath= installs[i].getInstallLocation().getAbsolutePath();
- // on MacOS X install locations end in an additional
- // "/Home" segment; remove it
- if (isMac && filePath.endsWith(HOME_SUFFIX))
- filePath= filePath.substring(0, filePath.length() - HOME_SUFFIX.length() + 1);
- locations.add(filePath);
- labels.add(label);
- }
- }
- }
- }
-
- private void processLibraryLocation(LibraryLocation[] libLocations, String label) {
- for (int l= 0; l < libLocations.length; l++) {
- LibraryLocation location= libLocations[l];
- fLib2Name.put(location.getSystemLibraryPath().toString(), label);
- }
- }
-
- private String getFormattedLabel(String name) {
- return MessageFormat.format(JavaUIMessages.FilteredTypesSelectionDialog_library_name_format, new Object[] { name });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object left, Object right) {
-
- TypeNameMatch leftInfo= (TypeNameMatch) left;
- TypeNameMatch rightInfo= (TypeNameMatch) right;
-
- int result= compareName(leftInfo.getSimpleTypeName(), rightInfo.getSimpleTypeName());
- if (result != 0)
- return result;
- result= compareTypeContainerName(leftInfo.getTypeContainerName(), rightInfo.getTypeContainerName());
- if (result != 0)
- return result;
-
- int leftCategory= getElementTypeCategory(leftInfo);
- int rightCategory= getElementTypeCategory(rightInfo);
- if (leftCategory < rightCategory)
- return -1;
- if (leftCategory > rightCategory)
- return +1;
- return compareContainerName(leftInfo, rightInfo);
- }
-
- private int compareName(String leftString, String rightString) {
- int result= leftString.compareToIgnoreCase(rightString);
- if (result != 0 || rightString.length() == 0) {
- return result;
- } else if (Strings.isLowerCase(leftString.charAt(0)) && !Strings.isLowerCase(rightString.charAt(0))) {
- return +1;
- } else if (Strings.isLowerCase(rightString.charAt(0)) && !Strings.isLowerCase(leftString.charAt(0))) {
- return -1;
- } else {
- return leftString.compareTo(rightString);
- }
- }
-
- private int compareTypeContainerName(String leftString, String rightString) {
- int leftLength= leftString.length();
- int rightLength= rightString.length();
- if (leftLength == 0 && rightLength > 0)
- return -1;
- if (leftLength == 0 && rightLength == 0)
- return 0;
- if (leftLength > 0 && rightLength == 0)
- return +1;
- return compareName(leftString, rightString);
- }
-
- private int compareContainerName(TypeNameMatch leftType, TypeNameMatch rightType) {
- return getContainerName(leftType).compareTo(getContainerName(rightType));
- }
-
- private String getContainerName(TypeNameMatch type) {
- IPackageFragmentRoot root= type.getPackageFragmentRoot();
- if (root.isExternal()) {
- String name= root.getPath().toOSString();
- for (int i= 0; i < fInstallLocations.length; i++) {
- if (name.startsWith(fInstallLocations[i])) {
- return fVMNames[i];
- }
- }
- String lib= (String) fLib2Name.get(name);
- if (lib != null)
- return lib;
- }
- StringBuffer buf= new StringBuffer();
- JavaScriptElementLabels.getPackageFragmentRootLabel(root, JavaScriptElementLabels.ROOT_QUALIFIED | JavaScriptElementLabels.ROOT_VARIABLE, buf);
- return buf.toString();
- }
-
- private int getElementTypeCategory(TypeNameMatch type) {
- try {
- if (type.getPackageFragmentRoot().getKind() == IPackageFragmentRoot.K_SOURCE)
- return 0;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return 1;
- }
- }
-
- /**
- * Extends the <code>SelectionHistory</code>, providing support for
- * <code>OpenTypeHistory</code>.
- */
- protected class TypeSelectionHistory extends SelectionHistory {
-
- /**
- * Creates new instance of TypeSelectionHistory
- */
-
- public TypeSelectionHistory() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#accessed(java.lang.Object)
- */
- public synchronized void accessed(Object object) {
- super.accessed(object);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#remove(java.lang.Object)
- */
- public synchronized boolean remove(Object element) {
- OpenTypeHistory.getInstance().remove((TypeNameMatch) element);
- return super.remove(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#load(org.eclipse.ui.IMemento)
- */
- public void load(IMemento memento) {
- TypeNameMatch[] types= OpenTypeHistory.getInstance().getTypeInfos();
-
- for (int i= 0; i < types.length; i++) {
- TypeNameMatch type= types[i];
- accessed(type);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#save(org.eclipse.ui.IMemento)
- */
- public void save(IMemento memento) {
- persistHistory();
- }
-
- /**
- * Stores contents of the local history into persistent history
- * container.
- */
- private synchronized void persistHistory() {
- if (getReturnCode() == OK) {
- Object[] items= getHistoryItems();
- for (int i= 0; i < items.length; i++) {
- OpenTypeHistory.getInstance().accessed((TypeNameMatch) items[i]);
- }
- }
- }
-
- protected Object restoreItemFromMemento(IMemento element) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
- * org.eclipse.ui.IMemento)
- */
- protected void storeItemToMemento(Object item, IMemento element) {
-
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/ListDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/ListDialog.java
deleted file mode 100644
index f36cba88..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/ListDialog.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-public class ListDialog extends SelectionDialog {
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fTableViewer;
- private boolean fAddCancelButton;
- private final int fShellStyle;
-
- public ListDialog(Shell parent, int shellStyle) {
- super(parent);
- fAddCancelButton= false;
- fShellStyle= shellStyle;
- }
-
- public void setInput(Object input) {
- fInput= input;
- }
-
- public void setContentProvider(IStructuredContentProvider sp){
- fContentProvider= sp;
- }
-
- public void setLabelProvider(ILabelProvider lp){
- fLabelProvider= lp;
- }
-
- public void setAddCancelButton(boolean addCancelButton) {
- fAddCancelButton= addCancelButton;
- }
-
- public TableViewer getTableViewer(){
- return fTableViewer;
- }
-
- public boolean hasFilters(){
- return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0;
- }
-
- public void create() {
- setShellStyle(fShellStyle);
- super.create();
- }
-
- protected Label createMessageArea(Composite composite) {
- Label label = new Label(composite,SWT.WRAP);
- label.setText(getMessage());
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(55);
- label.setLayoutData(gd);
- applyDialogFont(label);
- return label;
- }
-
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fTableViewer= new TableViewer(parent, getTableStyle());
- fTableViewer.setContentProvider(fContentProvider);
- Table table= fTableViewer.getTable();
- fTableViewer.setLabelProvider(fLabelProvider);
- fTableViewer.setInput(fInput);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(55);
- gd.heightHint= convertHeightInCharsToPixels(15);
- table.setLayoutData(gd);
- applyDialogFont(parent);
- return parent;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fAddCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- protected int getTableStyle() {
- return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/MultiElementListSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/MultiElementListSelectionDialog.java
deleted file mode 100644
index 68d8870d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/MultiElementListSelectionDialog.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.SWT;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.AbstractElementListSelectionDialog;
-import org.eclipse.ui.dialogs.FilteredList;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-
-/**
- * A class to select elements out of a list of elements, organized on multiple
- * pages.
- */
-public class MultiElementListSelectionDialog extends AbstractElementListSelectionDialog {
-
- private static class Page {
- private Object[] elements;
- public String filter;
- public boolean okState= false;
-
- public Page(Object[] elements) {
- this.elements= elements;
- }
- }
-
- private Page[] fPages;
- private int fCurrentPage;
- private int fNumberOfPages;
-
- private Button fFinishButton;
- private Button fBackButton;
- private Button fNextButton;
-
- private Label fPageInfoLabel;
- private String fPageInfoMessage= JavaUIMessages.MultiElementListSelectionDialog_pageInfoMessage;
- private Comparator fComparator;
-
- /**
- * Constructs a multi-page list selection dialog.
- * @param parent The parent shell
- * @param renderer the label renderer.
- */
- public MultiElementListSelectionDialog(Shell parent, ILabelProvider renderer) {
- super(parent, renderer);
- }
-
- /**
- * Sets message shown in the right top corner. Use {0} and {1} as placeholders
- * for the current and the total number of pages.
- * @param message the message.
- */
- public void setPageInfoMessage(String message) {
- fPageInfoMessage= message;
- }
-
- /**
- * Sets the elements to be displayed in the dialog.
- * @param elements an array of pages holding arrays of elements
- */
- public void setElements(Object[][] elements) {
- fNumberOfPages= elements.length;
- fPages= new Page[fNumberOfPages];
- for (int i= 0; i != fNumberOfPages; i++)
- fPages[i]= new Page(elements[i]);
-
- initializeResult(fNumberOfPages);
- }
-
- /*
- * @see Window#open()
- */
- public int open() {
- List selection= getInitialElementSelections();
- if (selection == null || selection.size() != fNumberOfPages) {
- setInitialSelections(new Object[fNumberOfPages]);
- selection= getInitialElementSelections();
- }
-
- Assert.isTrue(selection.size() == fNumberOfPages);
-
- return super.open();
- }
-
- /*
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite contents= (Composite) super.createDialogArea(parent);
-
- createMessageArea(contents);
- createFilterText(contents);
- createFilteredList(contents);
-
- fCurrentPage= 0;
- setPageData();
-
- applyDialogFont(contents);
- return contents;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(Composite)
- */
- protected void createButtonsForButtonBar(Composite parent) {
- fBackButton= createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
- fNextButton= createButton(parent, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, true);
- fFinishButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.FINISH_LABEL, false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- /*
- * @see org.eclipse.ui.dialogs.SelectionDialog#createMessageArea(Composite)
- */
- protected Label createMessageArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.horizontalSpacing= 5;
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- composite.setLayoutData(data);
-
- Label messageLabel= super.createMessageArea(composite);
-
- fPageInfoLabel= new Label(composite, SWT.NULL);
- fPageInfoLabel.setText(getPageInfoMessage());
-
- data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalAlignment= GridData.END;
- fPageInfoLabel.setLayoutData(data);
- applyDialogFont(messageLabel);
- return messageLabel;
- }
-
- /*
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
- */
- protected void computeResult() {
- setResult(fCurrentPage, getSelectedElements());
- }
-
- /*
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.BACK_ID) {
- turnPage(false);
- } else if (buttonId == IDialogConstants.NEXT_ID) {
- turnPage(true);
- } else {
- super.buttonPressed(buttonId);
- }
- }
-
- /**
- * @see AbstractElementListSelectionDialog#handleDefaultSelected()
- */
- protected void handleDefaultSelected() {
- if (validateCurrentSelection()) {
- if (fCurrentPage == fNumberOfPages - 1) {
- buttonPressed(IDialogConstants.OK_ID);
- } else {
- buttonPressed(IDialogConstants.NEXT_ID);
- }
- }
- }
-
- /**
- * @see AbstractElementListSelectionDialog#updateButtonsEnableState(IStatus)
- */
- protected void updateButtonsEnableState(IStatus status) {
- boolean isOK= !status.matches(IStatus.ERROR);
- fPages[fCurrentPage].okState= isOK;
-
- boolean isAllOK= isOK;
- for (int i= 0; i != fNumberOfPages; i++)
- isAllOK = isAllOK && fPages[i].okState;
-
- fFinishButton.setEnabled(isAllOK);
-
- boolean nextButtonEnabled= isOK && (fCurrentPage < fNumberOfPages - 1);
-
- fNextButton.setEnabled(nextButtonEnabled);
- fBackButton.setEnabled(fCurrentPage != 0);
-
- if (nextButtonEnabled) {
- getShell().setDefaultButton(fNextButton);
- } else if (isAllOK) {
- getShell().setDefaultButton(fFinishButton);
- }
- }
-
- private void turnPage(boolean toNextPage) {
- Page page= fPages[fCurrentPage];
-
- // store filter
- String filter= getFilter();
- if (filter == null)
- filter= ""; //$NON-NLS-1$
- page.filter= filter;
-
- // store selection
- Object[] selectedElements= getSelectedElements();
- List list= getInitialElementSelections();
- list.set(fCurrentPage, selectedElements);
-
- // store result
- setResult(fCurrentPage, getSelectedElements());
-
- if (toNextPage) {
- if (fCurrentPage + 1 >= fNumberOfPages)
- return;
-
- fCurrentPage++;
- } else {
- if (fCurrentPage - 1 < 0)
- return;
-
- fCurrentPage--;
- }
-
- if (fPageInfoLabel != null && !fPageInfoLabel.isDisposed())
- fPageInfoLabel.setText(getPageInfoMessage());
-
- setPageData();
-
- validateCurrentSelection();
- }
-
- private void setPageData() {
- Page page= fPages[fCurrentPage];
-
- // 1. set elements
- setListElements(page.elements);
-
- // 2. apply filter
- String filter= page.filter;
- if (filter == null)
- filter= ""; //$NON-NLS-1$
- setFilter(filter);
-
- // 3. select elements
- Object[] selectedElements= (Object[]) getInitialElementSelections().get(fCurrentPage);
- setSelection(selectedElements);
- fFilteredList.setFocus();
- }
-
- private String getPageInfoMessage() {
- if (fPageInfoMessage == null)
- return ""; //$NON-NLS-1$
-
- String[] args= new String[] { Integer.toString(fCurrentPage + 1), Integer.toString(fNumberOfPages) };
- return Messages.format(fPageInfoMessage, args);
- }
-
- private void initializeResult(int length) {
- List result= new ArrayList(length);
- for (int i= 0; i != length; i++)
- result.add(null);
-
- setResult(result);
- }
-
- /**
- * Gets the current Page.
- * @return Returns a int
- */
- public int getCurrentPage() {
- return fCurrentPage;
- }
-
- /**
- * Set the <code>Comparator</code> used to sort
- * the elements in the List.
- *
- * @param comparator the comparator to use, not null.
- */
- public void setComparator(Comparator comparator) {
- fComparator= comparator;
- if (fFilteredList != null)
- fFilteredList.setComparator(fComparator);
- }
-
- /**
- * {@inheritDoc}
- */
- protected FilteredList createFilteredList(Composite parent) {
- FilteredList filteredList= super.createFilteredList(parent);
- if (fComparator != null) {
- filteredList.setComparator(fComparator);
- }
- return filteredList;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog.java
deleted file mode 100644
index 7a849eed..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.dialogs.TypeSelectionExtension;
-
-/**
- * A type selection dialog used for opening types.
- */
-public class OpenTypeSelectionDialog extends FilteredTypesSelectionDialog {
-
- private static final String DIALOG_SETTINGS= "org.eclipse.wst.jsdt.internal.ui.dialogs.OpenTypeSelectionDialog2"; //$NON-NLS-1$
-
- public OpenTypeSelectionDialog(Shell parent, boolean multi, IRunnableContext context, IJavaScriptSearchScope scope, int elementKinds) {
- this(parent, multi, context, scope, elementKinds, null);
- }
-
- public OpenTypeSelectionDialog(Shell parent, boolean multi, IRunnableContext context, IJavaScriptSearchScope scope, int elementKinds, TypeSelectionExtension extension) {
- super(parent, multi, context, scope, elementKinds, extension);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.OPEN_TYPE_DIALOG);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog#getDialogSettings()
- */
- protected IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS);
-
- if (settings == null) {
- settings= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS);
- }
-
- return settings;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog2.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog2.java
deleted file mode 100644
index 53af66f1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OpenTypeSelectionDialog2.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.dialogs.TypeSelectionExtension;
-
-/**
- * @deprecated use {@link OpenTypeSelectionDialog}
- */
-public class OpenTypeSelectionDialog2 extends TypeSelectionDialog2 {
-
- private IDialogSettings fSettings;
- private Point fLocation;
- private Point fSize;
-
- private static final String DIALOG_SETTINGS= "org.eclipse.wst.jsdt.internal.ui.dialogs.OpenTypeSelectionDialog2"; //$NON-NLS-1$
- private static final String WIDTH= "width"; //$NON-NLS-1$
- private static final String HEIGHT= "height"; //$NON-NLS-1$
-
- public OpenTypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IJavaScriptSearchScope scope, int elementKinds) {
- this(parent, multi, context, scope, elementKinds, null);
- }
-
- public OpenTypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context,
- IJavaScriptSearchScope scope, int elementKinds, TypeSelectionExtension extension) {
- super(parent, multi, context, scope, elementKinds, extension);
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- fSettings= settings.getSection(DIALOG_SETTINGS);
- if (fSettings == null) {
- fSettings= new DialogSettings(DIALOG_SETTINGS);
- settings.addSection(fSettings);
- fSettings.put(WIDTH, 480);
- fSettings.put(HEIGHT, 320);
- }
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.OPEN_TYPE_DIALOG);
- }
-
- protected Point getInitialSize() {
- Point result= super.getInitialSize();
- if (fSize != null) {
- result.x= Math.max(result.x, fSize.x);
- result.y= Math.max(result.y, fSize.y);
- Rectangle display= getShell().getDisplay().getClientArea();
- result.x= Math.min(result.x, display.width);
- result.y= Math.min(result.y, display.height);
- }
- return result;
- }
-
- protected Point getInitialLocation(Point initialSize) {
- Point result= super.getInitialLocation(initialSize);
- if (fLocation != null) {
- result.x= fLocation.x;
- result.y= fLocation.y;
- Rectangle display= getShell().getDisplay().getClientArea();
- int xe= result.x + initialSize.x;
- if (xe > display.width) {
- result.x-= xe - display.width;
- }
- int ye= result.y + initialSize.y;
- if (ye > display.height) {
- result.y-= ye - display.height;
- }
- }
- return result;
- }
-
- protected Control createDialogArea(Composite parent) {
- readSettings();
- return super.createDialogArea(parent);
- }
-
- public boolean close() {
- writeSettings();
- return super.close();
- }
-
- /**
- * Initializes itself from the dialog settings with the same state
- * as at the previous invocation.
- */
- private void readSettings() {
- try {
- int x= fSettings.getInt("x"); //$NON-NLS-1$
- int y= fSettings.getInt("y"); //$NON-NLS-1$
- fLocation= new Point(x, y);
- } catch (NumberFormatException e) {
- fLocation= null;
- }
- try {
- int width= fSettings.getInt("width"); //$NON-NLS-1$
- int height= fSettings.getInt("height"); //$NON-NLS-1$
- fSize= new Point(width, height);
-
- } catch (NumberFormatException e) {
- fSize= null;
- }
- }
-
- /**
- * Stores it current configuration in the dialog store.
- */
- private void writeSettings() {
- Point location= getShell().getLocation();
- fSettings.put("x", location.x); //$NON-NLS-1$
- fSettings.put("y", location.y); //$NON-NLS-1$
-
- Point size= getShell().getSize();
- fSettings.put("width", size.x); //$NON-NLS-1$
- fSettings.put("height", size.y); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OptionalMessageDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OptionalMessageDialog.java
deleted file mode 100644
index 4feb5a04..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OptionalMessageDialog.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-
-/**
- * This is a <code>MessageDialog</code> which allows the user
- * to choose that the dialog isn't shown again the next time.
- */
-public class OptionalMessageDialog extends MessageDialog {
-
- // String constants for widgets
- private static final String CHECKBOX_TEXT= JavaUIMessages.OptionalMessageDialog_dontShowAgain;
-
- // Dialog store id constants
- private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$
-
- public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1;
-
- private Button fHideDialogCheckBox;
- private String fId;
-
- /**
- * Opens the dialog but only if the user hasn't choosen to hide it.
- * Returns <code>NOT_SHOWN</code> if the dialog was not shown.
- */
- public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
- if (!isDialogEnabled(id))
- return OptionalMessageDialog.NOT_SHOWN;
-
- MessageDialog dialog= new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
- return dialog.open();
- }
-
- protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
- super(parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
- fId= id;
- }
-
- protected Control createCustomArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fHideDialogCheckBox= new Button(composite, SWT.CHECK | SWT.LEFT);
- fHideDialogCheckBox.setText(CHECKBOX_TEXT);
- fHideDialogCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setDialogEnabled(fId, !((Button)e.widget).getSelection());
- }
- });
- applyDialogFont(fHideDialogCheckBox);
- return fHideDialogCheckBox;
- }
-
- //--------------- Configuration handling --------------
-
- /**
- * Returns this dialog
- *
- * @return the settings to be used
- */
- private static IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- settings= settings.getSection(STORE_ID);
- if (settings == null)
- settings= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
- return settings;
- }
-
- /**
- * Answers whether the optional dialog is enabled and should be shown.
- */
- public static boolean isDialogEnabled(String key) {
- IDialogSettings settings= getDialogSettings();
- return !settings.getBoolean(key);
- }
-
- /**
- * Sets whether the optional dialog is enabled and should be shown.
- */
- public static void setDialogEnabled(String key, boolean isEnabled) {
- IDialogSettings settings= getDialogSettings();
- settings.put(key, !isEnabled);
- }
-
- /**
- * Clears all remembered information about hidden dialogs
- */
- public static void clearAllRememberedStates() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- settings.addNewSection(STORE_ID);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OverrideMethodDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OverrideMethodDialog.java
deleted file mode 100644
index 3599e90b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/OverrideMethodDialog.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ViewerPane;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.BindingLabelProvider;
-
-public class OverrideMethodDialog extends SourceActionDialog {
-
- private static final boolean SHOW_ONLY_SUPER = true;
-
-
- private class OverrideFlatTreeAction extends Action {
-
- private boolean fToggle;
-
-
- public OverrideFlatTreeAction() {
- setToolTipText(JavaUIMessages.OverrideMethodDialog_groupMethodsByTypes);
-
- JavaPluginImages.setLocalImageDescriptors(this, "impl_co.gif"); //$NON-NLS-1$
-
- fToggle= getOverrideContentProvider().isShowTypes();
- setChecked(fToggle);
- }
-
- private OverrideMethodContentProvider getOverrideContentProvider() {
- return (OverrideMethodContentProvider) getContentProvider();
- }
-
- public void run() {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=39264
- Object[] elementList= getOverrideContentProvider().getViewer().getCheckedElements();
- fToggle= !fToggle;
- setChecked(fToggle);
- getOverrideContentProvider().setShowTypes(fToggle);
- getOverrideContentProvider().getViewer().setCheckedElements(elementList);
- }
-
- }
-
- private static class OverrideMethodContentProvider implements ITreeContentProvider {
-
- private final Object[] fEmpty= new Object[0];
-
- private IFunction[] fMethods;
-
- private IDialogSettings fSettings;
-
- private boolean fShowTypes;
-
- // private Object[] fTypes;
-
- private ContainerCheckedTreeViewer fViewer;
-
- private final String SETTINGS_SECTION= "OverrideMethodDialog"; //$NON-NLS-1$
-
- private final String SETTINGS_SHOWTYPES= "showtypes"; //$NON-NLS-1$
-
- /**
- * Constructor for OverrideMethodContentProvider.
- */
- public OverrideMethodContentProvider() {
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- fSettings= dialogSettings.getSection(SETTINGS_SECTION);
- if (fSettings == null) {
- fSettings= dialogSettings.addNewSection(SETTINGS_SECTION);
- fSettings.put(SETTINGS_SHOWTYPES, true);
- }
- fShowTypes= fSettings.getBoolean(SETTINGS_SHOWTYPES);
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IJavaScriptUnit) {
- ArrayList result= new ArrayList(fMethods.length);
- for (int index= 0; index < fMethods.length; index++) {
- if (fMethods[index].getCompilationUnit() == parentElement)
- result.add(fMethods[index]);
- }
- return result.toArray();
- }
- return fEmpty;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- return fMethods;
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- if (element instanceof IFunction) {
- return ((IFunction) element).getCompilationUnit();
- }
- return null;
- }
-
- public ContainerCheckedTreeViewer getViewer() {
- return fViewer;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public void init(IFunction[] methods) {
- fMethods= methods;
- //fTypes= types;
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fViewer= (ContainerCheckedTreeViewer) viewer;
- }
-
- public boolean isShowTypes() {
- return fShowTypes;
- }
-
- public void setShowTypes(boolean showTypes) {
- if (fShowTypes != showTypes) {
- fShowTypes= showTypes;
- fSettings.put(SETTINGS_SHOWTYPES, showTypes);
- if (fViewer != null)
- fViewer.refresh();
- }
- }
- }
-
- private static class OverrideMethodComparator extends ViewerComparator {
-
- private ITypeBinding[] fAllTypes= new ITypeBinding[0];
-
- public OverrideMethodComparator(ITypeBinding curr) {
- if (curr != null) {
- ITypeBinding[] superTypes= Bindings.getAllSuperTypes(curr);
- fAllTypes= new ITypeBinding[superTypes.length + 1];
- fAllTypes[0]= curr;
- System.arraycopy(superTypes, 0, fAllTypes, 1, superTypes.length);
- }
- }
-
- /*
- * @see ViewerSorter#compare(Viewer, Object, Object)
- */
- public int compare(Viewer viewer, Object first, Object second) {
- if (first instanceof ITypeBinding && second instanceof ITypeBinding) {
- final ITypeBinding left= (ITypeBinding) first;
- final ITypeBinding right= (ITypeBinding) second;
- if (right.getQualifiedName().equals("java.lang.Object")) //$NON-NLS-1$
- return -1;
- if (left.isEqualTo(right))
- return 0;
- if (Bindings.isSuperType(left, right))
- return +1;
- else if (Bindings.isSuperType(right, left))
- return -1;
- return 0;
- } else
- return super.compare(viewer, first, second);
- }
- }
-
- private static class OverrideMethodValidator implements ISelectionStatusValidator {
-
- private static int fNumMethods;
-
- public OverrideMethodValidator(int entries) {
- fNumMethods= entries;
- }
-
- /*
- * @see ISelectionValidator#validate(Object[])
- */
- public IStatus validate(Object[] selection) {
- int count= 0;
- for (int index= 0; index < selection.length; index++) {
- if (selection[index] instanceof IFunction)
- count++;
- }
- if (count == 0)
- return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
- return new StatusInfo(IStatus.INFO, Messages.format(JavaUIMessages.OverrideMethodDialog_selectioninfo_more, new String[] { String.valueOf(count), String.valueOf(fNumMethods)}));
- }
- }
-
- private static ITypeBinding getSuperType(final ITypeBinding binding, final String name) {
-
- if (binding.isArray() || binding.isPrimitive())
- return null;
-
- if (binding.getQualifiedName().startsWith(name))
- return binding;
-
- final ITypeBinding type= binding.getSuperclass();
- if (type != null) {
- final ITypeBinding result= getSuperType(type, name);
- if (result != null)
- return result;
- }
- final ITypeBinding[] types= binding.getInterfaces();
- for (int index= 0; index < types.length; index++) {
- final ITypeBinding result= getSuperType(types[index], name);
- if (result != null)
- return result;
- }
- return null;
- }
-
- private JavaScriptUnit fUnit= null;
-
- public OverrideMethodDialog(Shell shell, CompilationUnitEditor editor, IType type, boolean isSubType) throws JavaScriptModelException {
- super(shell, new BindingLabelProvider(), new OverrideMethodContentProvider(), editor, type, false);
-
-// IMethod[] methods = type.getMethods();
- String parentName = type.getSuperclassName();
- IType superType = type.getJavaScriptProject().findType(parentName);
- IFunction pMethods[] = superType.getMethods();
- IFunction tMethods[] = type.getMethods();
-
- IFunction parentMethods[] = new IFunction[0];
-
- if(OverrideMethodDialog.SHOW_ONLY_SUPER){
-
- ArrayList show = new ArrayList();
- start: for(int i = 0;pMethods!=null && i<pMethods.length;i++){
- for(int k=0;k<tMethods.length;k++){
- if(tMethods[k].getElementName().equals(pMethods[i].getElementName())){
- continue start;
- }
- }
- show.add(pMethods[i]);
-
-
- }
- parentMethods = (IFunction[]) show.toArray(new IFunction[show.size()]);
-
- }
-
-
-
- //IMethodBinding[] toImplementArray= (IMethodBinding[]) toImplement.toArray(new IMethodBinding[toImplement.size()]);
- setInitialSelections(parentMethods);
-
- HashSet expanded= new HashSet(parentMethods.length);
- for (int i= 0; i < parentMethods.length; i++) {
- expanded.add(parentMethods[i]);
- }
-
- HashSet types= new HashSet(parentMethods.length);
- for (int i= 0; i < parentMethods.length; i++) {
- types.add(parentMethods[i]);
- }
-
- IFunction[] typesArrays= (IFunction[]) types.toArray(new IFunction[types.size()]);
- OverrideMethodComparator comparator= null;//new OverrideMethodComparator(binding);
- if (expanded.isEmpty() && typesArrays.length > 0) {
- comparator.sort(null, typesArrays);
- expanded.add(typesArrays[0]);
- }
- setExpandedElements(expanded.toArray());
-
- ((OverrideMethodContentProvider) getContentProvider()).init(parentMethods);
-
- setTitle(JavaUIMessages.OverrideMethodDialog_dialog_title);
- setMessage(null);
- setValidator(new OverrideMethodValidator(parentMethods.length));
- setComparator(comparator);
- setContainerMode(true);
- setSize(60, 18);
- setInput(new Object());
- }
-
- public JavaScriptUnit getCompilationUnit() {
- return fUnit;
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.OVERRIDE_TREE_SELECTION_DIALOG);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.dialogs.SourceActionDialog#createLinkControl(org.eclipse.swt.widgets.Composite)
- */
- protected Control createLinkControl(Composite composite) {
- Link link= new Link(composite, SWT.WRAP);
- link.setText(JavaUIMessages.OverrideMethodDialog_link_message);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- openCodeTempatePage(CodeTemplateContextType.OVERRIDECOMMENT_ID);
- }
- });
- link.setToolTipText(JavaUIMessages.OverrideMethodDialog_link_tooltip);
-
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= convertWidthInCharsToPixels(40); // only expand further if anyone else requires it
- link.setLayoutData(gridData);
- return link;
- }
-
- /*
- * @see CheckedTreeSelectionDialog#createTreeViewer(Composite)
- */
- protected CheckboxTreeViewer createTreeViewer(Composite composite) {
- initializeDialogUnits(composite);
- ViewerPane pane= new ViewerPane(composite, SWT.BORDER | SWT.FLAT);
- pane.setText(JavaUIMessages.OverrideMethodDialog_dialog_description);
- CheckboxTreeViewer treeViewer= super.createTreeViewer(pane);
- pane.setContent(treeViewer.getControl());
- GridLayout paneLayout= new GridLayout();
- paneLayout.marginHeight= 0;
- paneLayout.marginWidth= 0;
- paneLayout.numColumns= 1;
- pane.setLayout(paneLayout);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(55);
- gd.heightHint= convertHeightInCharsToPixels(15);
- pane.setLayoutData(gd);
- ToolBarManager manager= pane.getToolBarManager();
- manager.add(new OverrideFlatTreeAction()); // create after tree is created
- manager.update(true);
- treeViewer.getTree().setFocus();
- return treeViewer;
- }
-
- public boolean hasMethodsToOverride() {
- return getContentProvider().getElements(null).length > 0;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/PackageSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/PackageSelectionDialog.java
deleted file mode 100644
index 2eeaa58f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/PackageSelectionDialog.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchMatch;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.core.search.SearchRequestor;
-import org.eclipse.wst.jsdt.internal.corext.util.SearchUtils;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-/**
- * Dialog to browse for package fragments.
- */
-public class PackageSelectionDialog extends ElementListSelectionDialog {
-
- public static final int F_REMOVE_DUPLICATES= 1;
- public static final int F_SHOW_PARENTS= 2;
- public static final int F_HIDE_DEFAULT_PACKAGE= 4;
- public static final int F_HIDE_EMPTY_INNER= 8;
-
-
- /** The dialog location. */
- private Point fLocation;
- /** The dialog size. */
- private Point fSize;
-
- private IRunnableContext fContext;
- private IJavaScriptSearchScope fScope;
- private int fFlags;
-
- /**
- * Creates a package selection dialog.
- * @param parent the parent shell
- * @param context the runnable context to run the search in
- * @param flags a combination of <code>F_REMOVE_DUPLICATES</code>, <code>F_SHOW_PARENTS</code>,
- * <code>F_HIDE_DEFAULT_PACKAGE</code> and <code>F_HIDE_EMPTY_INNER</code>
- * @param scope the scope defining the available packages.
- */
- public PackageSelectionDialog(Shell parent, IRunnableContext context, int flags, IJavaScriptSearchScope scope) {
- super(parent, createLabelProvider(flags));
- fFlags= flags;
- fScope= scope;
- fContext= context;
- }
-
- private static ILabelProvider createLabelProvider(int dialogFlags) {
- int flags= JavaScriptElementLabelProvider.SHOW_DEFAULT;
- if ((dialogFlags & F_REMOVE_DUPLICATES) == 0) {
- flags= flags | JavaScriptElementLabelProvider.SHOW_ROOT;
- }
- return new JavaScriptElementLabelProvider(flags);
- }
-
-
- /*
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open() {
- final ArrayList packageList= new ArrayList();
-
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- boolean hideEmpty= (fFlags & F_HIDE_EMPTY_INNER) != 0;
- monitor.beginTask(JavaUIMessages.PackageSelectionDialog_progress_search, hideEmpty ? 2 : 1);
- try {
- SearchRequestor requestor= new SearchRequestor() {
- private HashSet fSet= new HashSet();
- private final boolean fAddDefault= (fFlags & F_HIDE_DEFAULT_PACKAGE) == 0;
- private final boolean fDuplicates= (fFlags & F_REMOVE_DUPLICATES) == 0;
- private final boolean fIncludeParents= (fFlags & F_SHOW_PARENTS) != 0;
-
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- IJavaScriptElement enclosingElement= (IJavaScriptElement) match.getElement();
- String name= enclosingElement.getElementName();
- if (fAddDefault || name.length() > 0) {
- if (fDuplicates || fSet.add(name)) {
- packageList.add(enclosingElement);
- if (fIncludeParents) {
- addParentPackages(enclosingElement, name);
- }
- }
- }
- }
-
- private void addParentPackages(IJavaScriptElement enclosingElement, String name) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) enclosingElement.getParent();
- int idx= name.lastIndexOf('.');
- while (idx != -1) {
- name= name.substring(0, idx);
- if (fDuplicates || fSet.add(name)) {
- packageList.add(root.getPackageFragment(name));
- }
- idx= name.lastIndexOf('.');
- }
- }
- };
- SearchPattern pattern= SearchPattern.createPattern("*", //$NON-NLS-1$
- IJavaScriptSearchConstants.PACKAGE, IJavaScriptSearchConstants.DECLARATIONS,
- SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE);
- new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), fScope, requestor, new SubProgressMonitor(monitor, 1));
-
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- if (hideEmpty) {
- removeEmptyPackages(new SubProgressMonitor(monitor, 1));
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException();
- } finally {
- monitor.done();
- }
- }
-
- private void removeEmptyPackages(IProgressMonitor monitor) throws JavaScriptModelException, InterruptedException {
- monitor.beginTask(JavaUIMessages.PackageSelectionDialog_progress_findEmpty, packageList.size());
- try {
- ArrayList res= new ArrayList(packageList.size());
- for (int i= 0; i < packageList.size(); i++) {
- IPackageFragment pkg= (IPackageFragment) packageList.get(i);
- if (pkg.hasChildren() || !pkg.hasSubpackages()) {
- res.add(pkg);
- }
- monitor.worked(1);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- packageList.clear();
- packageList.addAll(res);
- } finally{
- monitor.done();
- }
- }
- };
-
- try {
- fContext.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, JavaUIMessages.PackageSelectionDialog_error_title, JavaUIMessages.PackageSelectionDialog_error3Message);
- return CANCEL;
- } catch (InterruptedException e) {
- // cancelled by user
- return CANCEL;
- }
-
- if (packageList.isEmpty()) {
- String title= JavaUIMessages.PackageSelectionDialog_nopackages_title;
- String message= JavaUIMessages.PackageSelectionDialog_nopackages_message;
- MessageDialog.openInformation(getShell(), title, message);
- return CANCEL;
- }
-
- setElements(packageList.toArray());
-
- return super.open();
- }
-
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.OPEN_PACKAGE_DIALOG);
- }
-
- /*
- * @see Window#close()
- */
- public boolean close() {
- writeSettings();
- return super.close();
- }
-
- /*
- * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- Control control= super.createContents(parent);
- readSettings();
- return control;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
- protected Point getInitialSize() {
- Point result= super.getInitialSize();
- if (fSize != null) {
- result.x= Math.max(result.x, fSize.x);
- result.y= Math.max(result.y, fSize.y);
- Rectangle display= getShell().getDisplay().getClientArea();
- result.x= Math.min(result.x, display.width);
- result.y= Math.min(result.y, display.height);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
- */
- protected Point getInitialLocation(Point initialSize) {
- Point result= super.getInitialLocation(initialSize);
- if (fLocation != null) {
- result.x= fLocation.x;
- result.y= fLocation.y;
- Rectangle display= getShell().getDisplay().getClientArea();
- int xe= result.x + initialSize.x;
- if (xe > display.width) {
- result.x-= xe - display.width;
- }
- int ye= result.y + initialSize.y;
- if (ye > display.height) {
- result.y-= ye - display.height;
- }
- }
- return result;
- }
-
-
-
- /**
- * Initializes itself from the dialog settings with the same state
- * as at the previous invocation.
- */
- private void readSettings() {
- IDialogSettings s= getDialogSettings();
- try {
- int x= s.getInt("x"); //$NON-NLS-1$
- int y= s.getInt("y"); //$NON-NLS-1$
- fLocation= new Point(x, y);
- int width= s.getInt("width"); //$NON-NLS-1$
- int height= s.getInt("height"); //$NON-NLS-1$
- fSize= new Point(width, height);
-
- } catch (NumberFormatException e) {
- fLocation= null;
- fSize= null;
- }
- }
-
- /**
- * Stores it current configuration in the dialog store.
- */
- private void writeSettings() {
- IDialogSettings s= getDialogSettings();
-
- Point location= getShell().getLocation();
- s.put("x", location.x); //$NON-NLS-1$
- s.put("y", location.y); //$NON-NLS-1$
-
- Point size= getShell().getSize();
- s.put("width", size.x); //$NON-NLS-1$
- s.put("height", size.y); //$NON-NLS-1$
- }
-
- /**
- * Returns the dialog settings object used to share state
- * between several find/replace dialogs.
- *
- * @return the dialog settings to be used
- */
- private IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- String sectionName= getClass().getName();
- IDialogSettings subSettings= settings.getSection(sectionName);
- if (subSettings == null)
- subSettings= settings.addNewSection(sectionName);
- return subSettings;
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SortMembersMessageDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SortMembersMessageDialog.java
deleted file mode 100644
index 8948b613..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SortMembersMessageDialog.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.preferences.MembersOrderPreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-
-public class SortMembersMessageDialog extends OptionalMessageDialog {
-
- private final static String OPTIONAL_ID= "SortMembersMessageDialog.optionalDialog.id"; //$NON-NLS-1$
-
- private final static String DIALOG_SETTINGS_SORT_ALL= "SortMembers.sort_all"; //$NON-NLS-1$
-
- private SelectionButtonDialogField fNotSortAllRadio;
- private SelectionButtonDialogField fSortAllRadio;
-
- private final IDialogSettings fDialogSettings;
-
- public SortMembersMessageDialog(Shell parentShell) {
- super(OPTIONAL_ID, parentShell, DialogsMessages.SortMembersMessageDialog_dialog_title, null, new String(), INFORMATION, new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
-
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
-
- boolean isSortAll= fDialogSettings.getBoolean(DIALOG_SETTINGS_SORT_ALL);
-
- fNotSortAllRadio= new SelectionButtonDialogField(SWT.RADIO);
- fNotSortAllRadio.setLabelText(DialogsMessages.SortMembersMessageDialog_do_not_sort_fields_label);
- fNotSortAllRadio.setSelection(!isSortAll);
-
- fSortAllRadio= new SelectionButtonDialogField(SWT.RADIO);
- fSortAllRadio.setLabelText(DialogsMessages.SortMembersMessageDialog_sort_all_label);
- fSortAllRadio.setSelection(isSortAll);
- }
-
- private Control createLinkControl(Composite composite) {
- Link link= new Link(composite, SWT.WRAP | SWT.RIGHT);
- link.setText(DialogsMessages.SortMembersMessageDialog_description);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- openCodeTempatePage(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID);
- }
- });
- link.setToolTipText(DialogsMessages.SortMembersMessageDialog_link_tooltip);
- GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false);
- gridData.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);//convertWidthInCharsToPixels(60);
- link.setLayoutData(gridData);
- link.setFont(composite.getFont());
-
- return link;
- }
-
- protected void openCodeTempatePage(String id) {
- PreferencesUtil.createPreferenceDialogOn(getShell(), MembersOrderPreferencePage.PREF_ID, null, null).open();
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- Control contents= super.createContents(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.SORT_MEMBERS_DIALOG);
- return contents;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createMessageArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite messageComposite= new Composite(parent, SWT.NONE);
- messageComposite.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- messageComposite.setLayout(layout);
- messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- createLinkControl(messageComposite);
-
- int indent= convertWidthInCharsToPixels(3);
-
- fNotSortAllRadio.doFillIntoGrid(messageComposite, 1);
- LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null), indent);
-
- fSortAllRadio.doFillIntoGrid(messageComposite, 1);
- LayoutUtil.setHorizontalIndent(fSortAllRadio.getSelectionButton(null), indent);
-
- final Composite warningComposite= new Composite(messageComposite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- warningComposite.setLayout(layout);
- warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- warningComposite.setFont(messageComposite.getFont());
-
- Image image= Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
- final Label imageLabel1= new Label(warningComposite, SWT.LEFT | SWT.WRAP);
- imageLabel1.setImage(image);
- imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
-
- final Label label= new Label(warningComposite, SWT.WRAP);
- label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label);
- GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
- gridData.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- label.setLayoutData(gridData);
- label.setFont(warningComposite.getFont());
-
- fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
- label.setEnabled(!fNotSortAllRadio.isSelected());
- }
- });
- imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
- label.setEnabled(!fNotSortAllRadio.isSelected());
-
- return messageComposite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open() {
- if (isDialogEnabled(OPTIONAL_ID)) {
- int res= super.open();
- if (res != Window.OK) {
- setDialogEnabled(OPTIONAL_ID, true); // don't save state on cancel
- }
- return res;
- }
- return Window.OK;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#close()
- */
- public boolean close() {
- fDialogSettings.put(DIALOG_SETTINGS_SORT_ALL, fSortAllRadio.isSelected());
- return super.close();
- }
-
-
- public boolean isNotSortingFieldsEnabled() {
- return fNotSortAllRadio.isSelected();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SourceActionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SourceActionDialog.java
deleted file mode 100644
index 9cc4b338..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/SourceActionDialog.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.StringConverter;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.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.swt.widgets.TreeItem;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.preferences.CodeTemplatePreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.IVisibilityChangeListener;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * An advanced version of CheckedTreeSelectionDialog with right-side button layout and
- * extra buttons and composites.
- */
-public class SourceActionDialog extends CheckedTreeSelectionDialog {
-
- protected List fInsertPositions;
- protected List fLabels;
- protected int fCurrentPositionIndex;
-
- protected IDialogSettings fSettings;
- protected CompilationUnitEditor fEditor;
- protected ITreeContentProvider fContentProvider;
- protected boolean fGenerateComment;
- protected IType fType;
- protected int fWidth, fHeight;
- protected String fCommentString;
- protected boolean fEnableInsertPosition= true;
-
- protected int fVisibilityModifier;
- protected boolean fFinal;
- protected boolean fSynchronized;
-
- protected final String SETTINGS_SECTION_METHODS= "SourceActionDialog.methods"; //$NON-NLS-1$
- protected final String SETTINGS_SECTION_CONSTRUCTORS= "SourceActionDialog.constructors"; //$NON-NLS-1$
-
- protected final String SETTINGS_INSERTPOSITION= "InsertPosition"; //$NON-NLS-1$
- protected final String SETTINGS_VISIBILITY_MODIFIER= "VisibilityModifier"; //$NON-NLS-1$
- protected final String SETTINGS_FINAL_MODIFIER= "FinalModifier"; //$NON-NLS-1$
- protected final String SETTINGS_SYNCHRONIZED_MODIFIER= "SynchronizedModifier"; //$NON-NLS-1$
- protected final String SETTINGS_COMMENTS= "Comments"; //$NON-NLS-1$
- protected Composite fInsertPositionComposite;
-
- public SourceActionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider, CompilationUnitEditor editor, IType type, boolean isConstructor) throws JavaScriptModelException {
- super(parent, labelProvider, contentProvider);
- fEditor= editor;
- fContentProvider= contentProvider;
- fType= type;
- fCommentString= ActionMessages.SourceActionDialog_createMethodComment;
- setEmptyListMessage(ActionMessages.SourceActionDialog_no_entries);
-
- fWidth= 60;
- fHeight= 18;
-
- int insertionDefault= isConstructor ? 0 : 1;
- boolean generateCommentsDefault= JavaPreferencesSettings.getCodeGenerationSettings(type.getJavaScriptProject()).createComments;
-
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- String sectionId= isConstructor ? SETTINGS_SECTION_CONSTRUCTORS : SETTINGS_SECTION_METHODS;
- fSettings= dialogSettings.getSection(sectionId);
- if (fSettings == null) {
- fSettings= dialogSettings.addNewSection(sectionId);
- }
-
- fVisibilityModifier= asInt(fSettings.get(SETTINGS_VISIBILITY_MODIFIER), Modifier.PUBLIC);
- fFinal= asBoolean(fSettings.get(SETTINGS_FINAL_MODIFIER), false);
- fSynchronized= asBoolean(fSettings.get(SETTINGS_SYNCHRONIZED_MODIFIER), false);
- fCurrentPositionIndex= asInt(fSettings.get(SETTINGS_INSERTPOSITION), insertionDefault);
- fGenerateComment= asBoolean(fSettings.get(SETTINGS_COMMENTS), generateCommentsDefault);
- setupInsertPostions();
- }
-
- public void setupInsertPostions(){
- fInsertPositions= new ArrayList();
- fLabels= new ArrayList();
-
- IJavaScriptElement[] members = new IJavaScriptElement[0];
- IFunction[] methods = new IFunction[0];
- try {
- members = fType.getChildren();
- methods= fType.getMethods();
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
-
- fInsertPositions.add(methods.length > 0 ? methods[0]: null); // first
- fInsertPositions.add(null); // last
-
- fLabels.add(ActionMessages.SourceActionDialog_first_method);
- fLabels.add(ActionMessages.SourceActionDialog_last_method);
-
- try {
- if (hasCursorPositionElement(fEditor, members, fInsertPositions)) {
- fLabels.add(ActionMessages.SourceActionDialog_cursor);
- fCurrentPositionIndex= 2;
- } else {
- // code is needed to deal with bogus values already present in the dialog store.
- fCurrentPositionIndex= Math.max(fCurrentPositionIndex, 0);
- fCurrentPositionIndex= Math.min(fCurrentPositionIndex, 1);
- }
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- for (int i = 0; i < methods.length; i++) {
- IFunction curr= methods[i];
- String methodLabel= JavaScriptElementLabels.getElementLabel(curr, JavaScriptElementLabels.M_PARAMETER_TYPES);
- fLabels.add(Messages.format(ActionMessages.SourceActionDialog_after, methodLabel));
- try {
- fInsertPositions.add(findSibling(curr, members));
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- fInsertPositions.add(null);
- }
-
- protected IType getType() {
- return fType;
- }
-
- protected boolean asBoolean(String string, boolean defaultValue) {
- if (string != null) {
- return StringConverter.asBoolean(string, defaultValue);
- }
- return defaultValue;
- }
-
- protected int asInt(String string, int defaultValue) {
- if (string != null) {
- return StringConverter.asInt(string, defaultValue);
- }
- return defaultValue;
- }
-
- private IJavaScriptElement findSibling(IFunction curr, IJavaScriptElement[] members) throws JavaScriptModelException {
- IJavaScriptElement res= null;
- int methodStart= curr.getSourceRange().getOffset();
- for (int i= members.length-1; i >= 0; i--) {
- IMember member= (IMember) members[i];
- if (methodStart >= member.getSourceRange().getOffset()) {
- return res;
- }
- res= member;
- }
- return null;
- }
-
- protected boolean hasCursorPositionElement(CompilationUnitEditor editor, IJavaScriptElement[] members, List insertPositions) throws JavaScriptModelException {
- if (editor == null) {
- return false;
- }
- int offset= ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset();
-
- for (int i= 0; i < members.length; i++) {
- IMember curr= (IMember) members[i];
- ISourceRange range= curr.getSourceRange();
- if (offset < range.getOffset()) {
- insertPositions.add(curr);
- return true;
- } else if (offset < range.getOffset() + range.getLength()) {
- return false; // in the middle of a member
- }
- }
- insertPositions.add(null);
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#close()
- */
- public boolean close() {
- fSettings.put(SETTINGS_VISIBILITY_MODIFIER, StringConverter.asString(fVisibilityModifier));
- fSettings.put(SETTINGS_FINAL_MODIFIER, StringConverter.asString(fFinal));
- fSettings.put(SETTINGS_SYNCHRONIZED_MODIFIER, StringConverter.asString(fSynchronized));
-
- if (fCurrentPositionIndex == 0 || fCurrentPositionIndex == 1) {
- fSettings.put(SETTINGS_INSERTPOSITION, StringConverter.asString(fCurrentPositionIndex));
- }
- fSettings.put(SETTINGS_COMMENTS, fGenerateComment);
- return super.close();
- }
-
- /**
- * Sets the size of the tree in unit of characters.
- * @param width the width of the tree.
- * @param height the height of the tree.
- */
- public void setSize(int width, int height) {
- fWidth = width;
- fHeight = height;
- }
-
-
- /***
- * Set insert position valid input is 0 for the first position, 1 for the last position, > 1 for all else.
- */
- private void setInsertPosition(int insert) {
- fCurrentPositionIndex= insert;
- }
-
- public void setCommentString(String string) {
- fCommentString= string;
- }
-
- protected ITreeContentProvider getContentProvider() {
- return fContentProvider;
- }
-
- public boolean getGenerateComment() {
- return fGenerateComment;
- }
-
- public int getVisibilityModifier() {
- return fVisibilityModifier;
- }
-
- public void setGenerateComment(boolean comment) {
- fGenerateComment= comment;
- }
-
- protected void setVisibility(int visibility) {
- fVisibilityModifier= visibility;
- }
-
- private void setFinal(boolean value) {
- fFinal= value;
- }
-
- private void setSynchronized(boolean value) {
- fSynchronized= value;
- }
-
- protected Composite createSelectionButtons(Composite composite) {
- Composite buttonComposite= super.createSelectionButtons(composite);
-
- GridLayout layout = new GridLayout();
- buttonComposite.setLayout(layout);
-
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 1;
-
- return buttonComposite;
- }
-
- protected void buttonPressed(int buttonId) {
- switch (buttonId) {
- case IDialogConstants.OK_ID: {
- okPressed();
- break;
- }
- case IDialogConstants.CANCEL_ID: {
- cancelPressed();
- break;
- }
- }
- }
-
- /**
- * Returns a composite containing the label created at the top of the dialog. Returns null if there is the
- * message for the label is null.
- */
- protected Label createMessageArea(Composite composite) {
- if (getMessage() != null) {
- Label label = new Label(composite,SWT.NONE);
- label.setText(getMessage());
- label.setFont(composite.getFont());
- return label;
- }
- return null;
- }
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- GridData gd= null;
-
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
-
- Label messageLabel = createMessageArea(composite);
- if (messageLabel != null) {
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- messageLabel.setLayoutData(gd);
- }
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout innerLayout = new GridLayout();
- innerLayout.numColumns= 2;
- innerLayout.marginHeight= 0;
- innerLayout.marginWidth= 0;
- inner.setLayout(innerLayout);
- inner.setFont(parent.getFont());
-
- CheckboxTreeViewer treeViewer= createTreeViewer(inner);
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint = convertWidthInCharsToPixels(fWidth);
- gd.heightHint = convertHeightInCharsToPixels(fHeight);
- treeViewer.getControl().setLayoutData(gd);
-
- Composite buttonComposite= createSelectionButtons(inner);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- buttonComposite.setLayoutData(gd);
-
- gd= new GridData(GridData.FILL_BOTH);
- inner.setLayoutData(gd);
-
- fInsertPositionComposite= createInsertPositionCombo(composite);
- fInsertPositionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite commentComposite= createCommentSelection(composite);
- commentComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control linkControl= createLinkControl(composite);
- if (linkControl != null)
- linkControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- applyDialogFont(composite);
-
- return composite;
- }
-
- protected Control createLinkControl(Composite composite) {
- return null; // No link as default
- }
-
- protected void openCodeTempatePage(String id) {
- HashMap arg= new HashMap();
- arg.put(CodeTemplatePreferencePage.DATA_SELECT_TEMPLATE, id);
- PreferencesUtil.createPropertyDialogOn(getShell(), fType.getJavaScriptProject().getProject(), CodeTemplatePreferencePage.PROP_ID, null, arg).open();
- }
-
-
- protected Composite createCommentSelection(Composite composite) {
- Composite commentComposite = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- commentComposite.setLayout(layout);
- commentComposite.setFont(composite.getFont());
-
- Button commentButton= new Button(commentComposite, SWT.CHECK);
- commentButton.setText(fCommentString);
-
- commentButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean isSelected= (((Button) e.widget).getSelection());
- setGenerateComment(isSelected);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
- commentButton.setSelection(getGenerateComment());
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- commentButton.setLayoutData(gd);
-
- return commentComposite;
- }
-
- protected Composite addVisibilityAndModifiersChoices(Composite buttonComposite) {
- // Add visibility and modifiers buttons: http://bugs.eclipse.org/bugs/show_bug.cgi?id=35870
- // Add persistence of options: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400
- IVisibilityChangeListener visibilityChangeListener= new IVisibilityChangeListener(){
- public void visibilityChanged(int newVisibility) {
- setVisibility(newVisibility);
- }
- public void modifierChanged(int modifier, boolean isChecked) {
- switch (modifier) {
- case Modifier.FINAL: {
- setFinal(isChecked);
- return;
- }
- case Modifier.SYNCHRONIZED: {
- setSynchronized(isChecked);
- return;
- }
- default: return;
- }
- }
- };
-
- int initialVisibility= getVisibilityModifier();
- int[] availableVisibilities= new int[]{Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE, Modifier.NONE};
-
- Composite visibilityComposite= createVisibilityControlAndModifiers(buttonComposite, visibilityChangeListener, availableVisibilities, initialVisibility);
- return visibilityComposite;
- }
-
- private List convertToIntegerList(int[] array) {
- List result= new ArrayList(array.length);
- for (int i= 0; i < array.length; i++) {
- result.add(new Integer(array[i]));
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.CheckedTreeSelectionDialog#create()
- */
- public void create() {
- super.create();
-
- // select the first checked element, or if none are checked, the first element
- CheckboxTreeViewer treeViewer= getTreeViewer();
- TreeItem[] items= treeViewer.getTree().getItems();
- if (items.length > 0) {
- Object revealedElement= items[0];
-
- for (int i= 0; i < items.length; i++) {
- if (items[i].getChecked()) {
- revealedElement= items[i].getData();
- break;
- }
- }
- treeViewer.setSelection(new StructuredSelection(revealedElement));
- treeViewer.reveal(revealedElement);
- }
- }
-
- protected Composite createVisibilityControl(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) {
- List allowedVisibilities= convertToIntegerList(availableVisibilities);
- if (allowedVisibilities.size() == 1)
- return null;
-
- Group group= new Group(parent, SWT.NONE);
- group.setText(ActionMessages.SourceActionDialog_modifier_group);
- GridData gd= new GridData(GridData.FILL_BOTH);
- group.setLayoutData(gd);
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= 4;
- group.setLayout(layout);
-
- String[] labels= new String[] {
- ActionMessages.SourceActionDialog_modifier_public,
- ActionMessages.SourceActionDialog_modifier_protected,
- ActionMessages.SourceActionDialog_modifier_default,
- ActionMessages.SourceActionDialog_modifier_private,
- };
- Integer[] data= new Integer[] {
- new Integer(Modifier.PUBLIC),
- new Integer(Modifier.PROTECTED),
- new Integer(Modifier.NONE),
- new Integer(Modifier.PRIVATE)};
- Integer initialVisibility= new Integer(correctVisibility);
- for (int i= 0; i < labels.length; i++) {
- Button radio= new Button(group, SWT.RADIO);
- Integer visibilityCode= data[i];
- radio.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- radio.setText(labels[i]);
- radio.setData(visibilityCode);
- radio.setSelection(visibilityCode.equals(initialVisibility));
- radio.setEnabled(allowedVisibilities.contains(visibilityCode));
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- visibilityChangeListener.visibilityChanged(((Integer)event.widget.getData()).intValue());
- }
- });
- }
- return group;
- }
-
- protected Composite createVisibilityControlAndModifiers(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) {
- Composite visibilityComposite= createVisibilityControl(parent, visibilityChangeListener, availableVisibilities, correctVisibility);
-
- Button finalCheckboxButton= new Button(visibilityComposite, SWT.CHECK);
- finalCheckboxButton.setText(ActionMessages.SourceActionDialog_modifier_final);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- finalCheckboxButton.setLayoutData(gd);
- finalCheckboxButton.setData(new Integer(Modifier.FINAL));
- finalCheckboxButton.setEnabled(true);
- finalCheckboxButton.setSelection(isFinal());
- finalCheckboxButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- visibilityChangeListener.modifierChanged(((Integer)event.widget.getData()).intValue(), ((Button) event.widget).getSelection());
- }
-
- public void widgetDefaultSelected(SelectionEvent event) {
- widgetSelected(event);
- }
- });
-
- Button syncCheckboxButton= new Button(visibilityComposite, SWT.CHECK);
- syncCheckboxButton.setText(ActionMessages.SourceActionDialog_modifier_synchronized);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- syncCheckboxButton.setLayoutData(gd);
- syncCheckboxButton.setData(new Integer(Modifier.SYNCHRONIZED));
- syncCheckboxButton.setEnabled(true);
- syncCheckboxButton.setSelection(isSynchronized());
- syncCheckboxButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- visibilityChangeListener.modifierChanged(((Integer)event.widget.getData()).intValue(), ((Button) event.widget).getSelection());
- }
-
- public void widgetDefaultSelected(SelectionEvent event) {
- widgetSelected(event);
- }
- });
- return visibilityComposite;
- }
-
- protected Composite createInsertPositionCombo(Composite composite) {
- Composite selectionComposite = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- selectionComposite.setLayout(layout);
-
- addOrderEntryChoices(selectionComposite);
-
- return selectionComposite;
- }
-
- private Composite addOrderEntryChoices(Composite buttonComposite) {
- Label enterLabel= new Label(buttonComposite, SWT.NONE);
- enterLabel.setText(ActionMessages.SourceActionDialog_enterAt_label);
- if (!fEnableInsertPosition)
- enterLabel.setEnabled(false);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- enterLabel.setLayoutData(gd);
-
- final Combo enterCombo= new Combo(buttonComposite, SWT.READ_ONLY);
- if (!fEnableInsertPosition)
- enterCombo.setEnabled(false);
- fillWithPossibleInsertPositions(enterCombo);
-
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(fWidth);
- enterCombo.setLayoutData(gd);
- enterCombo.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- int index= enterCombo.getSelectionIndex();
- // Add persistence only if first or last method: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400
- setInsertPosition(index);
- }
- });
-
- return buttonComposite;
- }
-
- private void fillWithPossibleInsertPositions(Combo combo) {
- combo.setItems((String[]) fLabels.toArray(new String[fLabels.size()]));
- combo.select(fCurrentPositionIndex);
- }
-
- public boolean getFinal() {
- return fFinal;
- }
-
- public boolean getSynchronized() {
- return fSynchronized;
- }
-
- public boolean isFinal() {
- return fFinal;
- }
-
- public boolean isSynchronized() {
- return fSynchronized;
- }
-
- public void setElementPositionEnabled(boolean enabled) {
- fEnableInsertPosition= enabled;
- }
-
- public boolean isElementPositionEnabled() {
- return fEnableInsertPosition;
- }
-
- /*
- * Determine where in the file to enter the newly created methods.
- */
- public IJavaScriptElement getElementPosition() {
- return (IJavaScriptElement) fInsertPositions.get(fCurrentPositionIndex);
- }
-
- public int getInsertOffset() throws JavaScriptModelException {
- IJavaScriptElement elementPosition= getElementPosition();
- if (elementPosition instanceof ISourceReference) {
- return ((ISourceReference) elementPosition).getSourceRange().getOffset();
- }
- return -1;
- }
-
- protected IDialogSettings getDialogSettings() {
- return fSettings;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusInfo.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusInfo.java
deleted file mode 100644
index e08a624d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusInfo.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * 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 {
-
- public static final IStatus OK_STATUS= new StatusInfo();
-
- private String fStatusMessage;
- private int fSeverity;
-
- /**
- * Creates a status set to OK (no message)
- */
- public StatusInfo() {
- this(OK, null);
- }
-
- /**
- * Creates a status .
- * @param severity The status severity: ERROR, WARNING, INFO and OK.
- * @param message The message of the status. Applies only for ERROR,
- * WARNING and INFO.
- */
- public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
-
- /**
- * Returns if the status' severity is OK.
- */
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
-
- /**
- * Returns if the status' severity is WARNING.
- */
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
-
- /**
- * Returns if the status' severity is INFO.
- */
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
-
- /**
- * Returns if the status' severity is ERROR.
- */
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
-
- /**
- * @see IStatus#getMessage
- */
- public String getMessage() {
- return fStatusMessage;
- }
-
- /**
- * Sets the status to ERROR.
- * @param errorMessage The error message (can be empty, but not null)
- */
- public void setError(String errorMessage) {
- Assert.isNotNull(errorMessage);
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
-
- /**
- * Sets the status to WARNING.
- * @param warningMessage The warning message (can be empty, but not null)
- */
- public void setWarning(String warningMessage) {
- Assert.isNotNull(warningMessage);
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
-
- /**
- * Sets the status to INFO.
- * @param infoMessage The info message (can be empty, but not null)
- */
- public void setInfo(String infoMessage) {
- Assert.isNotNull(infoMessage);
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
-
- /**
- * Sets the status to OK.
- */
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
-
- /*
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
-
- /**
- * Returns always <code>false</code>.
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /*
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /*
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return JavaScriptUI.ID_PLUGIN;
- }
-
- /**
- * Returns always <code>null</code>.
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
-
- /**
- * Returns always the error severity.
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
-
- /**
- * Returns always an empty array.
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("StatusInfo "); //$NON-NLS-1$
- if (fSeverity == OK) {
- buf.append("OK"); //$NON-NLS-1$
- } else if (fSeverity == ERROR) {
- buf.append("ERROR"); //$NON-NLS-1$
- } else if (fSeverity == WARNING) {
- buf.append("WARNING"); //$NON-NLS-1$
- } else if (fSeverity == INFO) {
- buf.append("INFO"); //$NON-NLS-1$
- } else {
- buf.append("severity="); //$NON-NLS-1$
- buf.append(fSeverity);
- }
- buf.append(": "); //$NON-NLS-1$
- buf.append(fStatusMessage);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusUtil.java
deleted file mode 100644
index 82554149..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/StatusUtil.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-
-/**
- * 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, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING:
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO:
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
- default:
- if (message.length() == 0) {
- message= null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TableTextCellEditor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TableTextCellEditor.java
deleted file mode 100644
index ab4eeace..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TableTextCellEditor.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-
-/**
- * <code>TableTextCellEditor</code> is a copy of TextCellEditor, with the
- * following changes:
- *
- * <ul>
- * <li> modify events are sent out as the text is changed, and not only after
- * editing is done </li>
- *
- * <li>a content assistant is supported</li>
- *
- * <li>the <code>Control</code> from <code>getControl(Composite)</code>
- * does not notify registered FocusListeners. This is a workaround for bug
- * 58777. </li>
- *
- * <li>the user can go to the next/previous row with up and down keys</li>
- * </ul>
- */
-public class TableTextCellEditor extends CellEditor {
- public interface IActivationListener {
- public void activate();
- }
-
- private final TableViewer fTableViewer;
- private final int fColumn;
- private final String fProperty;
- /**
- * The editor's value on activation. This value is reset to the
- * cell when the editor is left via ESC key.
- */
- String fOriginalValue;
- SubjectControlContentAssistant fContentAssistant;
- private IActivationListener fActivationListener;
-
- protected Text text;
-
- private boolean isSelection = false;
- private boolean isDeleteable = false;
- private boolean isSelectable = false;
-
- private static final int defaultStyle = SWT.SINGLE;
- private ModifyListener fModifyListener;
-
- public TableTextCellEditor(TableViewer tableViewer, int column) {
- super(tableViewer.getTable(), defaultStyle);
- fTableViewer= tableViewer;
- fColumn= column;
- fProperty= (String) tableViewer.getColumnProperties()[column];
- }
-
- public void activate() {
- super.activate();
- if (fActivationListener != null)
- fActivationListener.activate();
- fOriginalValue= text.getText();
- }
-
- private void fireModifyEvent(Object newValue) {
- fTableViewer.getCellModifier().modify(
- ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement(),
- fProperty, newValue);
- }
-
- protected void focusLost() {
- if (fContentAssistant != null && fContentAssistant.hasProposalPopupFocus()) {
- // skip focus lost if it went to the content assist popup
- } else {
- super.focusLost();
- }
- }
-
- public void setContentAssistant(SubjectControlContentAssistant assistant) {
- fContentAssistant= assistant;
- }
-
- public void setActivationListener(IActivationListener listener) {
- fActivationListener= listener;
- }
-
- public Text getText() {
- return text;
- }
-
- protected void checkDeleteable() {
- boolean oldIsDeleteable = isDeleteable;
- isDeleteable = isDeleteEnabled();
- if (oldIsDeleteable != isDeleteable) {
- fireEnablementChanged(DELETE);
- }
- }
-
- protected void checkSelectable() {
- boolean oldIsSelectable = isSelectable;
- isSelectable = isSelectAllEnabled();
- if (oldIsSelectable != isSelectable) {
- fireEnablementChanged(SELECT_ALL);
- }
- }
-
- protected void checkSelection() {
- boolean oldIsSelection = isSelection;
- isSelection = text.getSelectionCount() > 0;
- if (oldIsSelection != isSelection) {
- fireEnablementChanged(COPY);
- fireEnablementChanged(CUT);
- }
- }
-
- private ModifyListener getModifyListener() {
- if (fModifyListener == null) {
- fModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- editOccured(e);
- }
- };
- }
- return fModifyListener;
- }
-
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- protected Control createControl(Composite parent) {
- //workaround for bug 58777: don't accept focus listeners on the text control
- final Control[] textControl= new Control[1];
- Composite result= new Composite(parent, SWT.NONE) {
- public void addListener(int eventType, final Listener listener) {
- if (eventType != SWT.FocusIn && eventType != SWT.FocusOut) {
- textControl[0].addListener(eventType, listener);
- }
- }
- };
- result.setFont(parent.getFont());
- result.setBackground(parent.getBackground());
- result.setLayout(new FillLayout());
-
- text = new Text(result, getStyle());
- textControl[0]= text;
- text.addSelectionListener(new SelectionAdapter() {
- public void widgetDefaultSelected(SelectionEvent e) {
- handleDefaultSelection(e);
- }
- });
- text.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- // support switching rows while editing:
- if (e.stateMask == SWT.MOD1 || e.stateMask == SWT.MOD2) {
- if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN) {
- // allow starting multi-selection even if in edit mode
- deactivate();
- e.doit= false;
- return;
- }
- }
-
- if (e.stateMask != SWT.NONE)
- return;
-
- switch (e.keyCode) {
- case SWT.ARROW_DOWN :
- e.doit= false;
- int nextRow= fTableViewer.getTable().getSelectionIndex() + 1;
- if (nextRow >= fTableViewer.getTable().getItemCount())
- break;
- editRow(nextRow);
- break;
-
- case SWT.ARROW_UP :
- e.doit= false;
- int prevRow= fTableViewer.getTable().getSelectionIndex() - 1;
- if (prevRow < 0)
- break;
- editRow(prevRow);
- break;
-
- case SWT.F2 :
- e.doit= false;
- deactivate();
- break;
- }
- }
-
- private void editRow(int row) {
- fTableViewer.getTable().setSelection(row);
- IStructuredSelection newSelection= (IStructuredSelection) fTableViewer.getSelection();
- if (newSelection.size() == 1)
- fTableViewer.editElement(newSelection.getFirstElement(), fColumn);
- }
- });
- text.addKeyListener(new KeyAdapter() {
- // hook key pressed - see PR 14201
- public void keyPressed(KeyEvent e) {
- keyReleaseOccured(e);
-
- // as a result of processing the above call, clients may have
- // disposed this cell editor
- if ((getControl() == null) || getControl().isDisposed())
- return;
- checkSelection(); // see explaination below
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_ESCAPE
- || e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
- }
- });
- // We really want a selection listener but it is not supported so we
- // use a key listener and a mouse listener to know when selection changes
- // may have occured
- text.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- TableTextCellEditor.this.focusLost();
- }
- });
- text.setFont(parent.getFont());
- text.setBackground(parent.getBackground());
- text.setText("");//$NON-NLS-1$
- text.addModifyListener(getModifyListener());
-
- return result;
- }
-
- protected void fireCancelEditor() {
- /* bug 58540: change signature refactoring interaction: validate as you type [refactoring] */
- text.setText(fOriginalValue);
- super.fireApplyEditorValue();
- }
-
- /**
- * The <code>TextCellEditor</code> implementation of
- * this <code>CellEditor</code> framework method returns
- * the text string.
- *
- * @return the text string
- */
- protected Object doGetValue() {
- return text.getText();
- }
-
- protected void doSetFocus() {
- if (text != null) {
- text.selectAll();
- text.setFocus();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- }
-
- /**
- * The <code>TextCellEditor2</code> implementation of
- * this <code>CellEditor</code> framework method accepts
- * a text string (type <code>String</code>).
- *
- * @param value a text string (type <code>String</code>)
- */
- protected void doSetValue(Object value) {
- Assert.isTrue(text != null && (value instanceof String));
- text.removeModifyListener(getModifyListener());
- text.setText((String) value);
- text.addModifyListener(getModifyListener());
- }
-
- /**
- * Processes a modify event that occurred in this text cell editor.
- * This framework method performs validation and sets the error message
- * accordingly, and then reports a change via <code>fireEditorValueChanged</code>.
- * Subclasses should call this method at appropriate times. Subclasses
- * may extend or reimplement.
- *
- * @param e the SWT modify event
- */
- protected void editOccured(ModifyEvent e) {
- String value = text.getText();
- boolean oldValidState = isValueValid();
- boolean newValidState = isCorrect(value);
- if (!newValidState) {
- // try to insert the current value into the error message.
- setErrorMessage(Messages.format(getErrorMessage(),
- new Object[] { value }));
- }
- valueChanged(oldValidState, newValidState);
- fireModifyEvent(text.getText()); // update model on-the-fly
- }
-
- public LayoutData getLayoutData() {
- return new LayoutData();
- }
-
- protected void handleDefaultSelection(SelectionEvent event) {
- // same with enter-key handling code in keyReleaseOccured(e);
- fireApplyEditorValue();
- deactivate();
- }
-
- public boolean isCopyEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0;
- }
-
- public boolean isCutEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0;
- }
-
- public boolean isDeleteEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0
- || text.getCaretPosition() < text.getCharCount();
- }
-
- public boolean isPasteEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return true;
- }
-
- public boolean isSelectAllEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getCharCount() > 0;
- }
-
- protected void keyReleaseOccured(KeyEvent keyEvent) {
- if (keyEvent.character == '\r') { // Return key
- // Enter is handled in handleDefaultSelection.
- // Do not apply the editor value in response to an Enter key event
- // since this can be received from the IME when the intent is -not-
- // to apply the value.
- // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
- //
- // An exception is made for Ctrl+Enter for multi-line texts, since
- // a default selection event is not sent in this case.
- if (text != null && !text.isDisposed()
- && (text.getStyle() & SWT.MULTI) != 0) {
- if ((keyEvent.stateMask & SWT.CTRL) != 0) {
- super.keyReleaseOccured(keyEvent);
- }
- }
- return;
- }
- super.keyReleaseOccured(keyEvent);
- }
-
- public void performCopy() {
- text.copy();
- }
-
- public void performCut() {
- text.cut();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
-
- public void performDelete() {
- if (text.getSelectionCount() > 0)
- // remove the contents of the current selection
- text.insert(""); //$NON-NLS-1$
- else {
- // remove the next character
- int pos = text.getCaretPosition();
- if (pos < text.getCharCount()) {
- text.setSelection(pos, pos + 1);
- text.insert(""); //$NON-NLS-1$
- }
- }
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
-
- public void performPaste() {
- text.paste();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
-
- public void performSelectAll() {
- text.selectAll();
- checkSelection();
- checkDeleteable();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TextFieldNavigationHandler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TextFieldNavigationHandler.java
deleted file mode 100644
index 6e9c1b8f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TextFieldNavigationHandler.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.contexts.ContextManager;
-import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.jface.bindings.Scheme;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.bindings.keys.SWTKeySupport;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordIterator;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-import com.ibm.icu.text.BreakIterator;
-
-/**
- * Support for camelCase-aware sub-word navigation in dialog fields.
- */
-public class TextFieldNavigationHandler {
-
- public static void install(Text text) {
- if (isSubWordNavigationEnabled())
- new FocusHandler(new TextNavigable(text));
- }
-
- public static void install(StyledText styledText) {
- if (isSubWordNavigationEnabled())
- new FocusHandler(new StyledTextNavigable(styledText));
- }
-
- public static void install(Combo combo) {
- if (isSubWordNavigationEnabled())
- new FocusHandler(new ComboNavigable(combo));
- }
-
- private static boolean isSubWordNavigationEnabled() {
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- return preferenceStore.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION);
- }
-
- private abstract static class WorkaroundNavigable extends Navigable {
- /* workarounds for:
- * - bug 103630: Add API: Combo#getCaretPosition()
- * - bug 106024: Text#setSelection(int, int) does not handle start > end with SWT.SINGLE
- */
- Point fLastSelection;
- int fCaretPosition;
-
- void selectionChanged() {
- Point selection= getSelection();
- if (selection.equals(fLastSelection)) {
- // leave caret position
- } else if (selection.x == selection.y) { //empty range
- fCaretPosition= selection.x;
- } else if (fLastSelection.y == selection.y) {
- fCaretPosition= selection.x; //same end -> assume caret at start
- } else {
- fCaretPosition= selection.y;
- }
- fLastSelection= selection;
- }
- }
-
- private abstract static class Navigable {
- public abstract Control getControl();
-
- public abstract String getText();
-
- public abstract void setText(String text);
-
- public abstract Point getSelection();
-
- public abstract void setSelection(int start, int end);
-
- public abstract int getCaretPosition();
- }
-
- private static class TextNavigable extends WorkaroundNavigable {
- static final boolean BUG_106024_TEXT_SELECTION=
- "win32".equals(SWT.getPlatform()) //$NON-NLS-1$
- // on carbon, getCaretPosition() always returns getSelection().x
- || "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
-
- private final Text fText;
-
- public TextNavigable(Text text) {
- fText= text;
- // workaround for bug 106024:
- if (BUG_106024_TEXT_SELECTION) {
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
- fText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- selectionChanged();
- }
- });
- fText.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- selectionChanged();
- }
- });
- }
- }
-
- public Control getControl() {
- return fText;
- }
-
- public String getText() {
- return fText.getText();
- }
-
- public void setText(String text) {
- fText.setText(text);
- }
-
- public Point getSelection() {
- return fText.getSelection();
- }
-
- public int getCaretPosition() {
- if (BUG_106024_TEXT_SELECTION) {
- selectionChanged();
- return fCaretPosition;
- } else {
- return fText.getCaretPosition();
- }
- }
-
- public void setSelection(int start, int end) {
- fText.setSelection(start, end);
- }
- }
-
- private static class StyledTextNavigable extends Navigable {
- private final StyledText fStyledText;
-
- public StyledTextNavigable(StyledText styledText) {
- fStyledText= styledText;
- }
-
- public Control getControl() {
- return fStyledText;
- }
-
- public String getText() {
- return fStyledText.getText();
- }
-
- public void setText(String text) {
- fStyledText.setText(text);
- }
-
- public Point getSelection() {
- return fStyledText.getSelection();
- }
-
- public int getCaretPosition() {
- return fStyledText.getCaretOffset();
- }
-
- public void setSelection(int start, int end) {
- fStyledText.setSelection(start, end);
- }
- }
-
- private static class ComboNavigable extends WorkaroundNavigable {
- private final Combo fCombo;
-
- public ComboNavigable(Combo combo) {
- fCombo= combo;
- // workaround for bug 103630:
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
- fCombo.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- selectionChanged();
- }
- });
- fCombo.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- selectionChanged();
- }
- });
- }
-
- public Control getControl() {
- return fCombo;
- }
-
- public String getText() {
- return fCombo.getText();
- }
-
- public void setText(String text) {
- fCombo.setText(text);
- }
-
- public Point getSelection() {
- return fCombo.getSelection();
- }
-
- public int getCaretPosition() {
- selectionChanged();
- return fCaretPosition;
-// return fCombo.getCaretPosition(); // not available: bug 103630
- }
-
- public void setSelection(int start, int end) {
- fCombo.setSelection(new Point(start, end));
- }
- }
-
- private static class FocusHandler implements FocusListener {
-
- private static final String EMPTY_TEXT= ""; //$NON-NLS-1$
-
- private final JavaWordIterator fIterator;
- private final Navigable fNavigable;
- private KeyAdapter fKeyListener;
-
- private FocusHandler(Navigable navigable) {
- fIterator= new JavaWordIterator();
- fNavigable= navigable;
-
- Control control= navigable.getControl();
- control.addFocusListener(this);
- if (control.isFocusControl())
- activate();
- control.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- deactivate();
- }
- });
- }
-
- public void focusGained(FocusEvent e) {
- activate();
- }
-
- public void focusLost(FocusEvent e) {
- deactivate();
- }
-
- private void activate() {
- fNavigable.getControl().addKeyListener(getKeyListener());
- }
-
- private void deactivate() {
- if (fKeyListener != null) {
- Control control= fNavigable.getControl();
- if (! control.isDisposed())
- control.removeKeyListener(fKeyListener);
- fKeyListener= null;
- }
- }
-
- private KeyAdapter getKeyListener() {
- if (fKeyListener == null) {
- fKeyListener= new KeyAdapter() {
- private final boolean IS_WORKAROUND= (fNavigable instanceof ComboNavigable)
- || (fNavigable instanceof TextNavigable && TextNavigable.BUG_106024_TEXT_SELECTION);
- private List/*<Submission>*/ fSubmissions;
-
- public void keyPressed(KeyEvent e) {
- if (IS_WORKAROUND) {
- if (e.keyCode == SWT.ARROW_LEFT && e.stateMask == SWT.MOD2) {
- int caretPosition= fNavigable.getCaretPosition();
- if (caretPosition != 0) {
- Point selection= fNavigable.getSelection();
- if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, caretPosition - 1);
- else
- fNavigable.setSelection(selection.x, caretPosition - 1);
- }
- e.doit= false;
- return;
-
- } else if (e.keyCode == SWT.ARROW_RIGHT && e.stateMask == SWT.MOD2) {
- String text= fNavigable.getText();
- int caretPosition= fNavigable.getCaretPosition();
- if (caretPosition != text.length()) {
- Point selection= fNavigable.getSelection();
- if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, caretPosition + 1);
- else
- fNavigable.setSelection(selection.y, caretPosition + 1);
- }
- e.doit= false;
- return;
- }
- }
- int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
- KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
- getSubmissions();
- for (Iterator iter= getSubmissions().iterator(); iter.hasNext();) {
- Submission submission= (Submission) iter.next();
- TriggerSequence[] triggerSequences= submission.getTriggerSequences();
- for (int i= 0; i < triggerSequences.length; i++) {
- if (triggerSequences[i].equals(keySequence)) { // XXX does not work for multi-stroke bindings
- e.doit= false;
- submission.execute();
- return;
- }
- }
- }
- }
-
- private List/*<Submission>*/ getSubmissions() {
- if (fSubmissions != null)
- return fSubmissions;
-
- fSubmissions= new ArrayList();
-
- ICommandService commandService= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- if (commandService == null || bindingService == null)
- return fSubmissions;
-
- // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=184502 ,
- // similar to CodeAssistAdvancedConfigurationBlock.getKeyboardShortcut(..):
- BindingManager localBindingManager= new BindingManager(new ContextManager(), new CommandManager());
- final Scheme[] definedSchemes= bindingService.getDefinedSchemes();
- if (definedSchemes != null) {
- try {
- for (int i = 0; i < definedSchemes.length; i++) {
- Scheme scheme= definedSchemes[i];
- Scheme localSchemeCopy= localBindingManager.getScheme(scheme.getId());
- localSchemeCopy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
- }
- } catch (final NotDefinedException e) {
- JavaScriptPlugin.log(e);
- }
- }
- localBindingManager.setLocale(bindingService.getLocale());
- localBindingManager.setPlatform(bindingService.getPlatform());
-
- localBindingManager.setBindings(bindingService.getBindings());
- try {
- Scheme activeScheme= bindingService.getActiveScheme();
- if (activeScheme != null)
- localBindingManager.setActiveScheme(activeScheme);
- } catch (NotDefinedException e) {
- JavaScriptPlugin.log(e);
- }
-
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
- public void execute() {
- fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
- if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
- if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, newCaret);
- else
- fNavigable.setSelection(selection.y, newCaret);
- }
- fIterator.setText(EMPTY_TEXT);
- }
- });
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
- public void execute() {
- fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
- if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
- if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, newCaret);
- else
- fNavigable.setSelection(selection.x, newCaret);
- }
- fIterator.setText(EMPTY_TEXT);
- }
- });
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.WORD_NEXT)) {
- public void execute() {
- fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
- if (newCaret != BreakIterator.DONE)
- fNavigable.setSelection(newCaret, newCaret);
- fIterator.setText(EMPTY_TEXT);
- }
- });
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
- public void execute() {
- fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
- if (newCaret != BreakIterator.DONE)
- fNavigable.setSelection(newCaret, newCaret);
- fIterator.setText(EMPTY_TEXT);
- }
- });
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
- public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
- int start;
- int end;
- if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
- } else {
- fIterator.setText(text);
- start= fNavigable.getCaretPosition();
- end= fIterator.following(start);
- fIterator.setText(EMPTY_TEXT);
- if (end == BreakIterator.DONE)
- return;
- }
- fNavigable.setText(text.substring(0, start) + text.substring(end));
- fNavigable.setSelection(start, start);
- }
- });
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
- public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
- int start;
- int end;
- if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
- } else {
- fIterator.setText(text);
- end= fNavigable.getCaretPosition();
- start= fIterator.preceding(end);
- fIterator.setText(EMPTY_TEXT);
- if (start == BreakIterator.DONE)
- return;
- }
- fNavigable.setText(text.substring(0, start) + text.substring(end));
- fNavigable.setSelection(start, start);
- }
- });
-
- return fSubmissions;
- }
-
- private TriggerSequence[] getKeyBindings(BindingManager localBindingManager, ICommandService commandService, String commandID) {
- Command command= commandService.getCommand(commandID);
- ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
- return localBindingManager.getActiveBindingsDisregardingContextFor(pCmd);
- }
-
- };
- }
- return fKeyListener;
- }
- }
-
- private abstract static class Submission {
- private TriggerSequence[] fTriggerSequences;
-
- public Submission(TriggerSequence[] triggerSequences) {
- fTriggerSequences= triggerSequences;
- }
-
- public TriggerSequence[] getTriggerSequences() {
- return fTriggerSequences;
- }
-
- public abstract void execute();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeInfoViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeInfoViewer.java
deleted file mode 100644
index 2dce2d78..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeInfoViewer.java
+++ /dev/null
@@ -1,1583 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.ProgressMonitorWrapper;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatch;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatchRequestor;
-import org.eclipse.wst.jsdt.core.search.TypeNameRequestor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.OpenTypeHistory;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeFilter;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeInfoFilter;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeInfoRequestorAdapter;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.launching.IVMInstall;
-import org.eclipse.wst.jsdt.launching.IVMInstallType;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-import org.eclipse.wst.jsdt.launching.LibraryLocation;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeInfoFilterExtension;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeInfoImageProvider;
-
-/**
- * A viewer to present type queried form the type history and form the
- * search engine. All viewer updating takes place in the UI thread.
- * Therefore no synchronization of the methods is necessary.
- *
- *
- */
-public class TypeInfoViewer {
-
- private static class SearchRequestor extends TypeNameMatchRequestor {
- private volatile boolean fStop;
-
- private Set fHistory;
-
- private TypeInfoFilter fFilter;
- private List fResult;
-
- public SearchRequestor(TypeInfoFilter filter) {
- super();
- fResult= new ArrayList(2048);
- fFilter= filter;
- }
- public TypeNameMatch[] getResult() {
- return (TypeNameMatch[])fResult.toArray(new TypeNameMatch[fResult.size()]);
- }
- public void cancel() {
- fStop= true;
- }
- public void setHistory(Set history) {
- fHistory= history;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.core.search.TypeNameMatchRequestor#acceptTypeNameMatch(org.eclipse.wst.jsdt.core.search.TypeNameMatch)
- */
- public void acceptTypeNameMatch(TypeNameMatch match) {
- if (fStop)
- return;
- if (TypeFilter.isFiltered(match))
- return;
- if (fHistory.contains(match))
- return;
- if (fFilter.matchesFilterExtension(match))
- fResult.add(match);
- }
- }
-
- protected static class TypeInfoComparator implements Comparator {
- private TypeInfoLabelProvider fLabelProvider;
- private TypeInfoFilter fFilter;
- public TypeInfoComparator(TypeInfoLabelProvider labelProvider, TypeInfoFilter filter) {
- fLabelProvider= labelProvider;
- fFilter= filter;
- }
- public int compare(Object left, Object right) {
- TypeNameMatch leftInfo= (TypeNameMatch)left;
- TypeNameMatch rightInfo= (TypeNameMatch)right;
- int leftCategory= getCamelCaseCategory(leftInfo);
- int rightCategory= getCamelCaseCategory(rightInfo);
- if (leftCategory < rightCategory)
- return -1;
- if (leftCategory > rightCategory)
- return +1;
- int result= compareName(leftInfo.getSimpleTypeName(), rightInfo.getSimpleTypeName());
- if (result != 0)
- return result;
- result= compareTypeContainerName(leftInfo.getTypeContainerName(), rightInfo.getTypeContainerName());
- if (result != 0)
- return result;
-
- leftCategory= getElementTypeCategory(leftInfo);
- rightCategory= getElementTypeCategory(rightInfo);
- if (leftCategory < rightCategory)
- return -1;
- if (leftCategory > rightCategory)
- return +1;
- return compareContainerName(leftInfo, rightInfo);
- }
- private int compareName(String leftString, String rightString) {
- int result= leftString.compareToIgnoreCase(rightString);
- if (result != 0 || rightString.length() == 0) {
- return result;
- } else if (Strings.isLowerCase(leftString.charAt(0)) &&
- !Strings.isLowerCase(rightString.charAt(0))) {
- return +1;
- } else if (Strings.isLowerCase(rightString.charAt(0)) &&
- !Strings.isLowerCase(leftString.charAt(0))) {
- return -1;
- } else {
- return leftString.compareTo(rightString);
- }
- }
- private int compareTypeContainerName(String leftString, String rightString) {
- int leftLength= leftString.length();
- int rightLength= rightString.length();
- if (leftLength == 0 && rightLength > 0)
- return -1;
- if (leftLength == 0 && rightLength == 0)
- return 0;
- if (leftLength > 0 && rightLength == 0)
- return +1;
- return compareName(leftString, rightString);
- }
- private int compareContainerName(TypeNameMatch leftType, TypeNameMatch rightType) {
- return fLabelProvider.getContainerName(leftType).compareTo(
- fLabelProvider.getContainerName(rightType));
- }
- private int getCamelCaseCategory(TypeNameMatch type) {
- if (fFilter == null)
- return 0;
- if (!fFilter.isCamelCasePattern())
- return 0;
- return fFilter.matchesRawNamePattern(type) ? 0 : 1;
- }
- private int getElementTypeCategory(TypeNameMatch type) {
- try {
- if (type.getPackageFragmentRoot().getKind() == IPackageFragmentRoot.K_SOURCE)
- return 0;
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return 1;
- }
- }
-
- protected static class TypeInfoLabelProvider {
-
- private ITypeInfoImageProvider fProviderExtension;
- private TypeInfoRequestorAdapter fAdapter= new TypeInfoRequestorAdapter();
-
- private Map fLib2Name= new HashMap();
- private String[] fInstallLocations;
- private String[] fVMNames;
-
- private boolean fFullyQualifyDuplicates;
-
- public TypeInfoLabelProvider(ITypeInfoImageProvider extension) {
- fProviderExtension= extension;
- List locations= new ArrayList();
- List labels= new ArrayList();
- IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
- for (int i= 0; i < installs.length; i++) {
- processVMInstallType(installs[i], locations, labels);
- }
- fInstallLocations= (String[])locations.toArray(new String[locations.size()]);
- fVMNames= (String[])labels.toArray(new String[labels.size()]);
-
- }
- public void setFullyQualifyDuplicates(boolean value) {
- fFullyQualifyDuplicates= value;
- }
- private void processVMInstallType(IVMInstallType installType, List locations, List labels) {
- if (installType != null) {
- IVMInstall[] installs= installType.getVMInstalls();
- boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
- final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$
- for (int i= 0; i < installs.length; i++) {
- String label= getFormattedLabel(installs[i].getName());
- LibraryLocation[] libLocations= installs[i].getLibraryLocations();
- if (libLocations != null) {
- processLibraryLocation(libLocations, label);
- } else {
- String filePath= installs[i].getInstallLocation().getAbsolutePath();
- // on MacOS X install locations end in an additional "/Home" segment; remove it
- if (isMac && filePath.endsWith(HOME_SUFFIX))
- filePath= filePath.substring(0, filePath.length()- HOME_SUFFIX.length() + 1);
- locations.add(filePath);
- labels.add(label);
- }
- }
- }
- }
- private void processLibraryLocation(LibraryLocation[] libLocations, String label) {
- for (int l= 0; l < libLocations.length; l++) {
- LibraryLocation location= libLocations[l];
- fLib2Name.put(location.getSystemLibraryPath().toString(), label);
- }
- }
- private String getFormattedLabel(String name) {
- return Messages.format(JavaUIMessages.TypeInfoViewer_library_name_format, name);
- }
- public String getText(Object element) {
- return ((TypeNameMatch)element).getSimpleTypeName();
- }
- public String getQualifiedText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- result.append(type.getSimpleTypeName());
- String containerName= type.getTypeContainerName();
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- if (containerName.length() > 0) {
- result.append(containerName);
- } else {
- result.append(JavaUIMessages.TypeInfoViewer_default_package);
- }
- return result.toString();
- }
- public String getFullyQualifiedText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- result.append(type.getSimpleTypeName());
- String containerName= type.getTypeContainerName();
- if (containerName.length() > 0) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(containerName);
- }
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(type));
- return result.toString();
- }
- public String getText(TypeNameMatch last, TypeNameMatch current, TypeNameMatch next) {
- StringBuffer result= new StringBuffer();
- int qualifications= 0;
- String currentTN= current.getSimpleTypeName();
- result.append(currentTN);
- String currentTCN= getTypeContainerName(current);
- if (last != null) {
- String lastTN= last.getSimpleTypeName();
- String lastTCN= getTypeContainerName(last);
- if (currentTCN.equals(lastTCN)) {
- if (currentTN.equals(lastTN)) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- return result.toString();
- }
- } else if (currentTN.equals(lastTN)) {
- qualifications= 1;
- }
- }
- if (next != null) {
- String nextTN= next.getSimpleTypeName();
- String nextTCN= getTypeContainerName(next);
- if (currentTCN.equals(nextTCN)) {
- if (currentTN.equals(nextTN)) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- return result.toString();
- }
- } else if (currentTN.equals(nextTN)) {
- qualifications= 1;
- }
- }
- if (qualifications > 0) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(currentTCN);
- if (fFullyQualifyDuplicates) {
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- result.append(getContainerName(current));
- }
- }
- return result.toString();
- }
- public String getQualificationText(TypeNameMatch type) {
- StringBuffer result= new StringBuffer();
- String containerName= type.getTypeContainerName();
- if (containerName.length() > 0) {
- result.append(containerName);
- result.append(JavaScriptElementLabels.CONCAT_STRING);
- }
- result.append(getContainerName(type));
- return result.toString();
- }
-
- private boolean isInnerType(TypeNameMatch match) {
- return match.getTypeQualifiedName().indexOf('.') != -1;
- }
-
- public ImageDescriptor getImageDescriptor(Object element) {
- TypeNameMatch type= (TypeNameMatch)element;
- if (fProviderExtension != null) {
- fAdapter.setMatch(type);
- ImageDescriptor descriptor= fProviderExtension.getImageDescriptor(fAdapter);
- if (descriptor != null)
- return descriptor;
- }
- return JavaElementImageProvider.getTypeImageDescriptor(
- isInnerType(type), false, type.getModifiers(), false);
- }
-
- private String getTypeContainerName(TypeNameMatch info) {
- String result= info.getTypeContainerName();
- if (result.length() > 0)
- return result;
- return JavaUIMessages.TypeInfoViewer_default_package;
- }
-
- private String getContainerName(TypeNameMatch type) {
- IPackageFragmentRoot root= type.getPackageFragmentRoot();
- if (root.isExternal()) {
- String name= root.getPath().toOSString();
- for (int i= 0; i < fInstallLocations.length; i++) {
- if (name.startsWith(fInstallLocations[i])) {
- return fVMNames[i];
- }
- }
- String lib= (String)fLib2Name.get(name);
- if (lib != null)
- return lib;
- }
- StringBuffer buf= new StringBuffer();
- JavaScriptElementLabels.getPackageFragmentRootLabel(root, JavaScriptElementLabels.ROOT_QUALIFIED | JavaScriptElementLabels.ROOT_VARIABLE, buf);
- return buf.toString();
- }
- }
-
- private static class ProgressUpdateJob extends UIJob {
- private TypeInfoViewer fViewer;
- private boolean fStopped;
- public ProgressUpdateJob(Display display, TypeInfoViewer viewer) {
- super(display, JavaUIMessages.TypeInfoViewer_progressJob_label);
- fViewer= viewer;
- }
- public void stop() {
- fStopped= true;
- cancel();
- }
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (stopped())
- return new Status(IStatus.CANCEL, JavaScriptPlugin.getPluginId(), IStatus.CANCEL, "", null); //$NON-NLS-1$
- fViewer.updateProgressMessage();
- if (!stopped())
- schedule(300);
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
- private boolean stopped() {
- return fStopped || fViewer.getTable().isDisposed();
- }
- }
-
- private static class ProgressMonitor extends ProgressMonitorWrapper {
- private TypeInfoViewer fViewer;
- private String fName;
- private int fTotalWork;
- private double fWorked;
- private boolean fDone;
-
- public ProgressMonitor(IProgressMonitor monitor, TypeInfoViewer viewer) {
- super(monitor);
- fViewer= viewer;
- }
- public void setTaskName(String name) {
- super.setTaskName(name);
- fName= name;
- }
- public void beginTask(String name, int totalWork) {
- super.beginTask(name, totalWork);
- if (fName == null)
- fName= name;
- fTotalWork= totalWork;
- }
- public void worked(int work) {
- super.worked(work);
- internalWorked(work);
- }
- public void done() {
- fDone= true;
- fViewer.setProgressMessage(""); //$NON-NLS-1$
- super.done();
- }
- public void internalWorked(double work) {
- fWorked= fWorked + work;
- fViewer.setProgressMessage(getMessage());
- }
- private String getMessage() {
- if (fDone) {
- return ""; //$NON-NLS-1$
- } else if (fTotalWork == 0) {
- return fName;
- } else {
- return Messages.format(
- JavaUIMessages.TypeInfoViewer_progress_label,
- new Object[] { fName, new Integer((int)((fWorked * 100) / fTotalWork)) });
- }
- }
- }
-
- private static abstract class AbstractJob extends Job {
- protected TypeInfoViewer fViewer;
- protected AbstractJob(String name, TypeInfoViewer viewer) {
- super(name);
- fViewer= viewer;
- setSystem(true);
- }
- protected final IStatus run(IProgressMonitor parent) {
- ProgressMonitor monitor= new ProgressMonitor(parent, fViewer);
- try {
- fViewer.scheduleProgressUpdateJob();
- return doRun(monitor);
- } finally {
- fViewer.stopProgressUpdateJob();
- }
- }
- protected abstract IStatus doRun(ProgressMonitor monitor);
- }
-
- private static abstract class AbstractSearchJob extends AbstractJob {
- private int fMode;
-
- protected int fTicket;
- protected TypeInfoLabelProvider fLabelProvider;
-
- protected TypeInfoFilter fFilter;
- protected OpenTypeHistory fHistory;
-
- protected AbstractSearchJob(int ticket, TypeInfoViewer viewer, TypeInfoFilter filter, OpenTypeHistory history, int numberOfVisibleItems, int mode) {
- super(JavaUIMessages.TypeInfoViewer_job_label, viewer);
- fMode= mode;
- fTicket= ticket;
- fViewer= viewer;
- fLabelProvider= fViewer.getLabelProvider();
- fFilter= filter;
- fHistory= history;
- }
- public void stop() {
- cancel();
- }
- protected IStatus doRun(ProgressMonitor monitor) {
- try {
- if (VIRTUAL) {
- internalRunVirtual(monitor);
- } else {
- internalRun(monitor);
- }
- } catch (CoreException e) {
- fViewer.searchJobFailed(fTicket, e);
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, JavaUIMessages.TypeInfoViewer_job_error, e);
- } catch (InterruptedException e) {
- return canceled(e, true);
- } catch (OperationCanceledException e) {
- return canceled(e, false);
- }
- fViewer.searchJobDone(fTicket);
- return ok();
- }
- protected abstract TypeNameMatch[] getSearchResult(Set matchIdsInHistory, ProgressMonitor monitor) throws CoreException;
-
- private void internalRun(ProgressMonitor monitor) throws CoreException, InterruptedException {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- fViewer.clear(fTicket);
-
- // local vars to speed up rendering
- TypeNameMatch last= null;
- TypeNameMatch type= null;
- TypeNameMatch next= null;
- List elements= new ArrayList();
- List imageDescriptors= new ArrayList();
- List labels= new ArrayList();
- Set filteredMatches= new HashSet();
-
- TypeNameMatch[] matchingTypes= fHistory.getFilteredTypeInfos(fFilter);
- if (matchingTypes.length > 0) {
- Arrays.sort(matchingTypes, new TypeInfoComparator(fLabelProvider, fFilter));
- type= matchingTypes[0];
- int i= 1;
- while(type != null) {
- next= (i == matchingTypes.length) ? null : matchingTypes[i];
- elements.add(type);
- filteredMatches.add(type);
- imageDescriptors.add(fLabelProvider.getImageDescriptor(type));
- labels.add(fLabelProvider.getText(last, type, next));
- last= type;
- type= next;
- i++;
- }
- }
- matchingTypes= null;
- fViewer.fExpectedItemCount= elements.size();
- fViewer.addHistory(fTicket, elements, imageDescriptors, labels);
-
- if ((fMode & INDEX) == 0) {
- return;
- }
- TypeNameMatch[] result= getSearchResult(filteredMatches, monitor);
- fViewer.fExpectedItemCount+= result.length;
- if (result.length == 0) {
- return;
- }
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- int processed= 0;
- int nextIndex= 1;
- type= result[0];
- if (!filteredMatches.isEmpty()) {
- fViewer.addDashLineAndUpdateLastHistoryEntry(fTicket, type);
- }
- while (true) {
- long startTime= System.currentTimeMillis();
- elements.clear();
- imageDescriptors.clear();
- labels.clear();
- int delta = Math.min(nextIndex == 1 ? fViewer.getNumberOfVisibleItems() : 10, result.length - processed);
- if (delta == 0)
- break;
- processed= processed + delta;
- while(delta > 0) {
- next= (nextIndex == result.length) ? null : result[nextIndex];
- elements.add(type);
- labels.add(fLabelProvider.getText(last, type, next));
- imageDescriptors.add(fLabelProvider.getImageDescriptor(type));
- last= type;
- type= next;
- nextIndex++;
- delta--;
- }
- fViewer.addAll(fTicket, elements, imageDescriptors, labels);
- long sleep= 100 - (System.currentTimeMillis() - startTime);
- if (false)
- System.out.println("Sleeping for: " + sleep); //$NON-NLS-1$
-
- if (sleep > 0)
- Thread.sleep(sleep);
-
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- }
- }
- private void internalRunVirtual(ProgressMonitor monitor) throws CoreException, InterruptedException {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- fViewer.clear(fTicket);
-
- TypeNameMatch[] matchingTypes= fHistory.getFilteredTypeInfos(fFilter);
- fViewer.setHistoryResult(fTicket, matchingTypes);
- if ((fMode & INDEX) == 0)
- return;
-
- Set filteredMatches= new HashSet(matchingTypes.length * 2);
- for (int i= 0; i < matchingTypes.length; i++) {
- filteredMatches.add(matchingTypes[i]);
- }
-
- TypeNameMatch[] result= getSearchResult(filteredMatches, monitor);
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- fViewer.setSearchResult(fTicket, result);
- }
- private IStatus canceled(Exception e, boolean removePendingItems) {
- fViewer.searchJobCanceled(fTicket, removePendingItems);
- return new Status(IStatus.CANCEL, JavaScriptPlugin.getPluginId(), IStatus.CANCEL, JavaUIMessages.TypeInfoViewer_job_cancel, e);
- }
- private IStatus ok() {
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
- }
-
- private static class SearchEngineJob extends AbstractSearchJob {
- private IJavaScriptSearchScope fScope;
- private int fElementKind;
- private SearchRequestor fReqestor;
-
- public SearchEngineJob(int ticket, TypeInfoViewer viewer, TypeInfoFilter filter, OpenTypeHistory history, int numberOfVisibleItems, int mode,
- IJavaScriptSearchScope scope, int elementKind) {
- super(ticket, viewer, filter, history, numberOfVisibleItems, mode);
- fScope= scope;
- fElementKind= elementKind;
- fReqestor= new SearchRequestor(filter);
- }
- public void stop() {
- fReqestor.cancel();
- super.stop();
- }
- protected TypeNameMatch[] getSearchResult(Set matchIdsInHistory, ProgressMonitor monitor) throws CoreException {
- long start= System.currentTimeMillis();
- fReqestor.setHistory(matchIdsInHistory);
- // consider primary working copies during searching
- SearchEngine engine= new SearchEngine((WorkingCopyOwner)null);
- String packPattern= fFilter.getPackagePattern();
- monitor.setTaskName(JavaUIMessages.TypeInfoViewer_searchJob_taskName);
- engine.searchAllTypeNames(
- packPattern == null ? null : packPattern.toCharArray(),
- fFilter.getPackageFlags(),
- fFilter.getNamePattern().toCharArray(),
- fFilter.getSearchFlags(),
- fElementKind,
- fScope,
- fReqestor,
- IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- monitor);
- if (DEBUG)
- System.out.println("Time needed until search has finished: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
- TypeNameMatch[] result= fReqestor.getResult();
- Arrays.sort(result, new TypeInfoComparator(fLabelProvider, fFilter));
- if (DEBUG)
- System.out.println("Time needed until sort has finished: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
- fViewer.rememberResult(fTicket, result);
- return result;
- }
- }
-
- private static class CachedResultJob extends AbstractSearchJob {
- private TypeNameMatch[] fLastResult;
- public CachedResultJob(int ticket, TypeNameMatch[] lastResult, TypeInfoViewer viewer, TypeInfoFilter filter, OpenTypeHistory history, int numberOfVisibleItems, int mode) {
- super(ticket, viewer, filter, history, numberOfVisibleItems, mode);
- fLastResult= lastResult;
- }
- protected TypeNameMatch[] getSearchResult(Set filteredHistory, ProgressMonitor monitor) throws CoreException {
- List result= new ArrayList(2048);
- for (int i= 0; i < fLastResult.length; i++) {
- TypeNameMatch type= fLastResult[i];
- if (filteredHistory.contains(type))
- continue;
- if (fFilter.matchesCachedResult(type))
- result.add(type);
- }
- // we have to sort if the filter is a camel case filter.
- TypeNameMatch[] types= (TypeNameMatch[])result.toArray(new TypeNameMatch[result.size()]);
- if (fFilter.isCamelCasePattern()) {
- Arrays.sort(types, new TypeInfoComparator(fLabelProvider, fFilter));
- }
- return types;
- }
- }
-
- private static class SyncJob extends AbstractJob {
- public SyncJob(TypeInfoViewer viewer) {
- super(JavaUIMessages.TypeInfoViewer_syncJob_label, viewer);
- }
- public void stop() {
- cancel();
- }
- protected IStatus doRun(ProgressMonitor monitor) {
- try {
- monitor.setTaskName(JavaUIMessages.TypeInfoViewer_syncJob_taskName);
- new SearchEngine().searchAllTypeNames(
- null,
- 0,
- // make sure we search a concrete name. This is faster according to Kent
- "_______________".toCharArray(), //$NON-NLS-1$
- SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
- IJavaScriptSearchConstants.ENUM,
- SearchEngine.createWorkspaceScope(),
- new TypeNameRequestor() {},
- IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- monitor);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, JavaUIMessages.TypeInfoViewer_job_error, e);
- } catch (OperationCanceledException e) {
- return new Status(IStatus.CANCEL, JavaScriptPlugin.getPluginId(), IStatus.CANCEL, JavaUIMessages.TypeInfoViewer_job_cancel, e);
- } finally {
- fViewer.syncJobDone();
- }
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
- }
-
- private static class DashLine {
- private int fSeparatorWidth;
- private String fMessage;
- private int fMessageLength;
- public String getText(int width) {
- StringBuffer dashes= new StringBuffer();
- int chars= (((width - fMessageLength) / fSeparatorWidth) / 2) -2;
- for (int i= 0; i < chars; i++) {
- dashes.append(SEPARATOR);
- }
- StringBuffer result= new StringBuffer();
- result.append(dashes);
- result.append(fMessage);
- result.append(dashes);
- return result.toString();
- }
- public void initialize(GC gc) {
- fSeparatorWidth= gc.getAdvanceWidth(SEPARATOR);
- fMessage= " " + JavaUIMessages.TypeInfoViewer_separator_message + " "; //$NON-NLS-1$ //$NON-NLS-2$
- fMessageLength= gc.textExtent(fMessage).x;
- }
- }
-
- private static class ImageManager {
- private Map fImages= new HashMap(20);
-
- public Image get(ImageDescriptor descriptor) {
- if (descriptor == null)
- descriptor= ImageDescriptor.getMissingImageDescriptor();
-
- Image result= (Image)fImages.get(descriptor);
- if (result != null)
- return result;
- result= descriptor.createImage();
- if (result != null)
- fImages.put(descriptor, result);
- return result;
- }
-
- public void dispose() {
- for (Iterator iter= fImages.values().iterator(); iter.hasNext(); ) {
- Image image= (Image)iter.next();
- image.dispose();
- }
- fImages.clear();
- }
- }
-
- private Display fDisplay;
-
- private String fProgressMessage;
- private Label fProgressLabel;
- private int fProgressCounter;
- private ProgressUpdateJob fProgressUpdateJob;
-
- private OpenTypeHistory fHistory;
-
- /* non virtual table */
- private int fNextElement;
- private List fItems;
-
- /* virtual table */
- private TypeNameMatch[] fHistoryMatches;
- private TypeNameMatch[] fSearchMatches;
-
- private int fNumberOfVisibleItems;
- private int fExpectedItemCount;
- private Color fDashLineColor;
- private int fScrollbarWidth;
- private int fTableWidthDelta;
- private int fDashLineIndex= -1;
- private Image fSeparatorIcon;
- private DashLine fDashLine= new DashLine();
-
- private boolean fFullyQualifySelection;
- /* remembers the last selection to restore unqualified labels */
- private TableItem[] fLastSelection;
- private String[] fLastLabels;
-
- private TypeInfoLabelProvider fLabelProvider;
- private ImageManager fImageManager;
-
- private Table fTable;
-
- private SyncJob fSyncJob;
-
- private TypeInfoFilter fTypeInfoFilter;
- private ITypeInfoFilterExtension fFilterExtension;
- private TypeNameMatch[] fLastCompletedResult;
- private TypeInfoFilter fLastCompletedFilter;
-
- private int fSearchJobTicket;
- protected int fElementKind;
- protected IJavaScriptSearchScope fSearchScope;
-
- private AbstractSearchJob fSearchJob;
-
- private static final int HISTORY= 1;
- private static final int INDEX= 2;
- private static final int FULL= HISTORY | INDEX;
-
- private static final char SEPARATOR= '-';
-
- private static final boolean DEBUG= false;
- private static final boolean VIRTUAL= false;
-
- private static final TypeNameMatch[] EMTPY_TYPE_INFO_ARRAY= new TypeNameMatch[0];
- // only needed when in virtual table mode
-
- private static final TypeNameMatch DASH_LINE= SearchEngine.createTypeNameMatch(null, 0);
-
-
- public TypeInfoViewer(Composite parent, int flags, Label progressLabel,
- IJavaScriptSearchScope scope, int elementKind, String initialFilter,
- ITypeInfoFilterExtension filterExtension, ITypeInfoImageProvider imageExtension) {
- Assert.isNotNull(scope);
- fDisplay= parent.getDisplay();
- fProgressLabel= progressLabel;
- fSearchScope= scope;
- fElementKind= elementKind;
- fFilterExtension= filterExtension;
- fFullyQualifySelection= (flags & SWT.MULTI) != 0;
- fTable= new Table(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FLAT | flags | (VIRTUAL ? SWT.VIRTUAL : SWT.NONE));
- fTable.setFont(parent.getFont());
- fLabelProvider= new TypeInfoLabelProvider(imageExtension);
- fItems= new ArrayList(500);
- fTable.setHeaderVisible(false);
- addPopupMenu();
- fTable.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent event) {
- int itemHeight= fTable.getItemHeight();
- Rectangle clientArea= fTable.getClientArea();
- fNumberOfVisibleItems= (clientArea.height / itemHeight) + 1;
- }
- });
- fTable.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.DEL) {
- deleteHistoryEntry();
- } else if (e.keyCode == SWT.ARROW_DOWN) {
- int index= fTable.getSelectionIndex();
- if (index == fDashLineIndex - 1) {
- e.doit= false;
- setTableSelection(index + 2);
- }
- } else if (e.keyCode == SWT.ARROW_UP) {
- int index= fTable.getSelectionIndex();
- if (fDashLineIndex != -1 && index == fDashLineIndex + 1) {
- e.doit= false;
- setTableSelection(index - 2);
- }
- }
- }
- });
- fTable.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (fLastSelection != null) {
- for (int i= 0; i < fLastSelection.length; i++) {
- TableItem item= fLastSelection[i];
- // could be disposed by deleting element from
- // type info history
- if (!item.isDisposed())
- item.setText(fLastLabels[i]);
- }
- }
- TableItem[] items= fTable.getSelection();
- fLastSelection= new TableItem[items.length];
- fLastLabels= new String[items.length];
- for (int i= 0; i < items.length; i++) {
- TableItem item= items[i];
- fLastSelection[i]= item;
- fLastLabels[i]= item.getText();
- Object data= item.getData();
- if (data instanceof TypeNameMatch) {
- String qualifiedText= getQualifiedText((TypeNameMatch)data);
- if (qualifiedText.length() > fLastLabels[i].length())
- item.setText(qualifiedText);
- }
- }
- }
- });
- fTable.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- stop(true, true);
- fDashLineColor.dispose();
- fSeparatorIcon.dispose();
- fImageManager.dispose();
- if (fProgressUpdateJob != null) {
- fProgressUpdateJob.stop();
- fProgressUpdateJob= null;
- }
- }
- });
- if (VIRTUAL) {
- fHistoryMatches= EMTPY_TYPE_INFO_ARRAY;
- fSearchMatches= EMTPY_TYPE_INFO_ARRAY;
- fTable.addListener(SWT.SetData, new Listener() {
- public void handleEvent(Event event) {
- TableItem item= (TableItem)event.item;
- setData(item);
- }
- });
- }
-
- fDashLineColor= computeDashLineColor();
- fScrollbarWidth= computeScrollBarWidth();
- fTableWidthDelta= fTable.computeTrim(0, 0, 0, 0).width - fScrollbarWidth;
- fSeparatorIcon= JavaPluginImages.DESC_OBJS_TYPE_SEPARATOR.createImage(fTable.getDisplay());
- // Use a new image manager since an extension can provide its own
- // image descriptors. To avoid thread problems with SWT the registry
- // must be created in the UI thread.
- fImageManager= new ImageManager();
-
- fHistory= OpenTypeHistory.getInstance();
- if (initialFilter != null && initialFilter.length() > 0)
- fTypeInfoFilter= createTypeInfoFilter(initialFilter);
- GC gc= null;
- try {
- gc= new GC(fTable);
- gc.setFont(fTable.getFont());
- fDashLine.initialize(gc);
- } finally {
- gc.dispose();
- }
- // If we do have a type info filter then we are
- // scheduling a search job in startup. So no
- // need to sync the search indices.
- if (fTypeInfoFilter == null) {
- scheduleSyncJob();
- }
- }
-
- /* package */ void startup() {
- if (fTypeInfoFilter == null) {
- reset();
- } else {
- scheduleSearchJob(FULL);
- }
- }
-
- public Table getTable() {
- return fTable;
- }
-
- /* package */ TypeInfoLabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- private int getNumberOfVisibleItems() {
- return fNumberOfVisibleItems;
- }
-
- public void setFocus() {
- fTable.setFocus();
- }
-
-
- public void setQualificationStyle(boolean value) {
- if (fFullyQualifySelection == value)
- return;
- fFullyQualifySelection= value;
- if (fLastSelection != null) {
- for (int i= 0; i < fLastSelection.length; i++) {
- TableItem item= fLastSelection[i];
- Object data= item.getData();
- if (data instanceof TypeNameMatch) {
- item.setText(getQualifiedText((TypeNameMatch)data));
- }
- }
- }
- }
-
- public TypeNameMatch[] getSelection() {
- TableItem[] items= fTable.getSelection();
- List result= new ArrayList(items.length);
- for (int i= 0; i < items.length; i++) {
- Object data= items[i].getData();
- if (data instanceof TypeNameMatch) {
- result.add(data);
- }
- }
- return (TypeNameMatch[])result.toArray(new TypeNameMatch[result.size()]);
- }
-
- public void stop() {
- stop(true, false);
- }
-
- public void stop(boolean stopSyncJob, boolean dispose) {
- if (fSyncJob != null && stopSyncJob) {
- fSyncJob.stop();
- fSyncJob= null;
- }
- if (fSearchJob != null) {
- fSearchJob.stop();
- fSearchJob= null;
- }
- }
-
- public void forceSearch() {
- stop(false, false);
- if (fTypeInfoFilter == null) {
- reset();
- } else {
- // clear last results
- fLastCompletedFilter= null;
- fLastCompletedResult= null;
- scheduleSearchJob(isSyncJobRunning() ? HISTORY : FULL);
- }
- }
-
- public void setSearchPattern(String text) {
- stop(false, false);
- if (text.length() == 0 || "*".equals(text)) { //$NON-NLS-1$
- fTypeInfoFilter= null;
- reset();
- } else {
- fTypeInfoFilter= createTypeInfoFilter(text);
- scheduleSearchJob(isSyncJobRunning() ? HISTORY : FULL);
- }
- }
-
- public void setSearchScope(IJavaScriptSearchScope scope, boolean refresh) {
- fSearchScope= scope;
- if (!refresh)
- return;
- stop(false, false);
- fLastCompletedFilter= null;
- fLastCompletedResult= null;
- if (fTypeInfoFilter == null) {
- reset();
- } else {
- scheduleSearchJob(isSyncJobRunning() ? HISTORY : FULL);
- }
- }
-
- public void setFullyQualifyDuplicates(boolean value, boolean refresh) {
- fLabelProvider.setFullyQualifyDuplicates(value);
- if (!refresh)
- return;
- stop(false, false);
- if (fTypeInfoFilter == null) {
- reset();
- } else {
- scheduleSearchJob(isSyncJobRunning() ? HISTORY : FULL);
- }
- }
-
- public void reset() {
- fLastSelection= null;
- fLastLabels= null;
- fExpectedItemCount= 0;
- fDashLineIndex= -1;
- TypeInfoFilter filter= (fTypeInfoFilter != null)
- ? fTypeInfoFilter
- : new TypeInfoFilter("*", fSearchScope, fElementKind, fFilterExtension); //$NON-NLS-1$
- if (VIRTUAL) {
- fHistoryMatches= fHistory.getFilteredTypeInfos(filter);
- fExpectedItemCount= fHistoryMatches.length;
- fTable.setItemCount(fHistoryMatches.length);
- // bug under windows.
- if (fHistoryMatches.length == 0) {
- fTable.redraw();
- }
- fTable.clear(0, fHistoryMatches.length - 1);
- } else {
- fNextElement= 0;
- TypeNameMatch[] historyItems= fHistory.getFilteredTypeInfos(filter);
- if (historyItems.length == 0) {
- shortenTable();
- return;
- }
- fExpectedItemCount= historyItems.length;
- int lastIndex= historyItems.length - 1;
- TypeNameMatch last= null;
- TypeNameMatch type= historyItems[0];
- for (int i= 0; i < historyItems.length; i++) {
- TypeNameMatch next= i == lastIndex ? null : historyItems[i + 1];
- addSingleElement(type,
- fLabelProvider.getImageDescriptor(type),
- fLabelProvider.getText(last, type, next));
- last= type;
- type= next;
- }
- shortenTable();
- }
- }
-
- protected TypeInfoFilter createTypeInfoFilter(String text) {
- if ("**".equals(text)) //$NON-NLS-1$
- text= "*"; //$NON-NLS-1$
- return new TypeInfoFilter(text, fSearchScope, fElementKind, fFilterExtension);
- }
-
- private void addPopupMenu() {
- Menu menu= new Menu(fTable.getShell(), SWT.POP_UP);
- fTable.setMenu(menu);
- final MenuItem remove= new MenuItem(menu, SWT.NONE);
- remove.setText(JavaUIMessages.TypeInfoViewer_remove_from_history);
- menu.addMenuListener(new MenuAdapter() {
- public void menuShown(MenuEvent e) {
- TableItem[] selection= fTable.getSelection();
- remove.setEnabled(canEnable(selection));
- }
- });
- remove.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- deleteHistoryEntry();
- }
- });
- }
-
- private boolean canEnable(TableItem[] selection) {
- if (selection.length == 0)
- return false;
- for (int i= 0; i < selection.length; i++) {
- TableItem item= selection[i];
- Object data= item.getData();
- if (!(data instanceof TypeNameMatch))
- return false;
- if (!(fHistory.contains((TypeNameMatch)data)))
- return false;
- }
- return true;
- }
-
- //---- History management -------------------------------------------------------
-
- private void deleteHistoryEntry() {
- int index= fTable.getSelectionIndex();
- if (index == -1)
- return;
- TableItem item= fTable.getItem(index);
- Object element= item.getData();
- if (!(element instanceof TypeNameMatch))
- return;
- if (fHistory.remove(element) != null) {
- item.dispose();
- fItems.remove(index);
- int count= fTable.getItemCount();
- if (count > 0) {
- item= fTable.getItem(0);
- if (item.getData() instanceof DashLine) {
- item.dispose();
- fItems.remove(0);
- fDashLineIndex= -1;
- if (count > 1) {
- setTableSelection(0);
- }
- } else {
- if (index >= count) {
- index= count - 1;
- }
- setTableSelection(index);
- }
- } else {
- // send dummy selection
- fTable.notifyListeners(SWT.Selection, new Event());
- }
- }
- }
-
- //-- Search result updating ----------------------------------------------------
-
- private void clear(int ticket) {
- syncExec(ticket, new Runnable() {
- public void run() {
- fNextElement= 0;
- fDashLineIndex= -1;
- fLastSelection= null;
- fLastLabels= null;
- fExpectedItemCount= 0;
- }
- });
- }
-
- private void rememberResult(int ticket, final TypeNameMatch[] result) {
- syncExec(ticket, new Runnable() {
- public void run() {
- if (fLastCompletedResult == null) {
- fLastCompletedFilter= fTypeInfoFilter;
- fLastCompletedResult= result;
- }
- }
- });
- }
-
- private void addHistory(int ticket, final List elements, final List imageDescriptors, final List labels) {
- addAll(ticket, elements, imageDescriptors, labels);
- }
-
- private void addAll(int ticket, final List elements, final List imageDescriptors, final List labels) {
- syncExec(ticket, new Runnable() {
- public void run() {
- int size= elements.size();
- for(int i= 0; i < size; i++) {
- addSingleElement(elements.get(i),
- (ImageDescriptor)imageDescriptors.get(i),
- (String)labels.get(i));
- }
- }
- });
- }
-
- private void addDashLineAndUpdateLastHistoryEntry(int ticket, final TypeNameMatch next) {
- syncExec(ticket, new Runnable() {
- public void run() {
- if (fNextElement > 0) {
- TableItem item= fTable.getItem(fNextElement - 1);
- String label= item.getText();
- String newLabel= fLabelProvider.getText(null, (TypeNameMatch)item.getData(), next);
- if (newLabel.length() != label.length())
- item.setText(newLabel);
- if (fLastSelection != null && fLastSelection.length > 0) {
- TableItem last= fLastSelection[fLastSelection.length - 1];
- if (last == item) {
- fLastLabels[fLastLabels.length - 1]= newLabel;
- }
- }
- }
- fDashLineIndex= fNextElement;
- addDashLine();
- }
- });
- }
-
- private void addDashLine() {
- TableItem item= null;
- if (fItems.size() > fNextElement) {
- item= (TableItem)fItems.get(fNextElement);
- } else {
- item= new TableItem(fTable, SWT.NONE);
- fItems.add(item);
- }
- fillDashLine(item);
- fNextElement++;
- }
-
- private void addSingleElement(Object element, ImageDescriptor imageDescriptor, String label) {
- TableItem item= null;
- Object old= null;
- if (fItems.size() > fNextElement) {
- item= (TableItem)fItems.get(fNextElement);
- old= item.getData();
- item.setForeground(null);
- } else {
- item= new TableItem(fTable, SWT.NONE);
- fItems.add(item);
- }
- item.setData(element);
- item.setImage(fImageManager.get(imageDescriptor));
- if (fNextElement == 0) {
- if (needsSelectionChange(old, element) || fLastSelection != null) {
- item.setText(label);
- fTable.setSelection(0);
- fTable.notifyListeners(SWT.Selection, new Event());
- } else {
- fLastSelection= new TableItem[] { item };
- fLastLabels= new String[] { label };
- }
- } else {
- item.setText(label);
- }
- fNextElement++;
- }
-
- private boolean needsSelectionChange(Object oldElement, Object newElement) {
- int[] selected= fTable.getSelectionIndices();
- if (selected.length != 1)
- return true;
- if (selected[0] != 0)
- return true;
- if (oldElement == null)
- return true;
- return !oldElement.equals(newElement);
- }
-
- private void scheduleSearchJob(int mode) {
- fSearchJobTicket++;
- if (fLastCompletedFilter != null && fTypeInfoFilter.isSubFilter(fLastCompletedFilter.getText())) {
- fSearchJob= new CachedResultJob(fSearchJobTicket, fLastCompletedResult, this, fTypeInfoFilter,
- fHistory, fNumberOfVisibleItems,
- mode);
- } else {
- fLastCompletedFilter= null;
- fLastCompletedResult= null;
- fSearchJob= new SearchEngineJob(fSearchJobTicket, this, fTypeInfoFilter,
- fHistory, fNumberOfVisibleItems,
- mode, fSearchScope, fElementKind);
- }
- fSearchJob.schedule();
- }
-
- private void searchJobDone(int ticket) {
- syncExec(ticket, new Runnable() {
- public void run() {
- shortenTable();
- checkEmptyList();
- fSearchJob= null;
- }
- });
- }
-
- private void searchJobCanceled(int ticket, final boolean removePendingItems) {
- syncExec(ticket, new Runnable() {
- public void run() {
- if (removePendingItems) {
- shortenTable();
- checkEmptyList();
- }
- fSearchJob= null;
- }
- });
- }
-
- private synchronized void searchJobFailed(int ticket, CoreException e) {
- searchJobDone(ticket);
- JavaScriptPlugin.log(e);
- }
-
- //-- virtual table support -------------------------------------------------------
-
- private void setHistoryResult(int ticket, final TypeNameMatch[] types) {
- syncExec(ticket, new Runnable() {
- public void run() {
- fExpectedItemCount= types.length;
- int lastHistoryLength= fHistoryMatches.length;
- fHistoryMatches= types;
- int length= fHistoryMatches.length + fSearchMatches.length;
- int dash= (fHistoryMatches.length > 0 && fSearchMatches.length > 0) ? 1 : 0;
- fTable.setItemCount(length + dash);
- if (length == 0) {
- // bug under windows.
- fTable.redraw();
- return;
- }
- int update= Math.max(lastHistoryLength, fHistoryMatches.length);
- if (update > 0) {
- fTable.clear(0, update + dash - 1);
- }
- }
- });
- }
-
- private void setSearchResult(int ticket, final TypeNameMatch[] types) {
- syncExec(ticket, new Runnable() {
- public void run() {
- fExpectedItemCount+= types.length;
- fSearchMatches= types;
- int length= fHistoryMatches.length + fSearchMatches.length;
- int dash= (fHistoryMatches.length > 0 && fSearchMatches.length > 0) ? 1 : 0;
- fTable.setItemCount(length + dash);
- if (length == 0) {
- // bug under windows.
- fTable.redraw();
- return;
- }
- if (fHistoryMatches.length == 0) {
- fTable.clear(0, length + dash - 1);
- } else {
- fTable.clear(fHistoryMatches.length - 1, length + dash - 1);
- }
- }
- });
- }
-
- private void setData(TableItem item) {
- int index= fTable.indexOf(item);
- TypeNameMatch type= getTypeInfo(index);
- if (type == DASH_LINE) {
- item.setData(fDashLine);
- fillDashLine(item);
- } else {
- item.setData(type);
- item.setImage(fImageManager.get(fLabelProvider.getImageDescriptor(type)));
- item.setText(fLabelProvider.getText(
- getTypeInfo(index - 1),
- type,
- getTypeInfo(index + 1)));
- item.setForeground(null);
- }
- }
-
- private TypeNameMatch getTypeInfo(int index) {
- if (index < 0)
- return null;
- if (index < fHistoryMatches.length) {
- return fHistoryMatches[index];
- }
- int dash= (fHistoryMatches.length > 0 && fSearchMatches.length > 0) ? 1 : 0;
- if (index == fHistoryMatches.length && dash == 1) {
- return DASH_LINE;
- }
- index= index - fHistoryMatches.length - dash;
- if (index >= fSearchMatches.length)
- return null;
- return fSearchMatches[index];
- }
-
- //-- Sync Job updates ------------------------------------------------------------
-
- private void scheduleSyncJob() {
- fSyncJob= new SyncJob(this);
- fSyncJob.schedule();
- }
-
- private void syncJobDone() {
- syncExec(new Runnable() {
- public void run() {
- fSyncJob= null;
- if (fTypeInfoFilter != null) {
- scheduleSearchJob(FULL);
- }
- }
- });
- }
-
- private boolean isSyncJobRunning() {
- return fSyncJob != null;
- }
-
- //-- progress monitor updates -----------------------------------------------------
-
- private void scheduleProgressUpdateJob() {
- syncExec(new Runnable() {
- public void run() {
- if (fProgressCounter == 0) {
- clearProgressMessage();
- fProgressUpdateJob= new ProgressUpdateJob(fDisplay, TypeInfoViewer.this);
- fProgressUpdateJob.schedule(300);
- }
- fProgressCounter++;
- }
- });
- }
-
- private void stopProgressUpdateJob() {
- syncExec(new Runnable() {
- public void run() {
- fProgressCounter--;
- if (fProgressCounter == 0 && fProgressUpdateJob != null) {
- fProgressUpdateJob.stop();
- fProgressUpdateJob= null;
- clearProgressMessage();
- }
- }
- });
- }
-
- private void setProgressMessage(String message) {
- fProgressMessage= message;
- }
-
- private void clearProgressMessage() {
- fProgressMessage= ""; //$NON-NLS-1$
- fProgressLabel.setText(fProgressMessage);
- }
-
- private void updateProgressMessage() {
- fProgressLabel.setText(fProgressMessage);
- }
-
- //-- Helper methods --------------------------------------------------------------
-
- private void syncExec(final Runnable runnable) {
- if (fDisplay.isDisposed())
- return;
- fDisplay.syncExec(new Runnable() {
- public void run() {
- if (fTable.isDisposed())
- return;
- runnable.run();
- }
- });
- }
-
- private void syncExec(final int ticket, final Runnable runnable) {
- if (fDisplay.isDisposed())
- return;
- fDisplay.syncExec(new Runnable() {
- public void run() {
- if (fTable.isDisposed() || ticket != fSearchJobTicket)
- return;
- runnable.run();
- }
- });
- }
-
- private void fillDashLine(TableItem item) {
- Rectangle bounds= item.getImageBounds(0);
- Rectangle area= fTable.getBounds();
- boolean willHaveScrollBar= fExpectedItemCount + 1 > fNumberOfVisibleItems;
- item.setText(fDashLine.getText(area.width - bounds.x - bounds.width - fTableWidthDelta -
- (willHaveScrollBar ? fScrollbarWidth : 0)));
- item.setImage(fSeparatorIcon);
- item.setForeground(fDashLineColor);
- item.setData(fDashLine);
- }
-
- private void shortenTable() {
- if (VIRTUAL)
- return;
- if (fNextElement < fItems.size()) {
- fTable.setRedraw(false);
- fTable.remove(fNextElement, fItems.size() - 1);
- fTable.setRedraw(true);
- }
- for (int i= fItems.size() - 1; i >= fNextElement; i--) {
- fItems.remove(i);
- }
- }
-
- private void checkEmptyList() {
- if (fTable.getItemCount() == 0) {
- fTable.notifyListeners(SWT.Selection, new Event());
- }
- }
-
- private void setTableSelection(int index) {
- fTable.setSelection(index);
- fTable.notifyListeners(SWT.Selection, new Event());
- }
-
- private Color computeDashLineColor() {
- Color fg= fTable.getForeground();
- int fGray= (int)(0.3*fg.getRed() + 0.59*fg.getGreen() + 0.11*fg.getBlue());
- Color bg= fTable.getBackground();
- int bGray= (int)(0.3*bg.getRed() + 0.59*bg.getGreen() + 0.11*bg.getBlue());
- int gray= (int)((fGray + bGray) * 0.66);
- return new Color(fDisplay, gray, gray, gray);
- }
-
- private int computeScrollBarWidth() {
- Composite t= new Composite(fTable.getShell(), SWT.V_SCROLL);
- int result= t.computeTrim(0, 0, 0, 0).width;
- t.dispose();
- return result;
- }
-
- private String getQualifiedText(TypeNameMatch type) {
- return fFullyQualifySelection
- ? fLabelProvider.getFullyQualifiedText(type)
- : fLabelProvider.getQualifiedText(type);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionComponent.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionComponent.java
deleted file mode 100644
index 5b794ce2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionComponent.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-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.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatch;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchScopeFactory;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TypeNameMatchLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.wst.jsdt.ui.dialogs.ITypeSelectionComponent;
-import org.eclipse.wst.jsdt.ui.dialogs.TypeSelectionExtension;
-
-/**
- * @deprecated use {@link FilteredTypesSelectionDialog}
- */
-public class TypeSelectionComponent extends Composite implements ITypeSelectionComponent {
-
- private IDialogSettings fSettings;
- private boolean fMultipleSelection;
- private ITitleLabel fTitleLabel;
-
- private ToolBar fToolBar;
- private ToolItem fToolItem;
- private MenuManager fMenuManager;
- private WorkingSetFilterActionGroup fFilterActionGroup;
-
- private TypeSelectionExtension fTypeSelectionExtension;
- private Text fFilter;
- private String fInitialFilterText;
- private IJavaScriptSearchScope fScope;
- private TypeInfoViewer fViewer;
- private ViewForm fForm;
- private CLabel fLabel;
-
- public static final int NONE= 0;
- public static final int CARET_BEGINNING= 1;
- public static final int FULL_SELECTION= 2;
-
- private static final String DIALOG_SETTINGS= "org.eclipse.wst.jsdt.internal.ui.dialogs.TypeSelectionComponent"; //$NON-NLS-1$
- private static final String SHOW_STATUS_LINE= "show_status_line"; //$NON-NLS-1$
- private static final String FULLY_QUALIFY_DUPLICATES= "fully_qualify_duplicates"; //$NON-NLS-1$
- private static final String WORKINGS_SET_SETTINGS= "workingset_settings"; //$NON-NLS-1$
-
- private class ToggleStatusLineAction extends Action {
- public ToggleStatusLineAction() {
- super(JavaUIMessages.TypeSelectionComponent_show_status_line_label, IAction.AS_CHECK_BOX);
- }
- public void run() {
- if (fForm == null)
- return;
- GridData gd= (GridData)fForm.getLayoutData();
- boolean checked= isChecked();
- gd.exclude= !checked;
- fForm.setVisible(checked);
- fSettings.put(SHOW_STATUS_LINE, checked);
- TypeSelectionComponent.this.layout();
- }
- }
-
- private class FullyQualifyDuplicatesAction extends Action {
- public FullyQualifyDuplicatesAction() {
- super(JavaUIMessages.TypeSelectionComponent_fully_qualify_duplicates_label, IAction.AS_CHECK_BOX);
- }
- public void run() {
- boolean checked= isChecked();
- fViewer.setFullyQualifyDuplicates(checked, true);
- fSettings.put(FULLY_QUALIFY_DUPLICATES, checked);
- }
- }
-
- /**
- * Special interface to access a title lable in
- * a generic fashion.
- */
- public interface ITitleLabel {
- /**
- * Sets the title to the given text
- *
- * @param text the title text
- */
- public void setText(String text);
- }
-
- public TypeSelectionComponent(Composite parent, int style, String message, boolean multi,
- IJavaScriptSearchScope scope, int elementKind, String initialFilter, ITitleLabel titleLabel,
- TypeSelectionExtension extension) {
- super(parent, style);
- setFont(parent.getFont());
- fMultipleSelection= multi;
- fScope= scope;
- fInitialFilterText= initialFilter;
- fTitleLabel= titleLabel;
- fTypeSelectionExtension= extension;
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- fSettings= settings.getSection(DIALOG_SETTINGS);
- if (fSettings == null) {
- fSettings= new DialogSettings(DIALOG_SETTINGS);
- settings.addSection(fSettings);
- }
- if (fSettings.get(SHOW_STATUS_LINE) == null) {
- fSettings.put(SHOW_STATUS_LINE, true);
- }
- createContent(message, elementKind);
- }
-
- public void triggerSearch() {
- fViewer.forceSearch();
- }
-
- public TypeNameMatch[] getSelection() {
- return fViewer.getSelection();
- }
-
- public IJavaScriptSearchScope getScope() {
- return fScope;
- }
-
- private void createContent(final String message, int elementKind) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0; layout.marginHeight= 0;
- setLayout(layout);
- Font font= getFont();
-
- Control header= createHeader(this, font, message);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- header.setLayoutData(gd);
-
- fFilter= new Text(this, SWT.BORDER | SWT.FLAT);
- fFilter.setFont(font);
- if (fInitialFilterText != null) {
- fFilter.setText(fInitialFilterText);
- }
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- fFilter.setLayoutData(gd);
- fFilter.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- patternChanged((Text)e.widget);
- }
- });
- fFilter.addKeyListener(new KeyListener() {
- public void keyReleased(KeyEvent e) {
- }
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.ARROW_DOWN) {
- fViewer.setFocus();
- }
- }
- });
- fFilter.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result= Strings.removeMnemonicIndicator(message);
- }
- });
- TextFieldNavigationHandler.install(fFilter);
-
- Label label= new Label(this, SWT.NONE);
- label.setFont(font);
- label.setText(JavaUIMessages.TypeSelectionComponent_label);
- label.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
- e.detail= SWT.TRAVERSE_NONE;
- fViewer.setFocus();
- }
- }
- });
- label= new Label(this, SWT.RIGHT);
- label.setFont(font);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- label.setLayoutData(gd);
- fViewer= new TypeInfoViewer(this, fMultipleSelection ? SWT.MULTI : SWT.NONE, label,
- fScope, elementKind, fInitialFilterText,
- fTypeSelectionExtension != null ? fTypeSelectionExtension.getFilterExtension() : null,
- fTypeSelectionExtension != null ? fTypeSelectionExtension.getImageProvider() : null);
- gd= new GridData(GridData.FILL_BOTH);
- final Table table= fViewer.getTable();
- PixelConverter converter= new PixelConverter(table);
- gd.widthHint= converter.convertWidthInCharsToPixels(70);
- gd.heightHint= SWTUtil.getTableHeightHint(table, 10);
- gd.horizontalSpan= 2;
- table.setLayoutData(gd);
- table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- if (table.getSelectionCount() == 0) {
- e.result= Strings.removeMnemonicIndicator(JavaUIMessages.TypeSelectionComponent_label);
- }
- }
- });
- fViewer.setFullyQualifyDuplicates(fSettings.getBoolean(FULLY_QUALIFY_DUPLICATES), false);
- if (fTypeSelectionExtension != null) {
- Control addition= fTypeSelectionExtension.createContentArea(this);
- if (addition != null) {
- addition.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- }
- if (!fMultipleSelection) {
- fForm= new ViewForm(this, SWT.BORDER | SWT.FLAT);
- fForm.setFont(font);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- boolean showStatusLine= fSettings.getBoolean(SHOW_STATUS_LINE);
- gd.exclude= !showStatusLine;
- fForm.setVisible(showStatusLine);
- fForm.setLayoutData(gd);
- fLabel= new CLabel(fForm, SWT.FLAT);
- fLabel.setFont(fForm.getFont());
- fForm.setContent(fLabel);
- table.addSelectionListener(new SelectionAdapter() {
- private TypeNameMatchLabelProvider fLabelProvider= new TypeNameMatchLabelProvider(
- TypeNameMatchLabelProvider.SHOW_TYPE_CONTAINER_ONLY + TypeNameMatchLabelProvider.SHOW_ROOT_POSTFIX);
- public void widgetSelected(SelectionEvent event) {
- TypeNameMatch[] selection= fViewer.getSelection();
- if (selection.length != 1) {
- fLabel.setText(""); //$NON-NLS-1$
- fLabel.setImage(null);
- } else {
- TypeNameMatch type= selection[0];
- fLabel.setText(fViewer.getLabelProvider().getQualificationText(type));
- fLabel.setImage(fLabelProvider.getImage(type));
- }
- }
- });
- }
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- disposeComponent();
- }
- });
- if (fTypeSelectionExtension != null) {
- fTypeSelectionExtension.initialize(this);
- }
- }
-
- public void addSelectionListener(SelectionListener listener) {
- fViewer.getTable().addSelectionListener(listener);
- }
-
- public void populate(int selectionMode) {
- if (fInitialFilterText != null) {
- switch(selectionMode) {
- case CARET_BEGINNING:
- fFilter.setSelection(0, 0);
- break;
- case FULL_SELECTION:
- fFilter.setSelection(0, fInitialFilterText.length());
- break;
- }
- }
- fFilter.setFocus();
- fViewer.startup();
- }
-
- private void patternChanged(Text text) {
- fViewer.setSearchPattern(text.getText());
- }
-
- private Control createHeader(Composite parent, Font font, String message) {
- Composite header= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0; layout.marginHeight= 0;
- header.setLayout(layout);
- header.setFont(font);
- Label label= new Label(header, SWT.NONE);
- label.setText(message);
- label.setFont(font);
- label.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
- e.detail= SWT.TRAVERSE_NONE;
- fFilter.setFocus();
- }
- }
- });
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- label.setLayoutData(gd);
-
- createViewMenu(header);
- return header;
- }
-
- private void createViewMenu(Composite parent) {
- fToolBar= new ToolBar(parent, SWT.FLAT);
- fToolItem= new ToolItem(fToolBar, SWT.PUSH, 0);
-
- GridData data= new GridData();
- data.horizontalAlignment= GridData.END;
- fToolBar.setLayoutData(data);
-
- fToolItem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_ELCL_VIEW_MENU));
- fToolItem.setDisabledImage(JavaPluginImages.get(JavaPluginImages.IMG_DLCL_VIEW_MENU));
- fToolItem.setToolTipText(JavaUIMessages.TypeSelectionComponent_menu);
- fToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- showViewMenu();
- }
- });
-
- fMenuManager= new MenuManager();
- fillViewMenu(fMenuManager);
-
- // ICommandService commandService= (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- // IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
- }
-
- private void showViewMenu() {
- Menu menu = fMenuManager.createContextMenu(getShell());
- Rectangle bounds = fToolItem.getBounds();
- Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
- topLeft = fToolBar.toDisplay(topLeft);
- menu.setLocation(topLeft.x, topLeft.y);
- menu.setVisible(true);
- }
-
- private void fillViewMenu(IMenuManager viewMenu) {
- if (!fMultipleSelection) {
- ToggleStatusLineAction showStatusLineAction= new ToggleStatusLineAction();
- showStatusLineAction.setChecked(fSettings.getBoolean(SHOW_STATUS_LINE));
- viewMenu.add(showStatusLineAction);
- }
- FullyQualifyDuplicatesAction fullyQualifyDuplicatesAction= new FullyQualifyDuplicatesAction();
- fullyQualifyDuplicatesAction.setChecked(fSettings.getBoolean(FULLY_QUALIFY_DUPLICATES));
- viewMenu.add(fullyQualifyDuplicatesAction);
- if (fScope == null) {
- fFilterActionGroup= new WorkingSetFilterActionGroup(getShell(),
- JavaScriptPlugin.getActivePage(),
- new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- IWorkingSet ws= (IWorkingSet)event.getNewValue();
- if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
- fScope= SearchEngine.createWorkspaceScope();
- fTitleLabel.setText(null);
- } else {
- fScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true);
- fTitleLabel.setText(ws.getLabel());
- }
- fViewer.setSearchScope(fScope, true);
- }
- });
- String setting= fSettings.get(WORKINGS_SET_SETTINGS);
- if (setting != null) {
- try {
- IMemento memento= XMLMemento.createReadRoot(new StringReader(setting));
- fFilterActionGroup.restoreState(memento);
- } catch (WorkbenchException e) {
- }
- }
- IWorkingSet ws= fFilterActionGroup.getWorkingSet();
- if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
- fScope= SearchEngine.createWorkspaceScope();
- fTitleLabel.setText(null);
- } else {
- fScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true);
- fTitleLabel.setText(ws.getLabel());
- }
- fFilterActionGroup.fillViewMenu(viewMenu);
- }
- }
-
- private void disposeComponent() {
- if (fFilterActionGroup != null) {
- XMLMemento memento= XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$
- fFilterActionGroup.saveState(memento);
- fFilterActionGroup.dispose();
- StringWriter writer= new StringWriter();
- try {
- memento.save(writer);
- fSettings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString());
- } catch (IOException e) {
- // don't do anything. Simply don't store the settings
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionDialog2.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionDialog2.java
deleted file mode 100644
index b77d0505..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dialogs/TypeSelectionDialog2.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui.dialogs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatch;
-import org.eclipse.wst.jsdt.core.search.TypeNameRequestor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.OpenTypeHistory;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.dialogs.TypeSelectionExtension;
-
-/**
- * @deprecated use {@link FilteredTypesSelectionDialog}
- */
-public class TypeSelectionDialog2 extends SelectionStatusDialog {
-
- private String fTitle;
-
- private boolean fMultipleSelection;
- private IRunnableContext fRunnableContext;
- private IJavaScriptSearchScope fScope;
- private int fElementKind;
-
- private String fInitialFilter;
- private int fSelectionMode;
- private ISelectionStatusValidator fValidator;
- private TypeSelectionComponent fContent;
- private TypeSelectionExtension fExtension;
-
- public static final int NONE= TypeSelectionComponent.NONE;
- public static final int CARET_BEGINNING= TypeSelectionComponent.CARET_BEGINNING;
- public static final int FULL_SELECTION= TypeSelectionComponent.FULL_SELECTION;
-
- private static boolean fgFirstTime= true;
-
- private class TitleLabel implements TypeSelectionComponent.ITitleLabel {
- public void setText(String text) {
- if (text == null || text.length() == 0) {
- getShell().setText(fTitle);
- } else {
- getShell().setText(Messages.format(
- JavaUIMessages.TypeSelectionDialog2_title_format,
- new String[] { fTitle, text}));
- }
- }
- }
-
- public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context,
- IJavaScriptSearchScope scope, int elementKinds) {
- this(parent, multi, context, scope, elementKinds, null);
- }
-
- public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context,
- IJavaScriptSearchScope scope, int elementKinds, TypeSelectionExtension extension) {
- super(parent);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- fMultipleSelection= multi;
- fRunnableContext= context;
- fScope= scope;
- fElementKind= elementKinds;
- fSelectionMode= NONE;
- fExtension= extension;
- if (fExtension != null) {
- fValidator= fExtension.getSelectionValidator();
- }
- }
-
- public void setFilter(String filter) {
- setFilter(filter, FULL_SELECTION);
- }
-
- public void setFilter(String filter, int selectionMode) {
- fInitialFilter= filter;
- fSelectionMode= selectionMode;
- }
-
- public void setValidator(ISelectionStatusValidator validator) {
- fValidator= validator;
- }
-
- protected TypeNameMatch[] getSelectedTypes() {
- if (fContent == null || fContent.isDisposed())
- return null;
- return fContent.getSelection();
- }
-
- public void create() {
- super.create();
- fContent.populate(fSelectionMode);
- getOkButton().setEnabled(fContent.getSelection().length > 0);
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IJavaHelpContextIds.TYPE_SELECTION_DIALOG2);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite area= (Composite)super.createDialogArea(parent);
- fContent= new TypeSelectionComponent(area, SWT.NONE, getMessage(),
- fMultipleSelection, fScope, fElementKind, fInitialFilter,
- new TitleLabel(), fExtension);
- GridData gd= new GridData(GridData.FILL_BOTH);
- fContent.setLayoutData(gd);
- fContent.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- handleDefaultSelected(fContent.getSelection());
- }
- public void widgetSelected(SelectionEvent e) {
- handleWidgetSelected(fContent.getSelection());
- }
- });
- return area;
- }
-
- protected void handleDefaultSelected(TypeNameMatch[] selection) {
- if (selection.length == 0)
- return;
- okPressed();
- }
-
- protected void handleWidgetSelected(TypeNameMatch[] selection) {
- IStatus status= null;
- if (selection.length == 0) {
- status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, "",null); //$NON-NLS-1$
- } else {
- if (fValidator != null) {
- List jElements= new ArrayList();
- for (int i= 0; i < selection.length; i++) {
- IType type= selection[i].getType();
- if (type != null) {
- jElements.add(type);
- } else {
- status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR,
- Messages.format(JavaUIMessages.TypeSelectionDialog_error_type_doesnot_exist, selection[i].getFullyQualifiedName()),
- null);
- break;
- }
- }
- if (status == null) {
- status= fValidator.validate(jElements.toArray());
- }
- } else {
- status= new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "",null); //$NON-NLS-1$
- }
- }
- updateStatus(status);
- }
-
- public int open() {
- try {
- ensureConsistency();
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message);
- return CANCEL;
- } catch (InterruptedException e) {
- // cancelled by user
- return CANCEL;
- }
- if (fInitialFilter == null) {
- IWorkbenchWindow window= JavaScriptPlugin.getActiveWorkbenchWindow();
- if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
- if (selection instanceof ITextSelection) {
- String text= ((ITextSelection)selection).getText();
- if (text != null) {
- text= text.trim();
- if (text.length() > 0 && JavaScriptConventions.validateJavaScriptTypeName(text, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3).isOK()) {
- fInitialFilter= text;
- fSelectionMode= FULL_SELECTION;
- }
- }
- }
- }
- }
- return super.open();
- }
-
- public boolean close() {
- boolean result;
- try {
- if (getReturnCode() == OK) {
- OpenTypeHistory.getInstance().save();
- }
- } finally {
- result= super.close();
- }
- return result;
- }
-
- public void setTitle(String title) {
- super.setTitle(title);
- fTitle= title;
- }
-
- protected void computeResult() {
- TypeNameMatch[] selected= fContent.getSelection();
- if (selected == null || selected.length == 0) {
- setResult(null);
- return;
- }
-
- // If the scope is null then it got computed by the type selection component.
- if (fScope == null) {
- fScope= fContent.getScope();
- }
-
- OpenTypeHistory history= OpenTypeHistory.getInstance();
- List result= new ArrayList(selected.length);
- for (int i= 0; i < selected.length; i++) {
- TypeNameMatch typeInfo= selected[i];
- IType type= typeInfo.getType();
- if (!type.exists()) {
- String title= JavaUIMessages.TypeSelectionDialog_errorTitle;
- IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
- String containerName= JavaScriptElementLabels.getElementLabel(root, JavaScriptElementLabels.ROOT_QUALIFIED);
- String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName });
- MessageDialog.openError(getShell(), title, message);
- history.remove(typeInfo);
- setResult(null);
- } else {
- history.accessed(typeInfo);
- result.add(type);
- }
- }
- setResult(result);
- }
-
- private void ensureConsistency() throws InvocationTargetException, InterruptedException {
- // we only have to ensure history consistency here since the search engine
- // takes care of working copies.
- class ConsistencyRunnable implements IRunnableWithProgress {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- if (fgFirstTime) {
- // Join the initialize after load job.
- IJobManager manager= Job.getJobManager();
- manager.join(JavaScriptUI.ID_PLUGIN, monitor);
- }
- OpenTypeHistory history= OpenTypeHistory.getInstance();
- if (fgFirstTime || history.isEmpty()) {
- monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100);
- if (history.needConsistencyCheck()) {
- refreshSearchIndices(new SubProgressMonitor(monitor, 90));
- history.checkConsistency(new SubProgressMonitor(monitor, 10));
- } else {
- refreshSearchIndices(monitor);
- }
- monitor.done();
- fgFirstTime= false;
- } else {
- history.checkConsistency(monitor);
- }
- }
- public boolean needsExecution() {
- OpenTypeHistory history= OpenTypeHistory.getInstance();
- return fgFirstTime || history.isEmpty() || history.needConsistencyCheck();
- }
- private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- new SearchEngine().searchAllTypeNames(
- null,
- 0,
- // make sure we search a concrete name. This is faster according to Kent
- "_______________".toCharArray(), //$NON-NLS-1$
- SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
- IJavaScriptSearchConstants.ENUM,
- SearchEngine.createWorkspaceScope(),
- new TypeNameRequestor() {},
- IJavaScriptSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- monitor);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- ConsistencyRunnable runnable= new ConsistencyRunnable();
- if (!runnable.needsExecution())
- return;
- IRunnableContext context= fRunnableContext != null
- ? fRunnableContext
- : PlatformUI.getWorkbench().getProgressService();
- context.run(true, true, runnable);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
deleted file mode 100644
index 3a5f1280..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-
-public class BasicSelectionTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
-
- private ISelectionProvider fProvider;
-
- public BasicSelectionTransferDragAdapter(ISelectionProvider provider) {
- Assert.isNotNull(provider);
- fProvider= provider;
- }
-
- /**
- * @see TransferDragSourceListener#getTransfer
- */
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getInstance();
- }
-
- /* non Java-doc
- * @see org.eclipse.swt.dnd.DragSourceListener#dragStart
- */
- public void dragStart(DragSourceEvent event) {
- ISelection selection= fProvider.getSelection();
- LocalSelectionTransfer.getInstance().setSelection(selection);
- LocalSelectionTransfer.getInstance().setSelectionSetTime(event.time & 0xFFFFFFFFL);
- event.doit= isDragable(selection);
- }
-
- /**
- * Checks if the elements contained in the given selection can
- * be dragged.
- * <p>
- * Subclasses may override.
- *
- * @param selection containing the elements to be dragged
- */
- protected boolean isDragable(ISelection selection) {
- return true;
- }
-
-
- /* non Java-doc
- * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData
- */
- public void dragSetData(DragSourceEvent event) {
- // For consistency set the data to the selection even though
- // the selection is provided by the LocalSelectionTransfer
- // to the drop target adapter.
- event.data= LocalSelectionTransfer.getInstance().getSelection();
- }
-
-
- /* non Java-doc
- * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished
- */
- public void dragFinished(DragSourceEvent event) {
- // Make sure we don't have to do any remaining work
- Assert.isTrue(event.detail != DND.DROP_MOVE);
- LocalSelectionTransfer.getInstance().setSelection(null);
- LocalSelectionTransfer.getInstance().setSelectionSetTime(0);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDragAdapter.java
deleted file mode 100644
index 013fc004..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDragAdapter.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.TransferDragSourceListener;
-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;
-
-/**
- * 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> callback.
- */
-public class DelegatingDragAdapter implements DragSourceListener {
-
- private TransferDragSourceListener[] fPossibleListeners;
- private List fActiveListeners;
- private TransferDragSourceListener fFinishListener;
-
- public DelegatingDragAdapter(TransferDragSourceListener[] listeners) {
- setPossibleListeners(listeners);
- }
-
- protected void setPossibleListeners(TransferDragSourceListener[] listeners) {
- Assert.isNotNull(listeners);
- Assert.isTrue(fActiveListeners == null, "Can only set possible listeners before drag operation has started"); //$NON-NLS-1$
- fPossibleListeners= listeners;
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragStart(DragSourceEvent event) {
- fFinishListener= null;
- boolean saveDoit= event.doit;
- Object saveData= event.data;
- boolean doIt= false;
- List transfers= new ArrayList(fPossibleListeners.length);
- fActiveListeners= new ArrayList(fPossibleListeners.length);
-
- for (int i= 0; i < fPossibleListeners.length; i++) {
- TransferDragSourceListener listener= fPossibleListeners[i];
- event.doit= saveDoit;
- listener.dragStart(event);
- if (event.doit) {
- transfers.add(listener.getTransfer());
- fActiveListeners.add(listener);
- }
- doIt= doIt || event.doit;
- }
- if (doIt) {
- ((DragSource)event.widget).setTransfer((Transfer[])transfers.toArray(new Transfer[transfers.size()]));
- }
- event.data= saveData;
- event.doit= doIt;
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragSetData(DragSourceEvent event) {
- fFinishListener= getListener(event.dataType);
- if (fFinishListener != null)
- fFinishListener.dragSetData(event);
- }
-
- /* non Java-doc
- * @see DragSourceListener
- */
- public void dragFinished(DragSourceEvent event) {
- try{
- if (fFinishListener != null) {
- fFinishListener.dragFinished(event);
- } else {
- // If the user presses Escape then we get a dragFinished without
- // getting a dragSetData before.
- fFinishListener= getListener(event.dataType);
- if (fFinishListener != null)
- fFinishListener.dragFinished(event);
- }
- } finally{
- fFinishListener= null;
- fActiveListeners= null;
- }
- }
-
- private TransferDragSourceListener getListener(TransferData type) {
- if (type == null)
- return null;
-
- for (Iterator iter= fActiveListeners.iterator(); iter.hasNext();) {
- TransferDragSourceListener listener= (TransferDragSourceListener)iter.next();
- if (listener.getTransfer().isSupportedType(type)) {
- return listener;
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDropAdapter.java
deleted file mode 100644
index ab1b8c82..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/DelegatingDropAdapter.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-
-/**
- * A delegating drop adapter negotiates between a set of
- * <code>TransferDropTargetListener</code> s On <code>dragEnter</code> the
- * adapter determines the listener to be used for any further <code>drag*</code>
- * callback.
- */
-public class DelegatingDropAdapter implements DropTargetListener {
-
- private TransferDropTargetListener[] fListeners;
- private TransferDropTargetListener fCurrentListener;
- private int fOriginalDropType;
-
- /**
- * Creates a new delegating drop adapter.
- *
- * @param listeners an array of potential listeners
- */
- public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
- Assert.isNotNull(listeners);
- fListeners= listeners;
- }
-
- /**
- * The cursor has entered the drop target boundaries. The current listener
- * is updated, and <code>#dragEnter()</code> is forwarded to the current
- * listener.
- *
- * @param event the drop target event
- * @see DropTargetListener#dragEnter(DropTargetEvent)
- */
- public void dragEnter(DropTargetEvent event) {
- fOriginalDropType= event.detail;
- updateCurrentListener(event);
- }
-
- /**
- * The cursor has left the drop target boundaries. The event is forwarded to
- * the current listener.
- *
- * @param event the drop target event
- * @see DropTargetListener#dragLeave(DropTargetEvent)
- */
- public void dragLeave(final DropTargetEvent event) {
- setCurrentListener(null, event);
- }
-
- /**
- * The operation being performed has changed (usually due to the user
- * changing a drag modifier key while dragging). Updates the current
- * listener and forwards this event to that listener.
- *
- * @param event the drop target event
- * @see DropTargetListener#dragOperationChanged(DropTargetEvent)
- */
- public void dragOperationChanged(final DropTargetEvent event) {
- fOriginalDropType= event.detail;
- TransferDropTargetListener oldListener= getCurrentListener();
- updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
- // only notify the current listener if it hasn't changed based on the
- // operation change. otherwise the new listener would get a dragEnter
- // followed by a dragOperationChanged with the exact same event.
- if (newListener != null && newListener == oldListener) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- newListener.dragOperationChanged(event);
- }
- });
- }
- }
-
- /**
- * The cursor is moving over the drop target. Updates the current listener
- * and forwards this event to that listener. If no listener can handle the
- * drag operation the <code>event.detail</code> field is set to
- * <code>DND.DROP_NONE</code> to indicate an invalid drop.
- *
- * @param event the drop target event
- * @see DropTargetListener#dragOver(DropTargetEvent)
- */
- public void dragOver(final DropTargetEvent event) {
- TransferDropTargetListener oldListener= getCurrentListener();
- updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
-
- // only notify the current listener if it hasn't changed based on the
- // drag over. otherwise the new listener would get a dragEnter
- // followed by a dragOver with the exact same event.
- if (newListener != null && newListener == oldListener) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- newListener.dragOver(event);
- }
- });
- }
- }
-
- /**
- * Forwards this event to the current listener, if there is one. Sets the
- * current listener to <code>null</code> afterwards.
- *
- * @param event the drop target event
- * @see DropTargetListener#drop(DropTargetEvent)
- */
- public void drop(final DropTargetEvent event) {
- updateCurrentListener(event);
- if (getCurrentListener() != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- getCurrentListener().drop(event);
- }
- });
- }
- setCurrentListener(null, event);
- }
-
- /**
- * Forwards this event to the current listener if there is one.
- *
- * @param event the drop target event
- * @see DropTargetListener#dropAccept(DropTargetEvent)
- */
- public void dropAccept(final DropTargetEvent event) {
- if (getCurrentListener() != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- getCurrentListener().dropAccept(event);
- }
- });
- }
- }
-
- /**
- * Returns the listener which currently handles drop events.
- *
- * @return the <code>TransferDropTargetListener</code> which currently
- * handles drop events.
- */
- private TransferDropTargetListener getCurrentListener() {
- return fCurrentListener;
- }
-
- /**
- * Returns the transfer data type supported by the given listener. Returns
- * <code>null</code> if the listener does not support any of the specified
- * data types.
- *
- * @param dataTypes available data types
- * @param listener <code>TransferDropTargetListener</code> to use for
- * testing supported data types.
- * @return the transfer data type supported by the given listener or
- * <code>null</code>.
- */
- private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
- for (int i= 0; i < dataTypes.length; i++) {
- if (listener.getTransfer().isSupportedType(dataTypes[i])) {
- return dataTypes[i];
- }
- }
- return null;
- }
-
- /**
- * Returns the combined set of <code>Transfer</code> types of all
- * <code>TransferDropTargetListeners</code>.
- *
- * @return the combined set of <code>Transfer</code> types
- */
- public Transfer[] getTransfers() {
- Transfer[] types= new Transfer[fListeners.length];
- for (int i= 0; i < fListeners.length; i++) {
- types[i]= fListeners[i].getTransfer();
- }
- return types;
- }
-
- /**
- * Sets the current listener to <code>listener</code>. Sends the given
- * <code>DropTargetEvent</code> if the current listener changes.
- *
- * @return <code>true</code> if the new listener is different than the
- * previous <code>false</code> otherwise
- */
- private boolean setCurrentListener(TransferDropTargetListener listener, final DropTargetEvent event) {
- if (fCurrentListener == listener)
- return false;
- if (fCurrentListener != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- fCurrentListener.dragLeave(event);
- }
- });
- }
- fCurrentListener= listener;
- if (fCurrentListener != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- fCurrentListener.dragEnter(event);
- }
- });
- }
- return true;
- }
-
- /**
- * Updates the current listener to one that can handle the drop. There can
- * be many listeners and each listener may be able to handle many
- * <code>TransferData</code> types. The first listener found that can
- * handle a drop of one of the given <code>TransferData</code> types will
- * be selected. If no listener can handle the drag operation the
- * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code>
- * to indicate an invalid drop.
- *
- * @param event the drop target event
- */
- private void updateCurrentListener(DropTargetEvent event) {
- int originalDetail= event.detail;
- // Revert the detail to the "original" drop type that the User
- // indicated. This is necessary because the previous listener
- // may have changed the detail to something other than what the
- // user indicated.
- event.detail= fOriginalDropType;
-
- for (int i= 0; i < fListeners.length; i++) {
- TransferDropTargetListener listener= fListeners[i];
- TransferData dataType= getSupportedTransferType(event.dataTypes, listener);
- if (dataType != null) {
- TransferData originalDataType= event.currentDataType;
- // set the data type supported by the drop listener
- event.currentDataType= dataType;
- if (listener.isEnabled(event)) {
- // if the listener stays the same, set its previously
- // determined
- // event detail
- if (!setCurrentListener(listener, event))
- event.detail= originalDetail;
- return;
- } else {
- event.currentDataType= originalDataType;
- }
- }
- }
- setCurrentListener(null, event);
- event.detail= DND.DROP_NONE;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDragAdapter.java
deleted file mode 100644
index d54ef0dd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDragAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DragSourceEvent;
-
-public class JdtViewerDragAdapter extends DelegatingDragAdapter {
-
- private StructuredViewer fViewer;
-
- public JdtViewerDragAdapter(StructuredViewer viewer, TransferDragSourceListener[] listeners) {
- super(listeners);
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- public void dragStart(DragSourceEvent event) {
- IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
- if (selection.isEmpty()) {
- event.doit= false;
- return;
- }
- super.dragStart(event);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDropAdapter.java
deleted file mode 100644
index 4cde5d71..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/JdtViewerDropAdapter.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.TreeItem;
-
-/**
- * A drag and drop adapter to be used together with structured viewers.
- * The adapater delegates the <code>dragEnter</code>, <code>dragOperationChanged
- * </code>, <code>dragOver</code> and <code>dropAccept</code> method to the
- * <code>validateDrop</code> method. Furthermore it adds location feedback.
- */
-public class JdtViewerDropAdapter implements DropTargetListener {
-
- /**
- * Constant describing the position of the mouse cursor relative
- * to the target object. This means the mouse is not positioned
- * over or near any valid target.
- */
- public static final int LOCATION_NONE= DND.FEEDBACK_NONE;
-
- /**
- * Constant describing the position of the mouse cursor relative
- * to the target object. This means the mouse is positioned
- * directly on the target.
- */
- public static final int LOCATION_ON= DND.FEEDBACK_SELECT;
-
- /**
- * Constant describing the position of the mouse cursor relative
- * to the target object. This means the mouse is positioned
- * slightly before the target.
- */
- public static final int LOCATION_BEFORE= DND.FEEDBACK_INSERT_BEFORE;
-
- /**
- * Constant describing the position of the mouse cursor relative
- * to the target object. This means the mouse is positioned
- * slightly after the target.
- */
- public static final int LOCATION_AFTER= DND.FEEDBACK_INSERT_AFTER;
-
- /**
- * The threshold used to determine if the mouse is before or after
- * an item.
- */
- private static final int LOCATION_EPSILON= 5;
-
-
- private static final int ITEM_MARGIN_LEFT= 40;
- private static final int ITEM_MARGIN_RIGTH= 10;
-
- /**
- * Style to enable location feedback.
- */
- public static final int INSERTION_FEEDBACK= 1 << 1;
-
- private StructuredViewer fViewer;
- private int fFeedback;
- private boolean fShowInsertionFeedback;
- private boolean fFullWidthMatchesItem;
- private int fRequestedOperation;
- private int fLastOperation;
- protected int fLocation;
- protected Object fTarget;
-
-
-
- public JdtViewerDropAdapter(StructuredViewer viewer, int feedback) {
- Assert.isNotNull(viewer);
- fViewer= viewer;
- fFeedback= feedback;
- fLastOperation= -1;
- fFullWidthMatchesItem= true;
- }
-
- /**
- * Controls whether the drop adapter shows insertion feedback or not.
- *
- * @param showInsertionFeedback <code>true</code> if the drop adapter is supposed
- * to show insertion feedback. Otherwise <code>false</code>
- */
- public void showInsertionFeedback(boolean showInsertionFeedback) {
- fShowInsertionFeedback= showInsertionFeedback;
- }
-
- /**
- * Controls whether the drop adapter matches an tree or table item on the full width of the viewer.
- *
- * @param enable <code>true</code> if the drop adapter is supposed
- * to test the horizontal distance
- */
- protected void setFullWidthMatchesItem(boolean enable) {
- fFullWidthMatchesItem= enable;
- }
-
- /**
- * Returns the viewer this adapter is working on.
- */
- protected StructuredViewer getViewer() {
- return fViewer;
- }
-
- //---- Hooks to override -----------------------------------------------------
-
- /**
- * The actual drop has occurred. Calls <code>drop(Object target, DropTargetEvent event)
- * </code>.
- * @see DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
- */
- public void drop(DropTargetEvent event) {
- drop(fTarget, event);
- }
-
- /**
- * The actual drop has occurred.
- * @param target the drop target in form of a domain element.
- * @param event the drop traget event
- */
- public void drop(Object target, DropTargetEvent event) {
- }
-
- /**
- * Checks if the drop is valid. The method calls <code>validateDrop
- * (Object target, DropTargetEvent event). Implementors can alter the
- * <code>currentDataType</code> field and the <code>detail</code> field
- * to give feedback about drop acceptence.
- */
- public void validateDrop(DropTargetEvent event) {
- validateDrop(fTarget, event, fRequestedOperation);
- }
-
- /**
- * Checks if the drop on the current target is valid. The method
- * can alter the <code>currentDataType</code> field and the <code>
- * detail</code> field to give feedback about drop acceptence.
- * @param target the drop target in form of a domain element.
- * @param event the drop traget event
- * @param operation the operation requested by the user.
- */
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- }
-
- public void dragEnter(DropTargetEvent event) {
- dragOperationChanged(event);
- }
-
- public void dragLeave(DropTargetEvent event) {
- fTarget= null;
- fLocation= LOCATION_NONE;
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- fRequestedOperation= event.detail;
- fTarget= computeTarget(event);
- fLocation= computeLocation(event);
- validateDrop(event);
- fLastOperation= event.detail;
- computeFeedback(event);
- }
-
- public void dragOver(DropTargetEvent event) {
- Object oldTarget= fTarget;
- fTarget= computeTarget(event);
-
- //set the location feedback
- int oldLocation= fLocation;
- fLocation= computeLocation(event);
- if (oldLocation != fLocation || oldTarget != fTarget || fLastOperation != event.detail) {
- validateDrop(event);
- fLastOperation= event.detail;
- } else {
- event.detail= fLastOperation;
- }
- computeFeedback(event);
- }
-
- public void dropAccept(DropTargetEvent event) {
- fTarget= computeTarget(event);
- validateDrop(event);
- fLastOperation= event.detail;
- }
-
- /**
- * Returns the data held by <code>event.item</code>. Inside a viewer
- * this corresponds to the items data model element.
- */
- protected Object computeTarget(DropTargetEvent event) {
- if (event.item == null) {
- return null;
- }
- if (!fFullWidthMatchesItem) {
- Point coordinates= fViewer.getControl().toControl(new Point(event.x, event.y));
- Rectangle bounds= getBounds((Item) event.item);
- if (coordinates.x < bounds.x - ITEM_MARGIN_LEFT || coordinates.x >= bounds.x + bounds.width + ITEM_MARGIN_RIGTH) {
- event.item= null; // too far away
- return null;
- }
- }
- return event.item.getData();
- }
-
- /**
- * Returns the position of the given coordinates relative to the given target.
- * The position is determined to be before, after, or on the item, based on
- * some threshold value. The return value is one of the LOCATION_* constants
- * defined in this class.
- */
- protected int computeLocation(DropTargetEvent event) {
- if (!(event.item instanceof Item))
- return LOCATION_NONE;
-
- Item item= (Item) event.item;
- Point coordinates= fViewer.getControl().toControl(new Point(event.x, event.y));
- Rectangle bounds= getBounds(item);
- if (bounds == null) {
- return LOCATION_NONE;
- }
- if ((coordinates.y - bounds.y) < LOCATION_EPSILON) {
- return LOCATION_BEFORE;
- }
- if ((bounds.y + bounds.height - coordinates.y) < LOCATION_EPSILON) {
- return LOCATION_AFTER;
- }
- return LOCATION_ON;
- }
-
- /**
- * Returns the bounds of the given item, or <code>null</code> if it is not a
- * valid type of item.
- */
- private Rectangle getBounds(Item item) {
- if (item instanceof TreeItem)
- return ((TreeItem) item).getBounds();
-
- if (item instanceof TableItem)
- return ((TableItem) item).getBounds(0);
-
- return null;
- }
-
- /**
- * Sets the drag under feedback corresponding to the value of <code>fLocation</code>
- * and the <code>INSERTION_FEEDBACK</code> style bit.
- */
- protected void computeFeedback(DropTargetEvent event) {
- if (!fShowInsertionFeedback && fLocation != LOCATION_NONE) {
- event.feedback= DND.FEEDBACK_SELECT;
- } else {
- event.feedback= fLocation;
- }
- event.feedback|= fFeedback;
- }
-
- /**
- * Sets the drop operation to </code>DROP_NODE<code>.
- */
- protected void clearDropOperation(DropTargetEvent event) {
- event.detail= DND.DROP_NONE;
- }
-
- /**
- * Returns the requested drop operation.
- */
- protected int getRequestedOperation() {
- return fRequestedOperation;
- }
-
- protected void setDefaultFeedback(int feedback) {
- fFeedback= feedback;
- }
-
- //---- helper methods to test DnD
-
- public void internalTestSetLocation(int location) {
- fLocation= location;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/ResourceTransferDragAdapter.java
deleted file mode 100644
index 49d0e4e2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/dnd/ResourceTransferDragAdapter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.dnd;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.util.TransferDragSourceListener;
-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.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-/**
- * 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 extends DragSourceAdapter implements TransferDragSourceListener {
-
- private ISelectionProvider fProvider;
-
- private static final List EMPTY_LIST= new ArrayList(0);
-
- /**
- * Creates a new ResourceTransferDragAdapter for the given selection
- * provider.
- *
- * @param provider the selection provider to access the viewer's selection
- */
- public ResourceTransferDragAdapter(ISelectionProvider provider) {
- fProvider= provider;
- Assert.isNotNull(fProvider);
- }
-
- public Transfer getTransfer() {
- return ResourceTransfer.getInstance();
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit= convertSelection().size() > 0;
- }
-
- public void dragSetData(DragSourceEvent event) {
- List resources= convertSelection();
- event.data= resources.toArray(new IResource[resources.size()]);
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (!event.doit)
- return;
-
- if (event.detail == DND.DROP_MOVE) {
- handleFinishedDropMove(event);
- }
- }
-
- private List convertSelection() {
- ISelection s= fProvider.getSelection();
- if (!(s instanceof IStructuredSelection))
- return EMPTY_LIST;
- IStructuredSelection selection= (IStructuredSelection)s;
- List result= new ArrayList(selection.size());
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- Object element= iter.next();
- IResource resource= null;
- if (element instanceof IJavaScriptElement) {
- // don't use IAdaptable as for members only the top level type adapts
- resource= ((IJavaScriptElement) element).getResource();
- } else if (element instanceof IAdaptable) {
- resource= (IResource) ((IAdaptable) element).getAdapter(IResource.class);
- }
- if (resource != null)
- result.add(resource);
- }
- return result;
- }
-
- private void handleFinishedDropMove(DragSourceEvent event) {
- MultiStatus status= new MultiStatus(
- JavaScriptPlugin.getPluginId(),
- IJavaStatusConstants.INTERNAL_ERROR,
- JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_resource,
- null);
- List resources= convertSelection();
- for (Iterator iter= resources.iterator(); iter.hasNext();) {
- IResource resource= (IResource) iter.next();
- try {
- resource.delete(true, null);
- } catch (CoreException e) {
- status.add(e.getStatus());
- }
- }
- if (status.getChildren().length > 0) {
- Shell parent= SWTUtil.getShell(event.widget);
- ErrorDialog error= new ErrorDialog(parent,
- JavaUIMessages.ResourceTransferDragAdapter_moving_resource,
- JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files,
- status, IStatus.ERROR);
- error.open();
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClassFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClassFilter.java
deleted file mode 100644
index 03212b27..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClassFilter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-
-/**
- * Filters classes
- */
-public class ClassFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IType) {
- try {
- final IType type= (IType)element;
- return type.isInterface() || type.isEnum();
- } catch (JavaScriptModelException ex) {
- return true;
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClosedProjectFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClosedProjectFilter.java
deleted file mode 100644
index 5ac7af05..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ClosedProjectFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-/**
- * Filters closed projects
- */
-public class ClosedProjectFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IJavaScriptElement)
- return ((IJavaScriptElement)element).getJavaScriptProject().getProject().isOpen();
- if (element instanceof IResource)
- return ((IResource)element).getProject().isOpen();
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ContainedLibraryFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ContainedLibraryFilter.java
deleted file mode 100644
index 98030848..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ContainedLibraryFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-
-
-/**
- * The LibraryFilter is a filter used to determine whether
- * a Java internal library is shown
- */
-public class ContainedLibraryFilter extends ViewerFilter {
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot)element;
- if (root.isArchive()) {
- // don't filter out JARs contained in the project itself
- IResource resource= root.getResource();
- if (resource != null) {
- IProject jarProject= resource.getProject();
- IProject container= root.getJavaScriptProject().getProject();
- return !container.equals(jarProject);
- }
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/CustomFiltersDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/CustomFiltersDialog.java
deleted file mode 100644
index 16d0e709..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/CustomFiltersDialog.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.Stack;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-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.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-public class CustomFiltersDialog extends SelectionDialog {
-
- private static final String SEPARATOR= ","; //$NON-NLS-1$
-
- private String fViewId;
- private boolean fEnablePatterns;
- private String[] fPatterns;
- private String[] fEnabledFilterIds;
-
- private FilterDescriptor[] fBuiltInFilters;
-
- private CheckboxTableViewer fCheckBoxList;
- private Button fEnableUserDefinedPatterns;
- private Text fUserDefinedPatterns;
-
- private Stack fFilterDescriptorChangeHistory;
-
-
- /**
- * Creates a dialog to customize Java element filters.
- *
- * @param shell the parent shell
- * @param viewId the id of the view
- * @param enablePatterns <code>true</code> if pattern filters are enabled
- * @param patterns the filter patterns
- * @param enabledFilterIds the Ids of the enabled filters
- */
- public CustomFiltersDialog(
- Shell shell,
- String viewId,
- boolean enablePatterns,
- String[] patterns,
- String[] enabledFilterIds) {
-
- super(shell);
- Assert.isNotNull(viewId);
- Assert.isNotNull(patterns);
- Assert.isNotNull(enabledFilterIds);
-
- fViewId= viewId;
- fPatterns= patterns;
- fEnablePatterns= enablePatterns;
- fEnabledFilterIds= enabledFilterIds;
-
- fBuiltInFilters= FilterDescriptor.getFilterDescriptors(fViewId);
- fFilterDescriptorChangeHistory= new Stack();
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- protected void configureShell(Shell shell) {
- setTitle(FilterMessages.CustomFiltersDialog_title);
- setMessage(FilterMessages.CustomFiltersDialog_filterList_label);
- super.configureShell(shell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IJavaHelpContextIds.CUSTOM_FILTERS_DIALOG);
- }
-
- /**
- * Overrides method in Dialog
- *
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
- // create a composite with standard margins and spacing
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setFont(parent.getFont());
- Composite group= composite;
-
- // Checkbox
- fEnableUserDefinedPatterns= new Button(group, SWT.CHECK);
- fEnableUserDefinedPatterns.setFocus();
- fEnableUserDefinedPatterns.setText(FilterMessages.CustomFiltersDialog_enableUserDefinedPattern);
-
- // Pattern field
- fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER);
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- data.widthHint= convertWidthInCharsToPixels(59);
- fUserDefinedPatterns.setLayoutData(data);
- String patterns= convertToString(fPatterns, SEPARATOR);
- fUserDefinedPatterns.setText(patterns);
-
- // Info text
- final Label info= new Label(group, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_patternInfo);
-
- // Enabling / disabling of pattern group
- fEnableUserDefinedPatterns.setSelection(fEnablePatterns);
- fUserDefinedPatterns.setEnabled(fEnablePatterns);
- info.setEnabled(fEnablePatterns);
- fEnableUserDefinedPatterns.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean state= fEnableUserDefinedPatterns.getSelection();
- fUserDefinedPatterns.setEnabled(state);
- info.setEnabled(fEnableUserDefinedPatterns.getSelection());
- if (state)
- fUserDefinedPatterns.setFocus();
- }
- });
-
- // Filters provided by extension point
- if (fBuiltInFilters.length > 0)
- createCheckBoxList(group);
-
- applyDialogFont(parent);
- return parent;
- }
-
- private void createCheckBoxList(Composite parent) {
- // Filler
- new Label(parent, SWT.NONE);
-
- Label info= new Label(parent, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_filterList_label);
-
- fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10;
- fCheckBoxList.getTable().setLayoutData(data);
-
- fCheckBoxList.setLabelProvider(createLabelPrivder());
- fCheckBoxList.setContentProvider(new ArrayContentProvider());
- Arrays.sort(fBuiltInFilters);
- fCheckBoxList.setInput(fBuiltInFilters);
- setInitialSelections(getEnabledFilterDescriptors());
-
- List initialSelection= getInitialElementSelections();
- if (initialSelection != null && !initialSelection.isEmpty())
- checkInitialSelections();
-
- // Description
- info= new Label(parent, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_description_label);
- final Text description= new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint= convertHeightInCharsToPixels(3);
- description.setLayoutData(data);
- fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection= event.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object selectedElement= ((IStructuredSelection)selection).getFirstElement();
- if (selectedElement instanceof FilterDescriptor)
- description.setText(((FilterDescriptor)selectedElement).getDescription());
- }
- }
- });
- fCheckBoxList.addCheckStateListener(new ICheckStateListener() {
- /*
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
- public void checkStateChanged(CheckStateChangedEvent event) {
- Object element= event.getElement();
- if (element instanceof FilterDescriptor) {
- // renew if already touched
- if (fFilterDescriptorChangeHistory.contains(element))
- fFilterDescriptorChangeHistory.remove(element);
- fFilterDescriptorChangeHistory.push(element);
- }
- }});
-
- addSelectionButtons(parent);
- }
-
- private void addSelectionButtons(Composite composite) {
- Composite buttonComposite= new Composite(composite, SWT.RIGHT);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- buttonComposite.setLayout(layout);
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
- data.grabExcessHorizontalSpace= true;
- composite.setData(data);
-
- // Select All button
- String label= FilterMessages.CustomFiltersDialog_SelectAllButton_label;
- Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false);
- SWTUtil.setButtonDimensionHint(selectButton);
- SelectionListener listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fCheckBoxList.setAllChecked(true);
- fFilterDescriptorChangeHistory.clear();
- for (int i= 0; i < fBuiltInFilters.length; i++)
- fFilterDescriptorChangeHistory.push(fBuiltInFilters[i]);
- }
- };
- selectButton.addSelectionListener(listener);
-
- // De-select All button
- label= FilterMessages.CustomFiltersDialog_DeselectAllButton_label;
- Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false);
- SWTUtil.setButtonDimensionHint(deselectButton);
- listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fCheckBoxList.setAllChecked(false);
- fFilterDescriptorChangeHistory.clear();
- for (int i= 0; i < fBuiltInFilters.length; i++)
- fFilterDescriptorChangeHistory.push(fBuiltInFilters[i]);
- }
- };
- deselectButton.addSelectionListener(listener);
- }
-
- private void checkInitialSelections() {
- Iterator itemsToCheck= getInitialElementSelections().iterator();
- while (itemsToCheck.hasNext())
- fCheckBoxList.setChecked(itemsToCheck.next(),true);
- }
-
- protected void okPressed() {
- if (fBuiltInFilters != null) {
- ArrayList result= new ArrayList();
- for (int i= 0; i < fBuiltInFilters.length; ++i) {
- if (fCheckBoxList.getChecked(fBuiltInFilters[i]))
- result.add(fBuiltInFilters[i]);
- }
- setResult(result);
- }
- super.okPressed();
- }
-
- private ILabelProvider createLabelPrivder() {
- return
- new LabelProvider() {
- public Image getImage(Object element) {
- return null;
- }
- public String getText(Object element) {
- if (element instanceof FilterDescriptor)
- return ((FilterDescriptor)element).getName();
- else
- return null;
- }
- };
- }
-
- // ---------- result handling ----------
-
- protected void setResult(List newResult) {
- super.setResult(newResult);
- if (fUserDefinedPatterns.getText().length() > 0) {
- fEnablePatterns= fEnableUserDefinedPatterns.getSelection();
- fPatterns= convertFromString(fUserDefinedPatterns.getText(), SEPARATOR);
- } else {
- fEnablePatterns= false;
- fPatterns= new String[0];
- }
- }
-
-
- /**
- * @return the patterns which have been entered by the user
- */
- public String[] getUserDefinedPatterns() {
- return fPatterns;
- }
-
- /**
- * @return the Ids of the enabled built-in filters
- */
- public String[] getEnabledFilterIds() {
- Object[] result= getResult();
- Set enabledIds= new HashSet(result.length);
- for (int i= 0; i < result.length; i++)
- enabledIds.add(((FilterDescriptor)result[i]).getId());
- return (String[]) enabledIds.toArray(new String[enabledIds.size()]);
- }
-
- /**
- * @return <code>true</code> if the user-defined patterns are disabled
- */
- public boolean areUserDefinedPatternsEnabled() {
- return fEnablePatterns;
- }
-
- /**
- * @return a stack with the filter descriptor check history
- *
- */
- public Stack getFilterDescriptorChangeHistory() {
- return fFilterDescriptorChangeHistory;
- }
-
- private FilterDescriptor[] getEnabledFilterDescriptors() {
- FilterDescriptor[] filterDescs= fBuiltInFilters;
- List result= new ArrayList(filterDescs.length);
- List enabledFilterIds= Arrays.asList(fEnabledFilterIds);
- for (int i= 0; i < filterDescs.length; i++) {
- String id= filterDescs[i].getId();
- if (enabledFilterIds.contains(id))
- result.add(filterDescs[i]);
- }
- return (FilterDescriptor[])result.toArray(new FilterDescriptor[result.size()]);
- }
-
-
- public static String[] convertFromString(String patterns, String separator) {
- StringTokenizer tokenizer= new StringTokenizer(patterns, separator, true);
- int tokenCount= tokenizer.countTokens();
- List result= new ArrayList(tokenCount);
- boolean escape= false;
- boolean append= false;
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if (separator.equals(token)) {
- if (!escape)
- escape= true;
- else {
- addPattern(result, separator);
- append= true;
- }
- } else {
- if (!append)
- result.add(token);
- else
- addPattern(result, token);
- append= false;
- escape= false;
- }
- }
- return (String[])result.toArray(new String[result.size()]);
- }
-
- private static void addPattern(List list, String pattern) {
- if (list.isEmpty())
- list.add(pattern);
- else {
- int index= list.size() - 1;
- list.set(index, ((String)list.get(index)) + pattern);
- }
- }
-
- public static String convertToString(String[] patterns, String separator) {
- int length= patterns.length;
- StringBuffer strBuf= new StringBuffer();
- if (length > 0)
- strBuf.append(escapeSeparator(patterns[0], separator));
- else
- return ""; //$NON-NLS-1$
- int i= 1;
- while (i < length) {
- strBuf.append(separator);
- strBuf.append(" "); //$NON-NLS-1$
- strBuf.append(escapeSeparator(patterns[i++], separator));
- }
- return strBuf.toString();
- }
-
- private static String escapeSeparator(String pattern, String separator) {
- int length= pattern.length();
- StringBuffer buf= new StringBuffer(length);
- for (int i= 0; i < length; i++) {
- char ch= pattern.charAt(i);
- if (separator.equals(String.valueOf(ch)))
- buf.append(ch);
- buf.append(ch);
- }
- return buf.toString();
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyInnerPackageFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyInnerPackageFilter.java
deleted file mode 100644
index 5d686abf..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyInnerPackageFilter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-
-/**
- * Filters empty non-leaf package fragments
- */
-public class EmptyInnerPackageFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IPackageFragment) {
- IPackageFragment pkg= (IPackageFragment)element;
- try {
- if (pkg.isDefaultPackage())
- return true;//pkg.hasChildren();
- return !pkg.hasSubpackages() || pkg.hasChildren() || (pkg.getNonJavaScriptResources().length > 0);
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyPackageFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyPackageFilter.java
deleted file mode 100644
index edf0b362..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/EmptyPackageFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-
-/**
- * filters out all empty package fragments.
- */
-public class EmptyPackageFilter extends ViewerFilter {
-
- /**
- * Returns the result of this filter, when applied to the
- * given inputs.
- *
- * @return Returns true if element should be included in filtered set
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IPackageFragment) {
- IPackageFragment pkg= (IPackageFragment)element;
- try {
- return pkg.hasChildren();
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
- return true;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FieldsFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FieldsFilter.java
deleted file mode 100644
index 74eedbf7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FieldsFilter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.MemberFilter;
-
-/**
- * Fields filter.
- *
- *
- */
-public class FieldsFilter extends MemberFilter {
- public FieldsFilter() {
- addFilter(MemberFilter.FILTER_FIELDS);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterDescriptor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterDescriptor.java
deleted file mode 100644
index 8e6ef9f3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterDescriptor.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.ui.IPluginContribution;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-import com.ibm.icu.text.Collator;
-
-/**
- * Represents a custom filter which is provided by the
- * "org.eclipse.wst.jsdt.ui.javaElementFilters" extension point.
- *
- * since 2.0
- */
-public class FilterDescriptor implements Comparable, IPluginContribution {
-
- private static String PATTERN_FILTER_ID_PREFIX= "_patternFilterId_"; //$NON-NLS-1$
-
-
- private static final String EXTENSION_POINT_NAME= "javaElementFilters"; //$NON-NLS-1$
-
- private static final String FILTER_TAG= "filter"; //$NON-NLS-1$
-
- private static final String PATTERN_ATTRIBUTE= "pattern"; //$NON-NLS-1$
- private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- /**
- * @deprecated as of 3.0 use {@link FilterDescriptor#TARGET_ID_ATTRIBUTE}
- */
- private static final String VIEW_ID_ATTRIBUTE= "viewId"; //$NON-NLS-1$
- private static final String TARGET_ID_ATTRIBUTE= "targetId"; //$NON-NLS-1$
- private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
- private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
- /**
- * @deprecated use "enabled" instead
- */
- private static final String SELECTED_ATTRIBUTE= "selected"; //$NON-NLS-1$
-
- private static FilterDescriptor[] fgFilterDescriptors;
-
-
- private IConfigurationElement fElement;
-
- /**
- * Returns all contributed Java element filters.
- */
- public static FilterDescriptor[] getFilterDescriptors() {
- if (fgFilterDescriptors == null) {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaScriptUI.ID_PLUGIN, EXTENSION_POINT_NAME);
- fgFilterDescriptors= createFilterDescriptors(elements);
- }
- return fgFilterDescriptors;
- }
- /**
- * Returns all Java element filters which
- * are contributed to the given view.
- */
- public static FilterDescriptor[] getFilterDescriptors(String targetId) {
- FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors();
- List result= new ArrayList(filterDescs.length);
- for (int i= 0; i < filterDescs.length; i++) {
- String tid= filterDescs[i].getTargetId();
- if (WorkbenchActivityHelper.filterItem(filterDescs[i]))
- continue;
- if (tid == null || tid.equals(targetId))
- result.add(filterDescs[i]);
- }
- return (FilterDescriptor[])result.toArray(new FilterDescriptor[result.size()]);
- }
-
- /**
- * Creates a new filter descriptor for the given configuration element.
- */
- private FilterDescriptor(IConfigurationElement element) {
- fElement= element;
- // it is either a pattern filter or a custom filter
- Assert.isTrue(isPatternFilter() ^ isCustomFilter(), "An extension for extension-point org.eclipse.wst.jsdt.ui.javaElementFilters does not specify a correct filter"); //$NON-NLS-1$
- Assert.isNotNull(getId(), "An extension for extension-point org.eclipse.wst.jsdt.ui.javaElementFilters does not provide a valid ID"); //$NON-NLS-1$
- Assert.isNotNull(getName(), "An extension for extension-point org.eclipse.wst.jsdt.ui.javaElementFilters does not provide a valid name"); //$NON-NLS-1$
- }
-
- /**
- * Creates a new <code>ViewerFilter</code>.
- * This method is only valid for viewer filters.
- */
- public ViewerFilter createViewerFilter() {
- if (!isCustomFilter())
- return null;
-
- final ViewerFilter[] result= new ViewerFilter[1];
- String message= Messages.format(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
- ISafeRunnable code= new SafeRunnable(message) {
- /*
- * @see org.eclipse.core.runtime.ISafeRunnable#run()
- */
- public void run() throws Exception {
- result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
- }
-
- };
- SafeRunner.run(code);
- return result[0];
- }
-
- //---- XML Attribute accessors ---------------------------------------------
-
- /**
- * Returns the filter's id.
- * <p>
- * This attribute is mandatory for custom filters.
- * The ID for pattern filters is
- * PATTERN_FILTER_ID_PREFIX plus the pattern itself.
- * </p>
- */
- public String getId() {
- if (isPatternFilter()) {
- String targetId= getTargetId();
- if (targetId == null)
- return PATTERN_FILTER_ID_PREFIX + getPattern();
- else
- return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
- } else
- return fElement.getAttribute(ID_ATTRIBUTE);
- }
-
- /**
- * Returns the filter's name.
- * <p>
- * If the name of a pattern filter is missing
- * then the pattern is used as its name.
- * </p>
- */
- public String getName() {
- String name= fElement.getAttribute(NAME_ATTRIBUTE);
- if (name == null && isPatternFilter())
- name= getPattern();
- return name;
- }
-
- /**
- * Returns the filter's pattern.
- *
- * @return the pattern string or <code>null</code> if it's not a pattern filter
- */
- public String getPattern() {
- return fElement.getAttribute(PATTERN_ATTRIBUTE);
- }
-
- /**
- * Returns the filter's viewId.
- *
- * @return the view ID or <code>null</code> if the filter is for all views
- *
- */
- public String getTargetId() {
- String tid= fElement.getAttribute(TARGET_ID_ATTRIBUTE);
-
- if (tid != null)
- return tid;
-
- // Backwards compatibility code
- return fElement.getAttribute(VIEW_ID_ATTRIBUTE);
-
- }
-
- /**
- * Returns the filter's description.
- *
- * @return the description or <code>null</code> if no description is provided
- */
- public String getDescription() {
- String description= fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
- if (description == null)
- description= ""; //$NON-NLS-1$
- return description;
- }
-
- /**
- * @return <code>true</code> if this filter is a custom filter.
- */
- public boolean isPatternFilter() {
- return getPattern() != null;
- }
-
- /**
- * @return <code>true</code> if this filter is a pattern filter.
- */
- public boolean isCustomFilter() {
- return fElement.getAttribute(CLASS_ATTRIBUTE) != null;
- }
-
- /**
- * Returns <code>true</code> if the filter
- * is initially enabled.
- *
- * This attribute is optional and defaults to <code>true</code>.
- */
- public boolean isEnabled() {
- String strVal= fElement.getAttribute(ENABLED_ATTRIBUTE);
- if (strVal == null)
- // backward compatibility
- strVal= fElement.getAttribute(SELECTED_ATTRIBUTE);
- return strVal == null || Boolean.valueOf(strVal).booleanValue();
- }
-
- /*
- * Implements a method from IComparable
- */
- public int compareTo(Object o) {
- if (o instanceof FilterDescriptor)
- return Collator.getInstance().compare(getName(), ((FilterDescriptor)o).getName());
- else
- return Integer.MIN_VALUE;
- }
-
- //---- initialization ---------------------------------------------------
-
- /**
- * Creates the filter descriptors.
- */
- private static FilterDescriptor[] createFilterDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
- Set descIds= new HashSet(5);
- for (int i= 0; i < elements.length; i++) {
- final IConfigurationElement element= elements[i];
- if (FILTER_TAG.equals(element.getName())) {
-
- final FilterDescriptor[] desc= new FilterDescriptor[1];
- SafeRunner.run(new SafeRunnable(FilterMessages.FilterDescriptor_filterDescriptionCreationError_message) {
- public void run() throws Exception {
- desc[0]= new FilterDescriptor(element);
- }
- });
-
- if (desc[0] != null && !descIds.contains(desc[0].getId())) {
- result.add(desc[0]);
- descIds.add(desc[0].getId());
- }
- }
- }
- return (FilterDescriptor[])result.toArray(new FilterDescriptor[result.size()]);
- }
-
- public String getLocalId() {
- return fElement.getAttribute(ID_ATTRIBUTE);
- }
-
- public String getPluginId() {
- return fElement.getContributor().getName();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.java
deleted file mode 100644
index f9f6eaef..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class FilterMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.filters.FilterMessages";//$NON-NLS-1$
-
- private FilterMessages() {
- // Do not instantiate
- }
-
- public static String CustomFiltersDialog_title;
- public static String CustomFiltersDialog_patternInfo;
- public static String CustomFiltersDialog_enableUserDefinedPattern;
- public static String CustomFiltersDialog_filterList_label;
- public static String CustomFiltersDialog_description_label;
- public static String CustomFiltersDialog_SelectAllButton_label;
- public static String CustomFiltersDialog_DeselectAllButton_label;
- public static String OpenCustomFiltersDialogAction_text;
- public static String FilterDescriptor_filterDescriptionCreationError_message;
- public static String FilterDescriptor_filterCreationError_message;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, FilterMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.properties
deleted file mode 100644
index 87b3dbe8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/FilterMessages.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-CustomFiltersDialog_title= JavaScript Element Filters
-CustomFiltersDialog_patternInfo= The patterns are separated by comma, where\n* = any string, ? = any character, ,, = ,
-CustomFiltersDialog_enableUserDefinedPattern= &Name filter patterns (matching names will be hidden):
-CustomFiltersDialog_filterList_label= S&elect the elements to exclude from the view:
-CustomFiltersDialog_description_label= Filter description:
-CustomFiltersDialog_SelectAllButton_label= &Select All
-CustomFiltersDialog_DeselectAllButton_label= &Deselect All
-
-OpenCustomFiltersDialogAction_text= &Filters...
-
-FilterDescriptor_filterDescriptionCreationError_message= One of the extensions for extension-point org.eclipse.wst.jsdt.ui.javaElementFilters is incorrect.
-FilterDescriptor_filterCreationError_message= The org.eclipse.wst.jsdt.ui.javaElementFilters plug-in extension "{0}" specifies a viewer filter class which does not exist.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ImportDeclarationFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ImportDeclarationFilter.java
deleted file mode 100644
index 3277b19d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/ImportDeclarationFilter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IImportContainer;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-
-
-/**
- * Filters import declarations
- */
-public class ImportDeclarationFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- return !((element instanceof IImportContainer) || (element instanceof IImportDeclaration));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InnerClassFilesFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InnerClassFilesFilter.java
deleted file mode 100644
index 086ee70d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InnerClassFilesFilter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IClassFile;
-
-public class InnerClassFilesFilter extends ViewerFilter {
-
- public InnerClassFilesFilter() {
- }
-
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IClassFile) {
- IClassFile classFile= (IClassFile) element;
- return classFile.getElementName().indexOf('$') == -1;
- }
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InterfaceFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InterfaceFilter.java
deleted file mode 100644
index 408e4419..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/InterfaceFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * Filters interfaces.
- */
-public class InterfaceFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IType) {
- try {
- IType type= (IType) element;
- return !type.isInterface() || type.isAnnotation();
- } catch (JavaScriptModelException ex) {
- return true;
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/JavaFileFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/JavaFileFilter.java
deleted file mode 100644
index 48dc2e86..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/JavaFileFilter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-
-/**
- * Filters out all compilation units and class files elements.
- */
-public class JavaFileFilter extends ViewerFilter {
-
- /**
- * Returns the result of this filter, when applied to the
- * given inputs.
- *
- * @return Returns true if element should be included in filtered set
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IJavaScriptUnit)
- return false;
- if (element instanceof IClassFile)
- return false;
-
- if (element instanceof IPackageFragment)
- try {
- return ((IPackageFragment)element).getNonJavaScriptResources().length > 0;
- } catch (JavaScriptModelException ex) {
- return true;
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LibraryFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LibraryFilter.java
deleted file mode 100644
index ed991ddb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LibraryFilter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.internal.ui.packageview.JsGlobalScopeContainer;
-
-
-/**
- * The LibraryFilter is a filter used to determine whether
- * a Java library is shown
- */
-public class LibraryFilter extends ViewerFilter {
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot)element;
- if (root.isArchive()) {
- // don't filter out JARs contained in the project itself
- IResource resource= root.getResource();
- if (resource != null) {
- IProject jarProject= resource.getProject();
- IProject container= root.getJavaScriptProject().getProject();
- return container.equals(jarProject);
- }
- return false;
- }
- } else if (element instanceof JsGlobalScopeContainer.RequiredProjectWrapper) {
- return false;
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LocalTypesFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LocalTypesFilter.java
deleted file mode 100644
index 02977d42..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/LocalTypesFilter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.MemberFilter;
-
-
-/**
- * Filters local types
- */
-public class LocalTypesFilter extends MemberFilter {
- public LocalTypesFilter() {
- addFilter(MemberFilter.FILTER_LOCALTYPES);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NamePatternFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NamePatternFilter.java
deleted file mode 100644
index ae098e96..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NamePatternFilter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.util.StringMatcher;
-
-/**
- * The NamePatternFilter selects the elements which
- * match the given string patterns.
- * <p>
- * The following characters have special meaning:
- * ? => any character
- * * => any string
- * </p>
- *
- *
- */
-public class NamePatternFilter extends ViewerFilter {
- private String[] fPatterns;
- private StringMatcher[] fMatchers;
-
- /**
- * Return the currently configured StringMatchers.
- * @return returns the matchers
- */
- private StringMatcher[] getMatchers() {
- return fMatchers;
- }
-
- /**
- * Gets the patterns for the receiver.
- * @return returns the patterns to be filtered for
- */
- public String[] getPatterns() {
- return fPatterns;
- }
-
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (fMatchers.length == 0) {
- return true;
- }
- String matchName= null;
- if (element instanceof IJavaScriptElement) {
- matchName= ((IJavaScriptElement) element).getElementName();
- } else if (element instanceof IResource) {
- matchName= ((IResource) element).getName();
- }else if (element instanceof IStorage) {
- matchName= ((IStorage) element).getName();
- } else if (element instanceof IWorkingSet) {
- matchName= ((IWorkingSet) element).getLabel();
- } else if (element instanceof IAdaptable) {
- IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)element).getAdapter(IWorkbenchAdapter.class);
- if (wbadapter != null) {
- matchName= wbadapter.getLabel(element);
- }
- }
- if (matchName != null && matchName.length() > 0) {
- StringMatcher[] testMatchers= getMatchers();
- for (int i = 0; i < testMatchers.length; i++) {
- if (testMatchers[i].match(matchName))
- return false;
- }
- return true;
- }
- return true;
- }
-
- /**
- * Sets the patterns to filter out for the receiver.
- * <p>
- * The following characters have special meaning:
- * ? => any character
- * * => any string
- * </p>
- * @param newPatterns the new patterns
- */
- public void setPatterns(String[] newPatterns) {
- fPatterns = newPatterns;
- fMatchers = new StringMatcher[newPatterns.length];
- for (int i = 0; i < newPatterns.length; i++) {
- //Reset the matchers to prevent constructor overhead
- fMatchers[i]= new StringMatcher(newPatterns[i], true, false);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NoPackageContainingFoldersFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NoPackageContainingFoldersFilter.java
deleted file mode 100644
index 7a10d2da..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NoPackageContainingFoldersFilter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-public class NoPackageContainingFoldersFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IFolder) {
- try {
- if (containsPackage((IFolder)element))
- return true;
- else
- return false;
- } catch (CoreException e) {
- return true;
- }
- }
-
- return true;
- }
-
- private boolean containsPackage(IFolder folder) throws CoreException {
- IJavaScriptElement element= JavaScriptCore.create(folder);
- if (element instanceof IPackageFragment)
- return true;
- IResource[] resources= folder.members();
- for (int i= 0; i < resources.length; i++) {
- if (resources[i] instanceof IFolder && containsPackage((IFolder)resources[i]))
- return true;
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaElementFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaElementFilter.java
deleted file mode 100644
index f7429694..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaElementFilter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-
-/**
- * Filters out all non-Java elements.
- */
-public class NonJavaElementFilter extends ViewerFilter {
-
- /**
- * Returns the result of this filter, when applied to the
- * given inputs.
- *
- * @return Returns true if element should be included in filtered set
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IJavaScriptElement)
- return true;
-
- if (element instanceof IResource) {
- IProject project= ((IResource)element).getProject();
- return project == null || !project.isOpen();
- }
-
- // Exclude all IStorage elements which are neither Java elements nor resources
- if (element instanceof IStorage)
- return false;
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaProjectsFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaProjectsFilter.java
deleted file mode 100644
index 3a3f7fe7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonJavaProjectsFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-
-/**
- * Filters non-java projects
- */
-public class NonJavaProjectsFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IJavaScriptProject)
- return true;
- else if (element instanceof IProject)
- return !((IProject)element).isOpen();
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicFilter.java
deleted file mode 100644
index 22a96ac8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicFilter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.MemberFilter;
-
-/**
- * Non-public member filter.
- *
- *
- */
-public class NonPublicFilter extends MemberFilter {
- public NonPublicFilter() {
- addFilter(MemberFilter.FILTER_NONPUBLIC);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicTypeFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicTypeFilter.java
deleted file mode 100644
index 51965d97..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonPublicTypeFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-
-/**
- * Filters non-public types
- */
-public class NonPublicTypeFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IType) {
- IType type= (IType)element;
- try {
- return Flags.isPublic(type.getFlags());
- } catch (JavaScriptModelException ex) {
- return true;
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonSharedProjectFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonSharedProjectFilter.java
deleted file mode 100644
index 1fa62d41..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/NonSharedProjectFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-
-/**
- * Filters non-shared projects and Java projects. Non-shared projects are
- * projects that are not controlled by a team provider.
- *
- *
- */
-public class NonSharedProjectFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IProject)
- return isSharedProject((IProject)element);
-
- if (element instanceof IJavaScriptProject)
- return isSharedProject(((IJavaScriptProject)element).getProject());
-
- return true;
- }
-
- private boolean isSharedProject(IProject project) {
- return !project.isAccessible() || RepositoryProvider.isShared(project);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/OutputFolderFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/OutputFolderFilter.java
deleted file mode 100644
index a66f3c43..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/OutputFolderFilter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-/**
- * Filters out all output folders.
- * <p>
- * Note: Folder which are direct children of a Java element
- * are already filtered by the Java Model.
- * </p>
- *
- *
- */
-public class OutputFolderFilter extends ViewerFilter {
-
- /**
- * Returns the result of this filter, when applied to the
- * given element.
- *
- * @param element the element to test
- * @return <code>true</code> if element should be included
- *
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IFolder) {
- IFolder folder= (IFolder)element;
- IProject proj= folder.getProject();
- try {
- if (!proj.hasNature(JavaScriptCore.NATURE_ID))
- return true;
-
- IJavaScriptProject jProject= JavaScriptCore.create(folder.getProject());
- if (jProject == null || !jProject.exists())
- return true;
-
- // Check default output location
- IPath defaultOutputLocation= jProject.getOutputLocation();
- IPath folderPath= folder.getFullPath();
- if (defaultOutputLocation != null && defaultOutputLocation.equals(folderPath))
- return false;
-
- // Check output location for each class path entry
- IIncludePathEntry[] cpEntries= jProject.getRawIncludepath();
- for (int i= 0, length= cpEntries.length; i < length; i++) {
- IPath outputLocation= cpEntries[i].getOutputLocation();
- if (outputLocation != null && outputLocation.equals(folderPath))
- return false;
- }
- } catch (CoreException ex) {
- return true;
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/PackageDeclarationFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/PackageDeclarationFilter.java
deleted file mode 100644
index 69aedf21..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/PackageDeclarationFilter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-
-
-/**
- * Filters package declarations
- */
-public class PackageDeclarationFilter extends ViewerFilter {
-
- /*
- * @see ViewerFilter
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- return !(element instanceof IPackageDeclaration);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/StaticsFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/StaticsFilter.java
deleted file mode 100644
index 43128d09..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/StaticsFilter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.MemberFilter;
-
-/**
- * Statics filter.
- *
- *
- */
-public class StaticsFilter extends MemberFilter {
- public StaticsFilter() {
- addFilter(MemberFilter.FILTER_STATIC);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/SyntheticMembersFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/SyntheticMembersFilter.java
deleted file mode 100644
index 46518afe..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/filters/SyntheticMembersFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.filters;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- * Filters synthetic members
- *
- *
- */
-public class SyntheticMembersFilter extends ViewerFilter {
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (!(element instanceof IMember))
- return true;
- IMember member= (IMember)element;
- if (!(member.isBinary()))
- return true;
- try {
- return !Flags.isSynthetic(member.getFlags());
- } catch (JavaScriptModelException e) {
- return true;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/AbstractCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/AbstractCleanUp.java
deleted file mode 100644
index a02b98f0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/AbstractCleanUp.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-
-public abstract class AbstractCleanUp implements ICleanUp {
-
- private Map fOptions;
- private final boolean fCanReinitialize;
-
- public AbstractCleanUp() {
- this(null);
- }
-
- public AbstractCleanUp(Map options) {
- fOptions= options;
- fCanReinitialize= options == null;
- }
-
- protected int getNumberOfProblems(IProblem[] problems, int problemId) {
- int result= 0;
- for (int i= 0; i < problems.length; i++) {
- if (problems[i].getID() == problemId)
- result++;
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public RefactoringStatus checkPreConditions(IJavaScriptProject project, IJavaScriptUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException {
- if (monitor != null)
- monitor.done();
- return new RefactoringStatus();
- }
-
- /**
- * {@inheritDoc}
- */
- public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException {
- if (monitor != null)
- monitor.done();
- //Default do nothing
- return new RefactoringStatus();
- }
-
- /**
- * {@inheritDoc}
- */
- public void initialize(Map settings) throws CoreException {
- if (fCanReinitialize)
- fOptions= settings;
- }
-
- protected boolean isEnabled(String key) {
- Assert.isNotNull(key);
-
- Object value= fOptions.get(key);
- return CleanUpConstants.TRUE == value || CleanUpConstants.TRUE.equals(value);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean needsFreshAST(JavaScriptUnit compilationUnit) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(IJavaScriptUnit unit) throws CoreException {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpRefactoringWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpRefactoringWizard.java
deleted file mode 100644
index bbb3152a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpRefactoringWizard.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpPreferenceUtil;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.preferences.BulletListBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.CleanUpPreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CleanUpProfileVersioner;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CleanUpTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CodeFormatingTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CodeStyleTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.UnnecessaryCodeTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileStore;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.xml.sax.InputSource;
-
-public class CleanUpRefactoringWizard extends RefactoringWizard {
-
- private static final String USE_CUSTOM_PROFILE_KEY= "org.eclipse.wst.jsdt.ui.cleanup.use_dialog_profile"; //$NON-NLS-1$
- private static final String CUSTOM_PROFILE_KEY= "org.eclipse.wst.jsdt.ui.cleanup.custom_profile"; //$NON-NLS-1$
-
- private static class ProjectProfileLableProvider extends LabelProvider implements ITableLabelProvider {
-
- private Hashtable fProfileIdsTable;
-
- /**
- * {@inheritDoc}
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 0) {
- return ((IJavaScriptProject)element).getProject().getName();
- } else if (columnIndex == 1) {
-
- if (fProfileIdsTable == null)
- fProfileIdsTable= loadProfiles();
-
- InstanceScope instanceScope= new InstanceScope();
- IEclipsePreferences instancePreferences= instanceScope.getNode(JavaScriptUI.ID_PLUGIN);
-
- final String workbenchProfileId;
- if (instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null) != null) {
- workbenchProfileId= instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null);
- } else {
- workbenchProfileId= CleanUpConstants.DEFAULT_PROFILE;
- }
-
- return getProjectProfileName((IJavaScriptProject)element, fProfileIdsTable, workbenchProfileId);
- }
- return null;
- }
-
- private Hashtable loadProfiles() {
- List list= CleanUpPreferenceUtil.loadProfiles(new InstanceScope());
-
- Hashtable profileIdsTable= new Hashtable();
- for (Iterator iterator= list.iterator(); iterator.hasNext();) {
- Profile profile= (Profile)iterator.next();
- profileIdsTable.put(profile.getID(), profile);
- }
-
- return profileIdsTable;
- }
-
- private String getProjectProfileName(final IJavaScriptProject project, Hashtable profileIdsTable, String workbenchProfileId) {
- ProjectScope projectScope= new ProjectScope(project.getProject());
- IEclipsePreferences node= projectScope.getNode(JavaScriptUI.ID_PLUGIN);
- String id= node.get(CleanUpConstants.CLEANUP_PROFILE, null);
- if (id == null) {
- Profile profile= (Profile)profileIdsTable.get(workbenchProfileId);
- if (profile != null) {
- return profile.getName();
- } else {
- return MultiFixMessages.CleanUpRefactoringWizard_unknownProfile_Name;
- }
- } else {
- Profile profile= (Profile)profileIdsTable.get(id);
- if (profile != null) {
- return profile.getName();
- } else {
- return Messages.format(MultiFixMessages.CleanUpRefactoringWizard_UnmanagedProfileWithName_Name, id.substring(ProfileManager.ID_PREFIX.length()));
- }
- }
- }
-
- public void reset() {
- fProfileIdsTable= null;
- }
- }
-
- private static class CleanUpConfigurationPage extends UserInputWizardPage implements IModificationListener {
-
- private static final class ProfileTableAdapter implements IListAdapter {
- private final ProjectProfileLableProvider fProvider;
- private final Shell fShell;
-
- private ProfileTableAdapter(ProjectProfileLableProvider provider, Shell shell) {
- fProvider= provider;
- fShell= shell;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- openPropertyDialog(field);
- }
-
- public void doubleClicked(ListDialogField field) {
- openPropertyDialog(field);
- }
-
- private void openPropertyDialog(ListDialogField field) {
- IJavaScriptProject project= (IJavaScriptProject)field.getSelectedElements().get(0);
- PreferencesUtil.createPropertyDialogOn(fShell, project, CleanUpPreferencePage.PROP_ID, null, null).open();
- List selectedElements= field.getSelectedElements();
- fProvider.reset();
- field.refresh();
- field.selectElements(new StructuredSelection(selectedElements));
- }
-
- public void selectionChanged(ListDialogField field) {
- if (field.getSelectedElements().size() != 1) {
- field.enableButton(0, false);
- } else {
- field.enableButton(0, true);
- }
- }
- }
-
- private static final String ENCODING= "UTF-8"; //$NON-NLS-1$
-
- private final CleanUpRefactoring fCleanUpRefactoring;
- private Map fCustomSettings;
- private SelectionButtonDialogField fUseCustomField;
-
- private ControlEnableState fEnableState;
-
- public CleanUpConfigurationPage(CleanUpRefactoring refactoring) {
- super(MultiFixMessages.CleanUpRefactoringWizard_CleanUpConfigurationPage_title);
- fCleanUpRefactoring= refactoring;
- IJavaScriptUnit[] cus= fCleanUpRefactoring.getCompilationUnits();
- IJavaScriptProject[] projects= fCleanUpRefactoring.getProjects();
- if (cus.length == 1) {
- setMessage(MultiFixMessages.CleanUpRefactoringWizard_CleaningUp11_Title);
- } else if (projects.length == 1) {
- setMessage(Messages.format(MultiFixMessages.CleanUpRefactoringWizard_CleaningUpN1_Title, new Integer(cus.length)));
- } else {
- setMessage(Messages.format(MultiFixMessages.CleanUpRefactoringWizard_CleaningUpNN_Title, new Object[] {new Integer(cus.length), new Integer(projects.length)}));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- boolean isCustom= getDialogSettings().getBoolean(USE_CUSTOM_PROFILE_KEY);
-
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setFont(parent.getFont());
-
- SelectionButtonDialogField useProfile= new SelectionButtonDialogField(SWT.RADIO);
- useProfile.setLabelText(MultiFixMessages.CleanUpRefactoringWizard_use_configured_radio);
- useProfile.setSelection(!isCustom);
- useProfile.doFillIntoGrid(composite, 2);
-
- ProjectProfileLableProvider tableLabelProvider= new ProjectProfileLableProvider();
- IListAdapter listAdapter= new ProfileTableAdapter(tableLabelProvider, getShell());
- String[] buttons= new String[] {
- MultiFixMessages.CleanUpRefactoringWizard_Configure_Button
- };
- final ListDialogField settingsField= new ListDialogField(listAdapter, buttons, tableLabelProvider);
-
- String[] headerNames= new String[] {
- MultiFixMessages.CleanUpRefactoringWizard_Project_TableHeader,
- MultiFixMessages.CleanUpRefactoringWizard_Profile_TableHeader
- };
- ColumnLayoutData[] columns = new ColumnLayoutData[] {
- new ColumnWeightData(1, 100, true),
- new ColumnWeightData(2, 20, true)
- };
- settingsField.setTableColumns(new ListDialogField.ColumnsDescription(columns , headerNames, true));
- settingsField.setViewerComparator(new ViewerComparator());
-
- settingsField.doFillIntoGrid(composite, 3);
-
- Table table= settingsField.getTableViewer().getTable();
- GridData data= (GridData)settingsField.getListControl(null).getLayoutData();
- data.horizontalIndent= 15;
- data.grabExcessVerticalSpace= false;
- data.heightHint= SWTUtil.getTableHeightHint(table, Math.min(5, fCleanUpRefactoring.getProjects().length + 1));
- data.grabExcessHorizontalSpace= true;
- data.verticalAlignment= GridData.BEGINNING;
-
- data= (GridData)settingsField.getButtonBox(null).getLayoutData();
- data.grabExcessVerticalSpace= false;
- data.verticalAlignment= GridData.BEGINNING;
-
- data= (GridData)settingsField.getLabelControl(null).getLayoutData();
- data.exclude= true;
-
- settingsField.setElements(Arrays.asList(fCleanUpRefactoring.getProjects()));
- settingsField.selectFirstElement();
-
- fUseCustomField= new SelectionButtonDialogField(SWT.RADIO);
- fUseCustomField.setLabelText(MultiFixMessages.CleanUpRefactoringWizard_use_custom_radio);
- fUseCustomField.setSelection(isCustom);
- fUseCustomField.doFillIntoGrid(composite, 2);
-
- String settings= getDialogSettings().get(CUSTOM_PROFILE_KEY);
- if (settings == null) {
- fCustomSettings= CleanUpConstants.getEclipseDefaultSettings();
- } else {
- try {
- fCustomSettings= decodeSettings(settings);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- fCustomSettings= CleanUpConstants.getEclipseDefaultSettings();
- }
- }
-
- final BulletListBlock bulletListBlock= new BulletListBlock();
- Control bulletList= bulletListBlock.createControl(composite);
- GridData layoutData= (GridData)bulletList.getLayoutData();
- (layoutData).horizontalIndent= 15;
- layoutData.grabExcessVerticalSpace= true;
-
- final Button configure= new Button(composite, SWT.NONE);
- configure.setText(MultiFixMessages.CleanUpRefactoringWizard_ConfigureCustomProfile_button);
-
- data= new GridData(SWT.TOP, SWT.LEAD, false, false);
- data.widthHint= SWTUtil.getButtonWidthHint(configure);
- configure.setLayoutData(data);
-
- showCustomSettings(bulletListBlock);
- configure.addSelectionListener(new SelectionAdapter() {
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- CleanUpSaveParticipantConfigurationModifyDialog dialog= new CleanUpSaveParticipantConfigurationModifyDialog(getShell(), fCustomSettings, MultiFixMessages.CleanUpRefactoringWizard_CustomCleanUpsDialog_title) {
- protected CleanUpTabPage[] createTabPages(Map workingValues) {
- CleanUpTabPage[] result= new CleanUpTabPage[3];
- result[0]= new CodeStyleTabPage(this, workingValues, false);
-// result[1]= new MemberAccessesTabPage(this, workingValues, false);
- result[1]= new UnnecessaryCodeTabPage(this, workingValues, false);
-// result[3]= new MissingCodeTabPage(this, workingValues, false);
- result[2]= new CodeFormatingTabPage(this, workingValues, false);
-
- addTabPage(MultiFixMessages.CleanUpRefactoringWizard_code_style_tab, result[0]);
-// addTabPage(MultiFixMessages.CleanUpRefactoringWizard_member_accesses_tab, result[1]);
- addTabPage(MultiFixMessages.CleanUpRefactoringWizard_unnecessary_code_tab, result[1]);
-// addTabPage(MultiFixMessages.CleanUpRefactoringWizard_missing_code_tab, result[3]);
- addTabPage(MultiFixMessages.CleanUpRefactoringWizard_code_organizing_tab, result[2]);
-
- return result;
- }
- };
- dialog.open();
- showCustomSettings(bulletListBlock);
- }
- });
-
- updateEnableState(isCustom, settingsField, configure, bulletListBlock);
-
- fUseCustomField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- updateEnableState(fUseCustomField.isSelected(), settingsField, configure, bulletListBlock);
- }
- });
-
- Link preferencePageLink= new Link(composite, SWT.WRAP);
- preferencePageLink.setText(MultiFixMessages.CleanUpRefactoringWizard_HideWizard_Link);
- preferencePageLink.setFont(parent.getFont());
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, false);
- gridData.widthHint= convertWidthInCharsToPixels(300);
- gridData.horizontalSpan= 2;
- preferencePageLink.setLayoutData(gridData);
- preferencePageLink.addSelectionListener(new SelectionAdapter() {
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(composite.getShell(), CleanUpPreferencePage.PREF_ID, null, null).open();
- }
- });
-
- setControl(composite);
-
- Dialog.applyDialogFont(composite);
- }
-
- private void updateEnableState(boolean isCustom, final ListDialogField settingsField, Button configureCustom, BulletListBlock bulletListBlock) {
- settingsField.getListControl(null).setEnabled(!isCustom);
- if (isCustom) {
- fEnableState= ControlEnableState.disable(settingsField.getButtonBox(null));
- } else if (fEnableState != null) {
- fEnableState.restore();
- fEnableState= null;
- }
- bulletListBlock.setEnabled(isCustom);
- configureCustom.setEnabled(isCustom);
- }
-
- private void showCustomSettings(BulletListBlock bulletListBlock) {
- StringBuffer buf= new StringBuffer();
-
- final ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(fCustomSettings);
- for (int i= 0; i < cleanUps.length; i++) {
- String[] descriptions= cleanUps[i].getDescriptions();
- if (descriptions != null) {
- for (int j= 0; j < descriptions.length; j++) {
- if (buf.length() > 0) {
- buf.append('\n');
- }
- buf.append(descriptions[j]);
- }
- }
- }
- bulletListBlock.setText(buf.toString());
- }
-
- protected boolean performFinish() {
- initializeRefactoring();
- storeSettings();
- return super.performFinish();
- }
-
- public IWizardPage getNextPage() {
- initializeRefactoring();
- storeSettings();
- return super.getNextPage();
- }
-
- private void storeSettings() {
- getDialogSettings().put(USE_CUSTOM_PROFILE_KEY, fUseCustomField.isSelected());
- try {
- getDialogSettings().put(CUSTOM_PROFILE_KEY, encodeSettings(fCustomSettings));
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- private void initializeRefactoring() {
- ICleanUp[] cleanups;
- if (fUseCustomField.isSelected()) {
- cleanups= CleanUpRefactoring.createCleanUps(fCustomSettings);
- } else {
- cleanups= CleanUpRefactoring.createCleanUps();
- }
-
- CleanUpRefactoring refactoring= (CleanUpRefactoring)getRefactoring();
- refactoring.clearCleanUps();
- for (int i= 0; i < cleanups.length; i++) {
- refactoring.addCleanUp(cleanups[i]);
- }
- }
-
- public String encodeSettings(Map settings) throws CoreException {
- ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
- try {
- CleanUpProfileVersioner versioner= new CleanUpProfileVersioner();
- CustomProfile profile= new ProfileManager.CustomProfile("custom", settings, versioner.getCurrentVersion(), versioner.getProfileKind()); //$NON-NLS-1$
- ArrayList profiles= new ArrayList();
- profiles.add(profile);
- ProfileStore.writeProfilesToStream(profiles, stream, ENCODING, versioner);
- try {
- return stream.toString(ENCODING);
- } catch (UnsupportedEncodingException e) {
- return stream.toString();
- }
- } finally {
- try { stream.close(); } catch (IOException e) { /* ignore */ }
- }
- }
-
- public Map decodeSettings(String settings) throws CoreException {
- byte[] bytes;
- try {
- bytes= settings.getBytes(ENCODING);
- } catch (UnsupportedEncodingException e) {
- bytes= settings.getBytes();
- }
- InputStream is= new ByteArrayInputStream(bytes);
- try {
- List res= ProfileStore.readProfilesFromStream(new InputSource(is));
- if (res == null || res.size() == 0)
- return CleanUpConstants.getEclipseDefaultSettings();
-
- CustomProfile profile= (CustomProfile)res.get(0);
- new CleanUpProfileVersioner().update(profile);
- return profile.getSettings();
- } finally {
- try { is.close(); } catch (IOException e) { /* ignore */ }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void updateStatus(IStatus status) {}
-
- /**
- * {@inheritDoc}
- */
- public void valuesModified() {}
- }
-
- public CleanUpRefactoringWizard(CleanUpRefactoring refactoring, int flags) {
- super(refactoring, flags);
- setDefaultPageTitle(MultiFixMessages.CleanUpRefactoringWizard_PageTitle);
- setWindowTitle(MultiFixMessages.CleanUpRefactoringWizard_WindowTitle);
- setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_CLEAN_UP);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.ui.refactoring.RefactoringWizard#addUserInputPages()
- */
- protected void addUserInputPages() {
- addPage(new CleanUpConfigurationPage((CleanUpRefactoring)getRefactoring()));
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantConfigurationModifyDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantConfigurationModifyDialog.java
deleted file mode 100644
index 50a0c43a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantConfigurationModifyDialog.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CleanUpTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CodeFormatingTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CodeStyleTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.UnnecessaryCodeTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class CleanUpSaveParticipantConfigurationModifyDialog extends StatusDialog implements IModificationListener {
-
- private static final String DS_KEY_PREFERRED_WIDTH= "clean_up_save_particpant_modify_dialog.preferred_width"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_HEIGHT= "clean_up_save_particpant_modify_dialog.preferred_height"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_X= "clean_up_save_particpant_modify_dialog.preferred_x"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_Y= "clean_up_save_particpant_modify_dialog.preferred_y"; //$NON-NLS-1$
- private static final String DS_KEY_LAST_FOCUS= "clean_up_save_particpant_modify_dialog.last_focus"; //$NON-NLS-1$
-
- private static final int APPLY_BUTTON_ID= IDialogConstants.CLIENT_ID;
-
- private final Map fWorkingValues;
- private Map fOrginalValues;
- private final List fTabPages;
- private final IDialogSettings fDialogSettings;
- private TabFolder fTabFolder;
- private Button fApplyButton;
- private CleanUpTabPage[] fPages;
- private Label fCountLabel;
-
- public CleanUpSaveParticipantConfigurationModifyDialog(Shell parentShell, Map settings, String title) {
- super(parentShell);
-
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
-
- setTitle(title);
- fWorkingValues= settings;
- fOrginalValues= new HashMap(settings);
- setStatusLineAboveButtons(false);
- fTabPages= new ArrayList();
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- }
-
- public void create() {
- super.create();
- int lastFocusNr= 0;
- try {
- lastFocusNr= fDialogSettings.getInt(DS_KEY_LAST_FOCUS);
- if (lastFocusNr < 0)
- lastFocusNr= 0;
- if (lastFocusNr > fTabPages.size() - 1)
- lastFocusNr= fTabPages.size() - 1;
- } catch (NumberFormatException x) {
- lastFocusNr= 0;
- }
-
- fTabFolder.setSelection(lastFocusNr);
- ((ModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
- }
-
- protected Control createDialogArea(Composite parent) {
- final Composite composite= (Composite)super.createDialogArea(parent);
-
- fTabFolder= new TabFolder(composite, SWT.NONE);
- fTabFolder.setFont(composite.getFont());
- fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- fPages= createTabPages(fWorkingValues);
-
- fCountLabel= new Label(composite, SWT.NONE);
- fCountLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- updateCountLabel();
-
- applyDialogFont(composite);
-
- fTabFolder.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- final TabItem tabItem= (TabItem)e.item;
- final ModifyDialogTabPage page= (ModifyDialogTabPage)tabItem.getData();
- fDialogSettings.put(DS_KEY_LAST_FOCUS, fTabPages.indexOf(page));
- page.makeVisible();
- }
- });
-
- updateStatus(StatusInfo.OK_STATUS);
-
- return composite;
- }
-
- protected CleanUpTabPage[] createTabPages(Map workingValues) {
- CleanUpTabPage[] result= new CleanUpTabPage[3];
- result[0]= new CodeStyleTabPage(this, workingValues, true);
-// result[1]= new MemberAccessesTabPage(this, workingValues, true);
- result[1]= new UnnecessaryCodeTabPage(this, workingValues, true);
-// result[3]= new MissingCodeTabPage(this, workingValues, true);
- result[2]= new CodeFormatingTabPage(this, workingValues, true);
-
- addTabPage(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_CodeStyle_TabPage, result[0]);
-// addTabPage(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_MemberAccesses_TabPage, result[1]);
- addTabPage(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_UnnecessaryCode_TabPage, result[1]);
-// addTabPage(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_MissingCode_TabPage, result[3]);
- addTabPage(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_CodeOrganizing_TabPage, result[2]);
-
- return result;
- }
-
- public void updateStatus(IStatus status) {
- int count= 0;
- for (int i= 0; i < fPages.length; i++) {
- count+= fPages[i].getSelectedCleanUpCount();
- }
- if (count == 0) {
- super.updateStatus(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_SelectAnAction_Error));
- } else {
- if (status == null) {
- super.updateStatus(StatusInfo.OK_STATUS);
- } else {
- super.updateStatus(status);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
- protected Point getInitialSize() {
- Point initialSize= super.getInitialSize();
- try {
- int lastWidth= fDialogSettings.getInt(DS_KEY_PREFERRED_WIDTH);
- if (initialSize.x > lastWidth)
- lastWidth= initialSize.x;
- int lastHeight= fDialogSettings.getInt(DS_KEY_PREFERRED_HEIGHT);
- if (initialSize.y > lastHeight)
- lastHeight= initialSize.x;
- return new Point(lastWidth, lastHeight);
- } catch (NumberFormatException ex) {
- }
- return initialSize;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
- */
- protected Point getInitialLocation(Point initialSize) {
- try {
- return new Point(fDialogSettings.getInt(DS_KEY_PREFERRED_X), fDialogSettings.getInt(DS_KEY_PREFERRED_Y));
- } catch (NumberFormatException ex) {
- return super.getInitialLocation(initialSize);
- }
- }
-
- public boolean close() {
- final Rectangle shell= getShell().getBounds();
-
- fDialogSettings.put(DS_KEY_PREFERRED_WIDTH, shell.width);
- fDialogSettings.put(DS_KEY_PREFERRED_HEIGHT, shell.height);
- fDialogSettings.put(DS_KEY_PREFERRED_X, shell.x);
- fDialogSettings.put(DS_KEY_PREFERRED_Y, shell.y);
-
- return super.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- applyPressed();
- super.okPressed();
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == APPLY_BUTTON_ID) {
- applyPressed();
- } else {
- super.buttonPressed(buttonId);
- }
- }
-
- private void applyPressed() {
- fOrginalValues= new HashMap(fWorkingValues);
- updateStatus(StatusInfo.OK_STATUS);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- fApplyButton= createButton(parent, APPLY_BUTTON_ID, SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_Apply_Button, false);
- fApplyButton.setEnabled(false);
-
- GridLayout layout= (GridLayout)parent.getLayout();
- layout.numColumns++;
- layout.makeColumnsEqualWidth= false;
- Label label= new Label(parent, SWT.NONE);
- GridData data= new GridData();
- data.widthHint= layout.horizontalSpacing;
- label.setLayoutData(data);
- super.createButtonsForButtonBar(parent);
- }
-
- protected final void addTabPage(String title, ModifyDialogTabPage tabPage) {
- final TabItem tabItem= new TabItem(fTabFolder, SWT.NONE);
- applyDialogFont(tabItem.getControl());
- tabItem.setText(title);
- tabItem.setData(tabPage);
- tabItem.setControl(tabPage.createContents(fTabFolder));
- fTabPages.add(tabPage);
- }
-
- protected void updateButtonsEnableState(IStatus status) {
- super.updateButtonsEnableState(status);
- if (fApplyButton != null && !fApplyButton.isDisposed()) {
- fApplyButton.setEnabled(hasChanges() && !status.matches(IStatus.ERROR));
- }
- }
-
- private boolean hasChanges() {
- for (Iterator iterator= fWorkingValues.keySet().iterator(); iterator.hasNext();) {
- String key= (String)iterator.next();
- if (!fWorkingValues.get(key).equals(fOrginalValues.get(key)))
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void valuesModified() {
- updateCountLabel();
- updateStatus(StatusInfo.OK_STATUS);
- }
-
- private void updateCountLabel() {
- int size= 0, count= 0;
- for (int i= 0; i < fPages.length; i++) {
- size+= fPages[i].getCleanUpCount();
- count+= fPages[i].getSelectedCleanUpCount();
- }
-
- fCountLabel.setText(Messages.format(SaveParticipantMessages.CleanUpSaveParticipantConfigurationModifyDialog_XofYSelected_Label, new Object[] {new Integer(count), new Integer(size)}));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantPreferenceConfiguration.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantPreferenceConfiguration.java
deleted file mode 100644
index 726a10a6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CleanUpSaveParticipantPreferenceConfiguration.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpPostSaveListener;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpPreferenceUtil;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.AbstractSaveParticipantPreferenceConfiguration;
-import org.eclipse.wst.jsdt.internal.ui.preferences.BulletListBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.CodeFormatterPreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Preference configuration UI for the clean up save participant.
- *
- *
- */
-public class CleanUpSaveParticipantPreferenceConfiguration extends AbstractSaveParticipantPreferenceConfiguration {
-
- private static final int INDENT= 10;
-
- private IScopeContext fContext;
- private Map fSettings;
- private BulletListBlock fSelectedActionsText;
- private Button fFormatCodeButton;
-// private Button fOrganizeImportsButton;
- private Shell fShell;
- private Link fFormatConfigLink;
-// private Link fOrganizeImportsConfigLink;
- private IPreferencePageContainer fContainer;
- private Button fAdditionalActionButton;
- private Button fConfigureButton;
-
- /**
- * {@inheritDoc}
- */
- public Control createConfigControl(final Composite parent, IPreferencePageContainer container) {
- fContainer= container;
- fShell= parent.getShell();
-
- final Composite composite= new Composite(parent, SWT.NONE);
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData.horizontalIndent= INDENT;
- composite.setLayoutData(gridData);
- GridLayout gridLayout= new GridLayout(1, false);
- gridLayout.marginHeight= 0;
- gridLayout.marginWidth= 0;
- composite.setLayout(gridLayout);
-
- fFormatCodeButton= new Button(composite, SWT.CHECK);
- fFormatCodeButton.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_FormatSource_Checkbox);
- fFormatCodeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- fFormatCodeButton.addSelectionListener(new SelectionAdapter() {
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- changeSettingsValue(CleanUpConstants.FORMAT_SOURCE_CODE, fFormatCodeButton.getSelection());
- }
- });
-
- PixelConverter pixelConverter= new PixelConverter(parent);
- int heightOneHalf= (int)Math.round(pixelConverter.convertHeightInCharsToPixels(1) * 1.5);
-
- fFormatConfigLink= new Link(composite, SWT.NONE);
- fFormatConfigLink.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_ConfigureFormatter_Link);
- GridData gridData2= new GridData(SWT.LEFT, SWT.TOP, false, true);
- gridData2.horizontalIndent= 20;
- gridData2.minimumHeight= heightOneHalf;
- fFormatConfigLink.setLayoutData(gridData2);
-
-// fOrganizeImportsButton= new Button(composite, SWT.CHECK);
-// fOrganizeImportsButton.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_OrganizeImports_Checkbox);
-// fOrganizeImportsButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-// fOrganizeImportsButton.addSelectionListener(new SelectionAdapter() {
-// /**
-// * {@inheritDoc}
-// */
-// public void widgetSelected(SelectionEvent e) {
-// changeSettingsValue(CleanUpConstants.ORGANIZE_IMPORTS, fOrganizeImportsButton.getSelection());
-// }
-// });
-
-// fOrganizeImportsConfigLink= new Link(composite, SWT.NONE);
-// fOrganizeImportsConfigLink.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_ConfigureImports_Link);
-// GridData gridData3= new GridData(SWT.LEFT, SWT.TOP, false, true);
-// gridData3.horizontalIndent= 20;
-// gridData3.minimumHeight= heightOneHalf;
-// fOrganizeImportsConfigLink.setLayoutData(gridData3);
-
- fAdditionalActionButton= new Button(composite, SWT.CHECK);
- fAdditionalActionButton.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_AdditionalActions_Checkbox);
-
- createAdvancedComposite(composite);
- fAdditionalActionButton.addSelectionListener(new SelectionAdapter() {
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- changeSettingsValue(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS, fAdditionalActionButton.getSelection());
- }
- });
-
- return composite;
- }
-
- private Composite createAdvancedComposite(final Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData.horizontalIndent= INDENT;
- composite.setLayoutData(gridData);
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- fSelectedActionsText= new BulletListBlock();
- final GridData data= (GridData)fSelectedActionsText.createControl(composite).getLayoutData();
- data.heightHint= new PixelConverter(composite).convertHeightInCharsToPixels(8);
-
- fConfigureButton= new Button(composite, SWT.NONE);
- fConfigureButton.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_Configure_Button);
- fConfigureButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
- fConfigureButton.addSelectionListener(new SelectionAdapter() {
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- new CleanUpSaveParticipantConfigurationModifyDialog(parent.getShell(), fSettings, SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_CleanUpSaveParticipantConfiguration_Title).open();
- settingsChanged();
- }
-
- });
-
- return composite;
- }
-
- /**
- * {@inheritDoc}
- */
- public void initialize(final IScopeContext context, IAdaptable element) {
- fContext= context;
- fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(context);
-
- settingsChanged();
-
- IJavaScriptProject javaProject= null;
- if (element != null) {
- IProject project= (IProject)element.getAdapter(IProject.class);
- if (project != null) {
- IJavaScriptProject jProject= JavaScriptCore.create(project);
- if (jProject != null && jProject.exists()) {
- javaProject= jProject;
- }
- }
- }
-
- configurePreferenceLink(fFormatConfigLink, javaProject, CodeFormatterPreferencePage.PREF_ID, CodeFormatterPreferencePage.PROP_ID);
-// configurePreferenceLink(fOrganizeImportsConfigLink, javaProject, ImportOrganizePreferencePage.PREF_ID, ImportOrganizePreferencePage.PROP_ID);
-
- super.initialize(context, element);
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- */
- public void performDefaults() {
- fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(new InstanceScope());
- settingsChanged();
- }
-
- /**
- * {@inheritDoc}
- */
- public void performOk() {
- super.performOk();
-
- if (!ProjectScope.SCOPE.equals(fContext.getName()) || hasSettingsInScope(fContext))
- CleanUpPreferenceUtil.saveSaveParticipantOptions(fContext, fSettings);
- }
-
- /**
- * {@inheritDoc}
- */
- public void enableProjectSettings() {
- super.enableProjectSettings();
-
- CleanUpPreferenceUtil.saveSaveParticipantOptions(fContext, fSettings);
-
- updateAdvancedEnableState();
- }
-
- /**
- * {@inheritDoc}
- */
- public void disableProjectSettings() {
- super.disableProjectSettings();
-
- IEclipsePreferences node= fContext.getNode(JavaScriptUI.ID_PLUGIN);
-
- Map settings= CleanUpConstants.getSaveParticipantSettings();
- for (Iterator iterator= settings.keySet().iterator(); iterator.hasNext();) {
- String key= (String)iterator.next();
- node.remove(CleanUpPreferenceUtil.SAVE_PARTICIPANT_KEY_PREFIX + key);
- }
-
- updateAdvancedEnableState();
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getPostSaveListenerId() {
- return CleanUpPostSaveListener.POSTSAVELISTENER_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getPostSaveListenerName() {
- return SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_CleanUpActionsTopNodeName_Checkbox;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void enableConfigControl(boolean isEnabled) {
- super.enableConfigControl(isEnabled);
-
- updateAdvancedEnableState();
- }
-
- private void settingsChanged() {
- fFormatCodeButton.setSelection(CleanUpConstants.TRUE.equals(fSettings.get(CleanUpConstants.FORMAT_SOURCE_CODE)));
-// fOrganizeImportsButton.setSelection(CleanUpConstants.TRUE.equals(fSettings.get(CleanUpConstants.ORGANIZE_IMPORTS)));
- fAdditionalActionButton.setSelection(CleanUpConstants.TRUE.equals(fSettings.get(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS)));
-
- updateAdvancedEnableState();
-
- Map settings= new HashMap(fSettings);
- settings.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.FALSE);
- settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.FALSE);
-
- final ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(settings);
-
- if (cleanUps.length == 0) {
- fSelectedActionsText.setText(SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_NoActionEnabled_Info);
- } else {
- StringBuffer buf= new StringBuffer();
-
- boolean first= true;
- for (int i= 0; i < cleanUps.length; i++) {
- String[] descriptions= cleanUps[i].getDescriptions();
- if (descriptions != null) {
- for (int j= 0; j < descriptions.length; j++) {
- if (first) {
- first= false;
- } else {
- buf.append('\n');
- }
- buf.append(descriptions[j]);
- }
- }
- }
- fSelectedActionsText.setText(buf.toString());
- }
- }
-
- private void updateAdvancedEnableState() {
- boolean additionalOptionEnabled= isEnabled(fContext) && CleanUpConstants.TRUE.equals(fSettings.get(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS));
- boolean additionalEnabled= additionalOptionEnabled && (!ProjectScope.SCOPE.equals(fContext.getName()) || hasSettingsInScope(fContext));
- fSelectedActionsText.setEnabled(additionalEnabled);
- fConfigureButton.setEnabled(additionalEnabled);
- }
-
- private void configurePreferenceLink(Link link, final IJavaScriptProject javaProject, final String preferenceId, final String propertyId) {
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (fContainer instanceof IWorkbenchPreferenceContainer) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)fContainer;
- if (javaProject != null) {
- container.openPage(propertyId, null);
- } else {
- container.openPage(preferenceId, null);
- }
- } else {
- PreferencesUtil.createPreferenceDialogOn(fShell, preferenceId, null, null);
- }
- }
- });
- }
-
- private void changeSettingsValue(String key, boolean enabled) {
- String value;
- if (enabled) {
- value= CleanUpConstants.TRUE;
- } else {
- value= CleanUpConstants.FALSE;
- }
- fSettings.put(key, value);
- settingsChanged();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatCleanUp.java
deleted file mode 100644
index f7cd581c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatCleanUp.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class CodeFormatCleanUp extends AbstractCleanUp {
-
- public CodeFormatCleanUp() {
- super();
- }
-
- public CodeFormatCleanUp(Map options) {
- super(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return false;
- }
-
- public IFix createFix(IJavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean removeWhitespaces= isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES);
- return CodeFormatFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return null;
- }
-
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- ArrayList result= new ArrayList();
- if (isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE))
- result.add(MultiFixMessages.CodeFormatCleanUp_description);
-
- if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) {
- if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) {
- result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingAll_description);
- } else if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)) {
- result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingNoEmpty_description);
- }
- }
-
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
- buf.append(" function start() {}\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES) && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) {
- buf.append("\n"); //$NON-NLS-1$
- } else {
- buf.append(" \n"); //$NON-NLS-1$
- }
- if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) {
- buf.append(" function\n"); //$NON-NLS-1$
- } else {
- buf.append(" function \n"); //$NON-NLS-1$
- }
- buf.append(" stop() {\n"); //$NON-NLS-1$
- buf.append(" }\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatFix.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatFix.java
deleted file mode 100644
index c68a955e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeFormatFix.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.ltk.core.refactoring.CategorizedTextEditGroup;
-import org.eclipse.ltk.core.refactoring.GroupCategory;
-import org.eclipse.ltk.core.refactoring.GroupCategorySet;
-import org.eclipse.ltk.core.refactoring.TextChange;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.CompilationUnitChange;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-
-public class CodeFormatFix implements IFix {
-
- public static IFix createCleanUp(IJavaScriptUnit cu, boolean format, boolean removeTrailingWhitespacesAll, boolean removeTrailingWhitespacesIgnorEmpty) throws CoreException {
- if (!format && !removeTrailingWhitespacesAll && !removeTrailingWhitespacesIgnorEmpty)
- return null;
-
- if (format) {
- Map fomatterSettings= new HashMap(cu.getJavaScriptProject().getOptions(true));
-
- String content= cu.getBuffer().getContents();
- Document document= new Document(content);
-
- TextEdit edit= CodeFormatterUtil.reformat(CodeFormatter.K_JAVASCRIPT_UNIT, content, 0, TextUtilities.getDefaultLineDelimiter(document), fomatterSettings);
- if (edit == null || !edit.hasChildren())
- return null;
-
- String label= MultiFixMessages.CodeFormatFix_description;
- TextChange change= new CompilationUnitChange(label, cu);
- change.setEdit(edit);
-
- CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)));
- group.addTextEdit(edit);
- change.addTextEditGroup(group);
-
- return new CodeFormatFix(change, cu);
- } else if (removeTrailingWhitespacesAll || removeTrailingWhitespacesIgnorEmpty) {
- try {
- MultiTextEdit multiEdit= new MultiTextEdit();
- Document document= new Document(cu.getBuffer().getContents());
-
- int lineCount= document.getNumberOfLines();
- for (int i= 0; i < lineCount; i++) {
-
- IRegion region= document.getLineInformation(i);
- if (region.getLength() == 0)
- continue;
-
- int lineStart= region.getOffset();
- int lineExclusiveEnd= lineStart + region.getLength();
- int j= getIndexOfRightMostNoneWhitspaceCharacter(lineStart, lineExclusiveEnd - 1, document);
-
- if (removeTrailingWhitespacesAll) {
- j++;
- if (j < lineExclusiveEnd)
- multiEdit.addChild(new DeleteEdit(j, lineExclusiveEnd - j));
- } else if (removeTrailingWhitespacesIgnorEmpty) {
- if (j >= lineStart) {
- if (document.getChar(j) == '*' && getIndexOfRightMostNoneWhitspaceCharacter(lineStart, j - 1, document) < lineStart) {
- j++;
- }
- j++;
- if (j < lineExclusiveEnd)
- multiEdit.addChild(new DeleteEdit(j, lineExclusiveEnd - j));
- }
- }
- }
-
- if (multiEdit.getChildrenSize() == 0)
- return null;
-
- String label= MultiFixMessages.CodeFormatFix_RemoveTrailingWhitespace_changeDescription;
- CompilationUnitChange change= new CompilationUnitChange(label, cu);
- change.setEdit(multiEdit);
-
- CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)));
- group.addTextEdit(multiEdit);
- change.addTextEditGroup(group);
-
- return new CodeFormatFix(change, cu);
- } catch (BadLocationException x) {
- throw new CoreException(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, "", x)); //$NON-NLS-1$
- }
- }
-
- return null;
- }
-
- /**
- * Returns the index in document of a none whitespace character
- * between start (inclusive) and end (inclusive) such that if
- * more then one such character the index returned is the largest
- * possible (closest to end). Returns start - 1 if no such character.
- *
- * @param start
- * @param end
- * @param document
- * @return the position or start - 1
- * @throws BadLocationException
- */
- private static int getIndexOfRightMostNoneWhitspaceCharacter(int start, int end, Document document) throws BadLocationException {
- int position= end;
- while (position >= start && Character.isWhitespace(document.getChar(position)))
- position--;
-
- return position;
- }
-
- private final IJavaScriptUnit fCompilationUnit;
- private final TextChange fChange;
-
- public CodeFormatFix(TextChange change, IJavaScriptUnit compilationUnit) {
- fChange= change;
- fCompilationUnit= compilationUnit;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.fix.IFix#createChange()
- */
- public TextChange createChange() throws CoreException {
- return fChange;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.fix.IFix#getCompilationUnit()
- */
- public IJavaScriptUnit getCompilationUnit() {
- return fCompilationUnit;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.fix.IFix#getDescription()
- */
- public String getDescription() {
- return MultiFixMessages.CodeFormatFix_description;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.fix.IFix#getStatus()
- */
- public IStatus getStatus() {
- return StatusInfo.OK_STATUS;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeStyleCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeStyleCleanUp.java
deleted file mode 100644
index bc6791a9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CodeStyleCleanUp.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CodeStyleFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-/**
- * Creates fixes which can resolve code style issues
- * @see org.eclipse.wst.jsdt.internal.corext.fix.CodeStyleFix
- */
-public class CodeStyleCleanUp extends AbstractCleanUp {
-
- public CodeStyleCleanUp() {
- this(null);
- }
-
- public CodeStyleCleanUp(Map options) {
- super(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean nonStaticFields= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS);
- boolean nonStaticMethods= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS);
- boolean qualifyStatic= isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS);
-
- return nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS) ||
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS) ||
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD) ||
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS) ||
- nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS) ||
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD) ||
- nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY) ||
- nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean nonStaticFields= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS);
- boolean nonStaticMethods= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS);
- boolean qualifyStatic= isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS);
-
- return CodeStyleFix.createCleanUp(compilationUnit,
- nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS),
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS),
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD),
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS),
- nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS),
- qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD),
- nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY),
- nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY)
- );
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return CodeStyleFix.createCleanUp(compilationUnit, problems,
- isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS),
- isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS),
- isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS));
- }
-
- public Map getRequiredOptions() {
- Map options= new Hashtable();
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS))
- options.put(JavaScriptCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaScriptCore.WARNING);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS))
- options.put(JavaScriptCore.COMPILER_PB_INDIRECT_STATIC_ACCESS, JavaScriptCore.WARNING);
- return options;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS))
- result.add(MultiFixMessages.CodeStyleMultiFix_AddThisQualifier_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS))
- result.add(MultiFixMessages.CodeStyleCleanUp_QualifyNonStaticMethod_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY))
- result.add(MultiFixMessages.CodeStyleCleanUp_removeFieldThis_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY))
- result.add(MultiFixMessages.CodeStyleCleanUp_removeMethodThis_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD))
- result.add(MultiFixMessages.CodeStyleMultiFix_QualifyAccessToStaticField);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD))
- result.add(MultiFixMessages.CodeStyleCleanUp_QualifyStaticMethod_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS))
- result.add(MultiFixMessages.CodeStyleMultiFix_ChangeNonStaticAccess_description);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS))
- result.add(MultiFixMessages.CodeStyleMultiFix_ChangeIndirectAccessToStaticToDirect);
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- buf.append("private int value;\n"); //$NON-NLS-1$
- buf.append("public int get() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS)) {
- buf.append(" return this.value + this.value;\n"); //$NON-NLS-1$
- } else if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY)) {
- buf.append(" return value + value;\n"); //$NON-NLS-1$
- } else {
- buf.append(" return this.value + value;\n"); //$NON-NLS-1$
- }
- buf.append("}\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- buf.append("public int getZero() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS)) {
- buf.append(" return this.get() - this.get();\n"); //$NON-NLS-1$
- } else if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY)) {
- buf.append(" return get() - get();\n"); //$NON-NLS-1$
- } else {
- buf.append(" return this.get() - get();\n"); //$NON-NLS-1$
- }
- buf.append("}\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- buf.append("class E {\n"); //$NON-NLS-1$
- buf.append(" public static int NUMBER;\n"); //$NON-NLS-1$
- buf.append(" public static void set(int i) {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD)) {
- buf.append(" E.NUMBER= i;\n"); //$NON-NLS-1$
- } else {
- buf.append(" NUMBER= i;\n"); //$NON-NLS-1$
- }
- buf.append(" }\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- buf.append(" public void reset() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD)) {
- buf.append(" E.set(0);\n"); //$NON-NLS-1$
- } else {
- buf.append(" set(0);\n"); //$NON-NLS-1$
- }
- buf.append(" }\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- buf.append("class ESub extends E {\n"); //$NON-NLS-1$
- buf.append(" public void reset() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS)) {
- buf.append(" E.NUMBER= 0;\n"); //$NON-NLS-1$
- } else {
- buf.append(" ESub.NUMBER= 0;\n"); //$NON-NLS-1$
- }
- buf.append(" }\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- buf.append("public void dec() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS)) {
- buf.append(" E.NUMBER--;\n"); //$NON-NLS-1$
- } else {
- buf.append(" (new E()).NUMBER--;\n"); //$NON-NLS-1$
- }
- buf.append("}\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
-// if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS)) {
-// CodeStyleFix fix= CodeStyleFix.createAddFieldQualifierFix(compilationUnit, problem);
-// if (fix != null)
-// return true;
-// }
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS)) {
- CodeStyleFix fix= CodeStyleFix.createIndirectAccessToStaticFix(compilationUnit, problem);
- if (fix != null)
- return true;
- }
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS)) {
- CodeStyleFix[] fixes= CodeStyleFix.createNonStaticAccessFixes(compilationUnit, problem);
- if (fixes != null && fixes.length > 0)
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- int result= 0;
- IProblem[] problems= compilationUnit.getProblems();
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS))
- result+= getNumberOfProblems(problems, IProblem.UnqualifiedFieldAccess);
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS)) {
- for (int i=0;i<problems.length;i++) {
- int id= problems[i].getID();
- if (id == IProblem.IndirectAccessToStaticField || id == IProblem.IndirectAccessToStaticMethod)
- result++;
- }
- }
- if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS)) {
- for (int i=0;i<problems.length;i++) {
- int id= problems[i].getID();
- if (id == IProblem.NonStaticAccessToStaticField || id == IProblem.NonStaticAccessToStaticMethod)
- result++;
- }
- }
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatCleanUp.java
deleted file mode 100644
index 0dbf9533..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatCleanUp.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class CommentFormatCleanUp extends AbstractCleanUp {
-
- public CommentFormatCleanUp(Map options) {
- super(options);
- }
-
- public CommentFormatCleanUp() {
- super();
- }
-
- public IFix createFix(IJavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- if (!isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE))
- return null;
-
- HashMap preferences= new HashMap(compilationUnit.getJavaScriptProject().getOptions(true));
-
- boolean singleLineComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT));
- boolean blockComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT));
- boolean javaDoc= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT));
-
- return CommentFormatFix.createCleanUp(compilationUnit, singleLineComment, blockComment, javaDoc, preferences);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return null;
- }
-
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- return null;
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
- buf.append("/**\n"); //$NON-NLS-1$
- buf.append(" *A Jsdoc comment\n"); //$NON-NLS-1$
- buf.append("* \n"); //$NON-NLS-1$
- buf.append(" */\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatFix.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatFix.java
deleted file mode 100644
index 3f6c018a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/CommentFormatFix.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.ltk.core.refactoring.CategorizedTextEditGroup;
-import org.eclipse.ltk.core.refactoring.GroupCategory;
-import org.eclipse.ltk.core.refactoring.GroupCategorySet;
-import org.eclipse.ltk.core.refactoring.TextChange;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.CompilationUnitChange;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingContext;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingStrategy;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-public class CommentFormatFix implements IFix {
-
- public static IFix createCleanUp(IJavaScriptUnit unit, boolean singleLine, boolean multiLine, boolean javaDoc, HashMap preferences) throws CoreException {
- if (!singleLine && !multiLine && !javaDoc)
- return null;
-
- String content= unit.getBuffer().getContents();
- Document document= new Document(content);
-
- final List edits= format(document, singleLine, multiLine, javaDoc, preferences);
-
- if (edits.size() == 0)
- return null;
-
- MultiTextEdit resultEdit= new MultiTextEdit();
- resultEdit.addChildren((TextEdit[])edits.toArray(new TextEdit[edits.size()]));
-
- TextChange change= new CompilationUnitChange(MultiFixMessages.CommentFormatFix_description, unit);
- change.setEdit(resultEdit);
-
- String label= MultiFixMessages.CommentFormatFix_description;
- CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)));
- group.addTextEdit(resultEdit);
- change.addTextEditGroup(group);
-
- return new CommentFormatFix(change, unit);
- }
-
- static String format(String input, boolean singleLine, boolean multiLine, boolean javaDoc) {
- if (!singleLine && !multiLine && !javaDoc)
- return input;
-
- HashMap preferences= new HashMap(JavaScriptCore.getOptions());
- Document document= new Document(input);
- List edits= format(document, singleLine, multiLine, javaDoc, preferences);
-
- if (edits.size() == 0)
- return input;
-
- MultiTextEdit resultEdit= new MultiTextEdit();
- resultEdit.addChildren((TextEdit[])edits.toArray(new TextEdit[edits.size()]));
-
- try {
- resultEdit.apply(document);
- } catch (MalformedTreeException e) {
- JavaScriptPlugin.log(e);
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- return document.get();
- }
-
- private static List format(IDocument document, boolean singleLine, boolean multiLine, boolean javaDoc, HashMap preferences) {
- final List edits= new ArrayList();
-
- JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
-
- String content= document.get();
-
- CommentFormattingStrategy formattingStrategy= new CommentFormattingStrategy();
-
- IFormattingContext context= new CommentFormattingContext();
- context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE);
- context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, document);
-
- try {
- ITypedRegion[] regions= TextUtilities.computePartitioning(document, IJavaScriptPartitions.JAVA_PARTITIONING, 0, document.getLength(), false);
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion region= regions[i];
- if (singleLine && region.getType().equals(IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT)) {
- TextEdit edit= format(region, context, formattingStrategy, content);
- if (edit != null)
- edits.add(edit);
- } else if (multiLine && region.getType().equals(IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT)) {
- TextEdit edit= format(region, context, formattingStrategy, content);
- if (edit != null)
- edits.add(edit);
- } else if (javaDoc && region.getType().equals(IJavaScriptPartitions.JAVA_DOC)) {
- TextEdit edit= format(region, context, formattingStrategy, content);
- if (edit != null)
- edits.add(edit);
- }
- }
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- } finally {
- context.dispose();
- }
-
- return edits;
- }
-
- private static TextEdit format(ITypedRegion region, IFormattingContext context, CommentFormattingStrategy formattingStrategy, String content) {
- TypedPosition typedPosition= new TypedPosition(region.getOffset(), region.getLength(), region.getType());
- context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, typedPosition);
- formattingStrategy.formatterStarts(context);
- TextEdit edit= formattingStrategy.calculateTextEdit();
- formattingStrategy.formatterStops();
- if (edit == null)
- return null;
-
- if (!edit.hasChildren())
- return null;
-
- // Filter out noops
- TextEdit[] children= edit.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (!(children[i] instanceof ReplaceEdit))
- return edit;
- }
-
- IDocument doc= new Document(content);
- try {
- edit.copy().apply(doc, TextEdit.NONE);
- if (content.equals(doc.get()))
- return null;
- } catch (MalformedTreeException e) {
- } catch (BadLocationException e) {
- }
-
- return edit;
- }
-
- private final IJavaScriptUnit fCompilationUnit;
- private final TextChange fChange;
-
- public CommentFormatFix(TextChange change, IJavaScriptUnit compilationUnit) {
- fChange= change;
- fCompilationUnit= compilationUnit;
- }
-
- /**
- * {@inheritDoc}
- */
- public TextChange createChange() throws CoreException {
- return fChange;
- }
-
- /**
- * {@inheritDoc}
- */
- public IJavaScriptUnit getCompilationUnit() {
- return fCompilationUnit;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDescription() {
- return MultiFixMessages.CommentFormatFix_description;
- }
-
- /**
- * {@inheritDoc}
- */
- public IStatus getStatus() {
- return StatusInfo.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ControlStatementsCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ControlStatementsCleanUp.java
deleted file mode 100644
index ec13994e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ControlStatementsCleanUp.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.ControlStatementsFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class ControlStatementsCleanUp extends AbstractCleanUp {
-
- public ControlStatementsCleanUp(Map options) {
- super(options);
- }
-
- public ControlStatementsCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS);
-
- if (!useBlocks)
- return false;
-
- return isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS) ||
- isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER) ||
- isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS);
- if (!useBlocks)
- return null;
-
- return ControlStatementsFix.createCleanUp(compilationUnit,
- isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS),
- isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER),
- isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- //No warnings generated by the compiler
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS))
- result.add(MultiFixMessages.CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description);
- if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER))
- result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description);
- if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW))
- result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_description);
-
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) {
- buf.append("if (obj == null) {\n"); //$NON-NLS-1$
- buf.append(" throw ('some exception');\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
-
- buf.append("if (ids.length > 0) {\n"); //$NON-NLS-1$
- buf.append(" alert(ids[0]);\n"); //$NON-NLS-1$
- buf.append("} else {\n"); //$NON-NLS-1$
- buf.append(" return;\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)){
- buf.append("if (obj == null)\n"); //$NON-NLS-1$
- buf.append(" throw ('some exception');\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
-
- buf.append("if (ids.length > 0)\n"); //$NON-NLS-1$
- buf.append(" alert(ids[0]);\n"); //$NON-NLS-1$
- buf.append("else\n"); //$NON-NLS-1$
- buf.append(" return;\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) {
- buf.append("if (obj == null)\n"); //$NON-NLS-1$
- buf.append(" throw ('some exception');\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
-
- buf.append("if (ids.length > 0) {\n"); //$NON-NLS-1$
- buf.append(" alert(ids[0]);\n"); //$NON-NLS-1$
- buf.append("} else \n"); //$NON-NLS-1$
- buf.append(" return;\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- } else {
- buf.append("if (obj == null) {\n"); //$NON-NLS-1$
- buf.append(" throw ('some exception');\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
-
- buf.append("if (ids.length > 0) {\n"); //$NON-NLS-1$
- buf.append(" alert(ids[0]);\n"); //$NON-NLS-1$
- buf.append("} else \n"); //$NON-NLS-1$
- buf.append(" return;\n"); //$NON-NLS-1$
- buf.append("\n"); //$NON-NLS-1$
- }
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ConvertLoopCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ConvertLoopCleanUp.java
deleted file mode 100644
index 9a36dd9a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ConvertLoopCleanUp.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.ConvertLoopFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class ConvertLoopCleanUp extends AbstractCleanUp {
-
- public ConvertLoopCleanUp(Map options) {
- super(options);
- }
-
- public ConvertLoopCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean convertForLoops= isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);
-
- return ConvertLoopFix.createCleanUp(compilationUnit,
- convertForLoops, convertForLoops,
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- //No warnings generated by the compiler
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
-
- if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED))
- result.add(MultiFixMessages.Java50CleanUp_ConvertToEnhancedForLoop_description);
-
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) {
- buf.append("for (var element in ids) {\n"); //$NON-NLS-1$
- buf.append(" var value= element / 2; \n"); //$NON-NLS-1$
- buf.append(" alert(value);\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- } else {
- buf.append("for (var i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$
- buf.append(" var value= ids[i] / 2; \n"); //$NON-NLS-1$
- buf.append(" alert(value);\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- }
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ExpressionsCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ExpressionsCleanUp.java
deleted file mode 100644
index 7137437a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ExpressionsCleanUp.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.ExpressionsFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class ExpressionsCleanUp extends AbstractCleanUp {
-
- public ExpressionsCleanUp(Map options) {
- super(options);
- }
-
- public ExpressionsCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean usePrentheses= isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES);
- if (!usePrentheses)
- return false;
-
- return isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS) ||
- isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean usePrentheses= isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES);
- if (!usePrentheses)
- return null;
-
- return ExpressionsFix.createCleanUp(compilationUnit,
- isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS),
- isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- return createFix(compilationUnit);
- }
-
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS))
- result.add(MultiFixMessages.ExpressionsCleanUp_addParanoiac_description);
-
- if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER))
- result.add(MultiFixMessages.ExpressionsCleanUp_removeUnnecessary_description);
-
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) {
- buf.append("var b= (((i > 0) && (i < 10)) || (i == 50));\n"); //$NON-NLS-1$
- } else if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) {
- buf.append("var b= i > 0 && i < 10 || i == 50;\n"); //$NON-NLS-1$
- } else {
- buf.append("var b= (i > 0 && i < 10 || i == 50);\n"); //$NON-NLS-1$
- }
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) {
- IFix fix= ExpressionsFix.createAddParanoidalParenthesisFix(compilationUnit, new ASTNode[] {problem.getCoveredNode(compilationUnit)});
- if (fix != null)
- return true;
- }
- if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) {
- IFix fix= ExpressionsFix.createRemoveUnnecessaryParenthesisFix(compilationUnit, new ASTNode[] {problem.getCoveredNode(compilationUnit)});
- if (fix != null)
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ICleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ICleanUp.java
deleted file mode 100644
index 9f400b46..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ICleanUp.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-/**
- * A clean up can solve several different problems in a given
- * <code>JavaScriptUnit</code>. The <code>JavaScriptUnit</code> is
- * compiled by using the compiler options returned by
- * <code>getRequiredOptions</code>.
- *
- *
- */
-public interface ICleanUp {
-
- /**
- * Does this clean up require an AST for the given <code>unit</code>. If
- * true is returned an AST for unit is created by the clean up
- * infrastructure and {@link #createFix(JavaScriptUnit)} is executed,
- * otherwise {@link #createFix(IJavaScriptUnit)} is executed. The source
- * from which the AST is created may be differ from the source of
- * <code>unit</code>.
- * <p>
- * Implementors should return false whenever possible because creating an
- * AST is expensive.
- *
- * @param unit
- * the unit to create an ast for
- * @return true if {@link #createFix(JavaScriptUnit)} must be executed,
- * false if {@link #createFix(IJavaScriptUnit)} must be executed
- */
- public abstract boolean requireAST(IJavaScriptUnit unit) throws CoreException;
-
- /**
- * Create an <code>IFix</code> which fixes all problems in
- * <code>unit</code> or <code>null</code> if nothing to fix.
- * <p>
- * This is called iff {@link #requireAST(IJavaScriptUnit)} returns
- * <code>false</code>.
- *
- * @param unit
- * the IJavaScriptUnit to fix, not null
- * @return the fix for the problems or <code>null</code> if nothing to fix
- */
- public abstract IFix createFix(IJavaScriptUnit unit) throws CoreException;
-
- /**
- * Create an <code>IFix</code> which fixes all problems in
- * <code>compilationUnit</code> or <code>null</code> if nothing to fix.
- * <p>
- * This is called iff {@link #requireAST(IJavaScriptUnit)} returns
- * <code>true</code>.
- *
- * @param compilationUnit
- * The compilation unit to fix, may be null
- * @return The fix or null if no fixes possible
- * @throws CoreException
- */
- public abstract IFix createFix(JavaScriptUnit compilationUnit) throws CoreException;
-
- /**
- * Create a <code>IFix</code> which fixes all <code>problems</code> in
- * <code>JavaScriptUnit</code>
- *
- * @param compilationUnit
- * The compilation unit to fix, may be null
- * @param problems
- * The locations of the problems to fix
- * @return The fix or null if no fixes possible
- * @throws CoreException
- */
- public abstract IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException;
-
- /**
- * Required compiler options to allow <code>createFix</code> to work
- * correct.
- *
- * @return The options as map or null
- */
- public abstract Map getRequiredOptions();
-
- /**
- * If true a fresh AST, containing all the changes from previous clean ups,
- * will be created and passed to createFix.
- *
- * @param compilationUnit
- * The current available AST
- * @return true if the caller needs an up to date AST
- */
- public abstract boolean needsFreshAST(JavaScriptUnit compilationUnit);
-
- /**
- * Description for each operation this clean up will execute
- *
- * @return descriptions or null
- */
- public String[] getDescriptions();
-
- public void initialize(Map settings) throws CoreException;
-
- /**
- * After call to checkPreConditions clients will start creating fixes for
- * <code>compilationUnits</code> int <code>project</code> unless the
- * result of checkPreConditions contains a fatal error
- *
- * @param project
- * The project to clean up
- * @param compilationUnits
- * The compilation Units to clean up, all member of project
- * @param monitor
- * the monitor to show progress
- * @return the result of the precondition check, not null
- */
- public abstract RefactoringStatus checkPreConditions(IJavaScriptProject project, IJavaScriptUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Called when done cleaning up.
- *
- * @param monitor
- * the monitor to show progress
- * @return the result of the postcondition check, not null
- */
- public abstract RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException;
-
- /**
- * True if <code>problem</code> in <code>JavaScriptUnit</code> can be
- * fixed by this CleanUp. If true
- * <code>createFix(compilationUnit, new IProblemLocation[] {problem})</code>
- * does not return null.
- *
- * @param compilationUnit
- * The compilation unit to fix not null
- * @param problem
- * The location of the problem to fix
- * @return True if problem can be fixed
- * @throws CoreException
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException;
-
- /**
- * Maximal number of problems this clean up will fix in compilation unit.
- * There may be less then the returned number but never more.
- *
- * @param compilationUnit
- * The compilation unit to fix, not null
- * @return The maximal number of fixes or -1 if unknown.
- */
- public abstract int maximalNumberOfFixes(JavaScriptUnit compilationUnit);
-
- /**
- * A code snippet which complies to the current settings.
- *
- * @return A code snippet, not null.
- */
- public abstract String getPreview();
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ImportsCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ImportsCleanUp.java
deleted file mode 100644
index ef637a88..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/ImportsCleanUp.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.CodeGenerationSettings;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.ImportsFix;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class ImportsCleanUp extends AbstractCleanUp {
-
- private CodeGenerationSettings fCodeGeneratorSettings;
- private RefactoringStatus fStatus;
-
- public ImportsCleanUp(Map options) {
- super(options);
- }
-
- public ImportsCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return isEnabled(CleanUpConstants.ORGANIZE_IMPORTS);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(final JavaScriptUnit compilationUnit) throws CoreException {
- return ImportsFix.createCleanUp(compilationUnit, fCodeGeneratorSettings,
- isEnabled(CleanUpConstants.ORGANIZE_IMPORTS), fStatus);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public RefactoringStatus checkPreConditions(IJavaScriptProject project, IJavaScriptUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException {
- RefactoringStatus result= super.checkPreConditions(project, compilationUnits, monitor);
-
- if (isEnabled(CleanUpConstants.ORGANIZE_IMPORTS)) {
- fCodeGeneratorSettings= JavaPreferencesSettings.getCodeGenerationSettings(project);
- fStatus= new RefactoringStatus();
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException {
- fCodeGeneratorSettings= null;
- if (fStatus == null || fStatus.isOK()) {
- return super.checkPostConditions(monitor);
- } else {
- return fStatus;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- if (isEnabled(CleanUpConstants.ORGANIZE_IMPORTS))
- return new String[] {MultiFixMessages.ImportsCleanUp_OrganizeImports_Description};
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
-// if (isEnabled(CleanUpConstants.ORGANIZE_IMPORTS)) {
-// buf.append("import org.model.Engine;\n"); //$NON-NLS-1$
-// } else {
-// buf.append("import org.model.*;\n"); //$NON-NLS-1$
-// }
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean needsFreshAST(JavaScriptUnit compilationUnit) {
- if (isEnabled(CleanUpConstants.ORGANIZE_IMPORTS))
- return true;
-
- return super.needsFreshAST(compilationUnit);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/Java50CleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/Java50CleanUp.java
deleted file mode 100644
index fa425993..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/Java50CleanUp.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.Java50Fix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-/**
- * Create fixes which can transform pre Java50 code to Java50 code
- * @see org.eclipse.wst.jsdt.internal.corext.fix.Java50Fix
- *
- */
-public class Java50CleanUp extends AbstractCleanUp {
-
- public Java50CleanUp(Map options) {
- super(options);
- }
-
- public Java50CleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean addAnotations= isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS);
-
- return addAnotations && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE) ||
- addAnotations && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED) ||
- isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean addAnotations= isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS);
- return Java50Fix.createCleanUp(compilationUnit,
- addAnotations && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE),
- addAnotations && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED),
- isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return Java50Fix.createCleanUp(compilationUnit, problems,
- isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE),
- isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED),
- isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES));
- }
-
- public Map getRequiredOptions() {
- Map options= new Hashtable();
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE))
- options.put(JavaScriptCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION, JavaScriptCore.WARNING);
-
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED))
- options.put(JavaScriptCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION, JavaScriptCore.WARNING);
-
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES))
- options.put(JavaScriptCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaScriptCore.WARNING);
-
- return options;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE))
- result.add(MultiFixMessages.Java50MultiFix_AddMissingOverride_description);
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED))
- result.add(MultiFixMessages.Java50MultiFix_AddMissingDeprecated_description);
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES))
- result.add(MultiFixMessages.Java50CleanUp_AddTypeParameters_description);
- return (String[])result.toArray(new String[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- buf.append("class E {\n"); //$NON-NLS-1$
- buf.append(" /**\n"); //$NON-NLS-1$
- buf.append(" * @deprecated\n"); //$NON-NLS-1$
- buf.append(" */\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED)) {
- buf.append(" @Deprecated\n"); //$NON-NLS-1$
- }
- buf.append(" public void foo() {}\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
- buf.append("class ESub extends E {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE)) {
- buf.append(" @Override\n"); //$NON-NLS-1$
- }
- buf.append(" public void foo() {}\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
-// if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE)) {
-// Java50Fix fix= Java50Fix.createAddOverrideAnnotationFix(compilationUnit, problem);
-// if (fix != null)
-// return true;
-// }
-// if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED)) {
-// Java50Fix fix= Java50Fix.createAddDeprectatedAnnotation(compilationUnit, problem);
-// if (fix != null)
-// return true;
-// }
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES)) {
- Java50Fix fix= Java50Fix.createRawTypeReferenceFix(compilationUnit, problem);
- if (fix != null)
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- int result= 0;
- IProblem[] problems= compilationUnit.getProblems();
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE)) {
- result+= getNumberOfProblems(problems, IProblem.MissingOverrideAnnotation);
- }
- if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED)) {
- for (int i=0;i<problems.length;i++) {
- int id= problems[i].getID();
- if (id == IProblem.FieldMissingDeprecatedAnnotation || id == IProblem.MethodMissingDeprecatedAnnotation || id == IProblem.TypeMissingDeprecatedAnnotation)
- result++;
- }
- }
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES)) {
- for (int i=0;i<problems.length;i++) {
- int id= problems[i].getID();
- if (id == IProblem.UnsafeTypeConversion || id == IProblem.RawTypeReference || id == IProblem.UnsafeRawMethodInvocation)
- result++;
- }
- }
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.java
deleted file mode 100644
index aba88911..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import org.eclipse.osgi.util.NLS;
-
-public class MultiFixMessages extends NLS {
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.fix.MultiFixMessages"; //$NON-NLS-1$
-
- private MultiFixMessages() {
- }
-
- public static String CleanUpRefactoringWizard_CleaningUp11_Title;
- public static String CleanUpRefactoringWizard_CleaningUpN1_Title;
- public static String CleanUpRefactoringWizard_CleaningUpNN_Title;
- public static String CleanUpRefactoringWizard_CleanUpConfigurationPage_title;
- public static String CleanUpRefactoringWizard_code_organizing_tab;
- public static String CleanUpRefactoringWizard_code_style_tab;
- public static String CleanUpRefactoringWizard_Configure_Button;
- public static String CleanUpRefactoringWizard_ConfigureCustomProfile_button;
- public static String CleanUpRefactoringWizard_CustomCleanUpsDialog_title;
- public static String CleanUpRefactoringWizard_HideWizard_Link;
- public static String CleanUpRefactoringWizard_Profile_TableHeader;
- public static String CleanUpRefactoringWizard_Project_TableHeader;
- public static String CleanUpRefactoringWizard_unknownProfile_Name;
- public static String CleanUpRefactoringWizard_UnmanagedProfileWithName_Name;
- public static String CleanUpRefactoringWizard_unnecessary_code_tab;
- public static String CleanUpRefactoringWizard_use_configured_radio;
- public static String CleanUpRefactoringWizard_use_custom_radio;
- public static String CodeFormatCleanUp_RemoveTrailingAll_description;
- public static String CodeFormatCleanUp_RemoveTrailingNoEmpty_description;
- public static String CodeFormatFix_RemoveTrailingWhitespace_changeDescription;
- public static String ImportsCleanUp_OrganizeImports_Description;
- public static String SortMembersCleanUp_AllMembers_description;
- public static String SortMembersCleanUp_Excluding_description;
- public static String SortMembersCleanUp_RemoveMarkersWarning0;
- public static String StringMultiFix_AddMissingNonNls_description;
- public static String StringMultiFix_RemoveUnnecessaryNonNls_description;
-
- public static String UnusedCodeMultiFix_RemoveUnusedVariable_description;
- public static String UnusedCodeMultiFix_RemoveUnusedField_description;
- public static String UnusedCodeMultiFix_RemoveUnusedMethod_description;
- public static String UnusedCodeCleanUp_RemoveUnusedCasts_description;
-
- public static String CodeStyleMultiFix_ChangeNonStaticAccess_description;
- public static String CodeStyleMultiFix_AddThisQualifier_description;
- public static String CodeStyleMultiFix_QualifyAccessToStaticField;
- public static String CodeStyleMultiFix_ChangeIndirectAccessToStaticToDirect;
- public static String CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description;
- public static String CodeStyleCleanUp_QualifyNonStaticMethod_description;
- public static String CodeStyleCleanUp_QualifyStaticMethod_description;
- public static String CodeStyleCleanUp_removeFieldThis_description;
- public static String CodeStyleCleanUp_removeMethodThis_description;
-
- public static String Java50MultiFix_AddMissingDeprecated_description;
- public static String Java50MultiFix_AddMissingOverride_description;
- public static String Java50CleanUp_ConvertToEnhancedForLoop_description;
- public static String Java50CleanUp_AddTypeParameters_description;
-
- public static String CleanUpRefactoringWizard_WindowTitle;
- public static String CleanUpRefactoringWizard_PageTitle;
- public static String CleanUpRefactoringWizard_formatterException_errorMessage;
-
- public static String ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description;
- public static String ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_description;
-
- public static String ExpressionsCleanUp_addParanoiac_description;
- public static String ExpressionsCleanUp_removeUnnecessary_description;
-
- public static String VariableDeclarationCleanUp_AddFinalField_description;
- public static String VariableDeclarationCleanUp_AddFinalParameters_description;
- public static String VariableDeclarationCleanUp_AddFinalLocals_description;
-
- public static String CodeFormatCleanUp_description;
- public static String CodeFormatFix_description;
-
- public static String CommentFormatFix_description;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, MultiFixMessages.class);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.properties
deleted file mode 100644
index 42328a3c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/MultiFixMessages.properties
+++ /dev/null
@@ -1,73 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-StringMultiFix_AddMissingNonNls_description=Add missing '$NON-NLS$' tags
-StringMultiFix_RemoveUnnecessaryNonNls_description=Remove unnecessary '$NON-NLS$' tags
-
-UnusedCodeMultiFix_RemoveUnusedVariable_description=Remove unused local variables
-UnusedCodeMultiFix_RemoveUnusedField_description=Remove unused private vars
-UnusedCodeCleanUp_RemoveUnusedCasts_description=Remove unnecessary casts
-UnusedCodeMultiFix_RemoveUnusedMethod_description=Remove unused private functions
-
-CodeStyleMultiFix_ChangeNonStaticAccess_description=Change non static accesses to static members using declaring type
-ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description=Remove unnecessary blocks
-ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_description=Remove blocks containing a single return or throw statement
-CodeStyleMultiFix_ChangeIndirectAccessToStaticToDirect=Change indirect accesses to static members to direct accesses (accesses through subtypes)
-CodeFormatFix_RemoveTrailingWhitespace_changeDescription=Remove trailing whitespace
-CodeFormatCleanUp_RemoveTrailingNoEmpty_description=Remove trailing whitespaces on non empty lines
-CodeStyleCleanUp_QualifyNonStaticMethod_description=Add 'this' qualifier to unqualified function accesses
-CodeStyleCleanUp_QualifyStaticMethod_description=Qualify accesses to static functions with declaring class
-CodeStyleMultiFix_AddThisQualifier_description=Add 'this' qualifier to unqualified field accesses
-CodeFormatCleanUp_RemoveTrailingAll_description=Remove trailing whitespaces on all lines
-CodeStyleMultiFix_QualifyAccessToStaticField=Qualify accesses to static fields with declaring class
-CodeStyleCleanUp_removeFieldThis_description=Remove 'this' qualifier for non static var accesses
-CodeStyleCleanUp_removeMethodThis_description=Remove 'this' qualifier for non static var accesses
-CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description=Convert control statement bodies to block
-
-Java50MultiFix_AddMissingDeprecated_description=Add missing '@Deprecated' annotations
-Java50CleanUp_ConvertToEnhancedForLoop_description=Convert for loops to enhanced for loops
-Java50CleanUp_AddTypeParameters_description=Add type parameters to raw type references
-Java50MultiFix_AddMissingOverride_description=Add missing '@Override' annotations
-
-CleanUpRefactoringWizard_unknownProfile_Name=Unknown
-CleanUpRefactoringWizard_use_configured_radio=&Use configured profiles
-CleanUpRefactoringWizard_unnecessary_code_tab=U&nnecessary Code
-CleanUpRefactoringWizard_Project_TableHeader=Project
-CleanUpRefactoringWizard_Profile_TableHeader=Profile
-CleanUpRefactoringWizard_code_organizing_tab=Code &Organizing
-CleanUpRefactoringWizard_Configure_Button=Confi&gure...
-CleanUpRefactoringWizard_use_custom_radio=Use custom &profile
-CleanUpRefactoringWizard_code_style_tab=&Code Style
-CleanUpRefactoringWizard_HideWizard_Link=Go to the <a>Clean Up</a> preference page to hide this wizard in the future
-CleanUpRefactoringWizard_CleaningUp11_Title=Cleaning up 1 file in 1 project
-CleanUpRefactoringWizard_CleaningUpN1_Title=Cleaning up {0} files in 1 project
-CleanUpRefactoringWizard_CleaningUpNN_Title=Cleaning up {0} files in {1} projects
-CleanUpRefactoringWizard_formatterException_errorMessage=The formatter threw an unhandled exception while formatting the preview.
-CleanUpRefactoringWizard_WindowTitle=Clean Up
-CleanUpRefactoringWizard_PageTitle=Clean Up
-ExpressionsCleanUp_addParanoiac_description=Add paranoiac parentheses
-ExpressionsCleanUp_removeUnnecessary_description=Remove unnecessary parentheses
-VariableDeclarationCleanUp_AddFinalField_description=Add final modifier to private vars
-VariableDeclarationCleanUp_AddFinalParameters_description=Add final modifier to function parameters
-VariableDeclarationCleanUp_AddFinalLocals_description=Add final modifier to local variables
-
-CleanUpRefactoringWizard_CleanUpConfigurationPage_title=Clean Up Configuration
-CleanUpRefactoringWizard_UnmanagedProfileWithName_Name=Unmanaged profile ''{0}''
-CleanUpRefactoringWizard_ConfigureCustomProfile_button=Confi&gure...
-CleanUpRefactoringWizard_CustomCleanUpsDialog_title=Custom Clean Ups
-
-CommentFormatFix_description=Format comment
-
-CodeFormatFix_description=Format code
-CodeFormatCleanUp_description=Format source code
-ImportsCleanUp_OrganizeImports_Description=Organize imports
-SortMembersCleanUp_AllMembers_description=Sort all members
-SortMembersCleanUp_Excluding_description=Sort members excluding vars, enum constants, and initializers
-SortMembersCleanUp_RemoveMarkersWarning0=The file ''{0}'' in project ''{1}'' contains markers which may be removed by Sort Members
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.java
deleted file mode 100644
index 3453cfa8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import org.eclipse.osgi.util.NLS;
-
-public class SaveParticipantMessages extends NLS {
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.fix.SaveParticipantMessages"; //$NON-NLS-1$
-
- public static String CleanUpSaveParticipantConfigurationModifyDialog_Apply_Button;
- public static String CleanUpSaveParticipantConfigurationModifyDialog_CodeOrganizing_TabPage;
- public static String CleanUpSaveParticipantConfigurationModifyDialog_CodeStyle_TabPage;
-
- public static String CleanUpSaveParticipantConfigurationModifyDialog_SelectAnAction_Error;
- public static String CleanUpSaveParticipantConfigurationModifyDialog_UnnecessaryCode_TabPage;
-
- public static String CleanUpSaveParticipantConfigurationModifyDialog_XofYSelected_Label;
-
- public static String CleanUpSaveParticipantPreferenceConfiguration_AdditionalActions_Checkbox;
- public static String CleanUpSaveParticipantPreferenceConfiguration_CleanUpActionsTopNodeName_Checkbox;
- public static String CleanUpSaveParticipantPreferenceConfiguration_CleanUpSaveParticipantConfiguration_Title;
- public static String CleanUpSaveParticipantPreferenceConfiguration_Configure_Button;
- public static String CleanUpSaveParticipantPreferenceConfiguration_ConfigureFormatter_Link;
-// public static String CleanUpSaveParticipantPreferenceConfiguration_ConfigureImports_Link;
- public static String CleanUpSaveParticipantPreferenceConfiguration_NoActionEnabled_Info;
- public static String CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_FormatSource_Checkbox;
-// public static String CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_OrganizeImports_Checkbox;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, SaveParticipantMessages.class);
- }
-
- private SaveParticipantMessages() {}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.properties
deleted file mode 100644
index 906d9ad8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SaveParticipantMessages.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_FormatSource_Checkbox=Format &source code
-CleanUpSaveParticipantPreferenceConfiguration_CleanUpActionsTopNodeName_Checkbox=Per&form the selected actions on save
-CleanUpSaveParticipantPreferenceConfiguration_AdditionalActions_Checkbox=Addi&tional actions
-CleanUpSaveParticipantPreferenceConfiguration_Configure_Button=Co&nfigure...
-CleanUpSaveParticipantPreferenceConfiguration_ConfigureFormatter_Link=Configure the formatter settings on the <a>Formatter</a> page.
-#CleanUpSaveParticipantPreferenceConfiguration_ConfigureImports_Link=Configure the organize imports settings on the <a>Organize Imports</a> page.
-CleanUpSaveParticipantPreferenceConfiguration_NoActionEnabled_Info=No action enabled.\n\nSelect 'Configure...' to enable some actions.
-CleanUpSaveParticipantConfigurationModifyDialog_CodeStyle_TabPage=&Code Style
-CleanUpSaveParticipantConfigurationModifyDialog_UnnecessaryCode_TabPage=&Unnecessary Code
-CleanUpSaveParticipantConfigurationModifyDialog_SelectAnAction_Error=Select at least one save action.
-CleanUpSaveParticipantConfigurationModifyDialog_XofYSelected_Label={0} of {1} save actions activated
-CleanUpSaveParticipantConfigurationModifyDialog_CodeOrganizing_TabPage=Code &Organizing
-CleanUpSaveParticipantConfigurationModifyDialog_Apply_Button=&Apply
-CleanUpSaveParticipantPreferenceConfiguration_CleanUpSaveParticipantConfiguration_Title=Additional Save Actions
-#CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_OrganizeImports_Checkbox=Organize &imports
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SortMembersCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SortMembersCleanUp.java
deleted file mode 100644
index ee21098d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/SortMembersCleanUp.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Alex Blewitt - https://bugs.eclipse.org/bugs/show_bug.cgi?id=168954
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-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.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.SortMembersFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-import com.ibm.icu.text.MessageFormat;
-
-public class SortMembersCleanUp extends AbstractCleanUp {
-
- private HashSet fTouchedFiles;
-
- public SortMembersCleanUp() {
- super();
- }
-
- public SortMembersCleanUp(Map options) {
- super(options);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean sortMembers= isEnabled(CleanUpConstants.SORT_MEMBERS);
- IFix fix= SortMembersFix.createCleanUp(compilationUnit, sortMembers, sortMembers && isEnabled(CleanUpConstants.SORT_MEMBERS_ALL));
- if (fix != null) {
- if (fTouchedFiles == null) {
- fTouchedFiles= new HashSet();
- }
- fTouchedFiles.add(((IJavaScriptUnit)compilationUnit.getJavaElement()).getResource());
- }
- return fix;
- }
-
- public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException {
- if (fTouchedFiles == null) {
- return super.checkPostConditions(monitor);
- } else {
- if (monitor == null)
- monitor= new NullProgressMonitor();
-
- monitor.beginTask("", fTouchedFiles.size()); //$NON-NLS-1$
-
- try {
- RefactoringStatus result= new RefactoringStatus();
- for (Iterator iterator= fTouchedFiles.iterator(); iterator.hasNext();) {
- IFile file= (IFile)iterator.next();
- if (containsRelevantMarkers(file)) {
- String fileLocation= file.getProjectRelativePath().toOSString();
- String projectName= file.getProject().getName();
- result.addWarning(MessageFormat.format(MultiFixMessages.SortMembersCleanUp_RemoveMarkersWarning0, new Object[] {fileLocation, projectName}));
- }
-
- monitor.worked(1);
- }
-
- return result;
- } finally {
- monitor.done();
- fTouchedFiles= null;
- }
-
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- return null;
- }
-
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- if (isEnabled(CleanUpConstants.SORT_MEMBERS)) {
- if (isEnabled(CleanUpConstants.SORT_MEMBERS_ALL)) {
- return new String[] {MultiFixMessages.SortMembersCleanUp_AllMembers_description};
- } else {
- return new String[] {MultiFixMessages.SortMembersCleanUp_Excluding_description};
- }
- }
- return null;
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- buf.append("class SortExample {\n"); //$NON-NLS-1$
-
- if ((isEnabled(CleanUpConstants.SORT_MEMBERS) && isEnabled(CleanUpConstants.SORT_MEMBERS_ALL))) {
- buf.append(" private String bar;\n"); //$NON-NLS-1$
- buf.append(" private String foo;\n"); //$NON-NLS-1$
- } else {
- buf.append(" private String foo;\n"); //$NON-NLS-1$
- buf.append(" private String bar;\n"); //$NON-NLS-1$
- }
-
- if (isEnabled(CleanUpConstants.SORT_MEMBERS)) {
- buf.append(" private void bar() {}\n"); //$NON-NLS-1$
- buf.append(" private void foo() {}\n"); //$NON-NLS-1$
- } else {
- buf.append(" private void foo() {}\n"); //$NON-NLS-1$
- buf.append(" private void bar() {}\n"); //$NON-NLS-1$
- }
-
- buf.append("}\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return isEnabled(CleanUpConstants.SORT_MEMBERS);
- }
-
- private static boolean containsRelevantMarkers(IFile file) throws CoreException {
- IMarker[] bookmarks= file.findMarkers(IMarker.BOOKMARK, true, IResource.DEPTH_INFINITE);
- if (bookmarks.length != 0)
- return true;
-
- IMarker[] tasks= file.findMarkers(IMarker.TASK, true, IResource.DEPTH_INFINITE);
- if (tasks.length != 0)
- return true;
-
- IMarker[] breakpoints= file.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
- if (breakpoints.length != 0)
- return true;
-
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/StringCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/StringCleanUp.java
deleted file mode 100644
index 17c9cbde..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/StringCleanUp.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.StringFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-/**
- * Create fixes which can solve problems in connection with Strings
- * @see org.eclipse.wst.jsdt.internal.corext.fix.StringFix
- *
- */
-public class StringCleanUp extends AbstractCleanUp {
-
- public StringCleanUp(Map options) {
- super(options);
- }
-
- public StringCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS) ||
- isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return StringFix.createCleanUp(compilationUnit,
- isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS),
- isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return StringFix.createCleanUp(compilationUnit, problems,
- isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS),
- isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS));
- }
-
- public Map getRequiredOptions() {
- Map result= new Hashtable();
-
- if (isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS) || isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS))
- result.put(JavaScriptCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaScriptCore.WARNING);
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS))
- result.add(MultiFixMessages.StringMultiFix_AddMissingNonNls_description);
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS))
- result.add(MultiFixMessages.StringMultiFix_RemoveUnnecessaryNonNls_description);
- return (String[])result.toArray(new String[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS)) {
- buf.append("var s=\"\";"); //$NON-NLS-1$
- } else {
- buf.append("var s=\"\"; //$NON-NLS-1$"); //$NON-NLS-1$
- }
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- * @throws CoreException
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return StringFix.createFix(compilationUnit, problem, isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS), isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS)) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- int result= 0;
- IProblem[] problems= compilationUnit.getProblems();
- if (isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS))
- result+= getNumberOfProblems(problems, IProblem.NonExternalizedStringLiteral);
-
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS))
- result+= getNumberOfProblems(problems, IProblem.UnnecessaryNLSTag);
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnnecessaryCodeCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnnecessaryCodeCleanUp.java
deleted file mode 100644
index ec0b8d61..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnnecessaryCodeCleanUp.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.UnusedCodeFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class UnnecessaryCodeCleanUp extends AbstractCleanUp {
-
- public UnnecessaryCodeCleanUp(Map options) {
- super(options);
- }
-
- public UnnecessaryCodeCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- return isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return UnusedCodeFix.createCleanUp(compilationUnit,
- false,
- false,
- false,
- false,
- false,
- false,
- isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS));
- }
-
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- return UnusedCodeFix.createCleanUp(compilationUnit, problems,
- false,
- false,
- false,
- false,
- false,
- false,
- isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS));
- }
-
- public Map getRequiredOptions() {
- Map options= new Hashtable();
-
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS))
- options.put(JavaScriptCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaScriptCore.WARNING);
-
- return options;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS))
- result.add(MultiFixMessages.UnusedCodeCleanUp_RemoveUnusedCasts_description);
- return (String[])result.toArray(new String[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
-// if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS)) {
-// buf.append("Boolean b= Boolean.TRUE;\n"); //$NON-NLS-1$
-// } else {
-// buf.append("Boolean b= (Boolean) Boolean.TRUE;\n"); //$NON-NLS-1$
-// }
-//
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS)) {
- IFix fix= UnusedCodeFix.createRemoveUnusedCastFix(compilationUnit, problem);
- if (fix != null)
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- int result= 0;
- IProblem[] problems= compilationUnit.getProblems();
- if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS))
- result+= getNumberOfProblems(problems, IProblem.UnnecessaryCast);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnusedCodeCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnusedCodeCleanUp.java
deleted file mode 100644
index 128596a1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/UnusedCodeCleanUp.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.UnusedCodeFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-/**
- * Create fixes which can remove unused code
- * @see org.eclipse.wst.jsdt.internal.corext.fix.UnusedCodeFix
- *
- */
-public class UnusedCodeCleanUp extends AbstractCleanUp {
-
- public UnusedCodeCleanUp(Map options) {
- super(options);
- }
-
- public UnusedCodeCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean removeUnuseMembers= isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS);
-
- return removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS) ||
-// removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS) ||
- removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS) ||
-// removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES) ;
-// isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS);
- }
-
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean removeUnuseMembers= isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS);
-
- return UnusedCodeFix.createCleanUp(compilationUnit,
- removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS),
- removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS),
- removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS),
- removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES),
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES),
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS),
- false);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean removeMembers= isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS);
- return UnusedCodeFix.createCleanUp(compilationUnit, problems,
- removeMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS),
- removeMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS),
- removeMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS),
- removeMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES),
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES),
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS),
- false);
- }
-
- public Map getRequiredOptions() {
- Map options= new Hashtable();
-
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS))
- options.put(JavaScriptCore.COMPILER_PB_UNUSED_IMPORT, JavaScriptCore.WARNING);
-
- boolean removeMembers= isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS);
- if (removeMembers && (
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES)))
- options.put(JavaScriptCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaScriptCore.WARNING);
-
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES))
- options.put(JavaScriptCore.COMPILER_PB_UNUSED_LOCAL, JavaScriptCore.WARNING);
-
- return options;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
-// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS))
-// result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedImport_description);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS))
- result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedMethod_description);
-// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS))
-// result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedConstructor_description);
-// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES))
-// result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedType_description);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS))
- result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedField_description);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES))
- result.add(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedVariable_description);
- return (String[])result.toArray(new String[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-
-//// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS)) {
-//// } else {
-//// buf.append("import pack.Bar;\n"); //$NON-NLS-1$
-//// }
-//// buf.append("class Example {\n"); //$NON-NLS-1$
-// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES)) {
-// } else {
-// buf.append(" private class Sub {}\n"); //$NON-NLS-1$
-// }
-// if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS)) {
-// } else {
-// buf.append(" function Example() {}\n"); //$NON-NLS-1$
-// }
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS)) {
- } else {
- buf.append(" var fField;\n"); //$NON-NLS-1$
- }
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS)) {
- } else {
- buf.append(" function foo() {}\n"); //$NON-NLS-1$
- }
- buf.append(" function bar() {\n"); //$NON-NLS-1$
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES)) {
- } else {
- buf.append(" var i= 10;\n"); //$NON-NLS-1$
- }
- buf.append(" }\n"); //$NON-NLS-1$
-// buf.append("}\n"); //$NON-NLS-1$
-
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS)) {
- UnusedCodeFix fix= UnusedCodeFix.createRemoveUnusedImportFix(compilationUnit, problem);
- if (fix != null)
- return true;
- }
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS) ||
- isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES))
- {
- UnusedCodeFix fix= UnusedCodeFix.createUnusedMemberFix(compilationUnit, problem, false);
- if (fix != null)
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- int result= 0;
- IProblem[] problems= compilationUnit.getProblems();
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS)) {
- for (int i=0;i<problems.length;i++) {
- int id= problems[i].getID();
- if (id == IProblem.UnusedImport || id == IProblem.DuplicateImport || id == IProblem.ConflictingImport ||
- id == IProblem.CannotImportPackage || id == IProblem.ImportNotFound)
- result++;
- }
- }
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS))
- result+= getNumberOfProblems(problems, IProblem.UnusedPrivateMethod);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS))
- result+= getNumberOfProblems(problems, IProblem.UnusedPrivateConstructor);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES))
- result+= getNumberOfProblems(problems, IProblem.UnusedPrivateType);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS) && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS))
- result+= getNumberOfProblems(problems, IProblem.UnusedPrivateField);
- if (isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES))
- result+= getNumberOfProblems(problems, IProblem.LocalVariableIsNeverUsed);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/VariableDeclarationCleanUp.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/VariableDeclarationCleanUp.java
deleted file mode 100644
index fdf4b4cb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/fix/VariableDeclarationCleanUp.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.fix;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.IFix;
-import org.eclipse.wst.jsdt.internal.corext.fix.VariableDeclarationFix;
-import org.eclipse.wst.jsdt.ui.text.java.IProblemLocation;
-
-public class VariableDeclarationCleanUp extends AbstractCleanUp {
-
- public VariableDeclarationCleanUp(Map options) {
- super(options);
- }
-
- public VariableDeclarationCleanUp() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean requireAST(IJavaScriptUnit unit) throws CoreException {
- boolean addFinal= isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL);
- if (!addFinal)
- return false;
-
- return isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS) ||
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS) ||
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES);
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit) throws CoreException {
- if (compilationUnit == null)
- return null;
-
- boolean addFinal= isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL);
- if (!addFinal)
- return null;
-
- return VariableDeclarationFix.createCleanUp(compilationUnit,
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS),
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS),
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES));
- }
-
- /**
- * {@inheritDoc}
- */
- public IFix createFix(JavaScriptUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
- //No warnings generated by the compiler
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map getRequiredOptions() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptions() {
- List result= new ArrayList();
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS))
- result.add(MultiFixMessages.VariableDeclarationCleanUp_AddFinalField_description);
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS))
- result.add(MultiFixMessages.VariableDeclarationCleanUp_AddFinalParameters_description);
- if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES))
- result.add(MultiFixMessages.VariableDeclarationCleanUp_AddFinalLocals_description);
-
- return (String[])result.toArray(new String[result.size()]);
- }
-
- public String getPreview() {
- StringBuffer buf= new StringBuffer();
-//
-// if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS)) {
-// buf.append("private final int i= 0;\n"); //$NON-NLS-1$
-// } else {
-// buf.append("private int i= 0;\n"); //$NON-NLS-1$
-// }
-// if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS)) {
-// buf.append("public void foo(final int j) {\n"); //$NON-NLS-1$
-// } else {
-// buf.append("public void foo(int j) {\n"); //$NON-NLS-1$
-// }
-// if (isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES)) {
-// buf.append(" final int k;\n"); //$NON-NLS-1$
-// buf.append(" int h;\n"); //$NON-NLS-1$
-// buf.append(" h= 0;\n"); //$NON-NLS-1$
-// } else {
-// buf.append(" int k, h;\n"); //$NON-NLS-1$
-// buf.append(" h= 0;\n"); //$NON-NLS-1$
-// }
-// buf.append("}\n"); //$NON-NLS-1$
-//
- return buf.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canFix(JavaScriptUnit compilationUnit, IProblemLocation problem) throws CoreException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int maximalNumberOfFixes(JavaScriptUnit compilationUnit) {
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/AbstractInfoView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/AbstractInfoView.java
deleted file mode 100644
index b80f7afd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/AbstractInfoView.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ColorRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-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.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-/**
- * Abstract class for views which show information for a given element.
- *
- *
- */
-public abstract class AbstractInfoView extends ViewPart implements ISelectionListener, IMenuListener, IPropertyChangeListener {
-
-
- /** JavaScriptElementLabels flags used for the title */
- private final long TITLE_FLAGS= JavaScriptElementLabels.ALL_FULLY_QUALIFIED
- | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_EXCEPTIONS
- | JavaScriptElementLabels.F_PRE_TYPE_SIGNATURE | JavaScriptElementLabels.M_PRE_TYPE_PARAMETERS | JavaScriptElementLabels.T_TYPE_PARAMETERS
- | JavaScriptElementLabels.USE_RESOLVED;
- private final long LOCAL_VARIABLE_TITLE_FLAGS= TITLE_FLAGS & ~JavaScriptElementLabels.F_FULLY_QUALIFIED | JavaScriptElementLabels.F_POST_QUALIFIED;
-
- /** JavaScriptElementLabels flags used for the tool tip text */
- private static final long TOOLTIP_LABEL_FLAGS= JavaScriptElementLabels.DEFAULT_QUALIFIED | JavaScriptElementLabels.ROOT_POST_QUALIFIED | JavaScriptElementLabels.APPEND_ROOT_PATH |
- JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_APP_RETURNTYPE | JavaScriptElementLabels.M_EXCEPTIONS |
- JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.T_TYPE_PARAMETERS;
-
-
- /*
- * @see IPartListener2
- */
- private IPartListener2 fPartListener= new IPartListener2() {
- public void partVisible(IWorkbenchPartReference ref) {
- if (ref.getId().equals(getSite().getId())) {
- IWorkbenchPart activePart= ref.getPage().getActivePart();
- if (activePart != null)
- selectionChanged(activePart, ref.getPage().getSelection());
- startListeningForSelectionChanges();
- }
- }
- public void partHidden(IWorkbenchPartReference ref) {
- if (ref.getId().equals(getSite().getId()))
- stopListeningForSelectionChanges();
- }
- public void partInputChanged(IWorkbenchPartReference ref) {
- if (!ref.getId().equals(getSite().getId()))
- computeAndSetInput(ref.getPart(false));
- }
- public void partActivated(IWorkbenchPartReference ref) {
- }
- public void partBroughtToTop(IWorkbenchPartReference ref) {
- }
- public void partClosed(IWorkbenchPartReference ref) {
- }
- public void partDeactivated(IWorkbenchPartReference ref) {
- }
- public void partOpened(IWorkbenchPartReference ref) {
- }
- };
-
-
- /** The current input. */
- protected IJavaScriptElement fCurrentViewInput;
- /** The copy to clipboard action. */
- private SelectionDispatchAction fCopyToClipboardAction;
- /** The goto input action. */
- private GotoInputAction fGotoInputAction;
- /** Counts the number of background computation requests. */
- private volatile int fComputeCount;
-
- /**
- * Background color.
- *
- */
- private Color fBackgroundColor;
- private RGB fBackgroundColorRGB;
-
-
- /**
- * Set the input of this view.
- *
- * @param input the input object
- */
- abstract protected void setInput(Object input);
-
- /**
- * Computes the input for this view based on the given element.
- *
- * @param element the element from which to compute the input
- * @return the input or <code>null</code> if the input was not computed successfully
- */
- abstract protected Object computeInput(Object element);
-
- /**
- * Create the part control.
- *
- * @param parent the parent control
- * @see IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- abstract protected void internalCreatePartControl(Composite parent);
-
- /**
- * Set the view's foreground color.
- *
- * @param color the SWT color
- */
- abstract protected void setForeground(Color color);
-
- /**
- * Set the view's background color.
- *
- * @param color the SWT color
- */
- abstract protected void setBackground(Color color);
-
- /**
- * Returns the view's primary control.
- *
- * @return the primary control
- */
- abstract Control getControl();
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- *
- */
- abstract protected String getHelpContextId();
-
- /*
- * @see IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public final void createPartControl(Composite parent) {
- internalCreatePartControl(parent);
- inititalizeColors();
- getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener);
- createContextMenu();
- createActions();
- fillActionBars(getViewSite().getActionBars());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpContextId());
- }
-
- /**
- * Creates the actions and action groups for this view.
- */
- protected void createActions() {
- fGotoInputAction= new GotoInputAction(this);
- fGotoInputAction.setEnabled(false);
- fCopyToClipboardAction= new CopyToClipboardAction(getViewSite());
-
- ISelectionProvider provider= getSelectionProvider();
- if (provider != null)
- provider.addSelectionChangedListener(fCopyToClipboardAction);
- }
-
- /**
- * Creates the context menu for this view.
- */
- protected void createContextMenu() {
- MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- menuManager.addMenuListener(this);
- Menu contextMenu= menuManager.createContextMenu(getControl());
- getControl().setMenu(contextMenu);
- getSite().registerContextMenu(menuManager, getSelectionProvider());
- }
-
- /*
- * @see IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager menu) {
- menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
-
- IAction action;
-
- action= getCopyToClipboardAction();
- if (action != null)
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, action);
-
- action= getSelectAllAction();
- if (action != null)
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, action);
-
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fGotoInputAction);
- }
-
- protected IAction getSelectAllAction() {
- return null;
- }
-
- protected IAction getCopyToClipboardAction() {
- return fCopyToClipboardAction;
- }
-
- /**
- * Returns the input of this view.
- *
- * @return input the input object or <code>null</code> if not input is set
- */
- protected IJavaScriptElement getInput() {
- return fCurrentViewInput;
- }
-
- // Helper method
- ISelectionProvider getSelectionProvider() {
- return getViewSite().getSelectionProvider();
- }
-
- /**
- * Fills the actions bars.
- * <p>
- * Subclasses may extend.
- *
- * @param actionBars the action bars
- */
- protected void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
-
- IAction action;
-
- action= getCopyToClipboardAction();
- if (action != null)
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), action);
-
- action= getSelectAllAction();
- if (action != null)
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), action);
- }
-
- /**
- * Fills the tool bar.
- * <p>
- * Default is to do nothing.</p>
- *
- * @param tbm the tool bar manager
- */
- protected void fillToolBar(IToolBarManager tbm) {
- tbm.add(fGotoInputAction);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#inititalizeColors()
- *
- */
- private void inititalizeColors() {
- if (getSite().getShell().isDisposed())
- return;
-
- Display display= getSite().getShell().getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
-
- ColorRegistry registry= JFaceResources.getColorRegistry();
- registry.addListener(this);
-
- fBackgroundColorRGB= registry.getRGB(getBackgroundColorKey());
- Color bgColor;
- if (fBackgroundColorRGB == null) {
- bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fBackgroundColorRGB= bgColor.getRGB();
- } else {
- bgColor= new Color(display, fBackgroundColorRGB);
- fBackgroundColor= bgColor;
- }
-
- setBackground(bgColor);
- }
-
- /**
- * The preference key for the background color.
- *
- * @return the background color key
- *
- */
- abstract protected String getBackgroundColorKey();
-
- public void propertyChange(PropertyChangeEvent event) {
- if (getBackgroundColorKey().equals(event.getProperty()))
- inititalizeColors();
- }
-
- /**
- * Start to listen for selection changes.
- */
- protected void startListeningForSelectionChanges() {
- getSite().getPage().addPostSelectionListener(this);
- }
-
- /**
- * Stop to listen for selection changes.
- */
- protected void stopListeningForSelectionChanges() {
- getSite().getPage().removePostSelectionListener(this);
- }
-
- /*
- * @see ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (part.equals(this))
- return;
-
- computeAndSetInput(part);
- }
-
- /**
- * Tells whether the new input should be ignored
- * if the current input is the same.
- *
- * @param je the new input
- * @param selection the current selection from the part that provides the input
- * @return <code>true</code> if the new input should be ignored
- */
- protected boolean isIgnoringNewInput(IJavaScriptElement je, IWorkbenchPart part, ISelection selection) {
- return fCurrentViewInput != null && fCurrentViewInput.equals(je) && je != null;
- }
-
- /**
- * Finds and returns the Java element selected in the given part.
- *
- * @param part the workbench part for which to find the selected Java element
- * @param selection the selection
- * @return the selected Java element
- */
- protected IJavaScriptElement findSelectedJavaElement(IWorkbenchPart part, ISelection selection) {
- Object element;
- try {
- if (part instanceof JavaEditor && selection instanceof ITextSelection) {
- IJavaScriptElement[] elements= TextSelectionConverter.codeResolve((JavaEditor)part, (ITextSelection)selection);
- if (elements != null && elements.length > 0)
- return elements[0];
- else
- return null;
- } else if (selection instanceof IStructuredSelection) {
- element= SelectionUtil.getSingleElement(selection);
- } else {
- return null;
- }
- } catch (JavaScriptModelException e) {
- return null;
- }
-
- return findJavaElement(element);
- }
-
- /**
- * Tries to get a Java element out of the given element.
- *
- * @param element an object
- * @return the Java element represented by the given element or <code>null</code>
- */
- private IJavaScriptElement findJavaElement(Object element) {
-
- if (element == null)
- return null;
-
- IJavaScriptElement je= null;
- if (element instanceof IAdaptable)
- je= (IJavaScriptElement)((IAdaptable)element).getAdapter(IJavaScriptElement.class);
-
- return je;
- }
-
- /**
- * Finds and returns the type for the given CU.
- *
- * @param cu the compilation unit
- * @return the type with same name as the given CU or the first type in the CU
- */
- protected IType getTypeForCU(IJavaScriptUnit cu) {
-
- if (cu == null || !cu.exists())
- return null;
-
- // Use primary type if possible
- IType primaryType= cu.findPrimaryType();
- if (primaryType != null)
- return primaryType;
-
- // Use first top-level type
- try {
- IType[] types= cu.getTypes();
- if (types.length > 0)
- return types[0];
- else
- return null;
- } catch (JavaScriptModelException ex) {
- return null;
- }
- }
-
- /*
- * @see IWorkbenchPart#dispose()
- */
- final public void dispose() {
- // cancel possible running computation
- fComputeCount++;
-
- getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
-
- ISelectionProvider provider= getSelectionProvider();
- if (provider != null)
- provider.removeSelectionChangedListener(fCopyToClipboardAction);
-
- JFaceResources.getColorRegistry().removeListener(this);
- fBackgroundColorRGB= null;
- if (fBackgroundColor != null) {
- fBackgroundColor.dispose();
- fBackgroundColor= null;
- }
-
- internalDispose();
-
- }
-
- /*
- * @see IWorkbenchPart#dispose()
- */
- abstract protected void internalDispose();
-
- /**
- * Determines all necessary details and delegates the computation into
- * a background thread.
- *
- * @param part the workbench part
- */
- private void computeAndSetInput(final IWorkbenchPart part) {
-
- final int currentCount= ++fComputeCount;
-
- ISelectionProvider provider= part.getSite().getSelectionProvider();
- if (provider == null)
- return;
-
- final ISelection selection= provider.getSelection();
- if (selection == null || selection.isEmpty())
- return;
-
- Thread thread= new Thread("Info view input computer") { //$NON-NLS-1$
- public void run() {
- if (currentCount != fComputeCount)
- return;
-
- final IJavaScriptElement je= findSelectedJavaElement(part, selection);
-
- if (isIgnoringNewInput(je, part, selection))
- return;
-
- // The actual computation
- final Object input= computeInput(je);
- if (input == null)
- return;
-
- Shell shell= getSite().getShell();
- if (shell.isDisposed())
- return;
-
- Display display= shell.getDisplay();
- if (display.isDisposed())
- return;
-
- display.asyncExec(new Runnable() {
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
-
- if (fComputeCount != currentCount || getViewSite().getShell().isDisposed())
- return;
-
- fCurrentViewInput= je;
- doSetInput(input);
- }
- });
- }
- };
-
- thread.setDaemon(true);
- thread.setPriority(Thread.MIN_PRIORITY);
- thread.start();
- }
-
- private void doSetInput(Object input) {
- setInput(input);
-
- fGotoInputAction.setEnabled(true);
-
- IJavaScriptElement inputElement= getInput();
-
- long flags;
- if (inputElement instanceof ILocalVariable)
- flags= LOCAL_VARIABLE_TITLE_FLAGS;
- else
- flags= TITLE_FLAGS;
-
- setContentDescription(JavaScriptElementLabels.getElementLabel(inputElement, flags));
- setTitleToolTip(JavaScriptElementLabels.getElementLabel(inputElement, TOOLTIP_LABEL_FLAGS));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/CopyToClipboardAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/CopyToClipboardAction.java
deleted file mode 100644
index d3232d1f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/CopyToClipboardAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-class CopyToClipboardAction extends SelectionDispatchAction{
-
- private final static int MAX_REPEAT_COUNT= 10;
-
- private Clipboard fClipboard;
-
- public CopyToClipboardAction(IWorkbenchSite site) {
- super(site);
-
- setText(InfoViewMessages.CopyAction_label);
- setToolTipText(InfoViewMessages.CopyAction_tooltip);
- setDescription(InfoViewMessages.CopyAction_description);
-
- ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages();
- setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
- setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.COPY_ACTION);
-
- update(getSelection());
- }
-
- public void selectionChanged(ITextSelection selection) {
- setEnabled(selection != null && selection.getLength() > 0);
- }
-
- public void run(ITextSelection selection) {
- fClipboard= new Clipboard(getShell().getDisplay());
- try {
- copyToClipboard(selection, 0);
- } finally {
- fClipboard.dispose();
- }
- }
-
- private void copyToClipboard(ITextSelection selection, int repeatCount) {
- try{
- fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() });
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT)
- throw e;
-
- if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message))
- copyToClipboard(selection, repeatCount + 1);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/GotoInputAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/GotoInputAction.java
deleted file mode 100644
index 504ea9b6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/GotoInputAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.actions.OpenAction;
-
-class GotoInputAction extends Action {
-
- private AbstractInfoView fInfoView;
-
- public GotoInputAction(AbstractInfoView infoView) {
- Assert.isNotNull(infoView);
- fInfoView= infoView;
-
- JavaPluginImages.setLocalImageDescriptors(this, "goto_input.gif"); //$NON-NLS-1$
- setText(InfoViewMessages.GotoInputAction_label);
- setToolTipText(InfoViewMessages.GotoInputAction_tooltip);
- setDescription(InfoViewMessages.GotoInputAction_description);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_INPUT_ACTION);
- }
-
- public void run() {
- IJavaScriptElement inputElement= fInfoView.getInput();
- new OpenAction(fInfoView.getViewSite()).run(new Object[] { inputElement });
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.java
deleted file mode 100644
index a1dc4049..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-final class InfoViewMessages extends NLS {
-
- private static final String BUNDLE_NAME= InfoViewMessages.class.getName();
-
- private InfoViewMessages() {
- // Do not instantiate
- }
-
- public static String CopyAction_label;
- public static String CopyAction_tooltip;
- public static String CopyAction_description;
- public static String SelectAllAction_label;
- public static String SelectAllAction_tooltip;
- public static String SelectAllAction_description;
- public static String GotoInputAction_label;
- public static String GotoInputAction_tooltip;
- public static String GotoInputAction_description;
- public static String CopyToClipboard_error_title;
- public static String CopyToClipboard_error_message;
- public static String JavadocView_error_noBrowser_title;
- public static String JavadocView_error_noBrowser_message;
- public static String JavadocView_error_noBrowser_doNotWarn;
- public static String JavadocView_noAttachments;
- public static String JavadocView_noAttachedSource;
- public static String JavadocView_noAttachedJavadoc;
- public static String JavadocView_noInformation;
- public static String JavadocView_error_gettingJavadoc;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, InfoViewMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.properties
deleted file mode 100644
index 42f33630..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/InfoViewMessages.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-CopyAction_label= &Copy
-CopyAction_tooltip= Copy the Selected Text to the Clipboard
-CopyAction_description= Copy
-
-SelectAllAction_label= Select &All
-SelectAllAction_tooltip= Select All
-SelectAllAction_description= Select All
-
-GotoInputAction_label= Open &Input
-GotoInputAction_tooltip= Open Input
-GotoInputAction_description= Open Input
-
-CopyToClipboard_error_title= Problem Copying to Clipboard
-CopyToClipboard_error_message= There was a problem when accessing the system clipboard. Retry?
-
-JavadocView_error_noBrowser_title= Jsdoc view
-JavadocView_error_noBrowser_message= The HTML Browser widget could not be created. The standard text widget will be used instead.
-JavadocView_error_noBrowser_doNotWarn= Do not show this message again.
-JavadocView_noAttachments= <em>Note: This element neither has attached source nor attached Jsdoc and hence no Jsdoc could be found.</em>
-JavadocView_noAttachedSource= <em>Note: This element has no attached source and the Jsdoc could not be found in the attached Jsdoc.</em>
-JavadocView_noAttachedJavadoc= <em>Note: This element has no attached Jdoc and the Jdoc could not be found in the attached source.</em>
-JavadocView_noInformation= <em>Note: The Jsdoc for this element could neither be found in the attached source nor the attached Jsdoc.</em>
-JavadocView_error_gettingJavadoc= <em>Note: An exception occurred while getting the Jsdoc. See log for details.</em>
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/JavadocView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/JavadocView.java
deleted file mode 100644
index ac0aa806..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/JavadocView.java
+++ /dev/null
@@ -1,703 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.net.URL;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.wst.jsdt.internal.ui.text.html.HTMLPrinter;
-import org.eclipse.wst.jsdt.internal.ui.text.html.HTMLTextPresenter;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.TextUtilities;
-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.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.javadoc.JavaDocLocations;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JSdocContentAccess;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.osgi.framework.Bundle;
-
-/**
- * View which shows Javadoc for a given Java element.
- *
- * FIXME: As of 3.0 selectAll() and getSelection() is not working
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- *
- *
- */
-public class JavadocView extends AbstractInfoView {
-
- /**
- * Preference key for the preference whether to show a dialog
- * when the SWT Browser widget is not available.
- *
- */
- private static final String DO_NOT_WARN_PREFERENCE_KEY= "JavadocView.error.doNotWarn"; //$NON-NLS-1$
-
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=73558
- private static final boolean WARNING_DIALOG_ENABLED= false;
-
- /** Flags used to render a label in the text widget. */
- private static final long LABEL_FLAGS= JavaScriptElementLabels.ALL_FULLY_QUALIFIED
- | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_EXCEPTIONS
- | JavaScriptElementLabels.F_PRE_TYPE_SIGNATURE | JavaScriptElementLabels.T_TYPE_PARAMETERS;
-
-
- /** The HTML widget. */
- private Browser fBrowser;
- /** The text widget. */
- private StyledText fText;
- /** The information presenter. */
- private DefaultInformationControl.IInformationPresenter fPresenter;
- /** The text presentation. */
- private TextPresentation fPresentation= new TextPresentation();
- /** The select all action */
- private SelectAllAction fSelectAllAction;
- /** The style sheet (css) */
- private static String fgStyleSheet;
- /**
- * <code>true</code> once the style sheet has been loaded.
- *
- */
- private static boolean fgStyleSheetLoaded= false;
-
- /** The Browser widget */
- private boolean fIsUsingBrowserWidget;
-
- private RGB fBackgroundColorRGB;
- /**
- * The font listener.
- *
- */
- private IPropertyChangeListener fFontListener;
-
-
- /**
- * The Javadoc view's select all action.
- */
- private class SelectAllAction extends Action {
-
- /** The control. */
- private Control fControl;
- /** The selection provider. */
- private SelectionProvider fSelectionProvider;
-
- /**
- * Creates the action.
- *
- * @param control the widget
- * @param selectionProvider the selection provider
- */
- public SelectAllAction(Control control, SelectionProvider selectionProvider) {
- super("selectAll"); //$NON-NLS-1$
-
- Assert.isNotNull(control);
- Assert.isNotNull(selectionProvider);
- fControl= control;
- fSelectionProvider= selectionProvider;
-
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- setEnabled(!fIsUsingBrowserWidget);
-
- setText(InfoViewMessages.SelectAllAction_label);
- setToolTipText(InfoViewMessages.SelectAllAction_tooltip);
- setDescription(InfoViewMessages.SelectAllAction_description);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION);
- }
-
- /**
- * Selects all in the view.
- */
- public void run() {
- if (fControl instanceof StyledText)
- ((StyledText)fControl).selectAll();
- else {
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
-// ((Browser)fControl).selectAll();
- if (fSelectionProvider != null)
- fSelectionProvider.fireSelectionChanged();
- }
- }
- }
-
- /**
- * The Javadoc view's selection provider.
- */
- private static class SelectionProvider implements ISelectionProvider {
-
- /** The selection changed listeners. */
- private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
- /** The widget. */
- private Control fControl;
-
- /**
- * Creates a new selection provider.
- *
- * @param control the widget
- */
- public SelectionProvider(Control control) {
- Assert.isNotNull(control);
- fControl= control;
- if (fControl instanceof StyledText) {
- ((StyledText)fControl).addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fireSelectionChanged();
- }
- });
- } else {
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
-// ((Browser)fControl).addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// fireSelectionChanged();
-// }
-// });
- }
- }
-
- /**
- * Sends a selection changed event to all listeners.
- */
- public void fireSelectionChanged() {
- ISelection selection= getSelection();
- SelectionChangedEvent event= new SelectionChangedEvent(this, selection);
- Object[] selectionChangedListeners= fListeners.getListeners();
- for (int i= 0; i < selectionChangedListeners.length; i++)
- ((ISelectionChangedListener)selectionChangedListeners[i]).selectionChanged(event);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
- */
- public ISelection getSelection() {
- if (fControl instanceof StyledText) {
- IDocument document= new Document(((StyledText)fControl).getSelectionText());
- return new TextSelection(document, 0, document.getLength());
- } else {
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- return StructuredSelection.EMPTY;
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
- */
- public void setSelection(ISelection selection) {
- // not supported
- }
- }
-
- /*
- * @see AbstractInfoView#internalCreatePartControl(Composite)
- */
- protected void internalCreatePartControl(Composite parent) {
- try {
- fBrowser= new Browser(parent, SWT.NONE);
- fIsUsingBrowserWidget= true;
-
- } catch (SWTError er) {
-
- /* The Browser widget throws an SWTError if it fails to
- * instantiate properly. Application code should catch
- * this SWTError and disable any feature requiring the
- * Browser widget.
- * Platform requirements for the SWT Browser widget are available
- * from the SWT FAQ web site.
- */
-
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- boolean doNotWarn= store.getBoolean(DO_NOT_WARN_PREFERENCE_KEY);
- if (WARNING_DIALOG_ENABLED && !doNotWarn) {
- String title= InfoViewMessages.JavadocView_error_noBrowser_title;
- String message= InfoViewMessages.JavadocView_error_noBrowser_message;
- String toggleMessage= InfoViewMessages.JavadocView_error_noBrowser_doNotWarn;
- MessageDialogWithToggle dialog= MessageDialogWithToggle.openError(parent.getShell(), title, message, toggleMessage, false, null, null);
- if (dialog.getReturnCode() == Window.OK)
- store.setValue(DO_NOT_WARN_PREFERENCE_KEY, dialog.getToggleState());
- }
-
- fIsUsingBrowserWidget= false;
- }
-
- if (!fIsUsingBrowserWidget) {
- fText= new StyledText(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- fText.setEditable(false);
- fPresenter= new HTMLTextPresenter(false);
-
- fText.addControlListener(new ControlAdapter() {
- /*
- * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- setInput(fText.getText());
- }
- });
- }
-
- initStyleSheet();
- listenForFontChanges();
- getViewSite().setSelectionProvider(new SelectionProvider(getControl()));
- }
-
- /**
- * Registers a listener for the Java editor font.
- *
- *
- */
- private void listenForFontChanges() {
- fFontListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (PreferenceConstants.APPEARANCE_JAVADOC_FONT.equals(event.getProperty())) {
- fgStyleSheetLoaded= false;
- // trigger reloading, but make sure other listeners have already run, so that
- // the style sheet gets reloaded only once.
- final Display display= getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
- if (!display.isDisposed()) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (!display.isDisposed()) {
- initStyleSheet();
- refresh();
- }
- }
- });
- }
- }
- }
- };
- JFaceResources.getFontRegistry().addListener(fFontListener);
- }
-
- private static void initStyleSheet() {
- if (fgStyleSheetLoaded)
- return;
- fgStyleSheetLoaded= true;
- fgStyleSheet= loadStyleSheet();
- }
-
- private static String loadStyleSheet() {
- Bundle bundle= Platform.getBundle(JavaScriptPlugin.getPluginId());
- URL styleSheetURL= bundle.getEntry("/JavadocViewStyleSheet.css"); //$NON-NLS-1$
- if (styleSheetURL == null)
- return null;
-
- try {
- styleSheetURL= FileLocator.toFileURL(styleSheetURL);
- BufferedReader reader= new BufferedReader(new InputStreamReader(styleSheetURL.openStream()));
- StringBuffer buffer= new StringBuffer(200);
- String line= reader.readLine();
- while (line != null) {
- buffer.append(line);
- buffer.append('\n');
- line= reader.readLine();
- }
-
- FontData fontData= JFaceResources.getFontRegistry().getFontData(PreferenceConstants.APPEARANCE_JAVADOC_FONT)[0];
- return HTMLPrinter.convertTopLevelFont(buffer.toString(), fontData);
- } catch (IOException ex) {
- JavaScriptPlugin.log(ex);
- return null;
- }
- }
-
- /*
- * @see AbstractInfoView#createActions()
- */
- protected void createActions() {
- super.createActions();
- fSelectAllAction= new SelectAllAction(getControl(), (SelectionProvider)getSelectionProvider());
- }
-
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getSelectAllAction()
- *
- */
- protected IAction getSelectAllAction() {
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- if (fIsUsingBrowserWidget)
- return null;
-
- return fSelectAllAction;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getCopyToClipboardAction()
- *
- */
- protected IAction getCopyToClipboardAction() {
- // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- if (fIsUsingBrowserWidget)
- return null;
-
- return super.getCopyToClipboardAction();
- }
-
- /*
- * @see AbstractInfoView#setForeground(Color)
- */
- protected void setForeground(Color color) {
- getControl().setForeground(color);
- }
-
- /*
- * @see AbstractInfoView#setBackground(Color)
- */
- protected void setBackground(Color color) {
- getControl().setBackground(color);
- fBackgroundColorRGB= color.getRGB();
- refresh();
- }
-
- /**
- * Refreshes the view.
- *
- *
- */
- private void refresh() {
- IJavaScriptElement input= getInput();
- if (input == null) {
- StringBuffer buffer= new StringBuffer(""); //$NON-NLS-1$
- HTMLPrinter.insertPageProlog(buffer, 0, fBackgroundColorRGB, fgStyleSheet);
- setInput(buffer.toString());
- } else {
- setInput(computeInput(input));
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getBackgroundColorKey()
- *
- */
- protected String getBackgroundColorKey() {
- return "org.eclipse.wst.jsdt.ui.JavadocView.backgroundColor"; //$NON-NLS-1$
- }
-
- /*
- * @see AbstractInfoView#internalDispose()
- */
- protected void internalDispose() {
- fText= null;
- fBrowser= null;
- if (fFontListener != null) {
- JFaceResources.getFontRegistry().removeListener(fFontListener);
- fFontListener= null;
- }
- }
-
- /*
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- public void setFocus() {
- getControl().setFocus();
- }
-
- /*
- * @see AbstractInfoView#computeInput(Object)
- */
- protected Object computeInput(Object input) {
- if (getControl() == null || ! (input instanceof IJavaScriptElement))
- return null;
-
- IJavaScriptElement je= (IJavaScriptElement)input;
- String javadocHtml;
-
- switch (je.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- try {
- javadocHtml= getJavadocHtml(((IJavaScriptUnit)je).getTypes());
- } catch (JavaScriptModelException ex) {
- javadocHtml= null;
- }
- break;
- case IJavaScriptElement.CLASS_FILE:
- javadocHtml= getJavadocHtml(new IJavaScriptElement[] {((IClassFile)je).getType()});
- break;
- default:
- javadocHtml= getJavadocHtml(new IJavaScriptElement[] { je });
- }
-
- if (javadocHtml == null)
- return ""; //$NON-NLS-1$
-
- return javadocHtml;
- }
-
- /*
- * @see AbstractInfoView#setInput(Object)
- */
- protected void setInput(Object input) {
- String javadocHtml= (String)input;
-
- if (fIsUsingBrowserWidget) {
- if (javadocHtml != null && javadocHtml.length() > 0) {
- boolean RTL= (getSite().getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
- if (RTL) {
- StringBuffer buffer= new StringBuffer(javadocHtml);
- HTMLPrinter.insertStyles(buffer, new String[] { "direction:rtl" } ); //$NON-NLS-1$
- javadocHtml= buffer.toString();
- }
- }
- fBrowser.setText(javadocHtml);
- } else {
- fPresentation.clear();
- Rectangle size= fText.getClientArea();
-
- try {
- javadocHtml= ((DefaultInformationControl.IInformationPresenterExtension)fPresenter).updatePresentation(getSite().getShell(), javadocHtml, fPresentation, size.width, size.height);
- } catch (IllegalArgumentException ex) {
- // the javadoc might no longer be valid
- return;
- }
- fText.setText(javadocHtml);
- TextPresentation.applyTextPresentation(fPresentation, fText);
- }
- }
-
- /**
- * Returns the Javadoc in HTML format.
- *
- * @param result the Java elements for which to get the Javadoc
- * @return a string with the Javadoc in HTML format.
- */
- private String getJavadocHtml(IJavaScriptElement[] result) {
- StringBuffer buffer= new StringBuffer();
- int nResults= result.length;
-
- if (nResults == 0)
- return null;
-
- if (nResults > 1) {
-
- for (int i= 0; i < result.length; i++) {
- HTMLPrinter.startBulletList(buffer);
- IJavaScriptElement curr= result[i];
- if (curr instanceof IMember)
- HTMLPrinter.addBullet(buffer, getInfoText((IMember) curr));
- HTMLPrinter.endBulletList(buffer);
- }
-
- } else {
-
- IJavaScriptElement curr= result[0];
- if (curr instanceof IMember) {
- IMember member= (IMember) curr;
-// HTMLPrinter.addSmallHeader(buffer, getInfoText(member));
- Reader reader;
- try {
- reader= JSdocContentAccess.getHTMLContentReader(member, true, true);
-
- // Provide hint why there's no Javadoc
- if (reader == null && member.isBinary()) {
- boolean hasAttachedJavadoc= JavaDocLocations.getJavadocBaseLocation(member) != null;
- IPackageFragmentRoot root= (IPackageFragmentRoot)member.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- boolean hasAttachedSource= root != null && root.getSourceAttachmentPath() != null;
- IOpenable openable= member.getOpenable();
- boolean hasSource= openable.getBuffer() != null;
-
- if (!hasAttachedSource && !hasAttachedJavadoc)
- reader= new StringReader(InfoViewMessages.JavadocView_noAttachments);
- else if (!hasAttachedJavadoc && !hasSource)
- reader= new StringReader(InfoViewMessages.JavadocView_noAttachedJavadoc);
- else if (!hasAttachedSource)
- reader= new StringReader(InfoViewMessages.JavadocView_noAttachedSource);
- else if (!hasSource)
- reader= new StringReader(InfoViewMessages.JavadocView_noInformation);
- }
-
- } catch (JavaScriptModelException ex) {
- reader= new StringReader(InfoViewMessages.JavadocView_error_gettingJavadoc);
- JavaScriptPlugin.log(ex.getStatus());
- }
- if (reader != null) {
- HTMLPrinter.addParagraph(buffer, reader);
- }
- }
- }
-
- boolean flushContent= true;
- if (buffer.length() > 0 || flushContent) {
- HTMLPrinter.insertPageProlog(buffer, 0, fBackgroundColorRGB, fgStyleSheet);
- HTMLPrinter.addPageEpilog(buffer);
- return buffer.toString();
- }
-
- return null;
- }
-
- /**
- * Gets the label for the given member.
- *
- * @param member the Java member
- * @return a string containing the member's label
- */
- private String getInfoText(IMember member) {
- return JavaScriptElementLabels.getElementLabel(member, LABEL_FLAGS);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#isIgnoringNewInput(org.eclipse.wst.jsdt.core.IJavaScriptElement, org.eclipse.jface.viewers.ISelection)
- *
- */
- protected boolean isIgnoringNewInput(IJavaScriptElement je, IWorkbenchPart part, ISelection selection) {
- if (super.isIgnoringNewInput(je, part, selection)
- && part instanceof ITextEditor
- && selection instanceof ITextSelection) {
-
- ITextEditor editor= (ITextEditor)part;
- IDocumentProvider docProvider= editor.getDocumentProvider();
- if (docProvider == null)
- return false;
-
- IDocument document= docProvider.getDocument(editor.getEditorInput());
- if (!(document instanceof IDocumentExtension3))
- return false;
-
- try {
- int offset= ((ITextSelection)selection).getOffset();
- String partition= ((IDocumentExtension3)document).getContentType(IJavaScriptPartitions.JAVA_PARTITIONING, offset, false);
- return partition != IJavaScriptPartitions.JAVA_DOC;
- } catch (BadPartitioningException ex) {
- return false;
- } catch (BadLocationException ex) {
- return false;
- }
-
- }
- return false;
- }
-
- /*
- * @see AbstractInfoView#findSelectedJavaElement(IWorkbenchPart)
- */
- protected IJavaScriptElement findSelectedJavaElement(IWorkbenchPart part, ISelection selection) {
- IJavaScriptElement element;
- try {
- element= super.findSelectedJavaElement(part, selection);
-
- if (element == null && part instanceof JavaEditor && selection instanceof ITextSelection) {
-
- JavaEditor editor= (JavaEditor)part;
- ITextSelection textSelection= (ITextSelection)selection;
-
- IDocumentProvider documentProvider= editor.getDocumentProvider();
- if (documentProvider == null)
- return null;
-
- IDocument document= documentProvider.getDocument(editor.getEditorInput());
- if (document == null)
- return null;
-
- ITypedRegion typedRegion= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, textSelection.getOffset(), false);
- if (IJavaScriptPartitions.JAVA_DOC.equals(typedRegion.getType()))
- return TextSelectionConverter.getElementAtOffset((JavaEditor)part, textSelection);
- else
- return null;
- } else
- return element;
- } catch (JavaScriptModelException e) {
- return null;
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /*
- * @see AbstractInfoView#getControl()
- */
- protected Control getControl() {
- if (fIsUsingBrowserWidget)
- return fBrowser;
- else
- return fText;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getHelpContextId()
- *
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.JAVADOC_VIEW;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/SourceView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/SourceView.java
deleted file mode 100644
index 5321dc16..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/SourceView.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-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.TextViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.wst.jsdt.core.ICodeAssist;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.StubUtility;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaCodeReader;
-import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants;
-import org.eclipse.wst.jsdt.ui.actions.OpenAction;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-/**
- * View which shows source for a given Java element.
- *
- *
- */
-public class SourceView extends AbstractInfoView implements IMenuListener {
-
- /** Symbolic Java editor font name. */
- private static final String SYMBOLIC_FONT_NAME= "org.eclipse.wst.jsdt.ui.editors.textfont"; //$NON-NLS-1$
-
- /**
- * Internal property change listener for handling changes in the editor's preferences.
- *
- *
- */
- class PropertyChangeListener implements IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (fViewer == null)
- return;
-
- if (fViewerConfiguration.affectsTextPresentation(event)) {
- fViewerConfiguration.handlePropertyChangeEvent(event);
- fViewer.invalidateTextPresentation();
- }
- }
- }
-
- /**
- * Internal property change listener for handling workbench font changes.
- */
- class FontPropertyChangeListener implements IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (fViewer == null)
- return;
-
- String property= event.getProperty();
-
- if (SYMBOLIC_FONT_NAME.equals(property))
- setViewerFont();
- }
- }
-
- /**
- * The Javadoc view's select all action.
- */
- private static class SelectAllAction extends Action {
-
- private TextViewer fTextViewer;
-
- /**
- * Creates the action.
- *
- * @param textViewer the text viewer
- */
- public SelectAllAction(TextViewer textViewer) {
- super("selectAll"); //$NON-NLS-1$
-
- Assert.isNotNull(textViewer);
- fTextViewer= textViewer;
-
- setText(InfoViewMessages.SelectAllAction_label);
- setToolTipText(InfoViewMessages.SelectAllAction_tooltip);
- setDescription(InfoViewMessages.SelectAllAction_description);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION);
- }
-
- /**
- * Selects all in the viewer.
- */
- public void run() {
- fTextViewer.doOperation(ITextOperationTarget.SELECT_ALL);
- }
- }
-
- /** This view's source viewer */
- private SourceViewer fViewer;
- /** The viewers configuration */
- private JavaScriptSourceViewerConfiguration fViewerConfiguration;
- /** The viewer's font properties change listener. */
- private IPropertyChangeListener fFontPropertyChangeListener= new FontPropertyChangeListener();
- /**
- * The editor's property change listener.
- *
- */
- private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener();
- /** The open action */
- private OpenAction fOpen;
- /** The number of removed leading comment lines. */
- private int fCommentLineCount;
- /** The select all action. */
- private SelectAllAction fSelectAllAction;
- /** Element opened by the open action. */
- private IJavaScriptElement fLastOpenedElement;
-
-
- /*
- * @see AbstractInfoView#internalCreatePartControl(Composite)
- */
- protected void internalCreatePartControl(Composite parent) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
- fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
- fViewer.configure(fViewerConfiguration);
- fViewer.setEditable(false);
-
- setViewerFont();
- JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
-
- store.addPropertyChangeListener(fPropertyChangeListener);
-
- getViewSite().setSelectionProvider(fViewer);
- }
-
- /*
- * @see AbstractInfoView#internalCreatePartControl(Composite)
- */
- protected void createActions() {
- super.createActions();
- fSelectAllAction= new SelectAllAction(fViewer);
-
- // Setup OpenAction
- fOpen= new OpenAction(getViewSite()) {
-
- /*
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#getSelection()
- */
- public ISelection getSelection() {
- return convertToJavaElementSelection(fViewer.getSelection());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.actions.OpenAction#run(IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- getShell().getDisplay().beep();
- return;
- }
- super.run(selection);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.actions.OpenAction#getElementToOpen(Object)
- */
- public Object getElementToOpen(Object object) throws JavaScriptModelException {
- if (object instanceof IJavaScriptElement)
- fLastOpenedElement= (IJavaScriptElement)object;
- else
- fLastOpenedElement= null;
- return super.getElementToOpen(object);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.actions.OpenAction#run(Object[])
- */
- public void run(Object[] elements) {
- stopListeningForSelectionChanges();
- super.run(elements);
- startListeningForSelectionChanges();
- }
- };
- }
-
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getSelectAllAction()
- *
- */
- protected IAction getSelectAllAction() {
- return fSelectAllAction;
- }
-
- /*
- * @see AbstractInfoView#fillActionBars(IActionBars)
- */
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- actionBars.setGlobalActionHandler(JdtActionConstants.OPEN, fOpen);
- fOpen.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
- }
-
- /*
- * @see AbstractInfoView#getControl()
- */
- protected Control getControl() {
- return fViewer.getControl();
- }
-
- /*
- * @see AbstractInfoView#menuAboutToShow(IMenuManager)
- */
- public void menuAboutToShow(IMenuManager menu) {
- super.menuAboutToShow(menu);
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpen);
- }
-
- /*
- * @see AbstractInfoView#setForeground(Color)
- */
- protected void setForeground(Color color) {
- fViewer.getTextWidget().setForeground(color);
- }
-
- /*
- * @see AbstractInfoView#setBackground(Color)
- */
- protected void setBackground(Color color) {
- fViewer.getTextWidget().setBackground(color);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getBackgroundColorKey()
- *
- */
- protected String getBackgroundColorKey() {
- return "org.eclipse.wst.jsdt.ui.DeclarationView.backgroundColor"; //$NON-NLS-1$
- }
-
- /**
- * Converts the given selection to a structured selection
- * containing Java elements.
- *
- * @param selection the selection
- * @return a structured selection with Java elements
- */
- private IStructuredSelection convertToJavaElementSelection(ISelection selection) {
-
- if (!(selection instanceof ITextSelection && fCurrentViewInput instanceof ISourceReference))
- return StructuredSelection.EMPTY;
-
- ITextSelection textSelection= (ITextSelection)selection;
-
- Object codeAssist= fCurrentViewInput.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (codeAssist == null)
- codeAssist= fCurrentViewInput.getAncestor(IJavaScriptElement.CLASS_FILE);
-
- if (codeAssist instanceof ICodeAssist) {
- IJavaScriptElement[] elements= null;
- try {
- ISourceRange range= ((ISourceReference)fCurrentViewInput).getSourceRange();
- elements= ((ICodeAssist)codeAssist).codeSelect(range.getOffset() + getOffsetInUnclippedDocument(textSelection), textSelection.getLength());
- } catch (JavaScriptModelException e) {
- return StructuredSelection.EMPTY;
- }
- if (elements != null && elements.length > 0) {
- return new StructuredSelection(elements[0]);
- } else
- return StructuredSelection.EMPTY;
- }
-
- return StructuredSelection.EMPTY;
- }
-
- /**
- * Computes and returns the offset in the unclipped document
- * based on the given text selection from the clipped
- * document.
- *
- * @param textSelection
- * @return the offest in the unclipped document or <code>-1</code> if the offset cannot be computed
- */
- private int getOffsetInUnclippedDocument(ITextSelection textSelection) {
- IDocument unclippedDocument= null;
- try {
- unclippedDocument= new Document(((ISourceReference)fCurrentViewInput).getSource());
- } catch (JavaScriptModelException e) {
- return -1;
- }
- IDocument clippedDoc= (IDocument)fViewer.getInput();
- try {
- IRegion unclippedLineInfo= unclippedDocument.getLineInformation(fCommentLineCount + textSelection.getStartLine());
- IRegion clippedLineInfo= clippedDoc.getLineInformation(textSelection.getStartLine());
- int removedIndentation= unclippedLineInfo.getLength() - clippedLineInfo.getLength();
- int relativeLineOffset= textSelection.getOffset() - clippedLineInfo.getOffset();
- return unclippedLineInfo.getOffset() + removedIndentation + relativeLineOffset ;
- } catch (BadLocationException ex) {
- return -1;
- }
- }
-
- /*
- * @see AbstractInfoView#internalDispose()
- */
- protected void internalDispose() {
- fViewer= null;
- fViewerConfiguration= null;
- JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
- JavaScriptPlugin.getDefault().getCombinedPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- }
-
- /*
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- public void setFocus() {
- fViewer.getTextWidget().setFocus();
- }
-
- /*
- * @see AbstractInfoView#computeInput(Object)
- */
- protected Object computeInput(Object input) {
-
- if (fViewer == null || !(input instanceof ISourceReference))
- return null;
-
- ISourceReference sourceRef= (ISourceReference)input;
-
- if (fLastOpenedElement != null && input instanceof IJavaScriptElement && ((IJavaScriptElement)input).getHandleIdentifier().equals(fLastOpenedElement.getHandleIdentifier())) {
- fLastOpenedElement= null;
- return null;
- } else {
- fLastOpenedElement= null;
- }
-
- String source;
- try {
- source= sourceRef.getSource();
- } catch (JavaScriptModelException ex) {
- return ""; //$NON-NLS-1$
- }
-
- if (source == null)
- return ""; //$NON-NLS-1$
-
- source= removeLeadingComments(source);
- String delim= StubUtility.getLineDelimiterUsed((IJavaScriptElement) input);
-
- String[] sourceLines= Strings.convertIntoLines(source);
- if (sourceLines == null || sourceLines.length == 0)
- return ""; //$NON-NLS-1$
-
- String firstLine= sourceLines[0];
- boolean firstCharNotWhitespace= firstLine != null && firstLine.length() > 0 && !Character.isWhitespace(firstLine.charAt(0));
- if (firstCharNotWhitespace)
- sourceLines[0]= ""; //$NON-NLS-1$
- IJavaScriptProject project;
- if (input instanceof IJavaScriptElement)
- project= ((IJavaScriptElement) input).getJavaScriptProject();
- else
- project= null;
- Strings.trimIndentation(sourceLines, project);
-
- if (firstCharNotWhitespace)
- sourceLines[0]= firstLine;
-
- return Strings.concatenate(sourceLines, delim);
- }
-
- /*
- * @see AbstractInfoView#setInput(Object)
- */
- protected void setInput(Object input) {
- if (input instanceof IDocument)
- fViewer.setInput(input);
- else if (input == null)
- fViewer.setInput(new Document("")); //$NON-NLS-1$
- else {
- IDocument document= new Document(input.toString());
- JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- fViewer.setInput(document);
- }
- }
-
- /**
- * Removes the leading comments from the given source.
- *
- * @param source the string with the source
- * @return the source without leading comments
- */
- private String removeLeadingComments(String source) {
- JavaCodeReader reader= new JavaCodeReader();
- IDocument document= new Document(source);
- int i;
- try {
- reader.configureForwardReader(document, 0, document.getLength(), true, false);
- int c= reader.read();
- while (c != -1 && (c == '\r' || c == '\n' || c == '\t')) {
- c= reader.read();
- }
- i= reader.getOffset();
- reader.close();
- } catch (IOException ex) {
- i= 0;
- } finally {
- try {
- if (reader != null)
- reader.close();
- } catch (IOException ex) {
- JavaScriptPlugin.log(ex);
- }
- }
-
- try {
- fCommentLineCount= document.getLineOfOffset(i);
- } catch (BadLocationException e) {
- fCommentLineCount= 0;
- }
-
- if (i < 0)
- return source;
-
- return source.substring(i);
- }
-
- /**
- * Sets the font for this viewer sustaining selection and scroll position.
- */
- private void setViewerFont() {
- Font font= JFaceResources.getFont(SYMBOLIC_FONT_NAME);
-
- if (fViewer.getDocument() != null) {
-
- Point selection= fViewer.getSelectedRange();
- int topIndex= fViewer.getTopIndex();
-
- StyledText styledText= fViewer.getTextWidget();
- Control parent= fViewer.getControl();
-
- parent.setRedraw(false);
-
- styledText.setFont(font);
-
- fViewer.setSelectedRange(selection.x , selection.y);
- fViewer.setTopIndex(topIndex);
-
- if (parent instanceof Composite) {
- Composite composite= (Composite) parent;
- composite.layout(true);
- }
-
- parent.setRedraw(true);
-
-
- } else {
- StyledText styledText= fViewer.getTextWidget();
- styledText.setFont(font);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView#getHelpContextId()
- *
- */
- protected String getHelpContextId() {
- return IJavaHelpContextIds.SOURCE_VIEW;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/TextSelectionConverter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/TextSelectionConverter.java
deleted file mode 100644
index 89edb07e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/infoviews/TextSelectionConverter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.infoviews;
-
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.ICodeAssist;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-
-/**
- * Helper class to convert text selections to Java elements.
- *
- *
- */
-class TextSelectionConverter {
-
- /** Empty result. */
- private static final IJavaScriptElement[] EMPTY_RESULT= new IJavaScriptElement[0];
-
- /** Prevent instance creation. */
- private TextSelectionConverter() {
- }
-
- /**
- * Finds and returns the Java elements for the given editor selection.
- *
- * @param editor the Java editor
- * @param selection the text selection
- * @return the Java elements for the given editor selection
- * @throws JavaScriptModelException
- */
- public static IJavaScriptElement[] codeResolve(JavaEditor editor, ITextSelection selection) throws JavaScriptModelException {
- return codeResolve(getInput(editor), selection);
- }
-
- /**
- * Finds and returns the Java element that contains the
- * text selection in the given editor.
- *
- * @param editor the Java editor
- * @param selection the text selection
- * @return the Java elements for the given editor selection
- * @throws JavaScriptModelException
- */
- public static IJavaScriptElement getElementAtOffset(JavaEditor editor, ITextSelection selection) throws JavaScriptModelException {
- return getElementAtOffset(getInput(editor), selection);
- }
-
- //-------------------- Helper methods --------------------
-
- private static IJavaScriptElement getInput(JavaEditor editor) {
- if (editor == null)
- return null;
- IEditorInput input= editor.getEditorInput();
- if (input instanceof IClassFileEditorInput)
- return ((IClassFileEditorInput)input).getClassFile();
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- return manager.getWorkingCopy(input);
- }
-
- private static IJavaScriptElement[] codeResolve(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof ICodeAssist) {
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cunit= (IJavaScriptUnit)input;
- if (cunit.isWorkingCopy())
- JavaModelUtil.reconcile(cunit);
- }
- IJavaScriptElement[] elements= ((ICodeAssist)input).codeSelect(selection.getOffset(), selection.getLength());
- if (elements != null && elements.length > 0)
- return elements;
- }
- return EMPTY_RESULT;
- }
-
- private static IJavaScriptElement getElementAtOffset(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cunit= (IJavaScriptUnit)input;
- if (cunit.isWorkingCopy())
- JavaModelUtil.reconcile(cunit);
- IJavaScriptElement ref= cunit.getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- } else if (input instanceof IClassFile) {
- IJavaScriptElement ref= ((IClassFile)input).getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CheckboxTreeAndListGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CheckboxTreeAndListGroup.java
deleted file mode 100644
index 17e43b56..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CheckboxTreeAndListGroup.java
+++ /dev/null
@@ -1,804 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-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.ITreeContentProvider;
-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.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-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.Table;
-import org.eclipse.swt.widgets.Tree;
-
-/**
- * Combines a CheckboxTreeViewer and CheckboxListViewer.
- * All viewer selection-driven interactions are handled within this viewer
- */
-public class CheckboxTreeAndListGroup implements ICheckStateListener, ISelectionChangedListener, ITreeViewerListener {
-
- private Object fRoot;
- private Object fCurrentTreeSelection;
- private List fExpandedTreeNodes= new ArrayList();
- private Map fCheckedStateStore= new HashMap(9);
- private List fWhiteCheckedTreeItems= new ArrayList();
- private List fListeners= new ArrayList();
-
- private ITreeContentProvider fTreeContentProvider;
- private IStructuredContentProvider fListContentProvider;
- private ILabelProvider fTreeLabelProvider;
- private ILabelProvider fListLabelProvider;
-
- // widgets
- private CheckboxTreeViewer fTreeViewer;
- private CheckboxTableViewer fListViewer;
-
- /**
- * Creates an instance of this class. Use this constructor if you wish to specify
- * the width and/or height of the combined widget (to only hardcode one of the
- * sizing dimensions, specify the other dimension's value as -1)
- */
- public CheckboxTreeAndListGroup(
- Composite parent,
- Object rootObject,
- ITreeContentProvider treeContentProvider,
- ILabelProvider treeLabelProvider,
- IStructuredContentProvider listContentProvider,
- ILabelProvider listLabelProvider,
- int style,
- int width,
- int height) {
- fRoot= rootObject;
- fTreeContentProvider= treeContentProvider;
- fListContentProvider= listContentProvider;
- fTreeLabelProvider= treeLabelProvider;
- fListLabelProvider= listLabelProvider;
- createContents(parent, width, height, style);
- }
- /**
- * This method must be called just before this window becomes visible.
- */
- public void aboutToOpen() {
- determineWhiteCheckedDescendents(fRoot);
- checkNewTreeElements(getTreeChildren(fRoot));
- fCurrentTreeSelection= null;
-
- //select the first element in the list
- Object[] elements= getTreeChildren(fRoot);
- Object primary= elements.length > 0 ? elements[0] : null;
- if (primary != null) {
- fTreeViewer.setSelection(new StructuredSelection(primary));
- }
- fTreeViewer.getControl().setFocus();
- }
- /**
- * Adds the passed listener to self's collection of clients
- * that listen for changes to element checked states
- *
- * @param listener ICheckStateListener
- */
- public void addCheckStateListener(ICheckStateListener listener) {
- fListeners.add(listener);
- }
- /**
- * Adds the receiver and all of it's ancestors to the checkedStateStore if they
- * are not already there.
- */
- private void addToHierarchyToCheckedStore(Object treeElement) {
-
- // if this tree element is already gray then its ancestors all are as well
- if (!fCheckedStateStore.containsKey(treeElement))
- fCheckedStateStore.put(treeElement, new ArrayList());
-
- Object parent= fTreeContentProvider.getParent(treeElement);
- if (parent != null)
- addToHierarchyToCheckedStore(parent);
- }
- /**
- * Returns a boolean indicating whether all children of the passed tree element
- * are currently white-checked
- *
- * @return boolean
- * @param treeElement java.lang.Object
- */
- protected boolean areAllChildrenWhiteChecked(Object treeElement) {
- Object[] children= getTreeChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- if (!fWhiteCheckedTreeItems.contains(children[i]))
- return false;
- }
-
- return true;
- }
- /**
- * Returns a boolean indicating whether all list elements associated with
- * the passed tree element are currently checked
- *
- * @return boolean
- * @param treeElement java.lang.Object
- */
- protected boolean areAllElementsChecked(Object treeElement) {
- List checkedElements= (List)fCheckedStateStore.get(treeElement);
- if (checkedElements == null) // ie.- tree item not even gray-checked
- return false;
-
- return getListItemsSize(treeElement) == checkedElements.size();
- }
- /**
- * Iterates through the passed elements which are being realized for the first
- * time and check each one in the tree viewer as appropriate
- */
- protected void checkNewTreeElements(Object[] elements) {
- for (int i= 0; i < elements.length; ++i) {
- Object currentElement= elements[i];
- boolean checked= fCheckedStateStore.containsKey(currentElement);
- fTreeViewer.setChecked(currentElement, checked);
- fTreeViewer.setGrayed(
- currentElement,
- checked && !fWhiteCheckedTreeItems.contains(currentElement));
- }
- }
- /**
- * An item was checked in one of self's two views. Determine which
- * view this occurred in and delegate appropriately
- *
- * @param event CheckStateChangedEvent
- */
- public void checkStateChanged(final CheckStateChangedEvent event) {
-
- //Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- if (event.getCheckable().equals(fTreeViewer))
- treeItemChecked(event.getElement(), event.getChecked());
- else
- listItemChecked(event.getElement(), event.getChecked(), true);
-
- notifyCheckStateChangeListeners(event);
- }
- });
- }
- /**
- * Lay out and initialize self's visual components.
- *
- * @param parent org.eclipse.swt.widgets.Composite
- * @param width int
- * @param height int
- */
- protected void createContents(
- Composite parent,
- int width,
- int height,
- int style) {
- // group pane
- Composite composite= new Composite(parent, style);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.makeColumnsEqualWidth= true;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createTreeViewer(composite, width / 2, height);
- createListViewer(composite, width / 2, height);
-
- initialize();
- }
- /**
- * Creates this group's list viewer.
- */
- protected void createListViewer(Composite parent, int width, int height) {
- fListViewer= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
- fListViewer.setUseHashlookup(true);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= width;
- data.heightHint= height;
- fListViewer.getTable().setLayoutData(data);
- fListViewer.setContentProvider(fListContentProvider);
- fListViewer.setLabelProvider(fListLabelProvider);
- fListViewer.addCheckStateListener(this);
- }
- /**
- * Creates this group's tree viewer.
- */
- protected void createTreeViewer(Composite parent, int width, int height) {
- Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= width;
- data.heightHint= height;
- tree.setLayoutData(data);
-
- fTreeViewer= new CheckboxTreeViewer(tree);
- fTreeViewer.setUseHashlookup(true);
- fTreeViewer.setContentProvider(fTreeContentProvider);
- fTreeViewer.setLabelProvider(fTreeLabelProvider);
- fTreeViewer.addTreeListener(this);
- fTreeViewer.addCheckStateListener(this);
- fTreeViewer.addSelectionChangedListener(this);
- }
- /**
- * Returns a boolean indicating whether the passed tree element should be
- * at LEAST gray-checked. Note that this method does not consider whether
- * it should be white-checked, so a specified tree item which should be
- * white-checked will result in a <code>true</code> answer from this method.
- * To determine whether a tree item should be white-checked use method
- * #determineShouldBeWhiteChecked(Object).
- *
- * @param treeElement java.lang.Object
- * @return boolean
- * @see #determineShouldBeWhiteChecked(java.lang.Object)
- */
- protected boolean determineShouldBeAtLeastGrayChecked(Object treeElement) {
- // if any list items associated with treeElement are checked then it
- // retains its gray-checked status regardless of its children
- List checked= (List) fCheckedStateStore.get(treeElement);
- if (checked != null && (!checked.isEmpty()))
- return true;
-
- // if any children of treeElement are still gray-checked then treeElement
- // must remain gray-checked as well
- Object[] children= getTreeChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- if (fCheckedStateStore.containsKey(children[i]))
- return true;
- }
-
- return false;
- }
- /**
- * Returns a boolean indicating whether the passed tree item should be
- * white-checked.
- *
- * @return boolean
- * @param treeElement java.lang.Object
- */
- protected boolean determineShouldBeWhiteChecked(Object treeElement) {
- return areAllChildrenWhiteChecked(treeElement)
- && areAllElementsChecked(treeElement);
- }
- /**
- * Recursively adds appropriate tree elements to the collection of
- * known white-checked tree elements.
- *
- * @param treeElement java.lang.Object
- */
- protected void determineWhiteCheckedDescendents(Object treeElement) {
- // always go through all children first since their white-checked
- // statuses will be needed to determine the white-checked status for
- // this tree element
- Object[] children= getTreeChildren(treeElement);
- for (int i= 0; i < children.length; ++i)
- determineWhiteCheckedDescendents(children[i]);
-
- // now determine the white-checked status for this tree element
- if (determineShouldBeWhiteChecked(treeElement))
- setWhiteChecked(treeElement, true);
- }
- /**
- * Causes the tree viewer to expand all its items
- */
- public void expandAll() {
- fTreeViewer.expandAll();
- }
- /**
- * Answers a flat collection of all of the checked elements in the
- * list portion of self
- *
- * @return java.util.Vector
- */
- public Iterator getAllCheckedListItems() {
- Set result= new HashSet();
- Iterator listCollectionsEnum= fCheckedStateStore.values().iterator();
- while (listCollectionsEnum.hasNext())
- result.addAll((List)listCollectionsEnum.next());
- return result.iterator();
- }
- /**
- * Answer a collection of all of the checked elements in the tree portion
- * of self
- *
- * @return java.util.Vector
- */
- public Set getAllCheckedTreeItems() {
- return new HashSet(fCheckedStateStore.keySet());
- }
- /**
- * Answers the number of elements that have been checked by the
- * user.
- *
- * @return int
- */
- public int getCheckedElementCount() {
- return fCheckedStateStore.size();
- }
- /**
- * Returns a count of the number of list items associated with a
- * given tree item.
- *
- * @return int
- * @param treeElement java.lang.Object
- */
- protected int getListItemsSize(Object treeElement) {
- Object[] elements= getListElements(treeElement);
- return elements.length;
- }
- /**
- * Gets the table that displays the folder content
- *
- * @return the table used to show the list
- */
- public Table getTable() {
- return fListViewer.getTable();
- }
- /**
- * Gets the tree that displays the list for a folder
- *
- * @return the tree used to show the folders
- */
- public Tree getTree() {
- return fTreeViewer.getTree();
- }
- /**
- * Adds the given filter to the tree viewer and
- * triggers refiltering and resorting of the elements.
- *
- * @param filter a viewer filter
- */
- public void addTreeFilter(ViewerFilter filter) {
- fTreeViewer.addFilter(filter);
- }
- /**
- * Adds the given filter to the list viewer and
- * triggers refiltering and resorting of the elements.
- *
- * @param filter a viewer filter
- */
- public void addListFilter(ViewerFilter filter) {
- fListViewer.addFilter(filter);
- }
- /**
- * Logically gray-check all ancestors of treeItem by ensuring that they
- * appear in the checked table
- */
- protected void grayCheckHierarchy(Object treeElement) {
-
- // if this tree element is already gray then its ancestors all are as well
- if (fCheckedStateStore.containsKey(treeElement))
- return; // no need to proceed upwards from here
-
- fCheckedStateStore.put(treeElement, new ArrayList());
- if (determineShouldBeWhiteChecked(treeElement)) {
- setWhiteChecked(treeElement, true);
- }
- Object parent= fTreeContentProvider.getParent(treeElement);
- if (parent != null)
- grayCheckHierarchy(parent);
- }
- /**
- * Sets the initial checked state of the passed list element to true.
- */
- public void initialCheckListItem(Object element) {
- Object parent= fTreeContentProvider.getParent(element);
- fCurrentTreeSelection= parent;
- //As this is not done from the UI then set the box for updating from the selection to false
- listItemChecked(element, true, false);
- updateHierarchy(parent);
- }
- /**
- * Sets the initial checked state of the passed element to true,
- * as well as to all of its children and associated list elements
- */
- public void initialCheckTreeItem(Object element) {
- treeItemChecked(element, true);
- }
- /**
- * Initializes this group's viewers after they have been laid out.
- */
- protected void initialize() {
- fTreeViewer.setInput(fRoot);
- }
- /**
- * Callback that's invoked when the checked status of an item in the list
- * is changed by the user. Do not try and update the hierarchy if we are building the
- * initial list.
- */
- protected void listItemChecked(
- Object listElement,
- boolean state,
- boolean updatingFromSelection) {
- List checkedListItems= (List) fCheckedStateStore.get(fCurrentTreeSelection);
-
- if (state) {
- if (checkedListItems == null) {
- // since the associated tree item has gone from 0 -> 1 checked
- // list items, tree checking may need to be updated
- grayCheckHierarchy(fCurrentTreeSelection);
- checkedListItems= (List) fCheckedStateStore.get(fCurrentTreeSelection);
- }
- checkedListItems.add(listElement);
- } else {
- checkedListItems.remove(listElement);
- if (checkedListItems.isEmpty()) {
- // since the associated tree item has gone from 1 -> 0 checked
- // list items, tree checking may need to be updated
- ungrayCheckHierarchy(fCurrentTreeSelection);
- }
- }
-
- if (updatingFromSelection)
- updateHierarchy(fCurrentTreeSelection);
- }
- /**
- * Notifies all checked state listeners that the passed element has had
- * its checked state changed to the passed state
- */
- protected void notifyCheckStateChangeListeners(CheckStateChangedEvent event) {
- Iterator listenersEnum= fListeners.iterator();
- while (listenersEnum.hasNext())
- ((ICheckStateListener) listenersEnum.next()).checkStateChanged(event);
- }
- /**
- *Sets the contents of the list viewer based upon the specified selected
- *tree element. This also includes checking the appropriate list items.
- *
- *@param treeElement java.lang.Object
- */
- protected void populateListViewer(final Object treeElement) {
- if (treeElement == fCurrentTreeSelection)
- return;
- fCurrentTreeSelection= treeElement;
- fListViewer.setInput(treeElement);
- List listItemsToCheck= (List) fCheckedStateStore.get(treeElement);
-
- if (listItemsToCheck != null) {
- Iterator listItemsEnum= listItemsToCheck.iterator();
- while (listItemsEnum.hasNext())
- fListViewer.setChecked(listItemsEnum.next(), true);
- }
- }
- /**
- * Removes the passed listener from self's collection of clients
- * that listen for changes to element checked states
- *
- * @param listener ICheckStateListener
- */
- public void removeCheckStateListener(ICheckStateListener listener) {
- fListeners.remove(listener);
- }
- /**
- * Handles the selection of an item in the tree viewer
- *
- * @param event ISelection
- */
- public void selectionChanged(final SelectionChangedEvent event) {
- BusyIndicator.showWhile(getTable().getShell().getDisplay(), new Runnable() {
- public void run() {
- IStructuredSelection selection= (IStructuredSelection) event.getSelection();
- Object selectedElement= selection.getFirstElement();
- if (selectedElement == null) {
- fCurrentTreeSelection= null;
- fListViewer.setInput(fCurrentTreeSelection);
- return;
- }
- populateListViewer(selectedElement);
- }
- });
- }
-
- /**
- * Selects or deselect all of the elements in the tree depending on the value of the selection
- * boolean. Be sure to update the displayed files as well.
- */
- public void setAllSelections(final boolean selection) {
-
- //Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- setTreeChecked(fRoot, selection);
- fListViewer.setAllChecked(selection);
- }
- });
- }
-
- /**
- * Sets the list viewer's providers to those passed
- *
- * @param contentProvider ITreeContentProvider
- * @param labelProvider ILabelProvider
- */
- public void setListProviders(
- IStructuredContentProvider contentProvider,
- ILabelProvider labelProvider) {
- fListViewer.setContentProvider(contentProvider);
- fListViewer.setLabelProvider(labelProvider);
- }
- /**
- * Sets the sorter that is to be applied to self's list viewer
- */
- public void setListComparator(ViewerComparator comparator) {
- fListViewer.setComparator(comparator);
- }
- /**
- * Sets the root of the widget to be new Root. Regenerate all of the tables and lists from this
- * value.
- *
- * @param newRoot
- */
- public void setRoot(Object newRoot) {
- this.fRoot= newRoot;
- initialize();
- }
- /**
- * Sets the checked state of the passed tree element appropriately, and
- * do so recursively to all of its child tree elements as well
- */
- protected void setTreeChecked(Object treeElement, boolean state) {
-
- if (treeElement.equals(fCurrentTreeSelection)) {
- fListViewer.setAllChecked(state);
- }
-
- if (state) {
- Object[] listItems= getListElements(treeElement);
- List listItemsChecked= new ArrayList();
- for (int i= 0; i < listItems.length; ++i)
- listItemsChecked.add(listItems[i]);
-
- fCheckedStateStore.put(treeElement, listItemsChecked);
- } else
- fCheckedStateStore.remove(treeElement);
-
- setWhiteChecked(treeElement, state);
- fTreeViewer.setChecked(treeElement, state);
- fTreeViewer.setGrayed(treeElement, false);
-
- // now logically check/uncheck all children as well
- Object[] children= getTreeChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- setTreeChecked(children[i], state);
- }
- }
- /**
- * Sets the tree viewer's providers to those passed
- *
- * @param contentProvider ITreeContentProvider
- * @param labelProvider ILabelProvider
- */
- public void setTreeProviders(
- ITreeContentProvider contentProvider,
- ILabelProvider labelProvider) {
- fTreeViewer.setContentProvider(contentProvider);
- fTreeViewer.setLabelProvider(labelProvider);
- }
- /**
- * Sets the sorter that is to be applied to self's tree viewer
- */
- public void setTreeComparator(ViewerComparator sorter) {
- fTreeViewer.setComparator(sorter);
- }
- /**
- * Adjusts the collection of references to white-checked tree elements appropriately.
- *
- * @param treeElement java.lang.Object
- * @param isWhiteChecked boolean
- */
- protected void setWhiteChecked(Object treeElement, boolean isWhiteChecked) {
- if (isWhiteChecked) {
- if (!fWhiteCheckedTreeItems.contains(treeElement))
- fWhiteCheckedTreeItems.add(treeElement);
- } else
- fWhiteCheckedTreeItems.remove(treeElement);
- }
- /**
- * Handle the collapsing of an element in a tree viewer
- */
- public void treeCollapsed(TreeExpansionEvent event) {
- // We don't need to do anything with this
- }
-
- /**
- * Handles the expansionsion of an element in a tree viewer
- */
- public void treeExpanded(TreeExpansionEvent event) {
-
- Object item= event.getElement();
-
- // First see if the children need to be given their checked state at all. If they've
- // already been realized then this won't be necessary
- if (!fExpandedTreeNodes.contains(item)) {
- fExpandedTreeNodes.add(item);
- checkNewTreeElements(getTreeChildren(item));
- }
- }
-
- /**
- * Callback that's invoked when the checked status of an item in the tree
- * is changed by the user.
- */
- protected void treeItemChecked(Object treeElement, boolean state) {
-
- // recursively adjust all child tree elements appropriately
- setTreeChecked(treeElement, state);
-
- Object parent= fTreeContentProvider.getParent(treeElement);
- if (parent == null)
- return;
-
- // now update upwards in the tree hierarchy
- if (state)
- grayCheckHierarchy(parent);
- else
- ungrayCheckHierarchy(parent);
-
- updateHierarchy(treeElement);
- }
- /**
- * Logically un-gray-check all ancestors of treeItem iff appropriate.
- */
- protected void ungrayCheckHierarchy(Object treeElement) {
- if (!determineShouldBeAtLeastGrayChecked(treeElement))
- fCheckedStateStore.remove(treeElement);
-
- Object parent= fTreeContentProvider.getParent(treeElement);
- if (parent != null)
- ungrayCheckHierarchy(parent);
- }
- /**
- * Sets the checked state of self and all ancestors appropriately
- */
- protected void updateHierarchy(Object treeElement) {
-
- boolean whiteChecked= determineShouldBeWhiteChecked(treeElement);
- boolean shouldBeAtLeastGray= determineShouldBeAtLeastGrayChecked(treeElement);
-
- fTreeViewer.setChecked(treeElement, whiteChecked || shouldBeAtLeastGray);
- setWhiteChecked(treeElement, whiteChecked);
- if (whiteChecked)
- fTreeViewer.setGrayed(treeElement, false);
- else
- fTreeViewer.setGrayed(treeElement, shouldBeAtLeastGray);
-
- // proceed up the tree element hierarchy
- Object parent= fTreeContentProvider.getParent(treeElement);
- if (parent != null) {
- updateHierarchy(parent);
- }
- }
- /**
- * Update the selections of the tree elements in items to reflect the new
- * selections provided.
- *
- * @param items with keys of Object (the tree element) and values of List (the selected
- * list elements).
- */
- public void updateSelections(final Map items) {
-
- //Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- handleUpdateSelection(items);
- }
- });
- }
- /**
- * Returns the result of running the given elements through the filters.
- *
- * @param elements the elements to filter
- * @return only the elements which all filters accept
- */
- protected Object[] filter(ViewerFilter[] filters, Object[] elements) {
- if (filters != null) {
- ArrayList filtered = new ArrayList(elements.length);
- for (int i = 0; i < elements.length; i++) {
- boolean add = true;
- for (int j = 0; j < filters.length; j++) {
- add = filters[j].select(null, null, elements[i]);
- if (!add)
- break;
- }
- if (add)
- filtered.add(elements[i]);
- }
- return filtered.toArray();
- }
- return elements;
- }
-
- private Object[] getTreeChildren(Object element) {
- return filter(fTreeViewer.getFilters(), fTreeContentProvider.getChildren(element));
- }
-
- private Object[] getListElements(Object element) {
- return filter(fListViewer.getFilters(), fListContentProvider.getElements(element));
- }
-
- public Set getWhiteCheckedTreeItems() {
- return new HashSet(fWhiteCheckedTreeItems);
- }
-
- private void handleUpdateSelection(Map items) {
- Iterator keyIterator= items.keySet().iterator();
-
- //Update the store before the hierarchy to prevent updating parents before all of the children are done
- while (keyIterator.hasNext()) {
- Object key= keyIterator.next();
- //Replace the items in the checked state store with those from the supplied items
- List selections= (List) items.get(key);
- if (selections.size() == 0)
- //If it is empty remove it from the list
- fCheckedStateStore.remove(key);
- else {
- fCheckedStateStore.put(key, selections);
- // proceed up the tree element hierarchy
- Object parent= fTreeContentProvider.getParent(key);
- if (parent != null) {
- addToHierarchyToCheckedStore(parent);
- }
- }
- }
-
- //Now update hierarchies
- keyIterator= items.keySet().iterator();
-
- while (keyIterator.hasNext()) {
- Object key= keyIterator.next();
- updateHierarchy(key);
- if (fCurrentTreeSelection != null && fCurrentTreeSelection.equals(key)) {
- fListViewer.setAllChecked(false);
- fListViewer.setCheckedElements(((List) items.get(key)).toArray());
- }
- }
- }
-
- /**
- * Checks if an element is grey checked.
- */
- public boolean isTreeItemGreyChecked(Object object) {
- return fTreeViewer.getGrayed(object);
- }
-
- /**
- * For a given element, expand its chidren to a level.
- */
- public void expandTreeToLevel(Object object, int level) {
- fTreeViewer.expandToLevel(object, level);
- }
- /**
- * @param selection
- */
- public void setTreeSelection(ISelection selection) {
- fTreeViewer.setSelection(selection);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CreateJavadocActionDelegate.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CreateJavadocActionDelegate.java
deleted file mode 100644
index b7e51f8e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/CreateJavadocActionDelegate.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class CreateJavadocActionDelegate implements IObjectActionDelegate {
-
- private ISelection fCurrentSelection;
- private Shell fCurrentShell;
-
- /*
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fCurrentShell= targetPart.getSite().getShell();
- }
-
- /*
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- if (fCurrentSelection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) fCurrentSelection;
- Object first= structuredSelection.getFirstElement();
- if (first instanceof IFile) {
- JavadocWizard wizard= new JavadocWizard((IFile) first);
- JavadocWizard.openJavadocWizard(wizard, fCurrentShell, structuredSelection);
- }
- }
- }
-
- /*
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fCurrentSelection= selection;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocConsoleLineTracker.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocConsoleLineTracker.java
deleted file mode 100644
index 13d1ebdc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocConsoleLineTracker.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.ui.console.IConsole;
-import org.eclipse.debug.ui.console.IConsoleLineTracker;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.console.IHyperlink;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavadocConsoleLineTracker implements IConsoleLineTracker {
-
- private static class JavadocConsoleHyperLink implements IHyperlink {
-
- private IPath fExternalPath;
- private int fLineNumber;
-
- public JavadocConsoleHyperLink(IPath externalPath, int lineNumber) {
- fExternalPath= externalPath;
- fLineNumber= lineNumber;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkEntered()
- */
- public void linkEntered() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkExited()
- */
- public void linkExited() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkActivated()
- */
- public void linkActivated() {
- try {
- IFile[] files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(fExternalPath);
- if (files.length > 0) {
- for (int i = 0; i < files.length; i++) {
- IFile curr= files[0];
- IJavaScriptElement element= JavaScriptCore.create(curr);
- if (element != null && element.exists()) {
- IEditorPart part= JavaScriptUI.openInEditor(element, true, false);
- if (part instanceof ITextEditor) {
- revealLine((ITextEditor) part, fLineNumber);
- }
- return;
- }
- }
- }
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- } catch (PartInitException e) {
- JavaScriptPlugin.log(e);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- private void revealLine(ITextEditor editor, int lineNumber) throws BadLocationException {
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- IRegion region= document.getLineInformation(lineNumber - 1);
- editor.selectAndReveal(region.getOffset(), 0);
- }
-
- }
-
-
- private IConsole fConsole;
-
- /**
- *
- */
- public JavadocConsoleLineTracker() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleLineTracker#init(org.eclipse.debug.ui.console.IConsole)
- */
- public void init(IConsole console) {
- fConsole= console;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleLineTracker#lineAppended(org.eclipse.jface.text.IRegion)
- */
- public void lineAppended(IRegion line) {
- try {
- int offset = line.getOffset();
- int length = line.getLength();
- String text = fConsole.getDocument().get(offset, length);
-
- int index1= text.indexOf(':');
- if (index1 == -1) {
- return;
- }
-
- int lineNumber= -1;
- IPath path= null;
- int index2= text.indexOf(':', index1 + 1);
- while ((index2 != -1) && (path == null)) {
- if (index1 < index2) {
- try {
- String substr= text.substring(index1 + 1, index2);
- lineNumber= Integer.parseInt(substr);
- path= Path.fromOSString(text.substring(0, index1));
- } catch (NumberFormatException e) {
- // ignore
- }
- }
- index1= index2;
- index2= text.indexOf(':', index1 + 1);
- }
-
- if (lineNumber != -1) {
- JavadocConsoleHyperLink link= new JavadocConsoleHyperLink(path, lineNumber);
- fConsole.addLink(link, line.getOffset(), index1);
-
- }
- } catch (BadLocationException e) {
- // ignore
- }
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsoleLineTracker#dispose()
- */
- public void dispose() {
- fConsole = null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.java
deleted file mode 100644
index 9ff6e643..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class JavadocExportMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.javadocexport.JavadocExportMessages";//$NON-NLS-1$
-
- private JavadocExportMessages() {
- // Do not instantiate
- }
-
- public static String JavadocSpecificsWizardPage_description;
- public static String JavadocSpecificsWizardPage_stylesheetbrowsedialog_title;
- public static String JavadocSpecificsWizardPage_overviewbutton_label;
- public static String JavadocSpecificsWizardPage_overviewbrowse_label;
- public static String JavadocSpecificsWizardPage_extraoptionsfield_label;
- public static String JavadocSpecificsWizardPage_vmoptionsfield_label;
- public static String JavadocSpecificsWizardPage_overviewbrowsedialog_title;
- public static String JavadocSpecificsWizardPage_antscriptbutton_label;
- public static String JavadocSpecificsWizardPage_antscripttext_label;
- public static String JavadocSpecificsWizardPage_antscriptbrowse_label;
- public static String JavadocSpecificsWizardPage_openbrowserbutton_label;
- public static String JavadocSpecificsWizardPage_antscriptbrowsedialog_title;
- public static String JavadocSpecificsWizardPage_antscriptbrowsedialog_label;
-// public static String JavadocSpecificsWizardPage_sourcecompatibility_label;
- public static String JavadocSpecificsWizardPage_overviewnotfound_error;
- public static String JavadocSpecificsWizardPage_overviewincorrect_error;
- public static String JavadocSpecificsWizardPage_antfileincorrect_error;
- public static String JavadocSpecificsWizardPage_antfileoverwrite_warning;
- public static String JavadocTreeWizardPage_javadoctreewizardpage_description;
- public static String JavadocTreeWizardPage_checkboxtreeandlistgroup_label;
- public static String JavadocTreeWizardPage_visibilitygroup_label;
- public static String JavadocTreeWizardPage_privatebutton_label;
- public static String JavadocTreeWizardPage_packagebutton_label;
- public static String JavadocTreeWizardPage_protectedbutton_label;
- public static String JavadocTreeWizardPage_publicbutton_label;
- public static String JavadocTreeWizardPage_standarddocletbutton_label;
- public static String JavadocTreeWizardPage_destinationfield_label;
- public static String JavadocTreeWizardPage_destinationbrowse_label;
- public static String JavadocTreeWizardPage_customdocletbutton_label;
- public static String JavadocTreeWizardPage_docletnamefield_label;
- public static String JavadocTreeWizardPage_docletpathfield_label;
- public static String JavadocTreeWizardPage_destinationbrowsedialog_title;
- public static String JavadocTreeWizardPage_destinationbrowsedialog_label;
- public static String JavadocTreeWizardPage_nodocletname_error;
- public static String JavadocTreeWizardPage_invaliddocletname_error;
- public static String JavadocTreeWizardPage_invaliddocletpath_error;
- public static String JavadocTreeWizardPage_nodestination_error;
- public static String JavadocTreeWizardPage_invaliddestination_error;
- public static String JavadocTreeWizardPage_invalidtreeselection_error;
- public static String JavadocTreeWizardPage_javadoccmd_dialog_title;
- public static String JavadocTreeWizardPage_javadoccmd_error_enterpath;
- public static String JavadocTreeWizardPage_javadoccmd_error_notexists;
- public static String JavadocWizardPage_javadocwizardpage_description;
- public static String JavadocWizard_javadocwizard_title;
- public static String JavadocWizard_updatejavadoclocation_message;
- public static String JavadocWizard_updatejavadocdialog_label;
- public static String JavadocWizard_javadocprocess_label;
- public static String JavadocWizard_launchconfig_name;
- public static String JavadocWizard_error_title;
- public static String JavadocWizard_launch_error_message;
- public static String JavadocWizard_exec_error_message;
- public static String JavadocWizard_error_writeANT_title;
- public static String JavadocWizard_error_writeANT_message;
- public static String JavadocOptionsManager_antfileincorrectCE_warning;
- public static String JavadocOptionsManager_antfileincorrectIOE_warning;
- public static String JavadocOptionsManager_antfileincorrectSAXE_warning;
- public static String JavadocOptionsManager_createXM_error;
- public static String JavadocStandardWizardPage_description;
- public static String JavadocStandardWizardPage_titlebutton_label;
- public static String JavadocStandardWizardPage_basicgroup_label;
- public static String JavadocStandardWizardPage_usebutton_label;
- public static String JavadocStandardWizardPage_hierarchybutton_label;
- public static String JavadocStandardWizardPage_navigartorbutton_label;
- public static String JavadocStandardWizardPage_indexbutton_label;
- public static String JavadocStandardWizardPage_seperateindexbutton_label;
- public static String JavadocStandardWizardPage_tagsgroup_label;
- public static String JavadocStandardWizardPage_authorbutton_label;
- public static String JavadocStandardWizardPage_nojarlinkref_error;
- public static String JavadocStandardWizardPage_versionbutton_label;
- public static String JavadocStandardWizardPage_deprecatedbutton_label;
- public static String JavadocStandardWizardPage_deprecatedlistbutton_label;
- public static String JavadocStandardWizardPage_stylesheettext_label;
- public static String JavadocStandardWizardPage_selectallbutton_label;
- public static String JavadocStandardWizardPage_clearallbutton_label;
- public static String JavadocStandardWizardPage_referencedclasses_label;
- public static String JavadocStandardWizardPage_stylesheetnopath_error;
- public static String JavadocStandardWizardPage_stylesheetnotcss_error;
- public static String JavadocStandardWizardPage_stylesheetbrowsebutton_label;
- public static String JavadocStandardWizardPage_configurebutton_label;
- public static String JavadocStandardWizardPage_configurecontainer_error_title;
- public static String JavadocStandardWizardPage_configurecontainer_error_message;
- public static String JavadocStandardWizardPage_javadocpropertydialog_title;
- public static String JavadocStandardWizardPage_nolinkref_error;
- public static String JavadocLinkDialogLabelProvider_configuredentry;
- public static String JavadocLinkDialogLabelProvider_notconfiguredentry;
- public static String JavadocTreeWizardPage_privatevisibilitydescription_label;
- public static String JavadocTreeWizardPage_warning_mayoverwritefiles;
- public static String JavadocTreeWizardPage_packagevisibledescription_label;
- public static String JavadocTreeWizardPage_protectedvisibilitydescription_label;
- public static String JavadocTreeWizardPage_publicvisibilitydescription_label;
- public static String JavadocWizard_antInformationDialog_title;
- public static String JavadocWizard_antInformationDialog_message;
- public static String JavadocTreeWizardPage_javadoccommand_label;
- public static String JavadocTreeWizardPage_javadoccommand_button_label;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JavadocExportMessages.class);
- }
-
- public static String JavadocOptionsManager_status_title;
- public static String JavadocOptionsManager_status_non_local;
- public static String JavadocWizard_warning_starting_message;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.properties
deleted file mode 100644
index 1431d3cc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocExportMessages.properties
+++ /dev/null
@@ -1,119 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-JavadocSpecificsWizardPage_description=Configure Jsdoc arguments.
-
-JavadocSpecificsWizardPage_stylesheetbrowsedialog_title=Style sheet Selection
-JavadocSpecificsWizardPage_overviewbutton_label=&Overview:
-JavadocSpecificsWizardPage_overviewbrowse_label=Bro&wse...
-JavadocSpecificsWizardPage_extraoptionsfield_label=E&xtra Jsdoc options (path names with white spaces must be enclosed in quotes):
-JavadocSpecificsWizardPage_vmoptionsfield_label=&VM options (prefixed with '-J', e.g. -J-Xmx180m for larger heap space):
-JavadocSpecificsWizardPage_overviewbrowsedialog_title=Select overview page
-JavadocSpecificsWizardPage_antscriptbutton_label=&Save the settings of this Jsdoc export as an Ant script:
-JavadocSpecificsWizardPage_antscripttext_label=&Ant Script:
-JavadocSpecificsWizardPage_antscriptbrowse_label=Brows&e...
-JavadocSpecificsWizardPage_openbrowserbutton_label=O&pen generated index file in browser
-JavadocSpecificsWizardPage_antscriptbrowsedialog_title=Destination Selection
-JavadocSpecificsWizardPage_antscriptbrowsedialog_label=Select destination folder for ANT script:
-
-#JavadocSpecificsWizardPage_sourcecompatibility_label=&JRE source compatibility:
-JavadocSpecificsWizardPage_overviewnotfound_error=Overview path not found.
-JavadocSpecificsWizardPage_overviewincorrect_error=Overview must be an html document.
-JavadocSpecificsWizardPage_antfileincorrect_error=Not a valid Ant file name.
-JavadocSpecificsWizardPage_antfileoverwrite_warning=The generated ant file will overwrite the existing ant file.
-JavadocTreeWizardPage_javadoctreewizardpage_description=Select types for Jsdoc generation.
-JavadocTreeWizardPage_checkboxtreeandlistgroup_label=Select &types for which Jsdoc will be generated:
-JavadocTreeWizardPage_visibilitygroup_label=Create Jsdoc for members with visibility:
-JavadocTreeWizardPage_privatebutton_label=Pr&ivate
-JavadocTreeWizardPage_packagebutton_label=P&ackage
-JavadocTreeWizardPage_protectedbutton_label=Pr&otected
-JavadocTreeWizardPage_publicbutton_label=P&ublic
-JavadocTreeWizardPage_standarddocletbutton_label=Use &Standard Doclet
-JavadocTreeWizardPage_destinationfield_label=&Destination:
-JavadocTreeWizardPage_destinationbrowse_label=Bro&wse...
-JavadocTreeWizardPage_customdocletbutton_label=Use &Custom Doclet
-JavadocTreeWizardPage_docletnamefield_label=Doc&let name:
-JavadocTreeWizardPage_docletpathfield_label=Doclet class &path:
-JavadocTreeWizardPage_destinationbrowsedialog_title=Destination Selection
-JavadocTreeWizardPage_destinationbrowsedialog_label=Select the Jsdoc destination folder:
-JavadocTreeWizardPage_nodocletname_error=Enter a doclet name.
-JavadocTreeWizardPage_invaliddocletname_error=Invalid doclet name.
-JavadocTreeWizardPage_invaliddocletpath_error=Not a valid doclet class path.
-JavadocTreeWizardPage_nodestination_error=Enter the destination folder.
-JavadocTreeWizardPage_invaliddestination_error=Not a valid folder.
-JavadocTreeWizardPage_invalidtreeselection_error=Selection does not contain any JavaScript files
-JavadocTreeWizardPage_javadoccmd_dialog_title=Jsdoc Command Selection
-JavadocTreeWizardPage_javadoccmd_error_enterpath=Specify the Jsdoc command.
-JavadocTreeWizardPage_javadoccmd_error_notexists=The Jsdoc command does not exist.
-
-
-JavadocWizardPage_javadocwizardpage_description=Jsdoc Generation
-JavadocWizard_warning_starting_message=Problems while starting the Jsdoc command.
-JavadocWizard_javadocwizard_title=Generate Jsdoc
-JavadocWizard_updatejavadoclocation_message=Do you want to update the Jsdoc location for ''{0}'' with the chosen destination folder ''{1}''?
-JavadocWizard_updatejavadocdialog_label=Update Jsdoc Location
-JavadocWizard_javadocprocess_label=Jsdoc Generation
-JavadocWizard_launchconfig_name=Jsdoc
-
-JavadocWizard_error_title=Generate Jsdoc
-JavadocWizard_launch_error_message=Could not launch Jsdoc command. See log for details.
-JavadocWizard_exec_error_message=Could not launch Jsdoc command. See log for details.
-
-JavadocWizard_error_writeANT_title=Create ANT file
-JavadocWizard_error_writeANT_message=Create ANT file failed.
-
-JavadocOptionsManager_antfileincorrectCE_warning=Unable to run wizard from Ant file, loading previous settings.
-JavadocOptionsManager_antfileincorrectIOE_warning=Error reading Ant file, loading previous settings.
-JavadocOptionsManager_antfileincorrectSAXE_warning=Error reading Ant file, loading previous settings.
-
-JavadocOptionsManager_createXM_error=Error writing the Ant file. No file created.
-JavadocOptionsManager_status_title=Non-local files selected.
-JavadocOptionsManager_status_non_local=File ''{0}'' has been skipped as it is not local and can not be processed by the Jsdoc tool.
-
-JavadocStandardWizardPage_description=Configure Jsdoc arguments for standard doclet.
-JavadocStandardWizardPage_titlebutton_label=Document &title:
-JavadocStandardWizardPage_basicgroup_label=Basic Options
-JavadocStandardWizardPage_usebutton_label=Generate &use page
-JavadocStandardWizardPage_hierarchybutton_label=Generate &hierarchy tree
-JavadocStandardWizardPage_navigartorbutton_label=Generate navi&gator bar
-JavadocStandardWizardPage_indexbutton_label=Generate &index
-JavadocStandardWizardPage_seperateindexbutton_label=Separate index &per letter
-JavadocStandardWizardPage_tagsgroup_label=Document these tags
-JavadocStandardWizardPage_authorbutton_label=@&author
-JavadocStandardWizardPage_nojarlinkref_error=Archive references are not supported by the Jsdoc tool.
-JavadocStandardWizardPage_versionbutton_label=@&version
-JavadocStandardWizardPage_deprecatedbutton_label=@&deprecated
-JavadocStandardWizardPage_deprecatedlistbutton_label=deprecated &list
-JavadocStandardWizardPage_stylesheettext_label=St&yle sheet:
-JavadocStandardWizardPage_selectallbutton_label=&Select All
-JavadocStandardWizardPage_clearallbutton_label=&Clear All
-JavadocStandardWizardPage_referencedclasses_label=Select &referenced archives and projects to which links should be generated:
-JavadocStandardWizardPage_stylesheetnopath_error=Style sheet path not found.
-JavadocStandardWizardPage_stylesheetnotcss_error=Style sheet must be a css document.
-JavadocStandardWizardPage_stylesheetbrowsebutton_label=Bro&wse...
-JavadocStandardWizardPage_configurebutton_label=B&rowse...
-JavadocStandardWizardPage_configurecontainer_error_title=Configure Jsdoc Location
-JavadocStandardWizardPage_configurecontainer_error_message=Unexpected problem while updating the Jsdoc location.
-JavadocStandardWizardPage_javadocpropertydialog_title=Configure Jsdoc Location
-
-JavadocStandardWizardPage_nolinkref_error=Jsdoc location is not configured for a selected reference.
-
-JavadocLinkDialogLabelProvider_configuredentry={0} - {1}
-JavadocLinkDialogLabelProvider_notconfiguredentry={0} - not configured
-JavadocTreeWizardPage_privatevisibilitydescription_label=Private: Generate Jsdoc for all classes and members.
-JavadocTreeWizardPage_warning_mayoverwritefiles=Jsdoc generation may overwrite existing files
-JavadocTreeWizardPage_packagevisibledescription_label=Package: Generate Jsdoc for all but private classes and members.
-JavadocTreeWizardPage_protectedvisibilitydescription_label=Protected: Generate Jsdoc for protected and public classes and members.
-JavadocTreeWizardPage_publicvisibilitydescription_label=Public: Generate Jsdoc for public classes and members.
-JavadocWizard_antInformationDialog_title=Jsdoc Generation with Ant Scripts
-JavadocWizard_antInformationDialog_message=Ant file will be created.\nTo run the generated ant script, the operating system PATH must contain the Jsdoc command.
-JavadocTreeWizardPage_javadoccommand_label=J&sdoc command:
-JavadocTreeWizardPage_javadoccommand_button_label=Confi&gure...
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkDialogLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkDialogLabelProvider.java
deleted file mode 100644
index 1b5cbaab..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkDialogLabelProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.ISharedImages;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public class JavadocLinkDialogLabelProvider extends LabelProvider {
-
- public String getText(Object element) {
- if (element instanceof JavadocLinkRef) {
- JavadocLinkRef ref= (JavadocLinkRef) element;
- URL url= ref.getURL();
- String text= ref.getFullPath().lastSegment();
- if (url != null) {
- Object[] args= new Object[] { text, url.toExternalForm() };
- return Messages.format(JavadocExportMessages.JavadocLinkDialogLabelProvider_configuredentry, args);
- } else {
- return Messages.format(JavadocExportMessages.JavadocLinkDialogLabelProvider_notconfiguredentry, text);
- }
- }
- return super.getText(element);
- }
-
- public Image getImage(Object element) {
- if (element instanceof JavadocLinkRef) {
- JavadocLinkRef ref= (JavadocLinkRef) element;
- ImageDescriptor desc;
- if (ref.isProjectRef()) {
- desc= PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
- } else {
- desc= JavaScriptUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_JAR);
- }
- if (ref.getURL() == null) {
- return JavaScriptPlugin.getImageDescriptorRegistry().get(new JavaScriptElementImageDescriptor(desc, JavaScriptElementImageDescriptor.WARNING, JavaElementImageProvider.SMALL_SIZE));
- }
- return JavaScriptPlugin.getImageDescriptorRegistry().get(desc);
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkRef.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkRef.java
deleted file mode 100644
index 3796a961..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocLinkRef.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathSupport;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListElement;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public class JavadocLinkRef {
- private final IJavaScriptProject fProject;
- private final IPath fContainerPath;
- private IIncludePathEntry fClasspathEntry;
-
- public JavadocLinkRef(IPath containerPath, IIncludePathEntry classpathEntry, IJavaScriptProject project) {
- fContainerPath= containerPath;
- fProject= project;
- fClasspathEntry= classpathEntry;
- }
-
- public JavadocLinkRef(IJavaScriptProject project) {
- this(null, null, project);
- }
-
- public boolean isProjectRef() {
- return fClasspathEntry == null;
- }
-
- public IPath getFullPath() {
- return isProjectRef() ? fProject.getPath() : fClasspathEntry.getPath();
- }
-
- public URL getURL() {
- if (isProjectRef()) {
- return JavaScriptUI.getProjectJSdocLocation(fProject);
- } else {
- return JavaScriptUI.getLibraryJSdocLocation(fClasspathEntry);
- }
- }
-
- public void setURL(URL url, IProgressMonitor monitor) throws CoreException {
- if (isProjectRef()) {
- JavaScriptUI.setProjectJSdocLocation(fProject, url);
- } else {
- CPListElement element= CPListElement.createFromExisting(fClasspathEntry, fProject);
- String location= url != null ? url.toExternalForm() : null;
- element.setAttribute(CPListElement.JAVADOC, location);
- String[] changedAttributes= { CPListElement.JAVADOC };
- BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, monitor);
- fClasspathEntry= element.getClasspathEntry();
- }
- }
-
- public boolean equals(Object obj) {
- if (obj != null && obj.getClass().equals(getClass())) {
- JavadocLinkRef other= (JavadocLinkRef) obj;
- if (!fProject.equals(other.fProject) || isProjectRef() != other.isProjectRef()) {
- return false;
- }
- if (!isProjectRef()) {
- return !fClasspathEntry.equals(other.fClasspathEntry);
- }
- }
- return false;
- }
-
- public int hashCode() {
- if (isProjectRef()) {
- return fProject.hashCode();
- } else {
- return fProject.hashCode() + fClasspathEntry.hashCode();
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocMemberContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocMemberContentProvider.java
deleted file mode 100644
index d9989219..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocMemberContentProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-public class JavadocMemberContentProvider implements ITreeContentProvider {
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- return new Object[0];
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- //@test
- //System.out.println(element.getClass().toString());
- if (element instanceof IPackageFragment)
- return ((IPackageFragment) element).getParent();
- return null;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- try {
- if (element instanceof IPackageFragment) {
- IPackageFragment iPackageFragment= (IPackageFragment) element;
- return (iPackageFragment.getChildren().length > 0);
- }
- } catch (JavaScriptModelException e) {
- }
- return false;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- try {
- if (inputElement instanceof IPackageFragment) {
- IJavaScriptUnit[] cu= ((IPackageFragment) inputElement).getJavaScriptUnits();
- return cu;
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return new Object[0];
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocOptionsManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocOptionsManager.java
deleted file mode 100644
index 0adb68f7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocOptionsManager.java
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids, sdavids@gmx.de, - bug 38692
- * Matt Chapman, mpchapman@gmail.com - 89977 Make JDT .java agnostic
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.launching.ExecutionArguments;
-import org.eclipse.wst.jsdt.launching.IVMInstall;
-import org.eclipse.wst.jsdt.launching.IVMInstallType;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-public class JavadocOptionsManager {
-
- private IFile fXmlfile;
-
- private StatusInfo fWizardStatus;
-
- private String[] fJavadocCommandHistory;
-
-
- private IJavaScriptElement[] fSelectedElements;
- private IJavaScriptElement[] fInitialElements;
-
- private String fAccess;
- private String fDocletpath;
- private String fDocletname;
- private boolean fFromStandard;
- private String fStylesheet;
- private String fAdditionalParams;
- private String fVMParams;
- private String fOverview;
- private String fTitle;
-
- private String[] fHRefs;
-
- private IPath[] fSourcepath;
- private IPath[] fClasspath;
-
- private boolean fNotree;
- private boolean fNoindex;
- private boolean fSplitindex;
- private boolean fNonavbar;
- private boolean fNodeprecated;
- private boolean fNoDeprecatedlist;
- private boolean fAuthor;
- private boolean fVersion;
- private boolean fUse;
-
- private String fSource;
-
- private boolean fOpenInBrowser;
-
- private RecentSettingsStore fRecentSettings;
-
- //add-on for multi-project version
- private String fDestination;
- private String fAntpath;
-
- public final String PRIVATE= "private"; //$NON-NLS-1$
- public final String PROTECTED= "protected"; //$NON-NLS-1$
- public final String PACKAGE= "package"; //$NON-NLS-1$
- public final String PUBLIC= "public"; //$NON-NLS-1$
-
- public final String USE= "use"; //$NON-NLS-1$
- public final String NOTREE= "notree"; //$NON-NLS-1$
- public final String NOINDEX= "noindex"; //$NON-NLS-1$
- public final String NONAVBAR= "nonavbar"; //$NON-NLS-1$
- public final String NODEPRECATED= "nodeprecated"; //$NON-NLS-1$
- public final String NODEPRECATEDLIST= "nodeprecatedlist"; //$NON-NLS-1$
- public final String VERSION= "version"; //$NON-NLS-1$
- public final String AUTHOR= "author"; //$NON-NLS-1$
- public final String SPLITINDEX= "splitindex"; //$NON-NLS-1$
- public final String STYLESHEETFILE= "stylesheetfile"; //$NON-NLS-1$
- public final String OVERVIEW= "overview"; //$NON-NLS-1$
- public final String DOCLETNAME= "docletname"; //$NON-NLS-1$
- public final String DOCLETPATH= "docletpath"; //$NON-NLS-1$
- public final String SOURCEPATH= "sourcepath"; //$NON-NLS-1$
- public final String CLASSPATH= "classpath"; //$NON-NLS-1$
- public final String DESTINATION= "destdir"; //$NON-NLS-1$
- public final String OPENINBROWSER= "openinbrowser"; //$NON-NLS-1$
-
- public final String VISIBILITY= "access"; //$NON-NLS-1$
- public final String PACKAGENAMES= "packagenames"; //$NON-NLS-1$
- public final String SOURCEFILES= "sourcefiles"; //$NON-NLS-1$
- public final String EXTRAOPTIONS= "additionalparam"; //$NON-NLS-1$
- public final String VMOPTIONS= "vmparam"; //$NON-NLS-1$
- //public final String JAVADOCCOMMAND= "javadoccommand"; //$NON-NLS-1$
- public final String TITLE= "doctitle"; //$NON-NLS-1$
- public final String HREF= "href"; //$NON-NLS-1$
-
- public final String NAME= "name"; //$NON-NLS-1$
- public final String PATH= "path"; //$NON-NLS-1$
- public final String FROMSTANDARD= "fromStandard"; //$NON-NLS-1$
- public final String ANTPATH= "antpath"; //$NON-NLS-1$
- public final String SOURCE= "source"; //$NON-NLS-1$
-
- private final String SECTION_JAVADOC= "javadoc"; //$NON-NLS-1$
-
- private static final String JAVADOC_COMMAND_HISTORY= "javadoc_command_history"; //$NON-NLS-1$
-
- public JavadocOptionsManager(IFile xmlJavadocFile, IDialogSettings dialogSettings, List currSelection) {
- fXmlfile= xmlJavadocFile;
- fWizardStatus= new StatusInfo();
-
- IDialogSettings javadocSection= dialogSettings.getSection(SECTION_JAVADOC);
-
- String commandHistory= null;
- if (javadocSection != null) {
- commandHistory= javadocSection.get(JAVADOC_COMMAND_HISTORY);
- }
- if (commandHistory == null || commandHistory.length() == 0) {
- commandHistory= initJavadocCommandDefault();
- }
- fJavadocCommandHistory= arrayFromFlatString(commandHistory);
-
- fRecentSettings= new RecentSettingsStore(javadocSection);
-
- if (xmlJavadocFile != null) {
- try {
- JavadocReader reader= new JavadocReader(xmlJavadocFile.getContents());
- Element element= reader.readXML();
- if (element != null) {
- loadFromXML(element);
- return;
- }
- fWizardStatus.setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectCE_warning);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- fWizardStatus.setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectCE_warning);
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- fWizardStatus.setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectIOE_warning);
- } catch (SAXException e) {
- fWizardStatus.setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectSAXE_warning);
- }
- }
- if (javadocSection != null) {
- loadFromDialogStore(javadocSection, currSelection);
- } else {
- loadDefaults(currSelection);
- }
- }
-
-
- /*
- * Returns the Java project that is parent top all selected elements or null if
- * the elements are from several projects.
- */
- private IJavaScriptProject getSingleProjectFromInitialSelection() {
- IJavaScriptProject res= null;
- for (int i= 0; i < fInitialElements.length; i++) {
- IJavaScriptProject curr= fInitialElements[i].getJavaScriptProject();
- if (res == null) {
- res= curr;
- } else if (!res.equals(curr)) {
- return null;
- }
- }
- if (res != null && res.isOpen()) {
- return res;
- }
- return null;
- }
-
-
- private void loadFromDialogStore(IDialogSettings settings, List sel) {
- fInitialElements= getInitialElementsFromSelection(sel);
-
- IJavaScriptProject project= getSingleProjectFromInitialSelection();
-
- fAccess= settings.get(VISIBILITY);
- if (fAccess == null)
- fAccess= PROTECTED;
-
- //this is defaulted to false.
- fFromStandard= settings.getBoolean(FROMSTANDARD);
-
- //doclet is loaded even if the standard doclet is being used
- fDocletpath= settings.get(DOCLETPATH);
- fDocletname= settings.get(DOCLETNAME);
- if (fDocletpath == null || fDocletname == null) {
- fFromStandard= true;
- fDocletpath= ""; //$NON-NLS-1$
- fDocletname= ""; //$NON-NLS-1$
- }
-
-
- if (project != null) {
- fAntpath= getRecentSettings().getAntpath(project);
- } else {
- fAntpath= settings.get(ANTPATH);
- if (fAntpath == null) {
- fAntpath= ""; //$NON-NLS-1$
- }
- }
-
-
- if (project != null) {
- fDestination= getRecentSettings().getDestination(project);
- } else {
- fDestination= settings.get(DESTINATION);
- if (fDestination == null) {
- fDestination= ""; //$NON-NLS-1$
- }
- }
-
- fTitle= settings.get(TITLE);
- if (fTitle == null)
- fTitle= ""; //$NON-NLS-1$
-
- fStylesheet= settings.get(STYLESHEETFILE);
- if (fStylesheet == null)
- fStylesheet= ""; //$NON-NLS-1$
-
- fVMParams= settings.get(VMOPTIONS);
- if (fVMParams == null)
- fVMParams= ""; //$NON-NLS-1$
-
- fAdditionalParams= settings.get(EXTRAOPTIONS);
- if (fAdditionalParams == null)
- fAdditionalParams= ""; //$NON-NLS-1$
-
- fOverview= settings.get(OVERVIEW);
- if (fOverview == null)
- fOverview= ""; //$NON-NLS-1$
-
- fUse= loadBoolean(settings.get(USE));
- fAuthor= loadBoolean(settings.get(AUTHOR));
- fVersion= loadBoolean(settings.get(VERSION));
- fNodeprecated= loadBoolean(settings.get(NODEPRECATED));
- fNoDeprecatedlist= loadBoolean(settings.get(NODEPRECATEDLIST));
- fNonavbar= loadBoolean(settings.get(NONAVBAR));
- fNoindex= loadBoolean(settings.get(NOINDEX));
- fNotree= loadBoolean(settings.get(NOTREE));
- fSplitindex= loadBoolean(settings.get(SPLITINDEX));
- fOpenInBrowser= loadBoolean(settings.get(OPENINBROWSER));
-
- fSource= settings.get(SOURCE);
- if (project != null) {
- fSource= project.getOption(JavaScriptCore.COMPILER_SOURCE, true);
- }
-
- if (project != null) {
- fHRefs= getRecentSettings().getHRefs(project);
- } else {
- fHRefs= new String[0];
- }
- }
-
-
- //loads defaults for wizard (nothing is stored)
- private void loadDefaults(List sel) {
- fInitialElements= getInitialElementsFromSelection(sel);
-
- IJavaScriptProject project= getSingleProjectFromInitialSelection();
-
- if (project != null) {
- fAntpath= getRecentSettings().getAntpath(project);
- fDestination= getRecentSettings().getDestination(project);
- fHRefs= getRecentSettings().getHRefs(project);
- } else {
- fAntpath= ""; //$NON-NLS-1$
- fDestination= ""; //$NON-NLS-1$
- fHRefs= new String[0];
- }
-
- fAccess= PUBLIC;
-
- fDocletname= ""; //$NON-NLS-1$
- fDocletpath= ""; //$NON-NLS-1$
- fTitle= ""; //$NON-NLS-1$
- fStylesheet= ""; //$NON-NLS-1$
- fVMParams= ""; //$NON-NLS-1$
- fAdditionalParams= ""; //$NON-NLS-1$
- fOverview= ""; //$NON-NLS-1$
-
- fUse= true;
- fAuthor= true;
- fVersion= true;
- fNodeprecated= false;
- fNoDeprecatedlist= false;
- fNonavbar= false;
- fNoindex= false;
- fNotree= false;
- fSplitindex= true;
- fOpenInBrowser= false;
- fSource= "1.3"; //$NON-NLS-1$
- if (project != null) {
- fSource= project.getOption(JavaScriptCore.COMPILER_SOURCE, true);
- }
-
- //by default it is empty all project map to the empty string
- fFromStandard= true;
- }
-
- private void loadFromXML(Element element) {
-
- fAccess= element.getAttribute(VISIBILITY);
- if (fAccess.length() == 0)
- fAccess= PROTECTED;
-
- //Since the selected packages are stored we must locate the project
- String destination= element.getAttribute(DESTINATION);
- fDestination= makeAbsolutePathFromRelative(new Path(destination)).toOSString();
- fFromStandard= true;
- fDocletname= ""; //$NON-NLS-1$
- fDocletpath= ""; //$NON-NLS-1$
-
- if (destination.length() == 0) {
- NodeList list= element.getChildNodes();
- for (int i= 0; i < list.getLength(); i++) {
- Node child= list.item(i);
- if (child.getNodeName().equals("doclet")) { //$NON-NLS-1$
- fDocletpath= ((Element) child).getAttribute(PATH);
- fDocletname= ((Element) child).getAttribute(NAME);
- if (fDocletpath.length() != 0 || fDocletname.length() != 0) {
- fFromStandard= false;
- } else {
- fDocletname= ""; //$NON-NLS-1$
- fDocletpath= ""; //$NON-NLS-1$
- }
- break;
- }
- }
- }
-
- fInitialElements= getSelectedElementsFromAnt(element);
-
-
- //find all the links stored in the ant script
- NodeList children= element.getChildNodes();
- fHRefs= new String[children.getLength()];
- for (int i= 0; i < fHRefs.length; i++) {
- Node child= children.item(i);
- if (child.getNodeName().equals("link")) { //$NON-NLS-1$
- fHRefs[i]= ((Element) child).getAttribute(HREF);
- }
- }
-
- // The ant file for generating the Javadoc is always local.
- IPath p= fXmlfile.getLocation();
- if (p != null)
- fAntpath= p.toOSString();
- else
- fAntpath= ""; //$NON-NLS-1$
-
- fStylesheet= element.getAttribute(STYLESHEETFILE);
- fTitle= element.getAttribute(TITLE);
-
-
- StringBuffer additionals= new StringBuffer();
- StringBuffer vmargs= new StringBuffer();
- String extraOptions= element.getAttribute(EXTRAOPTIONS);
- if (extraOptions.length() > 0) {
- ExecutionArguments tokens= new ExecutionArguments("", extraOptions); //$NON-NLS-1$
- String[] args= tokens.getProgramArgumentsArray();
-
- boolean vmarg= false;
- for (int i= 0; i < args.length; i++) {
- String curr= args[i];
- if (curr.length() > 0 && curr.charAt(0) == '-') {
- // an command
- vmarg=(curr.length() > 1 && curr.charAt(1) == 'J');
- }
- if (vmarg) {
- vmargs.append(curr).append(' ');
- } else {
- additionals.append(curr).append(' ');
- }
- }
- }
-
- fAdditionalParams= additionals.toString();
- fVMParams= vmargs.toString();
- fOverview= element.getAttribute(OVERVIEW);
-
- fUse= loadBoolean(element.getAttribute(USE));
- fAuthor= loadBoolean(element.getAttribute(AUTHOR));
- fVersion= loadBoolean(element.getAttribute(VERSION));
- fNodeprecated= loadBoolean(element.getAttribute(NODEPRECATED));
- fNoDeprecatedlist= loadBoolean(element.getAttribute(NODEPRECATEDLIST));
- fNonavbar= loadBoolean(element.getAttribute(NONAVBAR));
- fNoindex= loadBoolean(element.getAttribute(NOINDEX));
- fNotree= loadBoolean(element.getAttribute(NOTREE));
- fSplitindex= loadBoolean(element.getAttribute(SPLITINDEX));
-
- fSource= element.getAttribute(SOURCE);
- }
-
- /*
- * Method creates an absolute path to the project. If the path is already
- * absolute it returns the path. If it encounters any difficulties in
- * creating the absolute path, the method returns null.
- *
- * @param path
- * @return IPath
- */
- private IPath makeAbsolutePathFromRelative(IPath path) {
- if (!path.isAbsolute()) {
- if (fXmlfile == null) {
- return null;
- }
- // The XML file is always local. So ok to use getLocation here
- IPath basePath= fXmlfile.getParent().getLocation(); // relative to the ant file location
- if (basePath == null) {
- return null;
- }
- return basePath.append(path);
- }
- return path;
- }
-
- private IContainer[] getSourceContainers(Element element) {
- String sourcePaths= element.getAttribute(SOURCEPATH);
-
- if (sourcePaths.endsWith(File.pathSeparator)) {
- sourcePaths += '.';
- }
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
-
- ArrayList res= new ArrayList();
-
- String[] strings= sourcePaths.split(File.pathSeparator);
- for (int i= 0; i < strings.length; i++) {
- IPath path= makeAbsolutePathFromRelative(new Path(strings[i].trim()));
- if (path != null) {
- IContainer[] containers= root.findContainersForLocation(path);
- for (int k= 0; k < containers.length; k++) {
- res.add(containers[k]);
- }
- }
-
- }
- return (IContainer[]) res.toArray(new IContainer[res.size()]);
- }
-
- private IJavaScriptElement[] getSelectedElementsFromAnt(Element element) {
- List res= new ArrayList();
-
- // get all the packages listed in the ANT file
- String packagenames= element.getAttribute(PACKAGENAMES);
- if (packagenames != null) {
- IContainer[] containers= getSourceContainers(element);
-
- StringTokenizer tokenizer= new StringTokenizer(packagenames, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- IPath relPackagePath= new Path(tokenizer.nextToken().trim().replace('.', '/'));
- for (int i= 0; i < containers.length; i++) {
- IContainer curr= containers[i];
- IResource resource= curr.findMember(relPackagePath);
- if (resource != null) {
- IJavaScriptElement javaElem= JavaScriptCore.create(resource);
- if (javaElem instanceof IPackageFragment) {
- res.add(javaElem);
- }
- }
- }
- }
- }
-
- //get all CompilationUnites listed in the ANT file
- String sourcefiles= element.getAttribute(SOURCEFILES);
- if (sourcefiles != null) {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
-
- StringTokenizer tokenizer= new StringTokenizer(sourcefiles, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String name= tokenizer.nextToken().trim();
- if (JavaScriptCore.isJavaScriptLikeFileName(name)) {
- IPath path= makeAbsolutePathFromRelative(new Path(name));
- //if unable to create an absolute path to the resource skip it
- if (path != null) {
- IFile[] files= root.findFilesForLocation(path);
- for (int i= 0; i < files.length; i++) {
- IJavaScriptElement el= JavaScriptCore.createCompilationUnitFrom(files[i]);
- if (el != null) {
- res.add(el);
- }
- }
- }
- }
- }
- }
- return (IJavaScriptElement[]) res.toArray(new IJavaScriptElement[res.size()]);
- }
-
- /**
- * @return Returns the javadocCommandHistory.
- */
- public String[] getJavadocCommandHistory() {
- return fJavadocCommandHistory;
- }
-
-
- //it is possible that the package list is empty
- public StatusInfo getWizardStatus() {
- return fWizardStatus;
- }
-
- public IJavaScriptElement[] getInitialElements() {
- return fInitialElements;
- }
-
- public IJavaScriptElement[] getSourceElements() {
- return fSelectedElements;
- }
-
- public String getAccess() {
- return fAccess;
- }
-
- public String getAntpath() {
- return fAntpath;
- }
-
- public boolean isFromStandard() {
- return fFromStandard;
- }
-
- public String getDestination() {
- return fDestination;
- }
-
- public String getDocletPath() {
- return fDocletpath;
- }
-
- public String getDocletName() {
- return fDocletname;
- }
-
- public String getStyleSheet() {
- return fStylesheet;
- }
-
- public String getOverview() {
- return fOverview;
- }
-
- public String getAdditionalParams() {
- return fAdditionalParams;
- }
-
- public String getVMParams() {
- return fVMParams;
- }
-
- public IPath[] getClasspath() {
- return fClasspath;
- }
-
- public IPath[] getSourcepath() {
- return fSourcepath;
- }
-
- public String getTitle() {
- return fTitle;
- }
-
- public boolean doOpenInBrowser() {
- return fOpenInBrowser;
- }
-
- public String[] getHRefs() {
- return fHRefs;
- }
-
- public boolean getBoolean(String flag) {
-
- if (flag.equals(AUTHOR))
- return fAuthor;
- else if (flag.equals(VERSION))
- return fVersion;
- else if (flag.equals(USE))
- return fUse;
- else if (flag.equals(NODEPRECATED))
- return fNodeprecated;
- else if (flag.equals(NODEPRECATEDLIST))
- return fNoDeprecatedlist;
- else if (flag.equals(NOINDEX))
- return fNoindex;
- else if (flag.equals(NOTREE))
- return fNotree;
- else if (flag.equals(SPLITINDEX))
- return fSplitindex;
- else if (flag.equals(NONAVBAR))
- return fNonavbar;
- else
- return false;
- }
-
- private boolean loadBoolean(String value) {
-
- if (value == null || value.length() == 0)
- return false;
- else {
- if (value.equals("true")) //$NON-NLS-1$
- return true;
- else
- return false;
- }
- }
-
- private String flatPathList(IPath[] paths) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < paths.length; i++) {
- if (i > 0) {
- buf.append(File.pathSeparatorChar);
- }
- buf.append(paths[i].toOSString());
- }
- return buf.toString();
- }
-
- private String flatStringList(String[] paths) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < paths.length; i++) {
- if (i > 0) {
- buf.append(File.pathSeparatorChar);
- }
- buf.append(paths[i]);
- }
- return buf.toString();
- }
-
- private String[] arrayFromFlatString(String str) {
- StringTokenizer tok= new StringTokenizer(str, File.pathSeparator);
- String[] res= new String[tok.countTokens()];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken();
- }
- return res;
- }
-
-
- public IStatus getArgumentArray(List vmArgs, List toolArgs) {
- MultiStatus status= new MultiStatus(JavaScriptUI.ID_PLUGIN, IStatus.OK, JavadocExportMessages.JavadocOptionsManager_status_title, null);
-
- //bug 38692
- vmArgs.add(getJavadocCommandHistory()[0]);
-
- if (fFromStandard) {
- toolArgs.add("-d"); //$NON-NLS-1$
- toolArgs.add(fDestination);
- } else {
- toolArgs.add("-doclet"); //$NON-NLS-1$
- toolArgs.add(fDocletname);
- toolArgs.add("-docletpath"); //$NON-NLS-1$
- toolArgs.add(fDocletpath);
- }
-
- if (fSourcepath.length > 0) {
- toolArgs.add("-sourcepath"); //$NON-NLS-1$
- toolArgs.add(flatPathList(fSourcepath));
- }
-
- if (fClasspath.length > 0) {
- toolArgs.add("-classpath"); //$NON-NLS-1$
- toolArgs.add(flatPathList(fClasspath));
- }
- toolArgs.add("-" + fAccess); //$NON-NLS-1$
-
- if (fFromStandard) {
- if (fSource.length() > 0 && !fSource.equals("-")) { //$NON-NLS-1$
- toolArgs.add("-source"); //$NON-NLS-1$
- toolArgs.add(fSource);
- }
-
- if (fUse)
- toolArgs.add("-use"); //$NON-NLS-1$
- if (fVersion)
- toolArgs.add("-version"); //$NON-NLS-1$
- if (fAuthor)
- toolArgs.add("-author"); //$NON-NLS-1$
- if (fNonavbar)
- toolArgs.add("-nonavbar"); //$NON-NLS-1$
- if (fNoindex)
- toolArgs.add("-noindex"); //$NON-NLS-1$
- if (fNotree)
- toolArgs.add("-notree"); //$NON-NLS-1$
- if (fNodeprecated)
- toolArgs.add("-nodeprecated"); //$NON-NLS-1$
- if (fNoDeprecatedlist)
- toolArgs.add("-nodeprecatedlist"); //$NON-NLS-1$
- if (fSplitindex)
- toolArgs.add("-splitindex"); //$NON-NLS-1$
-
- if (fTitle.length() != 0) {
- toolArgs.add("-doctitle"); //$NON-NLS-1$
- toolArgs.add(fTitle);
- }
-
-
- if (fStylesheet.length() != 0) {
- toolArgs.add("-stylesheetfile"); //$NON-NLS-1$
- toolArgs.add(fStylesheet);
- }
-
- for (int i= 0; i < fHRefs.length; i++) {
- toolArgs.add("-link"); //$NON-NLS-1$
- toolArgs.add(fHRefs[i]);
- }
-
- } //end standard options
-
- if (fAdditionalParams.length() + fVMParams.length() != 0) {
- ExecutionArguments tokens= new ExecutionArguments(fVMParams, fAdditionalParams);
- String[] vmArgsArray= tokens.getVMArgumentsArray();
- for (int i= 0; i < vmArgsArray.length; i++) {
- vmArgs.add(vmArgsArray[i]);
- }
- String[] argsArray= tokens.getProgramArgumentsArray();
- for (int i= 0; i < argsArray.length; i++) {
- toolArgs.add(argsArray[i]);
- }
- }
- addProxyOptions(vmArgs);
-
- if (fOverview.length() != 0) {
- toolArgs.add("-overview"); //$NON-NLS-1$
- toolArgs.add(fOverview);
- }
-
- for (int i= 0; i < fSelectedElements.length; i++) {
- IJavaScriptElement curr= fSelectedElements[i];
- if (curr instanceof IPackageFragment) {
- toolArgs.add(curr.getElementName());
- } else if (curr instanceof IJavaScriptUnit) {
- // Since the Javadoc tool is running locally we can only create
- // Javadoc for local resources. So using the location is fine here.
- IPath p= curr.getResource().getLocation();
- if (p != null) {
- toolArgs.add(p.toOSString());
- } else {
- String message= JavadocExportMessages.JavadocOptionsManager_status_non_local;
- status.add(new StatusInfo(IStatus.WARNING, Messages.format(message, curr.getPath().makeRelative().toString())));
- }
- }
- }
- return status;
- }
-
- private void addProxyOptions(List vmOptions) {
- // bug 74132
- String hostPrefix= "-J-Dhttp.proxyHost="; //$NON-NLS-1$
- String portPrefix= "-J-Dhttp.proxyPort="; //$NON-NLS-1$
- for (int i= 0; i < vmOptions.size(); i++) {
- String curr= (String) vmOptions.get(i);
- if (curr.startsWith(hostPrefix) || curr.startsWith(portPrefix)) {
- return;
- }
- }
- String proxyHost= System.getProperty("http.proxyHost"); //$NON-NLS-1$
- if (proxyHost != null) {
- vmOptions.add(hostPrefix + proxyHost);
- }
-
- String proxyPort= System.getProperty("http.proxyPort"); //$NON-NLS-1$
- if (proxyPort != null) {
- vmOptions.add(portPrefix + proxyPort);
- }
- }
-
-
- public File createXML(IJavaScriptProject[] projects) throws CoreException {
- FileOutputStream objectStreamOutput= null;
- //@change
- //for now only writing ant files for single project selection
- try {
- if (fAntpath.length() > 0) {
- File file= new File(fAntpath);
-
- String encoding= "UTF-8"; //$NON-NLS-1$
- IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.ant.core.antBuildFile"); //$NON-NLS-1$
- if (type != null)
- encoding= type.getDefaultCharset();
- IPath filePath= Path.fromOSString(fAntpath);
- IPath directoryPath= filePath.removeLastSegments(1);
-
- IPath basePath= null;
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- if (root.findFilesForLocation(filePath).length > 0) {
- basePath= directoryPath; // only do relative path if ant file is stored in the workspace
- }
-
- directoryPath.toFile().mkdirs();
-
- objectStreamOutput= new FileOutputStream(file);
- JavadocWriter writer= new JavadocWriter(objectStreamOutput, encoding, basePath, projects);
- writer.writeXML(this);
- return file;
- }
- } catch (IOException e) {
- String message= JavadocExportMessages.JavadocOptionsManager_createXM_error;
- throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
- } catch (ParserConfigurationException e) {
- String message= JavadocExportMessages.JavadocOptionsManager_createXM_error;
- throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
- } catch (TransformerException e) {
- String message= JavadocExportMessages.JavadocOptionsManager_createXM_error;
- throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
- } finally {
- if (objectStreamOutput != null) {
- try {
- objectStreamOutput.close();
- } catch (IOException e) {
- }
- }
- }
- return null;
- }
-
- public void updateDialogSettings(IDialogSettings dialogSettings, IJavaScriptProject[] checkedProjects) {
- IDialogSettings settings= dialogSettings.addNewSection(SECTION_JAVADOC);
-
- settings.put(JAVADOC_COMMAND_HISTORY, flatStringList(fJavadocCommandHistory));
- if (fJavadocCommandHistory.length > 0) {
- IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- store.setValue(PreferenceConstants.JAVADOC_COMMAND, fJavadocCommandHistory[0]);
- }
-
-
- settings.put(FROMSTANDARD, fFromStandard);
-
- settings.put(DOCLETNAME, fDocletname);
- settings.put(DOCLETPATH, fDocletpath);
-
- settings.put(VISIBILITY, fAccess);
-
- settings.put(USE, fUse);
- settings.put(AUTHOR, fAuthor);
- settings.put(VERSION, fVersion);
- settings.put(NODEPRECATED, fNodeprecated);
- settings.put(NODEPRECATEDLIST, fNoDeprecatedlist);
- settings.put(SPLITINDEX, fSplitindex);
- settings.put(NOINDEX, fNoindex);
- settings.put(NOTREE, fNotree);
- settings.put(NONAVBAR, fNonavbar);
- settings.put(OPENINBROWSER, fOpenInBrowser);
- settings.put(SOURCE, fSource);
-
- if (fAntpath.length() != 0)
- settings.put(ANTPATH, fAntpath);
- if (fDestination.length() != 0)
- settings.put(DESTINATION, fDestination);
- if (fAdditionalParams.length() != 0)
- settings.put(EXTRAOPTIONS, fAdditionalParams);
- if (fVMParams.length() != 0)
- settings.put(VMOPTIONS, fVMParams);
- if (fOverview.length() != 0)
- settings.put(OVERVIEW, fOverview);
- if (fStylesheet.length() != 0)
- settings.put(STYLESHEETFILE, fStylesheet);
- if (fTitle.length() != 0)
- settings.put(TITLE, fTitle);
-
- if (checkedProjects.length == 1) {
- updateRecentSettings(checkedProjects[0]);
- }
- getRecentSettings().store(settings);
- }
-
- public void setJavadocCommandHistory(String[] javadocCommandHistory) {
- fJavadocCommandHistory= javadocCommandHistory;
- }
-
- public void setAccess(String access) {
- fAccess= access;
- }
- public void setDestination(String destination) {
- fDestination= destination;
- }
-
- public void setDocletPath(String docletpath) {
- fDocletpath= docletpath;
- }
-
- public void setDocletName(String docletname) {
- fDocletname= docletname;
- }
-
- public void setStyleSheet(String stylesheet) {
- fStylesheet= stylesheet;
- }
-
- public void setOverview(String overview) {
- fOverview= overview;
- }
-
- public void setAdditionalParams(String params) {
- fAdditionalParams= params;
- }
-
- public void setVMParams(String params) {
- fVMParams= params;
- }
-
- public void setGeneralAntpath(String antpath) {
- fAntpath= antpath;
- }
- public void setClasspath(IPath[] classpath) {
- fClasspath= classpath;
- }
-
- public void setSourcepath(IPath[] sourcepath) {
- fSourcepath= sourcepath;
- }
-
- public void setSelectedElements(IJavaScriptElement[] elements) {
- fSelectedElements= elements;
- }
-
- public void setFromStandard(boolean fromStandard) {
- fFromStandard= fromStandard;
- }
-
- public void setTitle(String title) {
- fTitle= title;
- }
-
- public void setOpenInBrowser(boolean openInBrowser) {
- fOpenInBrowser= openInBrowser;
- }
-
- public void setHRefs(String[] hrefs) {
- fHRefs= hrefs;
- }
-
- public void setBoolean(String flag, boolean value) {
-
- if (flag.equals(AUTHOR))
- fAuthor= value;
- else if (flag.equals(USE))
- fUse= value;
- else if (flag.equals(VERSION))
- fVersion= value;
- else if (flag.equals(NODEPRECATED))
- fNodeprecated= value;
- else if (flag.equals(NODEPRECATEDLIST))
- fNoDeprecatedlist= value;
- else if (flag.equals(NOINDEX))
- fNoindex= value;
- else if (flag.equals(NOTREE))
- fNotree= value;
- else if (flag.equals(SPLITINDEX))
- fSplitindex= value;
- else if (flag.equals(NONAVBAR))
- fNonavbar= value;
- }
-
- public void setSource(String source) {
- fSource= source;
- }
-
- public String getSource() {
- return fSource;
- }
-
- private IJavaScriptElement[] getInitialElementsFromSelection(List candidates) {
- ArrayList res= new ArrayList();
- for (int i= 0; i < candidates.size(); i++) {
- try {
- IJavaScriptElement elem= getSelectableJavaElement(candidates.get(i));
- if (elem != null) {
- res.add(elem);
- }
- } catch (JavaScriptModelException ignore) {
- // ignore this
- }
- }
- return (IJavaScriptElement[]) res.toArray(new IJavaScriptElement[res.size()]);
- }
-
- private IJavaScriptElement getSelectableJavaElement(Object obj) throws JavaScriptModelException {
- IJavaScriptElement je= null;
- if (obj instanceof IAdaptable) {
- je= (IJavaScriptElement) ((IAdaptable) obj).getAdapter(IJavaScriptElement.class);
- }
-
- if (je != null) {
- switch (je.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_MODEL :
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- case IJavaScriptElement.CLASS_FILE :
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- if (containsCompilationUnits((IPackageFragmentRoot) je)) {
- return je;
- }
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- if (containsCompilationUnits((IPackageFragment) je)) {
- return je;
- }
- break;
- default :
- IJavaScriptUnit cu= (IJavaScriptUnit) je.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- return cu;
- }
- }
- IJavaScriptProject project= je.getJavaScriptProject();
- if (isValidProject(project))
- return project;
- }
-
- return null;
- }
-
- private boolean isValidProject(IJavaScriptProject project) throws JavaScriptModelException {
- if (project != null && project.exists() && project.isOpen()) {
- return true;
- }
- return false;
- }
-
- private boolean containsCompilationUnits(IPackageFragmentRoot root) throws JavaScriptModelException {
- if (root.getKind() != IPackageFragmentRoot.K_SOURCE) {
- return false;
- }
-
- IJavaScriptElement[] elements= root.getChildren();
- for (int i= 0; i < elements.length; i++) {
- if (elements[i] instanceof IPackageFragment) {
- IPackageFragment fragment= (IPackageFragment) elements[i];
- if (containsCompilationUnits(fragment)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean containsCompilationUnits(IPackageFragment pack) throws JavaScriptModelException {
- return pack.getJavaScriptUnits().length > 0;
- }
-
- public RecentSettingsStore getRecentSettings() {
- return fRecentSettings;
- }
-
- /**
- * @param project
- */
- public void updateRecentSettings(IJavaScriptProject project) {
- fRecentSettings.setProjectSettings(project, fDestination, fAntpath, fHRefs);
- }
-
-
- private static String initJavadocCommandDefault() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- String cmd= store.getString(PreferenceConstants.JAVADOC_COMMAND); // old location
- if (cmd != null && cmd.length() > 0) {
- store.setToDefault(PreferenceConstants.JAVADOC_COMMAND);
- return cmd;
- }
-
- File file= findJavaDocCommand();
- if (file != null) {
- return file.getPath();
- }
- return ""; //$NON-NLS-1$
- }
-
-
- private static File findJavaDocCommand() {
- IVMInstall install= JavaRuntime.getDefaultVMInstall();
- if (install != null) {
- File res= getCommand(install);
- if (res != null) {
- return res;
- }
- }
-
- IVMInstallType[] jreTypes= JavaRuntime.getVMInstallTypes();
- for (int i= 0; i < jreTypes.length; i++) {
- IVMInstallType jreType= jreTypes[i];
- IVMInstall[] installs= jreType.getVMInstalls();
- for (int k= 0; k < installs.length; k++) {
- File res= getCommand(installs[k]);
- if (res != null) {
- return res;
- }
- }
- }
- return null;
- }
-
- private static File getCommand(IVMInstall install) {
- File installLocation= install.getInstallLocation();
- if (installLocation != null) {
- File javaDocCommand= new File(installLocation, "bin/javadoc"); //$NON-NLS-1$
- if (javaDocCommand.isFile()) {
- return javaDocCommand;
- }
- javaDocCommand= new File(installLocation, "bin/javadoc.exe"); //$NON-NLS-1$
- if (javaDocCommand.isFile()) {
- return javaDocCommand;
- }
- }
- return null;
- }
-
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocProjectContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocProjectContentProvider.java
deleted file mode 100644
index 3e996b0e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocProjectContentProvider.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-public class JavadocProjectContentProvider implements ITreeContentProvider {
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- try {
- if (parentElement instanceof IJavaScriptProject) {
- IJavaScriptProject project= (IJavaScriptProject) parentElement;
- return getPackageFragmentRoots(project);
- } else if (parentElement instanceof IPackageFragmentRoot) {
- return getPackageFragments((IPackageFragmentRoot) parentElement);
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return new Object[0];
- }
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- try {
- return JavaScriptCore.create(root).getJavaScriptProjects();
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return new Object[0];
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
-
- IJavaScriptElement parent= ((IJavaScriptElement)element).getParent();
- if (parent instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) parent;
- if (root.getPath().equals(root.getJavaScriptProject().getProject().getFullPath())) {
- return root.getJavaScriptProject();
- }
- }
- return parent;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return (getChildren(element).length > 0);
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- private Object[] getPackageFragmentRoots(IJavaScriptProject project) throws JavaScriptModelException {
- ArrayList result= new ArrayList();
-
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
- if (root.getPath().equals(root.getJavaScriptProject().getPath())) {
- Object[] packageFragments= getPackageFragments(root);
- for (int k= 0; k < packageFragments.length; k++) {
- result.add(packageFragments[k]);
- }
- } else {
- result.add(root);
- }
- }
- }
- return result.toArray();
- }
-
- private Object[] getPackageFragments(IPackageFragmentRoot root) throws JavaScriptModelException {
- ArrayList packageFragments= new ArrayList();
-
- IJavaScriptElement[] children= root.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (((IPackageFragment) children[i]).containsJavaResources())
- packageFragments.add(children[i]);
- }
- return packageFragments.toArray();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocReader.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocReader.java
deleted file mode 100644
index 180bc2b4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocReader.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.runtime.Assert;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-
-/**
- * Reads data from an InputStream and returns a JarPackage
- */
-public class JavadocReader extends Object {
-
- private InputStream fInputStream;
-
- /**
- * Reads a Javadoc Ant Script from the underlying stream.
- * It is the client's responsibility to close the stream.
- */
- public JavadocReader(InputStream inputStream) {
- Assert.isNotNull(inputStream);
- fInputStream= new BufferedInputStream(inputStream);
- }
-
- /**
- * Closes this stream.
- * It is the clients responsibility to close the stream.
- *
- * @exception IOException
- */
- public void close() throws IOException {
- if (fInputStream != null)
- fInputStream.close();
- }
-
- public Element readXML() throws IOException, SAXException {
-
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- DocumentBuilder parser= null;
- try {
- parser= factory.newDocumentBuilder();
- } catch (ParserConfigurationException ex) {
- throw new IOException(ex.getMessage());
- } finally {
- // Note: Above code is OK since clients are responsible to close the stream
- }
-
- //find the project associated with the ant script
- Element xmlJavadocDesc= parser.parse(new InputSource(fInputStream)).getDocumentElement();
-
- NodeList targets= xmlJavadocDesc.getChildNodes();
-
- for (int i= 0; i < targets.getLength(); i++) {
- Node target= targets.item(i);
-
- //look through the XML file for the javadoc task
- if (target.getNodeName().equals("target")) { //$NON-NLS-1$
- NodeList children= target.getChildNodes();
- for (int j= 0; j < children.getLength(); j++) {
- Node child= children.item(j);
- if (child.getNodeName().equals("javadoc") && (child.getNodeType() == Node.ELEMENT_NODE)) { //$NON-NLS-1$
- return (Element) child;
- }
- }
- }
-
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java
deleted file mode 100644
index 83e5fa8d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-public class JavadocSpecificsWizardPage extends JavadocWizardPage {
-
- private Button fAntBrowseButton;
- private Button fCheckbrowser;
- private Text fAntText;
- private Button fOverViewButton;
- private Button fOverViewBrowseButton;
- private Button fAntButton;
-// private Combo fSourceCombo;
-
- private Composite fLowerComposite;
- private Text fOverViewText;
- private Text fExtraOptionsText;
- private Text fVMOptionsText;
-
- private StatusInfo fOverviewStatus;
- private StatusInfo fAntStatus;
-
- private JavadocTreeWizardPage fFirstPage;
-
- private JavadocOptionsManager fStore;
-
- private final int OVERVIEWSTATUS= 1;
- private final int ANTSTATUS= 2;
-
- protected JavadocSpecificsWizardPage(String pageName, JavadocTreeWizardPage firstPage, JavadocOptionsManager store) {
- super(pageName);
- setDescription(JavadocExportMessages.JavadocSpecificsWizardPage_description);
-
- fStore= store;
-
- fOverviewStatus= new StatusInfo();
- fAntStatus= new StatusInfo();
- fFirstPage= firstPage;
- }
-
- /*
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- fLowerComposite= new Composite(parent, SWT.NONE);
- fLowerComposite.setLayoutData(createGridData(GridData.FILL_BOTH, 1, 0));
-
- GridLayout layout= createGridLayout(3);
- layout.marginHeight= 0;
- fLowerComposite.setLayout(layout);
-
- createExtraOptionsGroup(fLowerComposite);
- createAntGroup(fLowerComposite);
-
- setControl(fLowerComposite);
- Dialog.applyDialogFont(fLowerComposite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fLowerComposite, IJavaHelpContextIds.JAVADOC_SPECIFICS_PAGE);
-
- } //end method createControl
-
- private void createExtraOptionsGroup(Composite composite) {
- Composite c= new Composite(composite, SWT.NONE);
- c.setLayout(createGridLayout(3));
- c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3, 0));
- ((GridLayout) c.getLayout()).marginWidth= 0;
-
- fOverViewButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbutton_label, createGridData(1));
- fOverViewText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- //there really aught to be a way to specify this
- ((GridData) fOverViewText.getLayoutData()).widthHint= 200;
- fOverViewBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
- SWTUtil.setButtonDimensionHint(fOverViewBrowseButton);
-
- String str= fStore.getOverview();
- if (str.length() == 0) {
- //default
- fOverViewText.setEnabled(false);
- fOverViewBrowseButton.setEnabled(false);
- } else {
- fOverViewButton.setSelection(true);
- fOverViewText.setText(str);
- }
-
- createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_vmoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0));
- fVMOptionsText= createText(composite, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3, 0));
- fVMOptionsText.setText(fStore.getVMParams());
-
-
- createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_extraoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0));
- fExtraOptionsText= createText(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, 3, 0));
- //fExtraOptionsText.setSize(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(10));
-
- fExtraOptionsText.setText(fStore.getAdditionalParams());
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3, 1));
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- inner.setLayout(layout);
-
-// createLabel(inner, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_sourcecompatibility_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 0));
-//
-// fSourceCombo= createCombo(inner, SWT.NONE, fStore.getSource(), createGridData(1));
-// String[] versions= { "-", "1.3", "1.4", "1.5" };//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
-// fSourceCombo.setItems(versions);
-// fSourceCombo.setText(fStore.getSource());
-
-
- //Listeners
- fOverViewButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fOverViewBrowseButton, fOverViewText }) {
- public void validate() {
- doValidation(OVERVIEWSTATUS);
- }
- });
-
- fOverViewText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(OVERVIEWSTATUS);
- }
- });
-
- fOverViewBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleFileBrowseButtonPressed(fOverViewText, new String[] { "*.html" }, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowsedialog_title); //$NON-NLS-1$
- }
- });
-
- }
-
- private void createAntGroup(Composite composite) {
- Composite c= new Composite(composite, SWT.NONE);
- c.setLayout(createGridLayout(3));
- c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3, 0));
- ((GridLayout) c.getLayout()).marginWidth= 0;
-
- fAntButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbutton_label, createGridData(3));
- createLabel(c, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_antscripttext_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 0));
- fAntText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- //there really aught to be a way to specify this
- ((GridData) fAntText.getLayoutData()).widthHint= 200;
-
- fAntText.setText(fStore.getAntpath());
-
- fAntBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
- SWTUtil.setButtonDimensionHint(fAntBrowseButton);
- fAntText.setEnabled(false);
- fAntBrowseButton.setEnabled(false);
-
- fCheckbrowser= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_openbrowserbutton_label, createGridData(3));
- fCheckbrowser.setSelection(fStore.doOpenInBrowser());
-
- fAntButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fAntText, fAntBrowseButton }) {
- public void validate() {
- doValidation(ANTSTATUS);
- }
- });
-
- fAntText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(ANTSTATUS);
- }
- });
-
- fAntBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- String temp= fAntText.getText();
- IPath path= Path.fromOSString(temp);
- String file= path.lastSegment();
- if (file == null)
- file= "javadoc.xml";//$NON-NLS-1$
- path= path.removeLastSegments(1);
-
- String selected= handleFolderBrowseButtonPressed(path.toOSString(), JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowsedialog_title, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowsedialog_label);
-
- path= Path.fromOSString(selected).append(file);
- fAntText.setText(path.toOSString());
-
- }
- });
- } //end method createExtraOptionsGroup
-
- private void doValidation(int val) {
- switch (val) {
-
- case OVERVIEWSTATUS :
- fOverviewStatus= new StatusInfo();
- if (fOverViewButton.getSelection()) {
- String filename= fOverViewText.getText();
- if (filename.length() == 0) {
- fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
- } else {
- File file= new File(filename);
- String ext= filename.substring(filename.lastIndexOf('.') + 1);
- if (!file.isFile()) {
- fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
- } else if (!ext.equalsIgnoreCase("html")) { //$NON-NLS-1$
- fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewincorrect_error);
- }
- }
- }
- break;
- case ANTSTATUS :
- fAntStatus= new StatusInfo();
- if (fAntButton.getSelection()) {
- String filename= fAntText.getText();
- if (filename.length() == 0) {
- fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_antfileincorrect_error);
- } else {
- File file= new File(filename);
- String ext= filename.substring(filename.lastIndexOf('.') + 1);
- if (file.isDirectory() || !(ext.equalsIgnoreCase("xml"))) //$NON-NLS-1$
- fAntStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_antfileincorrect_error);
- else if (file.exists())
- fAntStatus.setWarning(JavadocExportMessages.JavadocSpecificsWizardPage_antfileoverwrite_warning);
- }
- }
- break;
- }
-
- updateStatus(findMostSevereStatus());
-
- }
-
- /*
- * @see JavadocWizardPage#onFinish()
- */
-
- protected void updateStore() {
-
- fStore.setVMParams(fVMOptionsText.getText());
- fStore.setAdditionalParams(fExtraOptionsText.getText());
-
- if (fOverViewText.getEnabled())
- fStore.setOverview(fOverViewText.getText());
- else
- fStore.setOverview(""); //$NON-NLS-1$
-
- //for now if there are multiple then the ant file is not stored for specific projects
- if (fAntText.getEnabled()) {
- fStore.setGeneralAntpath(fAntText.getText());
- }
- fStore.setOpenInBrowser(fCheckbrowser.getSelection());
-// fStore.setSource(fSourceCombo.getText());
-
- }
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- doValidation(OVERVIEWSTATUS);
- doValidation(ANTSTATUS);
- fCheckbrowser.setVisible(!fFirstPage.getCustom());
- }
- }
-
- public void init() {
- updateStatus(new StatusInfo());
- }
-
- private IStatus findMostSevereStatus() {
- return StatusUtil.getMostSevere(new IStatus[] { fAntStatus, fOverviewStatus });
- }
-
- public boolean generateAnt() {
- return fAntButton.getSelection();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocStandardWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocStandardWizardPage.java
deleted file mode 100644
index 7f60afc6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocStandardWizardPage.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavadocConfigurationBlock;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-
-public class JavadocStandardWizardPage extends JavadocWizardPage {
-
-
- private final int STYLESHEETSTATUS= 1;
- private final int LINK_REFERENCES= 2;
-
- private JavadocOptionsManager fStore;
- private Composite fUpperComposite;
-
- private Group fBasicOptionsGroup;
- private Group fTagsGroup;
-
- private Button fTitleButton;
- private Text fTitleText;
- private Text fStyleSheetText;
- private FlaggedButton fDeprecatedList;
- private FlaggedButton fDeprecatedCheck;
- private FlaggedButton fIndexCheck;
- private FlaggedButton fSeperatedIndexCheck;
- private Button fStyleSheetBrowseButton;
- private Button fStyleSheetButton;
-
- private CheckedListDialogField fListDialogField;
-
- private StatusInfo fStyleSheetStatus;
- private StatusInfo fLinkRefStatus;
-
- private ArrayList fButtonsList;
- private JavadocTreeWizardPage fFirstPage;
-
-
- public JavadocStandardWizardPage(String pageName, JavadocTreeWizardPage firstPage, JavadocOptionsManager store) {
- super(pageName);
- fFirstPage= firstPage;
- setDescription(JavadocExportMessages.JavadocStandardWizardPage_description);
-
- fStore= store;
- fButtonsList= new ArrayList();
- fStyleSheetStatus= new StatusInfo();
- fLinkRefStatus= new StatusInfo();
- }
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
-
- initializeDialogUnits(parent);
-
- fUpperComposite= new Composite(parent, SWT.NONE);
- fUpperComposite.setFont(parent.getFont());
- fUpperComposite.setLayoutData(createGridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL, 1, 0));
-
- GridLayout layout= createGridLayout(4);
- layout.marginHeight= 0;
- fUpperComposite.setLayout(layout);
-
- createBasicOptionsGroup(fUpperComposite);
- createTagOptionsGroup(fUpperComposite);
- createListDialogField(fUpperComposite);
- createStyleSheetGroup(fUpperComposite);
-
- setControl(fUpperComposite);
- Dialog.applyDialogFont(fUpperComposite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpperComposite, IJavaHelpContextIds.JAVADOC_STANDARD_PAGE);
- }
- private void createBasicOptionsGroup(Composite composite) {
-
- fTitleButton= createButton(composite, SWT.CHECK, JavadocExportMessages.JavadocStandardWizardPage_titlebutton_label, createGridData(1));
- fTitleText= createText(composite, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 3, 0));
- String text= fStore.getTitle();
- if (!text.equals("")) { //$NON-NLS-1$
- fTitleText.setText(text);
- fTitleButton.setSelection(true);
- } else
- fTitleText.setEnabled(false);
-
- fBasicOptionsGroup= new Group(composite, SWT.SHADOW_ETCHED_IN);
- fBasicOptionsGroup.setLayout(createGridLayout(1));
- fBasicOptionsGroup.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 2, 0));
- fBasicOptionsGroup.setText(JavadocExportMessages.JavadocStandardWizardPage_basicgroup_label);
-
- new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_usebutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.USE, true);
- new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_hierarchybutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NOTREE, false);
- new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_navigartorbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NONAVBAR, false);
-
- fIndexCheck= new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_indexbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NOINDEX, false);
-
- fSeperatedIndexCheck= new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_seperateindexbutton_label, createGridData(GridData.GRAB_HORIZONTAL, 1, convertWidthInCharsToPixels(3)), fStore.SPLITINDEX, true);
- fSeperatedIndexCheck.getButton().setEnabled(fIndexCheck.getButton().getSelection());
-
- fIndexCheck.getButton().addSelectionListener(new ToggleSelectionAdapter(new Control[] { fSeperatedIndexCheck.getButton()}));
- fTitleButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fTitleText }));
-
- }
-
- private void createTagOptionsGroup(Composite composite) {
- fTagsGroup= new Group(composite, SWT.SHADOW_ETCHED_IN);
- fTagsGroup.setLayout(createGridLayout(1));
- fTagsGroup.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 2, 0));
- fTagsGroup.setText(JavadocExportMessages.JavadocStandardWizardPage_tagsgroup_label);
-
- new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_authorbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.AUTHOR, true);
- new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_versionbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.VERSION, true);
- fDeprecatedCheck= new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_deprecatedbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NODEPRECATED, false);
- fDeprecatedList= new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_deprecatedlistbutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, convertWidthInCharsToPixels(3)), fStore.NODEPRECATEDLIST, false);
- fDeprecatedList.getButton().setEnabled(fDeprecatedCheck.getButton().getSelection());
-
- fDeprecatedCheck.getButton().addSelectionListener(new ToggleSelectionAdapter(new Control[] { fDeprecatedList.getButton()}));
- } //end createTagOptionsGroup
-
- private void createStyleSheetGroup(Composite composite) {
- Composite c= new Composite(composite, SWT.NONE);
- c.setLayout(createGridLayout(3));
- c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 4, 0));
- ((GridLayout) c.getLayout()).marginWidth= 0;
-
- fStyleSheetButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocStandardWizardPage_stylesheettext_label, createGridData(1));
- fStyleSheetText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- //there really aught to be a way to specify this
- ((GridData) fStyleSheetText.getLayoutData()).widthHint= 200;
- fStyleSheetBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocStandardWizardPage_stylesheetbrowsebutton_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
- SWTUtil.setButtonDimensionHint(fStyleSheetBrowseButton);
-
- String str= fStore.getStyleSheet();
- if (str.equals("")) { //$NON-NLS-1$
- //default
- fStyleSheetText.setEnabled(false);
- fStyleSheetBrowseButton.setEnabled(false);
- } else {
- fStyleSheetButton.setSelection(true);
- fStyleSheetText.setText(str);
- }
-
- //Listeners
- fStyleSheetButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fStyleSheetText, fStyleSheetBrowseButton }) {
- public void validate() {
- doValidation(STYLESHEETSTATUS);
- }
- });
-
- fStyleSheetText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(STYLESHEETSTATUS);
- }
- });
-
- fStyleSheetBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleFileBrowseButtonPressed(fStyleSheetText, new String[] { "*.css" }, JavadocExportMessages.JavadocSpecificsWizardPage_stylesheetbrowsedialog_title); //$NON-NLS-1$
- }
- });
-
- }
-
- private void createListDialogField(Composite composite) {
- Composite c= new Composite(composite, SWT.NONE);
- c.setFont(composite.getFont());
- c.setLayout(createGridLayout(3));
- c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 4, 0));
- ((GridLayout) c.getLayout()).marginWidth= 0;
-
- String[] buttonlabels= new String[] { JavadocExportMessages.JavadocStandardWizardPage_selectallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_clearallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_configurebutton_label};
-
- JavadocLinkDialogLabelProvider labelProvider= new JavadocLinkDialogLabelProvider();
-
- ListAdapter adapter= new ListAdapter();
-
- fListDialogField= new CheckedListDialogField(adapter, buttonlabels, labelProvider);
- fListDialogField.setDialogFieldListener(adapter);
- fListDialogField.setCheckAllButtonIndex(0);
- fListDialogField.setUncheckAllButtonIndex(1);
- fListDialogField.setViewerComparator(new ViewerComparator());
-
- createLabel(c, SWT.NONE, JavadocExportMessages.JavadocStandardWizardPage_referencedclasses_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 4, 0));
- fListDialogField.doFillIntoGrid(c, 3);
-
- LayoutUtil.setHorizontalGrabbing(fListDialogField.getListControl(null));
-
- fListDialogField.enableButton(2, false);
- }
-
- private List getCheckedReferences(JavadocLinkRef[] referencesClasses) {
- List checkedElements= new ArrayList();
-
- String hrefs[]= fStore.getHRefs();
- if (hrefs.length > 0) {
- HashSet set= new HashSet();
- for (int i= 0; i < hrefs.length; i++) {
- set.add(hrefs[i]);
- }
- for (int i = 0; i < referencesClasses.length; i++) {
- JavadocLinkRef curr= referencesClasses[i];
- URL url= curr.getURL();
- if (url != null && set.contains(url.toExternalForm())) {
- checkedElements.add(curr);
- }
- }
- }
- return checkedElements;
- }
-
-
-
- /**
- * Returns IJavaProjects and IPaths that will be on the classpath
- */
- private JavadocLinkRef[] getReferencedElements(IJavaScriptProject[] checkedProjects) {
- HashSet result= new HashSet();
- for (int i= 0; i < checkedProjects.length; i++) {
- IJavaScriptProject project= checkedProjects[i];
- try {
- collectReferencedElements(project, result);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- // ignore
- }
- }
- return (JavadocLinkRef[]) result.toArray(new JavadocLinkRef[result.size()]);
- }
-
- private void collectReferencedElements(IJavaScriptProject project, HashSet result) throws CoreException {
- IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
- for (int i= 0; i < unresolved.length; i++) {
- IRuntimeClasspathEntry curr= unresolved[i];
- if (curr.getType() == IRuntimeClasspathEntry.PROJECT) {
- result.add(new JavadocLinkRef(JavaScriptCore.create((IProject) curr.getResource())));
- } else {
- IRuntimeClasspathEntry[] entries= JavaRuntime.resolveRuntimeClasspathEntry(curr, project);
- for (int k = 0; k < entries.length; k++) {
- IRuntimeClasspathEntry entry= entries[k];
- if (entry.getType() == IRuntimeClasspathEntry.PROJECT) {
- result.add(new JavadocLinkRef(JavaScriptCore.create((IProject) entry.getResource())));
- } else if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) {
- IIncludePathEntry classpathEntry= entry.getClasspathEntry();
- if (classpathEntry != null) {
- IPath containerPath= null;
- if (curr.getType() == IRuntimeClasspathEntry.CONTAINER) {
- containerPath= curr.getPath();
- }
- result.add(new JavadocLinkRef(containerPath, classpathEntry, project));
- }
- }
- }
- }
- }
- }
-
- final void doValidation(int VALIDATE) {
- switch (VALIDATE) {
- case STYLESHEETSTATUS :
- fStyleSheetStatus= new StatusInfo();
- if (fStyleSheetButton.getSelection()) {
- String filename= fStyleSheetText.getText();
- if (filename.length() == 0) {
- fStyleSheetStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
- } else {
- File file= new File(filename);
- String ext= filename.substring(filename.lastIndexOf('.') + 1);
- if (!file.isFile()) {
- fStyleSheetStatus.setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnopath_error);
- } else if (!ext.equalsIgnoreCase("css")) { //$NON-NLS-1$
- fStyleSheetStatus.setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnotcss_error);
- }
- }
- }
- break;
- case LINK_REFERENCES:
- fLinkRefStatus= new StatusInfo();
- List list= fListDialogField.getCheckedElements();
- for (int i= 0; i < list.size(); i++) {
- JavadocLinkRef curr= (JavadocLinkRef) list.get(i);
- URL url= curr.getURL();
- if (url == null) {
- fLinkRefStatus.setWarning(JavadocExportMessages.JavadocStandardWizardPage_nolinkref_error);
- break;
- } else if ("jar".equals(url.getProtocol())) { //$NON-NLS-1$
- fLinkRefStatus.setWarning(JavadocExportMessages.JavadocStandardWizardPage_nojarlinkref_error);
- break;
- }
- }
- break;
- }
-
- updateStatus(findMostSevereStatus());
-
- }
-
- private IStatus findMostSevereStatus() {
- return StatusUtil.getMostSevere(new IStatus[] { fStyleSheetStatus, fLinkRefStatus });
- }
-
- public void updateStore() {
-
- if (fTitleButton.getSelection())
- fStore.setTitle(fTitleText.getText());
- else
- fStore.setTitle(""); //$NON-NLS-1$
-
- //don't store the buttons if they are not enabled
- //this will change when there is a single page aimed at the standard doclet
- if (true) {
- Object[] buttons= fButtonsList.toArray();
- for (int i= 0; i < buttons.length; i++) {
- FlaggedButton button= (FlaggedButton) buttons[i];
- if (button.getButton().getEnabled())
- fStore.setBoolean(button.getFlag(), !(button.getButton().getSelection() ^ button.show()));
- else
- fStore.setBoolean(button.getFlag(), false == button.show());
- }
- }
-
- if (fStyleSheetText.getEnabled())
- fStore.setStyleSheet(fStyleSheetText.getText());
- else
- fStore.setStyleSheet(""); //$NON-NLS-1$
-
- fStore.setHRefs(getHRefs());
- }
-
- private String[] getHRefs() {
- HashSet res= new HashSet();
- List checked= fListDialogField.getCheckedElements();
- for (Iterator iterator= checked.iterator(); iterator.hasNext();) {
- JavadocLinkRef element= (JavadocLinkRef) iterator.next();
- URL url= element.getURL();
- if (url != null) {
- res.add(url.toExternalForm());
- }
- }
- return (String[]) res.toArray(new String[res.size()]);
- }
-
- //get the links
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- doValidation(STYLESHEETSTATUS);
- updateHRefList(fFirstPage.getCheckedProjects());
- } else {
- fStore.setHRefs(getHRefs());
- }
- }
-
- /**
- * Method will refresh the list of referenced libraries and projects
- * depended on the projects or elements of projects selected in the
- * TreeViewer on the JavadocTreeWizardPage.
- */
- private void updateHRefList(IJavaScriptProject[] checkedProjects) {
- JavadocLinkRef[] res= getReferencedElements(checkedProjects);
- fListDialogField.setElements(Arrays.asList(res));
-
- List checked= getCheckedReferences(res);
- fListDialogField.setCheckedElements(checked);
- }
-
- public void init() {
- updateStatus(new StatusInfo());
- }
-
- protected class FlaggedButton {
-
- private Button fButton;
- private String fFlag;
- private boolean fShowFlag;
-
- public FlaggedButton(Composite composite, String message, GridData gridData, String flag, boolean show) {
- fFlag= flag;
- fShowFlag= show;
- fButton= createButton(composite, SWT.CHECK, message, gridData);
- fButtonsList.add(this);
- setButtonSettings();
- }
-
- public Button getButton() {
- return fButton;
- }
-
- public String getFlag() {
- return fFlag;
- }
- public boolean show() {
- return fShowFlag;
- }
-
- private void setButtonSettings() {
-
- fButton.setSelection(!(fStore.getBoolean(fFlag) ^ fShowFlag));
- }
-
- } //end class FlaggesButton
-
- private class ListAdapter implements IListAdapter, IDialogFieldListener {
-
- /**
- * @see IListAdapter#customButtonPressed(ListDialogField, int)
- */
- public void customButtonPressed(ListDialogField field, int index) {
- if (index == 2)
- doEditButtonPressed();
- }
-
- /**
- * @see IListAdapter#selectionChanged(ListDialogField)
- */
- public void selectionChanged(ListDialogField field) {
- List selection= fListDialogField.getSelectedElements();
- if (selection.size() != 1) {
- fListDialogField.enableButton(2, false);
- } else {
- fListDialogField.enableButton(2, true);
- }
- }
-
- public void doubleClicked(ListDialogField field) {
- doEditButtonPressed();
- }
-
- public void dialogFieldChanged(DialogField field) {
- doValidation(LINK_REFERENCES);
- }
-
- }
-
- /**
- * Method doEditButtonPressed.
- */
- private void doEditButtonPressed() {
-
- List selected= fListDialogField.getSelectedElements();
- if (selected.isEmpty()) {
- return;
- }
- JavadocLinkRef obj= (JavadocLinkRef) selected.get(0);
- if (obj != null) {
- JavadocPropertyDialog jdialog= new JavadocPropertyDialog(getShell(), obj);
- if (jdialog.open() == Window.OK) {
- fListDialogField.refresh();
- }
- }
-
- }
-
- private class JavadocPropertyDialog extends StatusDialog implements IStatusChangeListener {
-
- private JavadocConfigurationBlock fJavadocConfigurationBlock;
- private JavadocLinkRef fElement;
-
- public JavadocPropertyDialog(Shell parent, JavadocLinkRef selection) {
- super(parent);
- setTitle(JavadocExportMessages.JavadocStandardWizardPage_javadocpropertydialog_title);
-
- fElement= selection;
- URL initialLocation= selection.getURL();
- fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, selection.isProjectRef());
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- Control inner= fJavadocConfigurationBlock.createContents(composite);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- applyDialogFont(composite);
- return composite;
- }
-
- public void statusChanged(IStatus status) {
- updateStatus(status);
-
- }
-
- /**
- * @see Dialog#okPressed()
- */
- protected void okPressed() {
- try {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation();
- fElement.setURL(javadocLocation, monitor);
- }
- };
- PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable));
-
- } catch (InvocationTargetException e) {
- String title= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_title;
- String message= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- } catch (InterruptedException e) {
- // user cancelled
- }
-
- fListDialogField.refresh();
- doValidation(LINK_REFERENCES);
- super.okPressed();
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.JAVADOC_PROPERTY_DIALOG);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocTreeWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocTreeWizardPage.java
deleted file mode 100644
index 8d6b28b5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocTreeWizardPage.java
+++ /dev/null
@@ -1,714 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-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.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class JavadocTreeWizardPage extends JavadocWizardPage {
-
- private CheckboxTreeAndListGroup fInputGroup;
-
- private Text fDestinationText;
- private Combo fJavadocCommandText;
- private Text fDocletText;
- private Text fDocletTypeText;
- private Button fStandardButton;
- private Button fDestinationBrowserButton;
- private Button fCustomButton;
- private Button fPrivateVisibility;
- private Button fProtectedVisibility;
- private Button fPackageVisibility;
- private Button fPublicVisibility;
- private Label fDocletLabel;
- private Label fDocletTypeLabel;
- private Label fDestinationLabel;
- private CLabel fDescriptionLabel;
-
- private String fVisibilitySelection;
-
- private JavadocOptionsManager fStore;
-
- private StatusInfo fJavadocStatus;
- private StatusInfo fDestinationStatus;
- private StatusInfo fDocletStatus;
- private StatusInfo fTreeStatus;
- private StatusInfo fPreferenceStatus;
- private StatusInfo fWizardStatus;
-
- private final int PREFERENCESTATUS= 0;
- private final int CUSTOMSTATUS= 1;
- private final int STANDARDSTATUS= 2;
- private final int TREESTATUS= 3;
- private final int JAVADOCSTATUS= 4;
-
- /**
- * Constructor for JavadocTreeWizardPage.
- * @param pageName
- */
- protected JavadocTreeWizardPage(String pageName, JavadocOptionsManager store) {
- super(pageName);
- setDescription(JavadocExportMessages.JavadocTreeWizardPage_javadoctreewizardpage_description);
-
- fStore= store;
-
- // Status variables
- fJavadocStatus= new StatusInfo();
- fDestinationStatus= new StatusInfo();
- fDocletStatus= new StatusInfo();
- fTreeStatus= new StatusInfo();
- fPreferenceStatus= new StatusInfo();
- fWizardStatus= store.getWizardStatus();
- }
-
- /*
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- final Composite composite= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 6;
- composite.setLayout(layout);
-
- createJavadocCommandSet(composite);
- createInputGroup(composite);
- createVisibilitySet(composite);
- createOptionsSet(composite);
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.JAVADOC_TREE_PAGE);
- }
-
- protected void createJavadocCommandSet(Composite composite) {
-
- final int numColumns= 2;
-
- GridLayout layout= createGridLayout(numColumns);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- Composite group = new Composite(composite, SWT.NONE);
- group.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 6, 0));
- group.setLayout(layout);
-
- createLabel(group, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_javadoccommand_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, numColumns, 0));
- fJavadocCommandText= createCombo(group, SWT.NONE, null, createGridData(GridData.FILL_HORIZONTAL, numColumns - 1, 0));
-
- fJavadocCommandText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(JAVADOCSTATUS);
- }
- });
-
- final Button javadocCommandBrowserButton= createButton(group, SWT.PUSH, JavadocExportMessages.JavadocTreeWizardPage_javadoccommand_button_label, createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 0));
- SWTUtil.setButtonDimensionHint(javadocCommandBrowserButton);
-
- javadocCommandBrowserButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- browseForJavadocCommand();
- }
- });
- }
-
-
-
-
- protected void createInputGroup(Composite composite) {
-
- createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_checkboxtreeandlistgroup_label, createGridData(6));
- Composite c= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.makeColumnsEqualWidth= true;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- c.setLayout(layout);
- c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 6, 0));
-
- ITreeContentProvider treeContentProvider= new JavadocProjectContentProvider();
- ITreeContentProvider listContentProvider= new JavadocMemberContentProvider();
- fInputGroup= new CheckboxTreeAndListGroup(c, this, treeContentProvider, new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT), listContentProvider, new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT), SWT.NONE, convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(10));
-
- fInputGroup.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent e) {
- doValidation(TREESTATUS);
- }
- });
- fInputGroup.setTreeComparator(new JavaScriptElementComparator());
-
- IJavaScriptElement[] elements= fStore.getInitialElements();
- setTreeChecked(elements);
- if (elements.length > 0) {
- fInputGroup.setTreeSelection(new StructuredSelection(elements[0].getJavaScriptProject()));
- }
-
- fInputGroup.aboutToOpen();
- }
-
- private void createVisibilitySet(Composite composite) {
-
- GridLayout visibilityLayout= createGridLayout(4);
- visibilityLayout.marginHeight= 0;
- visibilityLayout.marginWidth= 0;
- Composite visibilityGroup= new Composite(composite, SWT.NONE);
- visibilityGroup.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 6, 0));
- visibilityGroup.setLayout(visibilityLayout);
-
- createLabel(visibilityGroup, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_visibilitygroup_label, createGridData(GridData.FILL_HORIZONTAL, 4, 0));
- fPrivateVisibility= createButton(visibilityGroup, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_privatebutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- fPackageVisibility= createButton(visibilityGroup, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_packagebutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- fProtectedVisibility= createButton(visibilityGroup, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_protectedbutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
- fPublicVisibility= createButton(visibilityGroup, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_publicbutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
-
- fDescriptionLabel= new CLabel(visibilityGroup, SWT.LEFT);
- fDescriptionLabel.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 4, convertWidthInCharsToPixels(3) - 3)); // INDENT of CLabel
-
- fPrivateVisibility.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (((Button) e.widget).getSelection()) {
- fVisibilitySelection= fStore.PRIVATE;
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_privatevisibilitydescription_label);
- }
- }
- });
- fPackageVisibility.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (((Button) e.widget).getSelection()) {
- fVisibilitySelection= fStore.PACKAGE;
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_packagevisibledescription_label);
- }
- }
- });
- fProtectedVisibility.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (((Button) e.widget).getSelection()) {
- fVisibilitySelection= fStore.PROTECTED;
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_protectedvisibilitydescription_label);
- }
- }
- });
-
- fPublicVisibility.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (((Button) e.widget).getSelection()) {
- fVisibilitySelection= fStore.PUBLIC;
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_publicvisibilitydescription_label);
- }
- }
- });
-
- setVisibilitySettings();
-
- }
-
- protected void setVisibilitySettings() {
- fVisibilitySelection= fStore.getAccess();
- fPrivateVisibility.setSelection(fVisibilitySelection.equals(fStore.PRIVATE));
- if (fPrivateVisibility.getSelection())
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_privatevisibilitydescription_label);
-
- fProtectedVisibility.setSelection(fVisibilitySelection.equals(fStore.PROTECTED));
- if (fProtectedVisibility.getSelection())
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_protectedvisibilitydescription_label);
-
- fPackageVisibility.setSelection(fVisibilitySelection.equals(fStore.PACKAGE));
- if (fPackageVisibility.getSelection())
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_packagevisibledescription_label);
-
- fPublicVisibility.setSelection(fVisibilitySelection.equals(fStore.PUBLIC));
- if (fPublicVisibility.getSelection())
- fDescriptionLabel.setText(JavadocExportMessages.JavadocTreeWizardPage_publicvisibilitydescription_label);
- }
-
- private void createOptionsSet(Composite composite) {
-
- final int numColumns= 4;
-
- final GridLayout layout= createGridLayout(numColumns);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- Composite group= new Composite(composite, SWT.NONE);
- group.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 6, 0));
- group.setLayout(layout);
-
- fStandardButton= createButton(group, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_standarddocletbutton_label, createGridData(GridData.HORIZONTAL_ALIGN_FILL, numColumns, 0));
-
- fDestinationLabel= createLabel(group, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_destinationfield_label, createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, convertWidthInCharsToPixels(3)));
- fDestinationText= createText(group, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, numColumns - 2, 0));
- ((GridData) fDestinationText.getLayoutData()).widthHint= 0;
- fDestinationText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(STANDARDSTATUS);
- }
- });
-
- fDestinationBrowserButton= createButton(group, SWT.PUSH, JavadocExportMessages.JavadocTreeWizardPage_destinationbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
- SWTUtil.setButtonDimensionHint(fDestinationBrowserButton);
-
- //Option to use custom doclet
- fCustomButton= createButton(group, SWT.RADIO, JavadocExportMessages.JavadocTreeWizardPage_customdocletbutton_label, createGridData(GridData.HORIZONTAL_ALIGN_FILL, numColumns, 0));
-
- //For Entering location of custom doclet
- fDocletTypeLabel= createLabel(group, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_docletnamefield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, convertWidthInCharsToPixels(3)));
- fDocletTypeText= createText(group, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL, numColumns - 1, 0));
- ((GridData) fDocletTypeText.getLayoutData()).widthHint= 0;
-
-
- fDocletTypeText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(CUSTOMSTATUS);
- }
- });
-
- fDocletLabel= createLabel(group, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_docletpathfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, convertWidthInCharsToPixels(3)));
- fDocletText= createText(group, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL, numColumns - 1, 0));
- ((GridData) fDocletText.getLayoutData()).widthHint= 0;
-
- fDocletText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation(CUSTOMSTATUS);
- }
-
- });
-
- //Add Listeners
- fCustomButton.addSelectionListener(new EnableSelectionAdapter(new Control[] { fDocletLabel, fDocletText, fDocletTypeLabel, fDocletTypeText }, new Control[] { fDestinationLabel, fDestinationText, fDestinationBrowserButton }));
- fCustomButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- doValidation(CUSTOMSTATUS);
- }
- });
- fStandardButton.addSelectionListener(new EnableSelectionAdapter(new Control[] { fDestinationLabel, fDestinationText, fDestinationBrowserButton }, new Control[] { fDocletLabel, fDocletText, fDocletTypeLabel, fDocletTypeText }));
- fStandardButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- doValidation(STANDARDSTATUS);
- }
- });
- fDestinationBrowserButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- String text= handleFolderBrowseButtonPressed(fDestinationText.getText(), JavadocExportMessages.JavadocTreeWizardPage_destinationbrowsedialog_title,
- JavadocExportMessages.JavadocTreeWizardPage_destinationbrowsedialog_label);
- fDestinationText.setText(text);
- }
- });
-
- setOptionSetSettings();
- }
-
- public boolean getCustom() {
- return fCustomButton.getSelection();
- }
-
- private void setOptionSetSettings() {
-
- if (!fStore.isFromStandard()) {
- fCustomButton.setSelection(true);
- fDocletText.setText(fStore.getDocletPath());
- fDocletTypeText.setText(fStore.getDocletName());
- fDestinationText.setText(fStore.getDestination());
- fDestinationText.setEnabled(false);
- fDestinationBrowserButton.setEnabled(false);
- fDestinationLabel.setEnabled(false);
-
- } else {
- fStandardButton.setSelection(true);
- fDestinationText.setText(fStore.getDestination());
- fDocletText.setText(fStore.getDocletPath());
- fDocletTypeText.setText(fStore.getDocletName());
- fDocletText.setEnabled(false);
- fDocletLabel.setEnabled(false);
- fDocletTypeText.setEnabled(false);
- fDocletTypeLabel.setEnabled(false);
- }
-
- fJavadocCommandText.setItems(fStore.getJavadocCommandHistory());
- fJavadocCommandText.select(0);
- }
-
- /**
- * Receives of list of elements selected by the user and passes them
- * to the CheckedTree. List can contain multiple projects and elements from
- * different projects. If the list of seletected elements is empty a default
- * project is selected.
- */
- private void setTreeChecked(IJavaScriptElement[] sourceElements) {
- for (int i= 0; i < sourceElements.length; i++) {
- IJavaScriptElement curr= sourceElements[i];
- if (curr instanceof IJavaScriptUnit) {
- fInputGroup.initialCheckListItem(curr);
- } else if (curr instanceof IPackageFragment) {
- fInputGroup.initialCheckTreeItem(curr);
- } else if (curr instanceof IJavaScriptProject) {
- fInputGroup.initialCheckTreeItem(curr);
- } else if (curr instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) curr;
- if (!root.isArchive())
- fInputGroup.initialCheckTreeItem(curr);
- }
- }
- }
-
- private IPath[] getSourcePath(IJavaScriptProject[] projects) {
- HashSet res= new HashSet();
- //loops through all projects and gets a list if of their source paths
- for (int k= 0; k < projects.length; k++) {
- IJavaScriptProject iJavaProject= projects[k];
-
- try {
- IPackageFragmentRoot[] roots= iJavaProject.getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot curr= roots[i];
- if (curr.getKind() == IPackageFragmentRoot.K_SOURCE) {
- IResource resource= curr.getResource();
- if (resource != null) {
- // Using get location is OK here. If the source folder
- // isn't local we can't create Javadoc for it.
- IPath p= resource.getLocation();
- if (p != null) {
- res.add(p);
- }
- }
- }
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return (IPath[]) res.toArray(new IPath[res.size()]);
- }
-
- private IPath[] getClassPath(IJavaScriptProject[] javaProjects) {
- HashSet res= new HashSet();
-
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- for (int j= 0; j < javaProjects.length; j++) {
- IJavaScriptProject curr= javaProjects[j];
- try {
- IPath outputLocation= null;
-
- // Not really clear yet what to do here for EFS. See bug
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=113233.
-
- // However if the output location is not local it is currently
- // not part of JavaRuntime.computeDefaultRuntimeClassPath either
- // so it will be simply not added to the result which would be
- // correct.
- IResource outputPathFolder= root.findMember(curr.getOutputLocation());
- if (outputPathFolder != null)
- outputLocation= outputPathFolder.getLocation();
-
- String[] classPath= JavaRuntime.computeDefaultRuntimeClassPath(curr);
- for (int i= 0; i < classPath.length; i++) {
- IPath path= Path.fromOSString(classPath[i]);
- if (!path.equals(outputLocation)) {
- res.add(path);
- }
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return (IPath[]) res.toArray(new IPath[res.size()]);
- }
-
- /**
- * Gets a list of elements to generated javadoc for from each project.
- * Javadoc can be generated for either a IPackageFragment or a IJavaScriptUnit.
- */
- private IJavaScriptElement[] getSourceElements(IJavaScriptProject[] projects) {
- ArrayList res= new ArrayList();
- try {
- Set allChecked= fInputGroup.getAllCheckedTreeItems();
-
- Set incompletePackages= new HashSet();
- for (int h= 0; h < projects.length; h++) {
- IJavaScriptProject iJavaProject= projects[h];
-
- IPackageFragmentRoot[] roots= iJavaProject.getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
- IPath rootLocation= root.getResource().getLocation();
- IJavaScriptElement[] packs= root.getChildren();
- for (int k= 0; k < packs.length; k++) {
- IJavaScriptElement curr= packs[k];
- if (curr.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT) {
- // default packages are always incomplete
- if (curr.getElementName().length() == 0 || !allChecked.contains(curr)
- || fInputGroup.isTreeItemGreyChecked(curr) || !isAccessibleLocation(curr.getResource().getLocation(), rootLocation)) {
- incompletePackages.add(curr.getElementName());
- }
- }
- }
- }
- }
- }
-
- Iterator checkedElements= fInputGroup.getAllCheckedListItems();
- while (checkedElements.hasNext()) {
- Object element= checkedElements.next();
- if (element instanceof IJavaScriptUnit) {
- IJavaScriptUnit unit= (IJavaScriptUnit) element;
- if (incompletePackages.contains(unit.getParent().getElementName())) {
- res.add(unit);
- }
- }
- }
-
- Set addedPackages= new HashSet();
-
- checkedElements= allChecked.iterator();
- while (checkedElements.hasNext()) {
- Object element= checkedElements.next();
- if (element instanceof IPackageFragment) {
- IPackageFragment fragment= (IPackageFragment) element;
- String name= fragment.getElementName();
- if (!incompletePackages.contains(name) && !addedPackages.contains(name)) {
- res.add(fragment);
- addedPackages.add(name);
- }
- }
- }
-
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return (IJavaScriptElement[]) res.toArray(new IJavaScriptElement[res.size()]);
- }
-
- private boolean isAccessibleLocation(IPath packageLocation, IPath rootLocation) {
- return rootLocation != null && packageLocation != null && rootLocation.isPrefixOf(packageLocation);
- }
-
- protected void updateStore(IJavaScriptProject[] checkedProjects) {
-
- if (fCustomButton.getSelection()) {
- fStore.setDocletName(fDocletTypeText.getText());
- fStore.setDocletPath(fDocletText.getText());
- fStore.setFromStandard(false);
- }
- if (fStandardButton.getSelection()) {
- fStore.setFromStandard(true);
- //the destination used in javadoc generation
- fStore.setDestination(fDestinationText.getText());
- }
-
- fStore.setSourcepath(getSourcePath(checkedProjects));
- fStore.setClasspath(getClassPath(checkedProjects));
- fStore.setAccess(fVisibilitySelection);
- fStore.setSelectedElements(getSourceElements(checkedProjects));
-
- ArrayList commands= new ArrayList();
- commands.add(fJavadocCommandText.getText()); // must be first
- String[] items= fJavadocCommandText.getItems();
- for (int i= 0; i < items.length; i++) {
- String curr= items[i];
- if (!commands.contains(curr)) {
- commands.add(curr);
- }
- }
- fStore.setJavadocCommandHistory((String[]) commands.toArray(new String[commands.size()]));
- }
-
- public IJavaScriptProject[] getCheckedProjects() {
- ArrayList res= new ArrayList();
- TreeItem[] treeItems= fInputGroup.getTree().getItems();
- for (int i= 0; i < treeItems.length; i++) {
- if (treeItems[i].getChecked()) {
- Object curr= treeItems[i].getData();
- if (curr instanceof IJavaScriptProject) {
- res.add(curr);
- }
- }
- }
- return (IJavaScriptProject[]) res.toArray(new IJavaScriptProject[res.size()]);
- }
-
- protected void doValidation(int validate) {
-
-
- switch (validate) {
- case PREFERENCESTATUS :
- fPreferenceStatus= new StatusInfo();
- fDocletStatus= new StatusInfo();
- updateStatus(findMostSevereStatus());
- break;
- case CUSTOMSTATUS :
-
- if (fCustomButton.getSelection()) {
- fDestinationStatus= new StatusInfo();
- fDocletStatus= new StatusInfo();
- String doclet= fDocletTypeText.getText();
- String docletPath= fDocletText.getText();
- if (doclet.length() == 0) {
- fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_nodocletname_error);
-
- } else if (JavaScriptConventions.validateJavaScriptTypeName(doclet).matches(IStatus.ERROR)) {
- fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddocletname_error);
- } else if ((docletPath.length() == 0) || !validDocletPath(docletPath)) {
- fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddocletpath_error);
- }
- updateStatus(findMostSevereStatus());
- }
- break;
-
- case STANDARDSTATUS :
- if (fStandardButton.getSelection()) {
- fDestinationStatus= new StatusInfo();
- fDocletStatus= new StatusInfo();
- String dest= fDestinationText.getText();
- if (dest.length() == 0) {
- fDestinationStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_nodestination_error);
- }
- File file= new File(dest);
- if (!Path.ROOT.isValidPath(dest) || file.isFile()) {
- fDestinationStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddestination_error);
- }
- if (new File(dest, "package-list").exists() || new File(dest, "index.html").exists()) //$NON-NLS-1$//$NON-NLS-2$
- fDestinationStatus.setWarning(JavadocExportMessages.JavadocTreeWizardPage_warning_mayoverwritefiles);
- updateStatus(findMostSevereStatus());
- }
- break;
-
- case TREESTATUS :
-
- fTreeStatus= new StatusInfo();
-
- if (!fInputGroup.getAllCheckedListItems().hasNext())
- fTreeStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invalidtreeselection_error);
- updateStatus(findMostSevereStatus());
-
- break;
-
- case JAVADOCSTATUS:
- fJavadocStatus= new StatusInfo();
- String text= fJavadocCommandText.getText();
- if (text.length() == 0) {
- fJavadocStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_javadoccmd_error_enterpath);
- } else {
- File file= new File(text);
- if (!file.isFile()) {
- fJavadocStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_javadoccmd_error_notexists);
- }
- }
- updateStatus(findMostSevereStatus());
- break;
- } //end switch
-
-
- }
-
- protected void browseForJavadocCommand() {
- FileDialog dialog= new FileDialog(getShell());
- dialog.setText(JavadocExportMessages.JavadocTreeWizardPage_javadoccmd_dialog_title);
- String dirName= fJavadocCommandText.getText();
- dialog.setFileName(dirName);
- String selectedDirectory= dialog.open();
- if (selectedDirectory != null) {
- ArrayList newItems= new ArrayList();
- String[] items= fJavadocCommandText.getItems();
- newItems.add(selectedDirectory);
- for (int i= 0; i < items.length && newItems.size() < 5; i++) { // only keep the last 5 entries
- String curr= items[i];
- if (!newItems.contains(curr)) {
- newItems.add(curr);
- }
- }
- fJavadocCommandText.setItems((String[]) newItems.toArray(new String[newItems.size()]));
- fJavadocCommandText.select(0);
- }
- }
-
-
- private boolean validDocletPath(String docletPath) {
- StringTokenizer tokens= new StringTokenizer(docletPath, ";"); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- File file= new File(tokens.nextToken());
- if (!file.exists())
- return false;
- }
- return true;
- }
-
- /**
- * Finds the most severe error (if there is one)
- */
- private IStatus findMostSevereStatus() {
- return StatusUtil.getMostSevere(new IStatus[] { fJavadocStatus, fPreferenceStatus, fDestinationStatus, fDocletStatus, fTreeStatus, fWizardStatus });
- }
-
- public void init() {
- updateStatus(new StatusInfo());
- }
-
- public void setVisible(boolean visible) {
- if (visible) {
- doValidation(STANDARDSTATUS);
- doValidation(CUSTOMSTATUS);
- doValidation(TREESTATUS);
- doValidation(PREFERENCESTATUS);
- doValidation(JAVADOCSTATUS);
- }
- super.setVisible(visible);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizard.java
deleted file mode 100644
index 397a780a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizard.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids <sdavids@gmx.de> bug 38692
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.Launch;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IExportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.actions.OpenBrowserUtil;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.OptionalMessageDialog;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSaveHelper;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavadocWizard extends Wizard implements IExportWizard {
-
- private JavadocTreeWizardPage fJTWPage;
- private JavadocSpecificsWizardPage fJSWPage;
- private JavadocStandardWizardPage fJSpWPage;
-
- private IPath fDestination;
-
- private boolean fWriteCustom;
- private boolean fOpenInBrowser;
-
- private final String TREE_PAGE_DESC= "JavadocTreePage"; //$NON-NLS-1$
- private final String SPECIFICS_PAGE_DESC= "JavadocSpecificsPage"; //$NON-NLS-1$
- private final String STANDARD_PAGE_DESC= "JavadocStandardPage"; //$NON-NLS-1$
-
- private final int YES= 0;
- private final int YES_TO_ALL= 1;
- private final int NO= 2;
- private final int NO_TO_ALL= 3;
- private final String JAVADOC_ANT_INFORMATION_DIALOG= "javadocAntInformationDialog";//$NON-NLS-1$
-
-
- private JavadocOptionsManager fStore;
- private IWorkspaceRoot fRoot;
-
- private IFile fXmlJavadocFile;
-
- private static final String ID_JAVADOC_PROCESS_TYPE= "org.eclipse.wst.jsdt.ui.javadocProcess"; //$NON-NLS-1$
-
- public static void openJavadocWizard(JavadocWizard wizard, Shell shell, IStructuredSelection selection ) {
- wizard.init(PlatformUI.getWorkbench(), selection);
-
- WizardDialog dialog= new WizardDialog(shell, wizard);
- PixelConverter converter= new PixelConverter(JFaceResources.getDialogFont());
- dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(100), converter.convertHeightInCharsToPixels(20));
- dialog.open();
- }
-
-
- public JavadocWizard() {
- this(null);
- }
-
- public JavadocWizard(IFile xmlJavadocFile) {
- super();
- setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_EXPORT_JAVADOC);
- setWindowTitle(JavadocExportMessages.JavadocWizard_javadocwizard_title);
-
- setDialogSettings(JavaScriptPlugin.getDefault().getDialogSettings());
-
- fRoot= ResourcesPlugin.getWorkspace().getRoot();
- fXmlJavadocFile= xmlJavadocFile;
-
- fWriteCustom= false;
- }
-
- /*
- * @see IWizard#performFinish()
- */
- public boolean performFinish() {
-
- IJavaScriptProject[] checkedProjects= fJTWPage.getCheckedProjects();
- updateStore(checkedProjects);
-
- fStore.updateDialogSettings(getDialogSettings(), checkedProjects);
-
- // Wizard should not run with dirty editors
- if (!new RefactoringSaveHelper(RefactoringSaveHelper.SAVE_ALL_ALWAYS_ASK).saveEditors(getShell())) {
- return false;
- }
-
- fDestination= Path.fromOSString(fStore.getDestination());
- fDestination.toFile().mkdirs();
-
- fOpenInBrowser= fStore.doOpenInBrowser();
-
- //Ask if you wish to set the javadoc location for the projects (all) to
- //the location of the newly generated javadoc
- if (fStore.isFromStandard()) {
- try {
-
- URL newURL= fDestination.toFile().toURL();
- List projs= new ArrayList();
- //get javadoc locations for all projects
- for (int i= 0; i < checkedProjects.length; i++) {
- IJavaScriptProject curr= checkedProjects[i];
- URL currURL= JavaScriptUI.getProjectJSdocLocation(curr);
- if (!newURL.equals(currURL)) { // currURL can be null
- //if not all projects have the same javadoc location ask if you want to change
- //them to have the same javadoc location
- projs.add(curr);
- }
- }
- if (!projs.isEmpty()) {
- setAllJavadocLocations((IJavaScriptProject[]) projs.toArray(new IJavaScriptProject[projs.size()]), newURL);
- }
- } catch (MalformedURLException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- if (fJSWPage.generateAnt()) {
- //@Improve: make a better message
- OptionalMessageDialog.open(JAVADOC_ANT_INFORMATION_DIALOG, getShell(), JavadocExportMessages.JavadocWizard_antInformationDialog_title, null, JavadocExportMessages.JavadocWizard_antInformationDialog_message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
- try {
- File file= fStore.createXML(checkedProjects);
- if (file != null) {
- IFile[] files= fRoot.findFilesForLocation(Path.fromOSString(file.getPath()));
- if (files != null) {
- for (int i= 0; i < files.length; i++) {
- files[i].refreshLocal(IResource.DEPTH_ONE, null);
- }
- }
- }
-
- } catch (CoreException e) {
- ExceptionHandler.handle(e, getShell(),JavadocExportMessages.JavadocWizard_error_writeANT_title, JavadocExportMessages.JavadocWizard_error_writeANT_message);
- }
- }
-
- if (!executeJavadocGeneration())
- return false;
-
- return true;
- }
-
- private void updateStore(IJavaScriptProject[] checkedProjects) {
- //writes the new settings to store
- fJTWPage.updateStore(checkedProjects);
- if (!fJTWPage.getCustom())
- fJSpWPage.updateStore();
- fJSWPage.updateStore();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performCancel()
- */
- public boolean performCancel() {
-
- IJavaScriptProject[] checkedProjects= fJTWPage.getCheckedProjects();
- updateStore(checkedProjects);
-
- //If the wizard was not launched from an ant file store the settings
- if (fXmlJavadocFile == null) {
- fStore.updateDialogSettings(getDialogSettings(), checkedProjects);
- }
- return super.performCancel();
- }
-
- private void setAllJavadocLocations(IJavaScriptProject[] projects, URL newURL) {
- Shell shell= getShell();
- String[] buttonlabels= new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL };
-
- for (int j= 0; j < projects.length; j++) {
- IJavaScriptProject iJavaProject= projects[j];
- String message= Messages.format(JavadocExportMessages.JavadocWizard_updatejavadoclocation_message, new String[] { iJavaProject.getElementName(), fDestination.toOSString()});
- MessageDialog dialog= new MessageDialog(shell, JavadocExportMessages.JavadocWizard_updatejavadocdialog_label, null, message, MessageDialog.QUESTION, buttonlabels, 1);
-
- switch (dialog.open()) {
- case YES :
- JavaScriptUI.setProjectJSdocLocation(iJavaProject, newURL);
- break;
- case YES_TO_ALL :
- for (int i= j; i < projects.length; i++) {
- iJavaProject= projects[i];
- JavaScriptUI.setProjectJSdocLocation(iJavaProject, newURL);
- j++;
- }
- break;
- case NO_TO_ALL :
- j= projects.length;
- break;
- case NO :
- default :
- break;
- }
- }
- }
-
- private boolean executeJavadocGeneration() {
- Process process= null;
- try {
- ArrayList vmArgs= new ArrayList();
- ArrayList progArgs= new ArrayList();
-
- IStatus status= fStore.getArgumentArray(vmArgs, progArgs);
- if (!status.isOK()) {
- ErrorDialog.openError(getShell(), JavadocExportMessages.JavadocWizard_error_title, JavadocExportMessages.JavadocWizard_warning_starting_message, status);
- }
-
- File file= File.createTempFile("javadoc-arguments", ".tmp"); //$NON-NLS-1$//$NON-NLS-2$
- vmArgs.add('@' + file.getAbsolutePath());
-
- FileWriter writer= new FileWriter(file);
- try {
- for (int i= 0; i < progArgs.size(); i++) {
- String curr= (String) progArgs.get(i);
- curr= checkForSpaces(curr);
-
- writer.write(curr);
- writer.write(' ');
- }
- } finally {
- writer.close();
- }
-
- String[] args= (String[]) vmArgs.toArray(new String[vmArgs.size()]);
- process= Runtime.getRuntime().exec(args);
- if (process != null) {
- // construct a formatted command line for the process properties
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < args.length; i++) {
- buf.append(args[i]);
- buf.append(' ');
- }
-
- IDebugEventSetListener listener= new JavadocDebugEventListener(getShell().getDisplay(), file);
- DebugPlugin.getDefault().addDebugEventListener(listener);
-
- ILaunchConfigurationWorkingCopy wc= null;
- try {
- ILaunchConfigurationType lcType= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
- String name= JavadocExportMessages.JavadocWizard_launchconfig_name;
- wc= lcType.newInstance(null, name);
- wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
-
- ILaunch newLaunch= new Launch(wc, ILaunchManager.RUN_MODE, null);
- IProcess iprocess= DebugPlugin.newProcess(newLaunch, process, JavadocExportMessages.JavadocWizard_javadocprocess_label);
- iprocess.setAttribute(IProcess.ATTR_CMDLINE, buf.toString());
- iprocess.setAttribute(IProcess.ATTR_PROCESS_TYPE, ID_JAVADOC_PROCESS_TYPE);
-
- DebugPlugin.getDefault().getLaunchManager().addLaunch(newLaunch);
-
- } catch (CoreException e) {
- String title= JavadocExportMessages.JavadocWizard_error_title;
- String message= JavadocExportMessages.JavadocWizard_launch_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- }
-
- return true;
-
- }
- } catch (IOException e) {
- String title= JavadocExportMessages.JavadocWizard_error_title;
- String message= JavadocExportMessages.JavadocWizard_exec_error_message;
-
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.ERROR, e.getMessage(), e);
- ExceptionHandler.handle(new CoreException(status), getShell(), title, message);
- return false;
- }
- return false;
-
- }
-
- private String checkForSpaces(String curr) {
- if (curr.indexOf(' ') == -1) {
- return curr;
- }
- StringBuffer buf= new StringBuffer();
- buf.append('\'');
- for (int i= 0; i < curr.length(); i++) {
- char ch= curr.charAt(i);
- if (ch == '\\' || ch == '\'') {
- buf.append('\\');
- }
- buf.append(ch);
- }
- buf.append('\'');
- return buf.toString();
- }
-
- /*
- * @see IWizard#addPages()
- */
- public void addPages() {
-
- fJTWPage= new JavadocTreeWizardPage(TREE_PAGE_DESC, fStore);
- fJSWPage= new JavadocSpecificsWizardPage(SPECIFICS_PAGE_DESC, fJTWPage, fStore);
- fJSpWPage= new JavadocStandardWizardPage(STANDARD_PAGE_DESC, fJTWPage, fStore);
-
- super.addPage(fJTWPage);
- super.addPage(fJSpWPage);
- super.addPage(fJSWPage);
-
- fJTWPage.init();
- fJSpWPage.init();
- fJSWPage.init();
-
- }
-
- public void init(IWorkbench workbench, IStructuredSelection structuredSelection) {
- IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
- List selected= Collections.EMPTY_LIST;
- if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
- if (selection instanceof IStructuredSelection) {
- selected= ((IStructuredSelection) selection).toList();
- } else {
- IJavaScriptElement element= EditorUtility.getActiveEditorJavaInput();
- if (element != null) {
- selected= new ArrayList();
- selected.add(element);
- }
- }
- }
- fStore= new JavadocOptionsManager(fXmlJavadocFile, getDialogSettings(), selected);
- }
-
- private void refresh(IPath path) {
- if (fRoot.findContainersForLocation(path).length > 0) {
- try {
- fRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- private void spawnInBrowser(Display display) {
- if (fOpenInBrowser) {
- try {
- IPath indexFile= fDestination.append("index.html"); //$NON-NLS-1$
- URL url= indexFile.toFile().toURL();
- OpenBrowserUtil.open(url, display, getWindowTitle());
- } catch (MalformedURLException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- private class JavadocDebugEventListener implements IDebugEventSetListener {
- private Display fDisplay;
- private File fFile;
-
- public JavadocDebugEventListener(Display display, File file) {
- fDisplay= display;
- fFile= file;
- }
-
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i= 0; i < events.length; i++) {
- if (events[i].getKind() == DebugEvent.TERMINATE) {
- try {
- if (!fWriteCustom) {
- fFile.delete();
- refresh(fDestination); //If destination of javadoc is in workspace then refresh workspace
- spawnInBrowser(fDisplay);
- }
- } finally {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
- return;
- }
- }
- }
- }
-
- public IWizardPage getNextPage(IWizardPage page) {
- if (page instanceof JavadocTreeWizardPage) {
- if (!fJTWPage.getCustom()) {
- return fJSpWPage;
- }
- return fJSWPage;
- } else if (page instanceof JavadocSpecificsWizardPage) {
- return null;
- } else if (page instanceof JavadocStandardWizardPage)
- return fJSWPage;
- else
- return null;
- }
-
- public IWizardPage getPreviousPage(IWizardPage page) {
- if (page instanceof JavadocSpecificsWizardPage) {
- if (!fJTWPage.getCustom()) {
- return fJSpWPage;
- }
- return fJSWPage;
- } else if (page instanceof JavadocTreeWizardPage) {
- return null;
- } else if (page instanceof JavadocStandardWizardPage)
- return fJTWPage;
- else
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizardPage.java
deleted file mode 100644
index 361991b2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWizardPage.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-
-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.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.ui.wizards.NewElementWizardPage;
-
-public abstract class JavadocWizardPage extends NewElementWizardPage {
-
- protected JavadocWizardPage(String pageName) {
- super(pageName);
- setTitle(JavadocExportMessages.JavadocWizardPage_javadocwizardpage_description);
- }
-
- protected Button createButton(Composite composite, int style, String message, GridData gd) {
- Button button= new Button(composite, style);
- button.setText(message);
- button.setLayoutData(gd);
- return button;
- }
-
- protected GridLayout createGridLayout(int columns) {
- return new GridLayout(columns, false);
-
- }
-
- protected GridData createGridData(int flag, int hspan, int vspan, int indent) {
- GridData gd= new GridData(flag);
- gd.horizontalIndent= indent;
- gd.horizontalSpan= hspan;
- gd.verticalSpan= vspan;
- return gd;
- }
-
- protected GridData createGridData(int flag, int hspan, int indent) {
- GridData gd= new GridData(flag);
- gd.horizontalIndent= indent;
- gd.horizontalSpan= hspan;
- return gd;
- }
-
- protected GridData createGridData(int hspan) {
- GridData gd= new GridData();
- gd.horizontalSpan= hspan;
- return gd;
- }
-
- protected Label createLabel(Composite composite, int style, String message, GridData gd) {
- Label label= new Label(composite, style);
- label.setText(message);
- label.setLayoutData(gd);
- return label;
- }
-
- protected Text createText(Composite composite, int style, String message, GridData gd) {
- Text text= new Text(composite, style);
- if (message != null)
- text.setText(message);
- text.setLayoutData(gd);
- return text;
- }
-
- protected Combo createCombo(Composite composite, int style, String message, GridData gd) {
- Combo combo= new Combo(composite, style);
- if (message != null)
- combo.setText(message);
- combo.setLayoutData(gd);
- return combo;
- }
-
- protected void handleFileBrowseButtonPressed(Text text, String[] extensions, String title) {
- FileDialog dialog= new FileDialog(text.getShell());
- dialog.setText(title);
- dialog.setFilterExtensions(extensions);
- String dirName= text.getText();
- if (!dirName.equals("")) { //$NON-NLS-1$
- File path= new File(dirName);
- if (path.exists())
- dialog.setFilterPath(dirName);
-
- }
- String selectedDirectory= dialog.open();
- if (selectedDirectory != null)
- text.setText(selectedDirectory);
- }
-
- protected String handleFolderBrowseButtonPressed(String dir, String title, String message) {
- DirectoryDialog dialog= new DirectoryDialog(getShell());
- dialog.setFilterPath(dir);
- dialog.setText(title);
- dialog.setMessage(message);
- String res= dialog.open();
- if (res != null) {
- File file= new File(res);
- if (file.isDirectory())
- return res;
- }
- return dir;
- }
-
- protected static class EnableSelectionAdapter extends SelectionAdapter {
- private Control[] fEnable;
- private Control[] fDisable;
-
- protected EnableSelectionAdapter(Control[] enable, Control[] disable) {
- super();
- fEnable= enable;
- fDisable= disable;
- }
-
- public void widgetSelected(SelectionEvent e) {
- for (int i= 0; i < fEnable.length; i++) {
- fEnable[i].setEnabled(true);
- }
- for (int i= 0; i < fDisable.length; i++) {
- fDisable[i].setEnabled(false);
- }
- validate();
- }
- //copied from WizardNewProjectCreationPage
- public void validate() {
- }
-
- } //end class EnableSelectionAdapter
-
- protected static class ToggleSelectionAdapter extends SelectionAdapter {
- Control[] controls;
-
- protected ToggleSelectionAdapter(Control[] controls) {
- this.controls= controls;
- }
-
- public void widgetSelected(SelectionEvent e) {
-
- for (int i= 0; i < controls.length; i++) {
- Control control= controls[i];
- control.setEnabled(!control.getEnabled());
- }
- validate();
- }
-
- public void validate() {
- }
-
- } //end class ToggleSelection Adapter
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWriter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWriter.java
deleted file mode 100644
index 39e082a9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/JavadocWriter.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class JavadocWriter {
-
- private static final char PATH_SEPARATOR= '/'; // use forward slash for all platforms
-
- private final OutputStream fOutputStream;
- private final IJavaScriptProject[] fJavaProjects;
- private final IPath fBasePath;
- private final String fEncoding;
-
- /**
- * Create a JavadocWriter on the given output stream.
- * It is the client's responsibility to close the output stream.
- * @param basePath The base path to which all path will be made relative (if
- * possible). If <code>null</code>, paths are not made relative.
- */
- public JavadocWriter(OutputStream outputStream, String encoding, IPath basePath, IJavaScriptProject[] projects) {
- Assert.isNotNull(outputStream);
- Assert.isNotNull(encoding);
- fOutputStream= new BufferedOutputStream(outputStream);
- fEncoding= encoding;
- fBasePath= basePath;
- fJavaProjects= projects;
- }
-
- public void writeXML(JavadocOptionsManager store) throws ParserConfigurationException, TransformerException {
-
- DocumentBuilder docBuilder= null;
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- docBuilder= factory.newDocumentBuilder();
- Document document= docBuilder.newDocument();
-
- // Create the document
- Element project= document.createElement("project"); //$NON-NLS-1$
- document.appendChild(project);
-
- project.setAttribute("default", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$
-
- Element javadocTarget= document.createElement("target"); //$NON-NLS-1$
- project.appendChild(javadocTarget);
- javadocTarget.setAttribute("name", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$
-
- Element xmlJavadocDesc= document.createElement("javadoc"); //$NON-NLS-1$
- javadocTarget.appendChild(xmlJavadocDesc);
-
- if (!store.isFromStandard())
- xmlWriteDoclet(store, document, xmlJavadocDesc);
- else
- xmlWriteJavadocStandardParams(store, document, xmlJavadocDesc);
-
-
- // Write the document to the stream
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, fEncoding);
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(fOutputStream);
- transformer.transform(source, result);
-
- }
-
- //writes ant file, for now only worry about one project
- private void xmlWriteJavadocStandardParams(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException {
-
- String destination= getPathString(Path.fromOSString(store.getDestination()));
-
- xmlJavadocDesc.setAttribute(store.DESTINATION, destination);
- xmlJavadocDesc.setAttribute(store.VISIBILITY, store.getAccess());
- String source= store.getSource();
- if (source.length() > 0 && !source.equals("-")) { //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.SOURCE, store.getSource());
- }
- xmlJavadocDesc.setAttribute(store.USE, booleanToString(store.getBoolean("use"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.NOTREE, booleanToString(store.getBoolean("notree"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.NONAVBAR, booleanToString(store.getBoolean("nonavbar"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.NOINDEX, booleanToString(store.getBoolean("noindex"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.SPLITINDEX, booleanToString(store.getBoolean("splitindex"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.AUTHOR, booleanToString(store.getBoolean("author"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.VERSION, booleanToString(store.getBoolean("version"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.NODEPRECATEDLIST, booleanToString(store.getBoolean("nodeprecatedlist"))); //$NON-NLS-1$
- xmlJavadocDesc.setAttribute(store.NODEPRECATED, booleanToString(store.getBoolean("nodeprecated"))); //$NON-NLS-1$
-
-
- //set the packages and source files
- List packages= new ArrayList();
- List sourcefiles= new ArrayList();
- sortSourceElement(store.getSourceElements(), sourcefiles, packages);
- if (!packages.isEmpty())
- xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages));
-
- if (!sourcefiles.isEmpty())
- xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles));
-
- xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath()));
- xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath()));
-
- String overview= store.getOverview();
- if (overview.length() > 0)
- xmlJavadocDesc.setAttribute(store.OVERVIEW, overview);
-
- String styleSheet= store.getStyleSheet();
- if (styleSheet.length() > 0)
- xmlJavadocDesc.setAttribute(store.STYLESHEETFILE, styleSheet);
-
- String title= store.getTitle();
- if (title.length() > 0)
- xmlJavadocDesc.setAttribute(store.TITLE, title);
-
-
- String vmArgs= store.getVMParams();
- String additionalArgs= store.getAdditionalParams();
- if (vmArgs.length() + additionalArgs.length() > 0) {
- String str= vmArgs + ' ' + additionalArgs;
- xmlJavadocDesc.setAttribute(store.EXTRAOPTIONS, str);
- }
-
- String[] hrefs= store.getHRefs();
- for (int i= 0; i < hrefs.length; i++) {
- Element links= document.createElement("link"); //$NON-NLS-1$
- xmlJavadocDesc.appendChild(links);
- links.setAttribute(store.HREF, hrefs[i]);
- }
- }
-
- private void sortSourceElement(IJavaScriptElement[] iJavaElements, List sourcefiles, List packages) {
- for (int i= 0; i < iJavaElements.length; i++) {
- IJavaScriptElement element= iJavaElements[i];
- IPath p= element.getResource().getLocation();
- if (p == null)
- continue;
-
- if (element instanceof IJavaScriptUnit) {
- String relative= getPathString(p);
- sourcefiles.add(relative);
- } else if (element instanceof IPackageFragment) {
- packages.add(element.getElementName());
- }
- }
- }
-
- private String getPathString(IPath[] paths) {
- StringBuffer buf= new StringBuffer();
-
- for (int i= 0; i < paths.length; i++) {
- if (buf.length() != 0) {
- buf.append(File.pathSeparatorChar);
- }
- buf.append(getPathString(paths[i]));
- }
-
- if (buf.length() == 0) {
- buf.append('.');
- }
- return buf.toString();
- }
-
- private boolean hasSameDevice(IPath p1, IPath p2) {
- String dev= p1.getDevice();
- if (dev == null) {
- return p2.getDevice() == null;
- }
- return dev.equals(p2.getDevice());
- }
-
- //make the path relative to the base path
- private String getPathString(IPath fullPath) {
- if (fBasePath == null || !hasSameDevice(fullPath, fBasePath)) {
- return fullPath.toOSString();
- }
- int matchingSegments= fBasePath.matchingFirstSegments(fullPath);
- if (fBasePath.segmentCount() == matchingSegments) {
- return getRelativePath(fullPath, matchingSegments);
- }
- for (int i= 0; i < fJavaProjects.length; i++) {
- IProject proj= fJavaProjects[i].getProject();
- IPath projLoc= proj.getLocation();
- if (projLoc != null && projLoc.segmentCount() <= matchingSegments && projLoc.isPrefixOf(fullPath)) {
- return getRelativePath(fullPath, matchingSegments);
- }
- }
- IPath workspaceLoc= ResourcesPlugin.getWorkspace().getRoot().getLocation();
- if (workspaceLoc.segmentCount() <= matchingSegments && workspaceLoc.isPrefixOf(fullPath)) {
- return getRelativePath(fullPath, matchingSegments);
- }
- return fullPath.toOSString();
- }
-
- private String getRelativePath(IPath fullPath, int matchingSegments) {
- StringBuffer res= new StringBuffer();
- int backSegments= fBasePath.segmentCount() - matchingSegments;
- while (backSegments > 0) {
- res.append(".."); //$NON-NLS-1$
- res.append(PATH_SEPARATOR);
- backSegments--;
- }
- int segCount= fullPath.segmentCount();
- for (int i= matchingSegments; i < segCount; i++) {
- if (i > matchingSegments) {
- res.append(PATH_SEPARATOR);
- }
- res.append(fullPath.segment(i));
- }
- return res.toString();
- }
-
- private void xmlWriteDoclet(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException {
-
- //set the packages and source files
- List packages= new ArrayList();
- List sourcefiles= new ArrayList();
- sortSourceElement(store.getSourceElements(), sourcefiles, packages);
- if (!packages.isEmpty())
- xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages));
-
- if (!sourcefiles.isEmpty())
- xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles));
-
- xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath()));
- xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath()));
- xmlJavadocDesc.setAttribute(store.VISIBILITY, store.getAccess());
-
- Element doclet= document.createElement("doclet"); //$NON-NLS-1$
- xmlJavadocDesc.appendChild(doclet);
- doclet.setAttribute(store.NAME, store.getDocletName());
- doclet.setAttribute(store.PATH, store.getDocletPath());
-
- String str= store.getOverview();
- if (str.length() > 0)
- xmlJavadocDesc.setAttribute(store.OVERVIEW, str);
-
- str= store.getAdditionalParams();
- if (str.length() > 0)
- xmlJavadocDesc.setAttribute(store.EXTRAOPTIONS, str);
-
- }
-
- private String toSeparatedList(List packages) {
- StringBuffer buf= new StringBuffer();
- Iterator iter= packages.iterator();
- int nAdded= 0;
- while (iter.hasNext()) {
- if (nAdded > 0) {
- buf.append(',');
- }
- nAdded++;
- String curr= (String) iter.next();
- buf.append(curr);
- }
- return buf.toString();
- }
-
- private String booleanToString(boolean bool) {
- if (bool)
- return "true"; //$NON-NLS-1$
- else
- return "false"; //$NON-NLS-1$
- }
-
- public void close() throws IOException {
- if (fOutputStream != null) {
- fOutputStream.close();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/RecentSettingsStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/RecentSettingsStore.java
deleted file mode 100644
index df4d89a3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javadocexport/RecentSettingsStore.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javadocexport;
-
-import java.io.File;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class RecentSettingsStore {
-
- private final String HREF= "href"; //$NON-NLS-1$
- private final String DESTINATION= "destdir"; //$NON-NLS-1$
- private final String ANTPATH= "antpath"; //$NON-NLS-1$
-
- private final String SECTION_PROJECTS= "projects"; //$NON-NLS-1$
-
- private final static char REF_SEPARATOR= ';';
-
-
- //list of hrefs in string format
- private Map fPerProjectSettings;
-
- /**
- *
- */
- public RecentSettingsStore(IDialogSettings settings) {
- fPerProjectSettings= new HashMap();
- if (settings != null) {
- load(settings);
- }
- }
-
- /**
- * Method creates a list of data structes that contain
- * The destination, antfile location and the list of library/project references for every
- * project in the workspace.Defaults are created for new project.
- */
- private void load(IDialogSettings settings) {
-
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
-
- IDialogSettings projectsSection= settings.getSection(SECTION_PROJECTS);
- if (projectsSection != null) {
- IDialogSettings[] sections= projectsSection.getSections();
- for (int i= 0; i < sections.length; i++) {
- IDialogSettings curr= sections[i];
- String projectName= curr.getName();
- IProject project= root.getProject(projectName);
- //make sure project has not been removed
- if (project.isAccessible()) {
- IJavaScriptProject javaProject= JavaScriptCore.create(project);
- if (!fPerProjectSettings.containsKey(javaProject)) {
- String hrefs= curr.get(HREF);
- if (hrefs == null) {
- hrefs= ""; //$NON-NLS-1$
- }
- String destdir= curr.get(DESTINATION);
- if (destdir == null || destdir.length() == 0) {
- destdir= getDefaultDestination(javaProject);
- }
- String antpath= curr.get(ANTPATH);
- if (antpath == null || antpath.length() == 0) {
- antpath= getDefaultAntPath(javaProject);
- }
- ProjectData data= new ProjectData();
- data.setDestination(destdir);
- data.setAntpath(antpath);
- data.setHRefs(hrefs);
- if (!fPerProjectSettings.containsValue(javaProject))
- fPerProjectSettings.put(javaProject, data);
- }
- }
- }
- }
- //finds projects in the workspace that have been added since the
- //last time the wizard was run
- IProject[] projects= root.getProjects();
- for (int i= 0; i < projects.length; i++) {
- IProject project= projects[i];
- if (project.isAccessible()) {
- IJavaScriptProject curr= JavaScriptCore.create(project);
- if (!fPerProjectSettings.containsKey(curr)) {
- ProjectData data= new ProjectData();
- data.setDestination(getDefaultDestination(curr));
- data.setAntpath(getDefaultAntPath(curr));
- data.setHRefs(""); //$NON-NLS-1$
- fPerProjectSettings.put(curr, data);
- }
- }
- }
- }
-
- public void store(IDialogSettings settings) {
-
- IDialogSettings projectsSection= settings.addNewSection(SECTION_PROJECTS);
-
- //Write all project information to DialogSettings.
- Set keys= fPerProjectSettings.keySet();
- for (Iterator iter= keys.iterator(); iter.hasNext();) {
-
- IJavaScriptProject curr= (IJavaScriptProject) iter.next();
-
- IDialogSettings proj= projectsSection.addNewSection(curr.getElementName());
- if (!keys.contains(curr)) {
- proj.put(HREF, ""); //$NON-NLS-1$
- proj.put(DESTINATION, ""); //$NON-NLS-1$
- proj.put(ANTPATH, ""); //$NON-NLS-1$
- } else {
- ProjectData data= (ProjectData) fPerProjectSettings.get(curr);
- proj.put(HREF, data.getHRefs());
- proj.put(DESTINATION, data.getDestination());
- proj.put(ANTPATH, data.getAntPath());
- }
- projectsSection.addSection(proj);
- }
- }
-
- public void setProjectSettings(IJavaScriptProject project, String destination, String antpath, String[] hrefs) {
- ProjectData data= (ProjectData) fPerProjectSettings.get(project);
- if (data == null) {
- data= new ProjectData();
- }
- data.setDestination(destination);
- data.setAntpath(antpath);
-
- StringBuffer refs= new StringBuffer();
- for (int i= 0; i < hrefs.length; i++) {
- if (i > 0) {
- refs.append(REF_SEPARATOR);
- }
- refs.append(hrefs[i]);
-
- }
- data.setHRefs(refs.toString());
- }
-
- public static String[] getRefTokens(String refs) {
- StringTokenizer tok= new StringTokenizer(refs, String.valueOf(REF_SEPARATOR));
- String[] res= new String[tok.countTokens()];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken();
- }
- return res;
- }
-
-
-
- public String[] getHRefs(IJavaScriptProject project) {
- ProjectData data= (ProjectData) fPerProjectSettings.get(project);
- if (data != null) {
- String refs= data.getHRefs();
- return getRefTokens(refs);
- }
- return new String[0];
- }
-
- //for now if multiple projects are selected the destination
- //feild will be empty,
- public String getDestination(IJavaScriptProject project) {
-
- ProjectData data= (ProjectData) fPerProjectSettings.get(project);
- if (data != null)
- return data.getDestination();
- else
- return getDefaultDestination(project);
- }
-
- public String getAntpath(IJavaScriptProject project) {
- ProjectData data= (ProjectData) fPerProjectSettings.get(project);
- if (data != null)
- return data.getAntPath();
- else
- return getDefaultAntPath(project);
- }
-
- /// internal
-
-
- private String getDefaultAntPath(IJavaScriptProject project) {
- if (project != null) {
- // The Javadoc.xml file can only be stored locally. So if
- // the project isn't local then we can't provide a good
- // default location.
- IPath path= project.getProject().getLocation();
- if (path != null)
- return path.append("javadoc.xml").toOSString(); //$NON-NLS-1$
- }
-
- return ""; //$NON-NLS-1$
- }
-
- private String getDefaultDestination(IJavaScriptProject project) {
- if (project != null) {
- URL url= JavaScriptUI.getProjectJSdocLocation(project);
- //uses default if source is has http protocol
- if (url == null || !url.getProtocol().equals("file")) { //$NON-NLS-1$
- // Since Javadoc.exe is a local tool its output is local.
- // So if the project isn't local then the default location
- // can't be local to a project. So use #getLocation() to
- // test this is fine here.
- IPath path= project.getProject().getLocation();
- if (path != null)
- return path.append("doc").toOSString(); //$NON-NLS-1$
- } else {
- //must do this to remove leading "/"
- return (new File(url.getFile())).getPath();
- }
- }
-
- return ""; //$NON-NLS-1$
-
- }
-
- private static class ProjectData {
-
- private String fHrefs;
- private String fDestinationDir;
- private String fAntPath;
-
- public void setHRefs(String hrefs) {
- if (hrefs == null)
- fHrefs= ""; //$NON-NLS-1$
- else
- fHrefs= hrefs;
- }
-
- public void setDestination(String destination) {
- if (destination == null)
- fDestinationDir= ""; //$NON-NLS-1$
- else
- fDestinationDir= destination;
- }
-
- public void setAntpath(String antpath) {
- if (antpath == null)
- fAntPath= ""; //$NON-NLS-1$
- else
- fAntPath= antpath;
- }
-
- public String getHRefs() {
- return fHrefs;
- }
-
- public String getDestination() {
- return fDestinationDir;
- }
-
- public String getAntPath() {
- return fAntPath;
- }
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ASTProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ASTProvider.java
deleted file mode 100644
index 96b061fe..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ASTProvider.java
+++ /dev/null
@@ -1,672 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTParser;
-import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-/**
- * Provides a shared AST for clients. The shared AST is
- * the AST of the active Java editor's input element.
- *
- *
- */
-public final class ASTProvider {
-
- /**
- * Wait flag.
- *
- *
- */
- public static final class WAIT_FLAG {
-
- String fName;
-
- private WAIT_FLAG(String name) {
- fName= name;
- }
-
- /*
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return fName;
- }
- }
-
- /**
- * Wait flag indicating that a client requesting an AST
- * wants to wait until an AST is ready.
- * <p>
- * An AST will be created by this AST provider if the shared
- * AST is not for the given java element.
- * </p>
- *
- *
- */
- public static final WAIT_FLAG WAIT_YES= new WAIT_FLAG("wait yes"); //$NON-NLS-1$
-
- /**
- * Wait flag indicating that a client requesting an AST
- * only wants to wait for the shared AST of the active editor.
- * <p>
- * No AST will be created by the AST provider.
- * </p>
- *
- *
- */
- public static final WAIT_FLAG WAIT_ACTIVE_ONLY= new WAIT_FLAG("wait active only"); //$NON-NLS-1$
-
- /**
- * Wait flag indicating that a client requesting an AST
- * only wants the already available shared AST.
- * <p>
- * No AST will be created by the AST provider.
- * </p>
- *
- *
- */
- public static final WAIT_FLAG WAIT_NO= new WAIT_FLAG("don't wait"); //$NON-NLS-1$
-
-
- /**
- * Tells whether this class is in debug mode.
- *
- */
- private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.ui/debug/ASTProvider")); //$NON-NLS-1$//$NON-NLS-2$
-
-
- /**
- * Internal activation listener.
- *
- *
- */
- private class ActivationListener implements IPartListener2, IWindowListener {
-
-
- /*
- * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partActivated(IWorkbenchPartReference ref) {
- if (isJavaEditor(ref) && !isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partBroughtToTop(IWorkbenchPartReference ref) {
- if (isJavaEditor(ref) && !isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partClosed(IWorkbenchPartReference ref) {
- if (isActiveEditor(ref)) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "closed active editor: " + ref.getTitle()); //$NON-NLS-1$ //$NON-NLS-2$
-
- activeJavaEditorChanged(null);
- }
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partDeactivated(IWorkbenchPartReference ref) {
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partOpened(IWorkbenchPartReference ref) {
- if (isJavaEditor(ref) && !isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partHidden(IWorkbenchPartReference ref) {
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partVisible(IWorkbenchPartReference ref) {
- if (isJavaEditor(ref) && !isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partInputChanged(IWorkbenchPartReference ref) {
- if (isJavaEditor(ref) && isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
- */
- public void windowActivated(IWorkbenchWindow window) {
- IWorkbenchPartReference ref= window.getPartService().getActivePartReference();
- if (isJavaEditor(ref) && !isActiveEditor(ref))
- activeJavaEditorChanged(ref.getPart(true));
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
- */
- public void windowDeactivated(IWorkbenchWindow window) {
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
- */
- public void windowClosed(IWorkbenchWindow window) {
- if (fActiveEditor != null && fActiveEditor.getSite() != null && window == fActiveEditor.getSite().getWorkbenchWindow()) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "closed active editor: " + fActiveEditor.getTitle()); //$NON-NLS-1$ //$NON-NLS-2$
-
- activeJavaEditorChanged(null);
- }
- window.getPartService().removePartListener(this);
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
- */
- public void windowOpened(IWorkbenchWindow window) {
- window.getPartService().addPartListener(this);
- }
-
- private boolean isActiveEditor(IWorkbenchPartReference ref) {
- return ref != null && isActiveEditor(ref.getPart(false));
- }
-
- private boolean isActiveEditor(IWorkbenchPart part) {
- return part != null && (part == fActiveEditor);
- }
-
- private boolean isJavaEditor(IWorkbenchPartReference ref) {
- if (ref == null)
- return false;
-
- String id= ref.getId();
-
- // The instanceof check is not need but helps clients, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84862
- return JavaScriptUI.ID_CF_EDITOR.equals(id) || JavaScriptUI.ID_CU_EDITOR.equals(id) || ref.getPart(false) instanceof JavaEditor;
- }
- }
-
- public static final int SHARED_AST_LEVEL= AST.JLS3;
- public static final boolean SHARED_AST_STATEMENT_RECOVERY= true;
- public static final boolean SHARED_BINDING_RECOVERY= true;
-
- private static final String DEBUG_PREFIX= "ASTProvider > "; //$NON-NLS-1$
-
-
- private IJavaScriptElement fReconcilingJavaElement;
- private IJavaScriptElement fActiveJavaElement;
- private JavaScriptUnit fAST;
- private ActivationListener fActivationListener;
- private Object fReconcileLock= new Object();
- private Object fWaitLock= new Object();
- private boolean fIsReconciling;
- private IWorkbenchPart fActiveEditor;
-
-
- /**
- * Returns the Java plug-in's AST provider.
- *
- * @return the AST provider
- *
- */
- public static ASTProvider getASTProvider() {
- return JavaScriptPlugin.getDefault().getASTProvider();
- }
-
- /**
- * Creates a new AST provider.
- */
- public ASTProvider() {
- install();
- }
-
- /**
- * Installs this AST provider.
- */
- void install() {
- // Create and register activation listener
- fActivationListener= new ActivationListener();
- PlatformUI.getWorkbench().addWindowListener(fActivationListener);
-
- // Ensure existing windows get connected
- IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
- for (int i= 0, length= windows.length; i < length; i++)
- windows[i].getPartService().addPartListener(fActivationListener);
- }
-
- private void activeJavaEditorChanged(IWorkbenchPart editor) {
-
- IJavaScriptElement javaElement= null;
- if (editor instanceof JavaEditor)
- javaElement= ((JavaEditor)editor).getInputJavaElement();
-
- synchronized (this) {
- fActiveEditor= editor;
- fActiveJavaElement= javaElement;
- cache(null, javaElement);
- }
-
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "active editor is: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$
-
- synchronized (fReconcileLock) {
- if (fIsReconciling && (fReconcilingJavaElement == null || !fReconcilingJavaElement.equals(javaElement))) {
- fIsReconciling= false;
- fReconcilingJavaElement= null;
- } else if (javaElement == null) {
- fIsReconciling= false;
- fReconcilingJavaElement= null;
- }
- }
- }
-
- /**
- * Returns whether the given compilation unit AST is
- * cached by this AST provided.
- *
- * @param ast the compilation unit AST
- * @return <code>true</code> if the given AST is the cached one
- */
- public boolean isCached(JavaScriptUnit ast) {
- return ast != null && fAST == ast;
- }
-
- /**
- * Returns whether this AST provider is active on the given
- * compilation unit.
- *
- * @param cu the compilation unit
- * @return <code>true</code> if the given compilation unit is the active one
- *
- */
- public boolean isActive(IJavaScriptUnit cu) {
- return cu != null && cu.equals(fActiveJavaElement);
- }
-
- /**
- * Informs that reconciling for the given element is about to be started.
- *
- * @param javaElement the Java element
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
- */
- void aboutToBeReconciled(IJavaScriptElement javaElement) {
-
- if (javaElement == null)
- return;
-
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "about to reconcile: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$
-
- synchronized (fReconcileLock) {
- fIsReconciling= true;
- fReconcilingJavaElement= javaElement;
- }
- cache(null, javaElement);
- }
-
- /**
- * Disposes the cached AST.
- */
- private synchronized void disposeAST() {
-
- if (fAST == null)
- return;
-
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveJavaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- fAST= null;
-
- cache(null, null);
- }
-
- /**
- * Returns a string for the given Java element used for debugging.
- *
- * @param javaElement the compilation unit AST
- * @return a string used for debugging
- */
- private String toString(IJavaScriptElement javaElement) {
- if (javaElement == null)
- return "null"; //$NON-NLS-1$
- else
- return javaElement.getElementName();
-
- }
-
- /**
- * Returns a string for the given AST used for debugging.
- *
- * @param ast the compilation unit AST
- * @return a string used for debugging
- */
- private String toString(JavaScriptUnit ast) {
- if (ast == null)
- return "null"; //$NON-NLS-1$
-
- List types= ast.types();
- if (types != null && types.size() > 0)
- return ((AbstractTypeDeclaration)types.get(0)).getName().getIdentifier();
- else
- return "AST without any type"; //$NON-NLS-1$
- }
-
- /**
- * Caches the given compilation unit AST for the given Java element.
- *
- * @param ast
- * @param javaElement
- */
- private synchronized void cache(JavaScriptUnit ast, IJavaScriptElement javaElement) {
-
- if (fActiveJavaElement != null && !fActiveJavaElement.equals(javaElement)) {
- if (DEBUG && javaElement != null) // don't report call from disposeAST()
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "don't cache AST for inactive: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- if (DEBUG && (javaElement != null || ast != null)) // don't report call from disposeAST()
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "caching AST: " + toString(ast) + " for: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- if (fAST != null)
- disposeAST();
-
- fAST= ast;
-
- // Signal AST change
- synchronized (fWaitLock) {
- fWaitLock.notifyAll();
- }
- }
-
- /**
- * Returns a shared compilation unit AST for the given
- * Java element.
- * <p>
- * Clients are not allowed to modify the AST and must
- * synchronize all access to its nodes.
- * </p>
- *
- * @param je the Java element
- * @param waitFlag {@link #WAIT_YES}, {@link #WAIT_NO} or {@link #WAIT_ACTIVE_ONLY}
- * @param progressMonitor the progress monitor or <code>null</code>
- * @return the AST or <code>null</code> if the AST is not available
- */
- public JavaScriptUnit getAST(IJavaScriptElement je, WAIT_FLAG waitFlag, IProgressMonitor progressMonitor) {
- if (je == null)
- return null;
-
- Assert.isTrue(je.getElementType() == IJavaScriptElement.CLASS_FILE || je.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT);
-
- if (progressMonitor != null && progressMonitor.isCanceled())
- return null;
-
- boolean isActiveElement;
- synchronized (this) {
- isActiveElement= je.equals(fActiveJavaElement);
- if (isActiveElement) {
- if (fAST != null) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning cached AST:" + toString(fAST) + " for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- return fAST;
- }
- if (waitFlag == WAIT_NO) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning null (WAIT_NO) for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
-
- return null;
-
- }
- }
- }
- if (isActiveElement && isReconciling(je)) {
- try {
- final IJavaScriptElement activeElement= fReconcilingJavaElement;
-
- // Wait for AST
- synchronized (fWaitLock) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "waiting for AST for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
-
- fWaitLock.wait();
- }
-
- // Check whether active element is still valid
- synchronized (this) {
- if (activeElement == fActiveJavaElement && fAST != null) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "...got AST for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
-
- return fAST;
- }
- }
- return getAST(je, waitFlag, progressMonitor);
- } catch (InterruptedException e) {
- return null; // thread has been interrupted don't compute AST
- }
- } else if (waitFlag == WAIT_NO || (waitFlag == WAIT_ACTIVE_ONLY && !(isActiveElement && fAST == null)))
- return null;
-
- if (isActiveElement)
- aboutToBeReconciled(je);
-
- JavaScriptUnit ast= null;
- try {
- ast= createAST(je, progressMonitor);
- if (progressMonitor != null && progressMonitor.isCanceled()) {
- ast= null;
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for: " + je.getElementName() + " - operation has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- } finally {
- if (isActiveElement) {
- if (fAST != null) {
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for " + je.getElementName() + " - AST from reconciler is newer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- reconciled(fAST, je, null);
- } else
- reconciled(ast, je, null);
- }
- }
-
- return ast;
- }
-
- /**
- * Tells whether the given Java element is the one
- * reported as currently being reconciled.
- *
- * @param javaElement the Java element
- * @return <code>true</code> if reported as currently being reconciled
- */
- private boolean isReconciling(IJavaScriptElement javaElement) {
- synchronized (fReconcileLock) {
- return javaElement != null && javaElement.equals(fReconcilingJavaElement) && fIsReconciling;
- }
- }
-
- /**
- * Creates a new compilation unit AST.
- *
- * @param je the Java element for which to create the AST
- * @param progressMonitor the progress monitor
- * @return AST
- */
- private JavaScriptUnit createAST(final IJavaScriptElement je, final IProgressMonitor progressMonitor) {
- if (!hasSource(je))
- return null;
-
- if (progressMonitor != null && progressMonitor.isCanceled())
- return null;
-
- final ASTParser parser = ASTParser.newParser(SHARED_AST_LEVEL);
- parser.setResolveBindings(true);
- parser.setStatementsRecovery(SHARED_AST_STATEMENT_RECOVERY);
- parser.setBindingsRecovery(SHARED_BINDING_RECOVERY);
-
- if (progressMonitor != null && progressMonitor.isCanceled())
- return null;
-
- if (je.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT)
- parser.setSource((IJavaScriptUnit)je);
- else if (je.getElementType() == IJavaScriptElement.CLASS_FILE)
- parser.setSource((IClassFile)je);
-
- if (progressMonitor != null && progressMonitor.isCanceled())
- return null;
-
- final JavaScriptUnit root[]= new JavaScriptUnit[1];
-
- SafeRunner.run(new ISafeRunnable() {
- public void run() {
- try {
- if (progressMonitor != null && progressMonitor.isCanceled())
- return;
- if (DEBUG)
- System.err.println(getThreadName() + " - " + DEBUG_PREFIX + "creating AST for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
- root[0]= (JavaScriptUnit)parser.createAST(progressMonitor);
- } catch (OperationCanceledException ex) {
- return;
- }
- }
- public void handleException(Throwable ex) {
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.OK, "Error in JSDT Core during AST creation", ex); //$NON-NLS-1$
- JavaScriptPlugin.getDefault().getLog().log(status);
- }
- });
-
- // mark as unmodifiable
- if (root[0] != null)
- ASTNodes.setFlagsToAST(root[0], ASTNode.PROTECT);
-
- return root[0];
- }
-
- /**
- * Checks whether the given Java element has accessible source.
- *
- * @param je the Java element to test
- * @return <code>true</code> if the element has source
- *
- */
- private boolean hasSource(IJavaScriptElement je) {
- if (je == null || !je.exists())
- return false;
-
- try {
- return je instanceof ITypeRoot && ((ITypeRoot)je).getBuffer() != null;
- } catch (JavaScriptModelException ex) {
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.OK, "Error in JSDT Core during AST creation", ex); //$NON-NLS-1$
- JavaScriptPlugin.getDefault().getLog().log(status);
- }
- return false;
- }
-
- /**
- * Disposes this AST provider.
- */
- public void dispose() {
-
- // Dispose activation listener
- PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
- fActivationListener= null;
-
- disposeAST();
-
- synchronized (fWaitLock) {
- fWaitLock.notifyAll();
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(org.eclipse.wst.jsdt.core.dom.JavaScriptUnit)
- */
- void reconciled(JavaScriptUnit ast, IJavaScriptElement javaElement, IProgressMonitor progressMonitor) {
-
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "reconciled: " + toString(javaElement) + ", AST: " + toString(ast)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- synchronized (fReconcileLock) {
-
- fIsReconciling= progressMonitor != null && progressMonitor.isCanceled();
- if (javaElement == null || !javaElement.equals(fReconcilingJavaElement)) {
-
- if (DEBUG)
- System.out.println(getThreadName() + " - " + DEBUG_PREFIX + " ignoring AST of out-dated editor"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Signal - threads might wait for wrong element
- synchronized (fWaitLock) {
- fWaitLock.notifyAll();
- }
-
- return;
- }
-
- cache(ast, javaElement);
- }
- }
-
- private String getThreadName() {
- String name= Thread.currentThread().getName();
- if (name != null)
- return name;
- else
- return Thread.currentThread().toString();
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddClassFileMarkerAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddClassFileMarkerAction.java
deleted file mode 100644
index 4c41a102..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddClassFileMarkerAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.AddMarkerAction;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IResourceLocator;
-
-
-
-class AddClassFileMarkerAction extends AddMarkerAction {
-
-
- /**
- * Creates a marker action.
- */
- public AddClassFileMarkerAction(String prefix, ITextEditor textEditor, String markerType, boolean askForLabel) {
- super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, textEditor, markerType, askForLabel);
- }
-
- /**
- * @see AddMarkerAction#getResource()
- */
- protected IResource getResource() {
-
- IResource resource= null;
-
- IEditorInput input= getTextEditor().getEditorInput();
- if (input instanceof IClassFileEditorInput) {
- IClassFile c= ((IClassFileEditorInput) input).getClassFile();
- IResourceLocator locator= (IResourceLocator) c.getAdapter(IResourceLocator.class);
- if (locator != null) {
- try {
- resource= locator.getContainingResource(c);
- } catch (JavaScriptModelException x) {
- // ignore but should inform
- }
- }
- }
-
- return resource;
- }
-
- /**
- * @see AddMarkerAction#getInitialAttributes()
- */
- protected Map getInitialAttributes() {
-
- Map attributes= super.getInitialAttributes();
-
- IEditorInput input= getTextEditor().getEditorInput();
- if (input instanceof IClassFileEditorInput) {
-
- IClassFile classFile= ((IClassFileEditorInput) input).getClassFile();
- JavaScriptCore.addJavaScriptElementMarkerAttributes(attributes, classFile);
- }
-
- return attributes;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddImportOnSelectionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddImportOnSelectionAction.java
deleted file mode 100644
index c0881b67..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/AddImportOnSelectionAction.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Comparator;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IEditingSupport;
-import org.eclipse.jface.text.IEditingSupportRegistry;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.dialogs.FilteredList;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.search.TypeNameMatch;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddImportsOperation;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddImportsOperation.IChooseImportQuery;
-import org.eclipse.wst.jsdt.internal.corext.util.History;
-import org.eclipse.wst.jsdt.internal.corext.util.QualifiedTypeNameHistory;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.ElementValidator;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.TypeNameMatchLabelProvider;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-
-import com.ibm.icu.text.Collator;
-
-
-public class AddImportOnSelectionAction extends Action implements IUpdate {
-
- private static final AddImportComparator ADD_IMPORT_COMPARATOR= new AddImportComparator();
-
- private static final class AddImportComparator implements Comparator {
-
- public int compare(Object o1, Object o2) {
- if (((String)o1).equals(o2))
- return 0;
-
- History history= QualifiedTypeNameHistory.getDefault();
-
- int pos1= history.getPosition(o1);
- int pos2= history.getPosition(o2);
-
- if (pos1 == pos2)
- return Collator.getInstance().compare(o1, o2);
-
- if (pos1 > pos2) {
- return -1;
- } else {
- return 1;
- }
- }
-
- }
-
- private CompilationUnitEditor fEditor;
-
- public AddImportOnSelectionAction(CompilationUnitEditor editor) {
- super(JavaEditorMessages.AddImportOnSelection_label);
- setToolTipText(JavaEditorMessages.AddImportOnSelection_tooltip);
- setDescription(JavaEditorMessages.AddImportOnSelection_description);
- fEditor= editor;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ADD_IMPORT_ON_SELECTION_ACTION);
- setEnabled(getCompilationUnit() != null);
- }
-
- public void update() {
- setEnabled(fEditor != null && getCompilationUnit() != null);
- }
-
- private IJavaScriptUnit getCompilationUnit () {
- if (fEditor == null) {
- return null;
- }
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- return manager.getWorkingCopy(fEditor.getEditorInput());
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- final IJavaScriptUnit cu= getCompilationUnit();
- if (cu == null || fEditor == null)
- return;
- if (!ElementValidator.checkValidateEdit(cu, getShell(), JavaEditorMessages.AddImportOnSelection_error_title))
- return;
- if (!ActionUtil.isEditable(fEditor))
- return;
-
- ISelection selection= fEditor.getSelectionProvider().getSelection();
- if (selection instanceof ITextSelection) {
- final ITextSelection textSelection= (ITextSelection) selection;
- AddImportOnSelectionAction.SelectTypeQuery query= new SelectTypeQuery(getShell());
- AddImportsOperation op= new AddImportsOperation(cu, textSelection.getOffset(), textSelection.getLength(), query, false);
- IEditingSupport helper= createViewerHelper(textSelection, query);
- try {
- registerHelper(helper);
- IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
- progressService.runInUI(fEditor.getSite().getWorkbenchWindow(), new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule());
- IStatus status= op.getStatus();
- if (!status.isOK()) {
- IStatusLineManager manager= getStatusLineManager();
- if (manager != null) {
- manager.setMessage(status.getMessage());
- }
- }
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), JavaEditorMessages.AddImportOnSelection_error_title, null);
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- } finally {
- deregisterHelper(helper);
- }
- }
- }
-
- private IEditingSupport createViewerHelper(final ITextSelection selection, final SelectTypeQuery query) {
- return new IEditingSupport() {
-
- public boolean isOriginator(DocumentEvent event, IRegion subjectRegion) {
- return subjectRegion.getOffset() <= selection.getOffset() + selection.getLength() && selection.getOffset() <= subjectRegion.getOffset() + subjectRegion.getLength();
- }
-
- public boolean ownsFocusShell() {
- return query.isShowing();
- }
-
- };
- }
-
- private void registerHelper(IEditingSupport helper) {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
- registry.register(helper);
- }
- }
-
- private void deregisterHelper(IEditingSupport helper) {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
- registry.unregister(helper);
- }
- }
-
- private Shell getShell() {
- return fEditor.getSite().getShell();
- }
-
- private static class SelectTypeQuery implements IChooseImportQuery {
-
- private final Shell fShell;
- private boolean fIsShowing;
-
- public SelectTypeQuery(Shell shell) {
- fShell= shell;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddImportsOperation.IChooseImportQuery#chooseImport(org.eclipse.wst.jsdt.internal.corext.util.TypeInfo[], java.lang.String)
- */
- public TypeNameMatch chooseImport(TypeNameMatch[] results, String containerName) {
- int nResults= results.length;
-
- if (nResults == 0) {
- return null;
- } else if (nResults == 1) {
- return results[0];
- }
-
- if (containerName.length() != 0) {
- for (int i= 0; i < nResults; i++) {
- TypeNameMatch curr= results[i];
- if (containerName.equals(curr.getTypeContainerName())) {
- return curr;
- }
- }
- }
- fIsShowing= true;
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(fShell, new TypeNameMatchLabelProvider(TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED)) {
- protected FilteredList createFilteredList(Composite parent) {
- FilteredList filteredList= super.createFilteredList(parent);
- filteredList.setComparator(ADD_IMPORT_COMPARATOR);
- return filteredList;
- }
- };
- dialog.setTitle(JavaEditorMessages.AddImportOnSelection_dialog_title);
- dialog.setMessage(JavaEditorMessages.AddImportOnSelection_dialog_message);
- dialog.setElements(results);
- if (dialog.open() == Window.OK) {
- fIsShowing= false;
- TypeNameMatch result= (TypeNameMatch) dialog.getFirstResult();
- QualifiedTypeNameHistory.remember(result.getFullyQualifiedName());
- return result;
- }
- fIsShowing= false;
- return null;
- }
-
- boolean isShowing() {
- return fIsShowing;
- }
- }
-
- private IStatusLineManager getStatusLineManager() {
- return fEditor.getEditorSite().getActionBars().getStatusLineManager();
- }
-
- /**
- * @return Returns the scheduling rule for this operation
- */
- public ISchedulingRule getScheduleRule() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicCompilationUnitEditorActionContributor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicCompilationUnitEditorActionContributor.java
deleted file mode 100644
index a28ce11e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicCompilationUnitEditorActionContributor.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-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.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.RetargetAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalCategory;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalComputerRegistry;
-import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants;
-
-
-public class BasicCompilationUnitEditorActionContributor extends BasicJavaEditorActionContributor {
-
- /**
- * A menu listener that can remove itself from the menu it listens to.
- *
- */
- private final class MenuListener implements IMenuListener {
- private final IMenuManager fMenu;
-
- public MenuListener(IMenuManager menu) {
- fMenu= menu;
- }
-
- public void menuAboutToShow(IMenuManager manager) {
- for (int i= 0; i < fSpecificAssistActions.length; i++) {
- fSpecificAssistActions[i].update();
- }
- }
-
- public void dispose() {
- fMenu.removeMenuListener(this);
- }
- }
-
- protected RetargetAction fRetargetContentAssist;
- protected RetargetTextEditorAction fContentAssist;
- protected RetargetTextEditorAction fContextInformation;
- protected RetargetTextEditorAction fQuickAssistAction;
- protected RetargetTextEditorAction fChangeEncodingAction;
-
- /* */
- protected SpecificContentAssistAction[] fSpecificAssistActions;
- /* */
- private MenuListener fContentAssistMenuListener;
-
-
- public BasicCompilationUnitEditorActionContributor() {
-
- fRetargetContentAssist= new RetargetAction(JdtActionConstants.CONTENT_ASSIST, JavaEditorMessages.ContentAssistProposal_label);
- fRetargetContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- fRetargetContentAssist.setImageDescriptor(JavaPluginImages.DESC_ELCL_CODE_ASSIST);
- fRetargetContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
- markAsPartListener(fRetargetContentAssist);
-
- fContentAssist= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistProposal."); //$NON-NLS-1$
- fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- fContentAssist.setImageDescriptor(JavaPluginImages.DESC_ELCL_CODE_ASSIST);
- fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
-
- fContextInformation= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistContextInformation."); //$NON-NLS-1$
- fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
-
- fQuickAssistAction= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "CorrectionAssistProposal."); //$NON-NLS-1$
- fQuickAssistAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
-
- fChangeEncodingAction= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.ChangeEncodingAction."); //$NON-NLS-1$
- }
-
- /*
- * @see EditorActionBarContributor#contributeToMenu(IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
-
- super.contributeToMenu(menu);
- if (fContentAssistMenuListener != null)
- fContentAssistMenuListener.dispose();
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(fChangeEncodingAction);
- IMenuManager caMenu= new MenuManager(JavaEditorMessages.BasicEditorActionContributor_specific_content_assist_menu, "specific_content_assist"); //$NON-NLS-1$
- editMenu.insertAfter(ITextEditorActionConstants.GROUP_ASSIST, caMenu);
-
- caMenu.add(fRetargetContentAssist);
- Collection descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
- List specificAssistActions= new ArrayList(descriptors.size());
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- final CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
- if (cat.hasComputers()) {
- IAction caAction= new SpecificContentAssistAction(cat);
- caMenu.add(caAction);
- specificAssistActions.add(caAction);
- }
- }
- fSpecificAssistActions= (SpecificContentAssistAction[]) specificAssistActions.toArray(new SpecificContentAssistAction[specificAssistActions.size()]);
- if (fSpecificAssistActions.length > 0) {
- fContentAssistMenuListener= new MenuListener(caMenu);
- caMenu.addMenuListener(fContentAssistMenuListener);
- }
- caMenu.add(new Separator("context_info")); //$NON-NLS-1$
- caMenu.add(fContextInformation);
-
- editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fQuickAssistAction);
- }
- }
-
- /*
- * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
- super.setActiveEditor(part);
-
- ITextEditor textEditor= null;
- if (part instanceof ITextEditor)
- textEditor= (ITextEditor) part;
-
- fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
- fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
- fQuickAssistAction.setAction(getAction(textEditor, ITextEditorActionConstants.QUICK_ASSIST));
-
- if (fSpecificAssistActions != null) {
- for (int i= 0; i < fSpecificAssistActions.length; i++) {
- SpecificContentAssistAction assistAction= fSpecificAssistActions[i];
- assistAction.setActiveEditor(part);
- }
- }
-
- fChangeEncodingAction.setAction(getAction(textEditor, ITextEditorActionConstants.CHANGE_ENCODING));
-
- IActionBars actionBars= getActionBars();
- actionBars.setGlobalActionHandler(JdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
- actionBars.setGlobalActionHandler(JdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
-
- actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
- actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
- }
-
- /*
- * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
- */
- public void init(IActionBars bars, IWorkbenchPage page) {
- super.init(bars, page);
- // register actions that have a dynamic editor.
- bars.setGlobalActionHandler(JdtActionConstants.CONTENT_ASSIST, fContentAssist);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.BasicJavaEditorActionContributor#dispose()
- *
- */
- public void dispose() {
- if (fRetargetContentAssist != null) {
- fRetargetContentAssist.dispose();
- fRetargetContentAssist= null;
- }
- if (fContentAssistMenuListener != null) {
- fContentAssistMenuListener.dispose();
- fContentAssistMenuListener= null;
- }
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicJavaEditorActionContributor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicJavaEditorActionContributor.java
deleted file mode 100644
index 52554114..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/BasicJavaEditorActionContributor.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-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.action.Separator;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.RetargetAction;
-import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.CopyQualifiedNameAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.FoldingActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.GoToNextPreviousMemberAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectionAction;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-
-/**
- * Common base class for action contributors for Java editors.
- */
-public class BasicJavaEditorActionContributor extends BasicTextEditorActionContributor {
-
- private List fPartListeners= new ArrayList();
-
- private TogglePresentationAction fTogglePresentation;
- private ToggleMarkOccurrencesAction fToggleMarkOccurrencesAction;
-
- private RetargetTextEditorAction fGotoMatchingBracket;
- private RetargetTextEditorAction fShowOutline;
- private RetargetTextEditorAction fOpenStructure;
- private RetargetTextEditorAction fOpenHierarchy;
-
- private RetargetTextEditorAction fRetargetShowInformationAction;
-
- private RetargetTextEditorAction fStructureSelectEnclosingAction;
- private RetargetTextEditorAction fStructureSelectNextAction;
- private RetargetTextEditorAction fStructureSelectPreviousAction;
- private RetargetTextEditorAction fStructureSelectHistoryAction;
-
- private RetargetTextEditorAction fGotoNextMemberAction;
- private RetargetTextEditorAction fGotoPreviousMemberAction;
-
- private RetargetTextEditorAction fRemoveOccurrenceAnnotationsAction;
-
- public BasicJavaEditorActionContributor() {
- super();
-
- ResourceBundle b= JavaEditorMessages.getBundleForConstructedKeys();
-
- fRetargetShowInformationAction= new RetargetTextEditorAction(b, "Editor.ShowInformation."); //$NON-NLS-1$
- fRetargetShowInformationAction.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
-
- // actions that are "contributed" to editors, they are considered belonging to the active editor
- fTogglePresentation= new TogglePresentationAction();
-
- fToggleMarkOccurrencesAction= new ToggleMarkOccurrencesAction();
-
- fGotoMatchingBracket= new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
- fGotoMatchingBracket.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
-
- fShowOutline= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ShowOutline."); //$NON-NLS-1$
- fShowOutline.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);
-
- fOpenHierarchy= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "OpenHierarchy."); //$NON-NLS-1$
- fOpenHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);
-
- fOpenStructure= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "OpenStructure."); //$NON-NLS-1$
- fOpenStructure.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE);
-
- fStructureSelectEnclosingAction= new RetargetTextEditorAction(b, "StructureSelectEnclosing."); //$NON-NLS-1$
- fStructureSelectEnclosingAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_ENCLOSING);
- fStructureSelectNextAction= new RetargetTextEditorAction(b, "StructureSelectNext."); //$NON-NLS-1$
- fStructureSelectNextAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT);
- fStructureSelectPreviousAction= new RetargetTextEditorAction(b, "StructureSelectPrevious."); //$NON-NLS-1$
- fStructureSelectPreviousAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_PREVIOUS);
- fStructureSelectHistoryAction= new RetargetTextEditorAction(b, "StructureSelectHistory."); //$NON-NLS-1$
- fStructureSelectHistoryAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST);
-
- fGotoNextMemberAction= new RetargetTextEditorAction(b, "GotoNextMember."); //$NON-NLS-1$
- fGotoNextMemberAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
- fGotoPreviousMemberAction= new RetargetTextEditorAction(b, "GotoPreviousMember."); //$NON-NLS-1$
- fGotoPreviousMemberAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
-
- fRemoveOccurrenceAnnotationsAction= new RetargetTextEditorAction(b, "RemoveOccurrenceAnnotations."); //$NON-NLS-1$
- fRemoveOccurrenceAnnotationsAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
- }
-
- protected final void markAsPartListener(RetargetAction action) {
- fPartListeners.add(action);
- }
-
- /*
- * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
- */
- public void init(IActionBars bars, IWorkbenchPage page) {
- Iterator e= fPartListeners.iterator();
- while (e.hasNext())
- page.addPartListener((RetargetAction) e.next());
-
- super.init(bars, page);
-
- bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
- bars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction);
-
- }
-
- /*
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
-
- super.contributeToMenu(menu);
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
-
- MenuManager structureSelection= new MenuManager(JavaEditorMessages.ExpandSelectionMenu_label, "expandSelection"); //$NON-NLS-1$
- editMenu.insertAfter(ITextEditorActionConstants.SELECT_ALL, structureSelection);
- structureSelection.add(fStructureSelectEnclosingAction);
- structureSelection.add(fStructureSelectNextAction);
- structureSelection.add(fStructureSelectPreviousAction);
- structureSelection.add(fStructureSelectHistoryAction);
-
- editMenu.appendToGroup(ITextEditorActionConstants.GROUP_INFORMATION, fRetargetShowInformationAction);
- }
-
- IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
- if (navigateMenu != null) {
- navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
- navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fOpenHierarchy);
- }
-
- IMenuManager gotoMenu= menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
- if (gotoMenu != null) {
- gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
- gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
- gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
- gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
- }
- }
-
- /*
- * @see EditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
-
- super.setActiveEditor(part);
-
- ITextEditor textEditor= null;
- if (part instanceof ITextEditor)
- textEditor= (ITextEditor)part;
-
- fTogglePresentation.setEditor(textEditor);
- fToggleMarkOccurrencesAction.setEditor(textEditor);
-
- fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
- fShowOutline.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_OUTLINE));
- fOpenHierarchy.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY));
- fOpenStructure.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_STRUCTURE));
-
- fStructureSelectEnclosingAction.setAction(getAction(textEditor, StructureSelectionAction.ENCLOSING));
- fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
- fStructureSelectPreviousAction.setAction(getAction(textEditor, StructureSelectionAction.PREVIOUS));
- fStructureSelectHistoryAction.setAction(getAction(textEditor, StructureSelectionAction.HISTORY));
-
- fGotoNextMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
- fGotoPreviousMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));
-
- fRemoveOccurrenceAnnotationsAction.setAction(getAction(textEditor, "RemoveOccurrenceAnnotations")); //$NON-NLS-1$
- fRetargetShowInformationAction.setAction(getAction(textEditor, ITextEditorActionConstants.SHOW_INFORMATION));
-
- if (part instanceof JavaEditor) {
- JavaEditor javaEditor= (JavaEditor) part;
- javaEditor.getActionGroup().fillActionBars(getActionBars());
- FoldingActionGroup foldingActions= javaEditor.getFoldingActionGroup();
- if (foldingActions != null)
- foldingActions.updateActionBars();
- }
-
- IActionBars actionBars= getActionBars();
- IStatusLineManager manager= actionBars.getStatusLineManager();
- manager.setMessage(null);
- manager.setErrorMessage(null);
-
- /** The global actions to be connected with editor actions */
- IAction action= getAction(textEditor, ITextEditorActionConstants.NEXT);
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
- action= getAction(textEditor, ITextEditorActionConstants.PREVIOUS);
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
- action= getAction(textEditor, IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
- actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, action);
- }
-
- /*
- * @see IEditorActionBarContributor#dispose()
- */
- public void dispose() {
-
- Iterator e= fPartListeners.iterator();
- while (e.hasNext())
- getPage().removePartListener((RetargetAction) e.next());
- fPartListeners.clear();
-
- setActiveEditor(null);
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileDocumentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileDocumentProvider.java
deleted file mode 100644
index ef0c58c3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileDocumentProvider.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ISynchronizable;
-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.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IResourceLocator;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-/**
- * A document provider for class files. Class files can be either inside
- */
-public class ClassFileDocumentProvider extends FileDocumentProvider {
-
- /**
- * An input change listener to request the editor to reread the input.
- */
- public interface InputChangeListener {
- void inputChanged(IClassFileEditorInput input);
- }
-
- /**
- * Synchronizes the document with external resource changes.
- */
- protected class ClassFileSynchronizer implements IElementChangedListener {
-
- protected IClassFileEditorInput fInput;
- protected IPackageFragmentRoot fPackageFragmentRoot;
-
- /**
- * Default constructor.
- */
- public ClassFileSynchronizer(IClassFileEditorInput input) {
-
- fInput= input;
-
- IJavaScriptElement parent= fInput.getClassFile().getParent();
- while (parent != null && !(parent instanceof IPackageFragmentRoot)) {
- parent= parent.getParent();
- }
- fPackageFragmentRoot= (IPackageFragmentRoot) parent;
- }
-
- /**
- * Installs the synchronizer.
- */
- public void install() {
- JavaScriptCore.addElementChangedListener(this);
- }
-
- /**
- * Uninstalls the synchronizer.
- */
- public void uninstall() {
- JavaScriptCore.removeElementChangedListener(this);
- }
-
- /*
- * @see IElementChangedListener#elementChanged
- */
- public void elementChanged(ElementChangedEvent e) {
- check(fPackageFragmentRoot, e.getDelta());
- }
-
- /**
- * Recursively check whether the class file has been deleted.
- * Returns true if delta processing can be stopped.
- */
- protected boolean check(IPackageFragmentRoot input, IJavaScriptElementDelta delta) {
- IJavaScriptElement element= delta.getElement();
-
- if ((delta.getKind() & IJavaScriptElementDelta.REMOVED) != 0 || (delta.getFlags() & IJavaScriptElementDelta.F_CLOSED) != 0) {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=19023
- if (element.equals(input.getJavaScriptProject()) || element.equals(input)) {
- handleDeleted(fInput);
- return true;
- }
- }
-
- if (((delta.getFlags() & IJavaScriptElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) && input.equals(element)) {
- handleDeleted(fInput);
- return true;
- }
-
- if (((delta.getFlags() & IJavaScriptElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) && input.equals(element)) {
- handleDeleted(fInput);
- return true;
- }
-
- IJavaScriptElementDelta[] subdeltas= delta.getAffectedChildren();
- for (int i= 0; i < subdeltas.length; i++) {
- if (check(input, subdeltas[i]))
- return true;
- }
-
- if ((delta.getFlags() & IJavaScriptElementDelta.F_SOURCEDETACHED) != 0 ||
- (delta.getFlags() & IJavaScriptElementDelta.F_SOURCEATTACHED) != 0)
- {
- IClassFile file= fInput != null ? fInput.getClassFile() : null;
- IJavaScriptProject project= input != null ? input.getJavaScriptProject() : null;
-
- boolean isOnClasspath= false;
- if (file != null && project != null)
- isOnClasspath= project.isOnIncludepath(file);
-
- if (isOnClasspath) {
- fireInputChanged(fInput);
- return false;
- } else {
- handleDeleted(fInput);
- return true;
- }
- }
-
- return false;
- }
- }
-
- /**
- * Correcting the visibility of <code>FileSynchronizer</code>.
- */
- protected class _FileSynchronizer extends FileSynchronizer {
- public _FileSynchronizer(IFileEditorInput fileEditorInput) {
- super(fileEditorInput);
- }
- }
-
- /**
- * Bundle of all required informations.
- */
- protected class ClassFileInfo extends FileInfo {
-
- ClassFileSynchronizer fClassFileSynchronizer= null;
-
- ClassFileInfo(IDocument document, IAnnotationModel model, _FileSynchronizer fileSynchronizer) {
- super(document, model, fileSynchronizer);
- }
-
- ClassFileInfo(IDocument document, IAnnotationModel model, ClassFileSynchronizer classFileSynchronizer) {
- super(document, model, null);
- fClassFileSynchronizer= classFileSynchronizer;
- }
- }
-
- /** Input change listeners. */
- private List fInputListeners= new ArrayList();
-
- /**
- * Creates a new document provider.
- */
- public ClassFileDocumentProvider() {
- super();
- }
-
- /*
- * @see StorageDocumentProvider#setDocumentContent(IDocument, IEditorInput)
- */
- protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
- if (editorInput instanceof IClassFileEditorInput) {
- IClassFile classFile= ((IClassFileEditorInput) editorInput).getClassFile();
- classFile.makeConsistent(getProgressMonitor());
- String source= classFile.getSource();
- if (source == null)
- source= ""; //$NON-NLS-1$
- classFile.makeConsistent(getProgressMonitor());
- document.set(source);
- return true;
- }
- return super.setDocumentContent(document, editorInput, encoding);
- }
-
- /**
- * Creates an annotation model derived from the given class file editor input.
- *
- * @param classFileEditorInput the editor input from which to query the annotations
- * @return the created annotation model
- * @exception CoreException if the editor input could not be accessed
- */
- protected IAnnotationModel createClassFileAnnotationModel(IClassFileEditorInput classFileEditorInput) throws CoreException {
- IResource resource= null;
- IClassFile classFile= classFileEditorInput.getClassFile();
-
- IResourceLocator locator= (IResourceLocator) classFile.getAdapter(IResourceLocator.class);
- if (locator != null)
- resource= locator.getContainingResource(classFile);
-
- if (resource != null) {
- ClassFileMarkerAnnotationModel model= new ClassFileMarkerAnnotationModel(resource);
- model.setClassFile(classFile);
- return model;
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.StorageDocumentProvider#createEmptyDocument()
- *
- */
- protected IDocument createEmptyDocument() {
- IDocument document= FileBuffers.getTextFileBufferManager().createEmptyDocument(null, LocationKind.IFILE);
- if (document instanceof ISynchronizable)
- ((ISynchronizable)document).setLockObject(new Object());
- return document;
- }
-
- /*
- * @see AbstractDocumentProvider#createDocument(Object)
- */
- protected IDocument createDocument(Object element) throws CoreException {
- IDocument document= super.createDocument(element);
- if (document != null) {
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- }
- return document;
- }
-
- public String getEncoding(Object element) {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null)
- return info.fEncoding;
- return getPersistedEncoding(element);
- }
- if(element instanceof InternalClassFileEditorInput){
- InternalClassFileEditorInput input = (InternalClassFileEditorInput)element;
- IClassFile file = input.getClassFile();
- if(file!=null){
- String fileEncoding = null;
- try {
- IResource resource =( file.getResource());
- fileEncoding = (resource==null&&resource instanceof IFile)?null:((IFile)resource).getCharset();
- } catch (CoreException e) {
- // resource not in workspace, use default encoding.
- }
- return fileEncoding;
- }
- }
- return null;
- }
-
- /*
- * @see AbstractDocumentProvider#createElementInfo(Object)
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
-
- if (element instanceof IClassFileEditorInput) {
-
- IClassFileEditorInput input = (IClassFileEditorInput) element;
- ExternalClassFileEditorInput external= null;
- if (input instanceof ExternalClassFileEditorInput)
- external= (ExternalClassFileEditorInput) input;
-
- if (external != null) {
- try {
- refreshFile(external.getFile());
- } catch (CoreException x) {
- handleCoreException(x, JavaEditorMessages.ClassFileDocumentProvider_error_createElementInfo);
- }
- }
-
- IDocument d= createDocument(input);
- IAnnotationModel m= createClassFileAnnotationModel(input);
-
- if (external != null) {
- ClassFileInfo info= new ClassFileInfo(d, m, (_FileSynchronizer) null);
- info.fModificationStamp= computeModificationStamp(external.getFile());
- info.fEncoding= getPersistedEncoding(element);
- return info;
- } else if (input instanceof InternalClassFileEditorInput) {
- ClassFileSynchronizer s= new ClassFileSynchronizer(input);
- s.install();
- ClassFileInfo info= new ClassFileInfo(d, m, s);
- info.fEncoding= getPersistedEncoding(element);
- return info;
- }
- }
-
- return null;
- }
-
- /*
- * @see FileDocumentProvider#disposeElementInfo(Object, ElementInfo)
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
- ClassFileInfo classFileInfo= (ClassFileInfo) info;
- if (classFileInfo.fClassFileSynchronizer != null) {
- classFileInfo.fClassFileSynchronizer.uninstall();
- classFileInfo.fClassFileSynchronizer= null;
- }
-
- super.disposeElementInfo(element, info);
- }
-
- /*
- * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document) throws CoreException {
- }
-
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
- *
- */
- public boolean isSynchronized(Object element) {
- Object elementInfo= getElementInfo(element);
- if (elementInfo instanceof ClassFileInfo) {
- IClassFileEditorInput input= (IClassFileEditorInput)element;
- IResource resource;
- try {
- resource= input.getClassFile().getUnderlyingResource();
- } catch (JavaScriptModelException e) {
- return true;
- }
- return resource == null || resource.isSynchronized(IResource.DEPTH_ZERO);
- }
- return false;
- }
-
- /**
- * Handles the deletion of the element underlying the given class file editor input.
- * @param input the editor input
- */
- protected void handleDeleted(IClassFileEditorInput input) {
- fireElementDeleted(input);
- }
-
- /**
- * Fires input changes to input change listeners.
- */
- protected void fireInputChanged(IClassFileEditorInput input) {
- List list= new ArrayList(fInputListeners);
- for (Iterator i = list.iterator(); i.hasNext();)
- ((InputChangeListener) i.next()).inputChanged(input);
- }
-
- /**
- * Adds an input change listener.
- */
- public void addInputChangeListener(InputChangeListener listener) {
- fInputListeners.add(listener);
- }
-
- /**
- * Removes an input change listener.
- */
- public void removeInputChangeListener(InputChangeListener listener) {
- fInputListeners.remove(listener);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditor.java
deleted file mode 100644
index 72ab8c56..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditor.java
+++ /dev/null
@@ -1,871 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.FillLayout;
-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.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModelStatusConstants;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-/**
- * Java specific text editor.
- */
-public class ClassFileEditor extends JavaEditor implements ClassFileDocumentProvider.InputChangeListener {
-
-
- /**
- * A form to attach source to a class file.
- */
- private class SourceAttachmentForm implements IPropertyChangeListener {
-
- private final IClassFile fFile;
- private Composite fComposite;
- private Color fBackgroundColor;
- private Color fForegroundColor;
- private Color fSeparatorColor;
- private List fBannerLabels= new ArrayList();
- private List fHeaderLabels= new ArrayList();
- private Font fFont;
-
- /**
- * Creates a source attachment form for a class file.
- *
- * @param file the class file
- */
- public SourceAttachmentForm(IClassFile file) {
- fFile= file;
- }
-
- /**
- * Returns the package fragment root of this file.
- *
- * @param file the class file
- * @return the package fragment root of the given class file
- */
- private IPackageFragmentRoot getPackageFragmentRoot(IClassFile file) {
-
- IJavaScriptElement element= file.getParent();
- while (element != null && element.getElementType() != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT)
- element= element.getParent();
-
- return (IPackageFragmentRoot) element;
- }
-
- /**
- * Creates the control of the source attachment form.
- *
- * @param parent the parent composite
- * @return the creates source attachment form
- */
- public Control createControl(Composite parent) {
-
- Display display= parent.getDisplay();
- fBackgroundColor= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- fForegroundColor= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- fSeparatorColor= new Color(display, 152, 170, 203);
-
- JFaceResources.getFontRegistry().addListener(this);
-
- fComposite= createComposite(parent);
- fComposite.setLayout(new GridLayout());
- fComposite.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- JFaceResources.getFontRegistry().removeListener(SourceAttachmentForm.this);
- fComposite= null;
- fSeparatorColor.dispose();
- fSeparatorColor= null;
- fBannerLabels.clear();
- fHeaderLabels.clear();
- if (fFont != null) {
- fFont.dispose();
- fFont= null;
- }
- }
- });
-
- createTitleLabel(fComposite, JavaEditorMessages.SourceAttachmentForm_title);
- createLabel(fComposite, null);
- createLabel(fComposite, null);
-
- createHeadingLabel(fComposite, JavaEditorMessages.SourceAttachmentForm_heading);
-
- Composite separator= createCompositeSeparator(fComposite);
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint= 2;
- separator.setLayoutData(data);
-
-// try {
-// IPackageFragmentRoot root= getPackageFragmentRoot(fFile);
-// if (root != null) {
-// createSourceAttachmentControls(fComposite, root);
-// }
-// } catch (JavaScriptModelException e) {
-// String title= JavaEditorMessages.SourceAttachmentForm_error_title;
-// String message= JavaEditorMessages.SourceAttachmentForm_error_message;
-// ExceptionHandler.handle(e, fComposite.getShell(), title, message);
-// }
-
- separator= createCompositeSeparator(fComposite);
- data= new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint= 2;
- separator.setLayoutData(data);
-
- fNoSourceTextWidget= createCodeView(fComposite);
- data= new GridData(GridData.FILL_BOTH);
- fNoSourceTextWidget.setLayoutData(data);
-
-// updateCodeView(fNoSourceTextWidget, fFile);
-
- return fComposite;
- }
-
-// private void createSourceAttachmentControls(Composite composite, IPackageFragmentRoot root) throws JavaScriptModelException {
-// IIncludePathEntry entry;
-// try {
-// entry= root.getRawIncludepathEntry();
-// } catch (JavaScriptModelException ex) {
-// if (ex.isDoesNotExist())
-// entry= null;
-// else
-// throw ex;
-// }
-// IPath containerPath= null;
-//
-// if (entry == null || root.getKind() != IPackageFragmentRoot.K_BINARY) {
-// createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSource, fFile.getDisplayName()));
-// return;
-// }
-//
-// IJavaScriptProject jproject= root.getJavaScriptProject();
-// if (entry.getEntryKind() == IIncludePathEntry.CPE_CONTAINER) {
-// containerPath= entry.getPath();
-// JsGlobalScopeContainerInitializer initializer= JavaScriptCore.getJsGlobalScopeContainerInitializer(containerPath.segment(0));
-// IJsGlobalScopeContainer container= JavaScriptCore.getJsGlobalScopeContainer(containerPath, jproject);
-// if (initializer == null || container == null) {
-// createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_cannotconfigure, containerPath.toString()));
-// return;
-// }
-// String containerName= container.getDescription();
-// IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject);
-// if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
-// createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_notsupported, containerName));
-// return;
-// }
-// if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_READ_ONLY) {
-// createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_readonly, containerName));
-// return;
-// }
-// entry= JavaModelUtil.findEntryInContainer(container, root.getPath());
-// Assert.isNotNull(entry);
-// }
-//
-//
-// Button button;
-//
-// IPath path= entry.getSourceAttachmentPath();
-// if (path == null || path.isEmpty()) {
-// createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSourceAttachment, root.getElementName()));
-// createLabel(composite, JavaEditorMessages.SourceAttachmentForm_message_pressButtonToAttach);
-// createLabel(composite, null);
-//
-// button= createButton(composite, JavaEditorMessages.SourceAttachmentForm_button_attachSource);
-//
-// } else {
-// createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSourceInAttachment, fFile.getDisplayName()));
-// createLabel(composite, JavaEditorMessages.SourceAttachmentForm_message_pressButtonToChange);
-// createLabel(composite, null);
-//
-// button= createButton(composite, JavaEditorMessages.SourceAttachmentForm_button_changeAttachedSource);
-// }
-//
-// button.addSelectionListener(getButtonListener(entry, containerPath, jproject));
-// }
-//
-// private SelectionListener getButtonListener(final IIncludePathEntry entry, final IPath containerPath, final IJavaScriptProject jproject) {
-// return new SelectionListener() {
-// public void widgetSelected(SelectionEvent event) {
-// Shell shell= getSite().getShell();
-// try {
-// IIncludePathEntry result= BuildPathDialogAccess.configureSourceAttachment(shell, entry);
-// if (result != null) {
-// applySourceAttachment(shell, result, jproject, containerPath);
-// verifyInput(getEditorInput());
-// }
-// } catch (CoreException e) {
-// String title= JavaEditorMessages.SourceAttachmentForm_error_title;
-// String message= JavaEditorMessages.SourceAttachmentForm_error_message;
-// ExceptionHandler.handle(e, shell, title, message);
-// }
-// }
-//
-// public void widgetDefaultSelected(SelectionEvent e) {}
-// };
-// }
-
- protected void applySourceAttachment(Shell shell, IIncludePathEntry newEntry, IJavaScriptProject project, IPath containerPath) {
- try {
- IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(shell, newEntry, project, containerPath);
- PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
-
- } catch (InvocationTargetException e) {
- String title= JavaEditorMessages.SourceAttachmentForm_attach_error_title;
- String message= JavaEditorMessages.SourceAttachmentForm_attach_error_message;
- ExceptionHandler.handle(e, shell, title, message);
-
- } catch (InterruptedException e) {
- // cancelled
- }
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
-
- for (Iterator iterator = fBannerLabels.iterator(); iterator.hasNext();) {
- Label label = (Label) iterator.next();
- label.setFont(JFaceResources.getBannerFont());
- }
-
- for (Iterator iterator = fHeaderLabels.iterator(); iterator.hasNext();) {
- Label label = (Label) iterator.next();
- label.setFont(JFaceResources.getHeaderFont());
- }
-
- fComposite.layout(true);
- fComposite.redraw();
- }
-
- // --- copied from org.eclipse.update.ui.forms.internal.FormWidgetFactory
-
- private Composite createComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(fBackgroundColor);
- // composite.addMouseListener(new MouseAdapter() {
- // public void mousePressed(MouseEvent e) {
- // ((Control) e.widget).setFocus();
- // }
- // });
- return composite;
- }
-
- private Composite createCompositeSeparator(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(fSeparatorColor);
- return composite;
- }
-
- private StyledText createCodeView(Composite parent) {
- int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION;
- StyledText styledText= new StyledText(parent, styles);
- styledText.setBackground(fBackgroundColor);
- styledText.setForeground(fForegroundColor);
- styledText.setEditable(false);
- return styledText;
- }
-
- private Label createLabel(Composite parent, String text) {
- Label label= new Label(parent, SWT.WRAP);
- if (text != null)
- label.setText(text);
- label.setBackground(fBackgroundColor);
- label.setForeground(fForegroundColor);
- GridData gd= new GridData();
- gd.widthHint= new PixelConverter(label).convertWidthInCharsToPixels(80);
- label.setLayoutData(gd);
- return label;
- }
-
- private Label createTitleLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.NONE);
- if (text != null)
- label.setText(text);
- label.setBackground(fBackgroundColor);
- label.setForeground(fForegroundColor);
- label.setFont(JFaceResources.getHeaderFont());
- fHeaderLabels.add(label);
- return label;
- }
-
- private Label createHeadingLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.NONE);
- if (text != null)
- label.setText(text);
- label.setBackground(fBackgroundColor);
- label.setForeground(fForegroundColor);
- label.setFont(JFaceResources.getBannerFont());
- fBannerLabels.add(label);
- return label;
- }
-
- private Button createButton(Composite parent, String text) {
- Button button = new Button(parent, SWT.FLAT);
- button.setBackground(fBackgroundColor);
- button.setForeground(fForegroundColor);
- if (text != null)
- button.setText(text);
- return button;
- }
-
-// private void updateCodeView(StyledText styledText, IClassFile classFile) {
-// String content= null;
-// ClassFileBytesDisassembler disassembler= ToolFactory.createDefaultClassFileBytesDisassembler();
-// try {
-// content= disassembler.disassemble(classFile.getBytes(), "\n", ClassFileBytesDisassembler.DETAILED); //$NON-NLS-1$
-// } catch (JavaScriptModelException ex) {
-// JavaScriptPlugin.log(ex.getStatus());
-// } catch (ClassFormatException ex) {
-// JavaScriptPlugin.log(ex);
-// }
-// styledText.setText(content == null ? "" : content); //$NON-NLS-1$
-// }
- }
-
- /**
- * Updater that takes care of minimizing changes of the editor input.
- */
- private class InputUpdater implements Runnable {
-
- /** Has the runnable already been posted? */
- private boolean fPosted= false;
- /** Editor input */
- private IClassFileEditorInput fClassFileEditorInput;
-
-
- public InputUpdater() {
- }
-
- /*
- * @see Runnable#run()
- */
- public void run() {
-
- IClassFileEditorInput input;
- synchronized (this) {
- input= fClassFileEditorInput;
- }
-
- try {
-
- if (getSourceViewer() != null)
- setInput(input);
-
- } finally {
- synchronized (this) {
- fPosted= false;
- }
- }
- }
-
- /**
- * Posts this runnable into the event queue if not already there.
- *
- * @param input the input to be set when executed
- */
- public void post(IClassFileEditorInput input) {
-
- synchronized(this) {
- if (fPosted) {
- if (input != null && input.equals(fClassFileEditorInput))
- fClassFileEditorInput= input;
- return;
- }
- }
-
- if (input != null && input.equals(getEditorInput())) {
- ISourceViewer viewer= getSourceViewer();
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- synchronized (this) {
- fPosted= true;
- fClassFileEditorInput= input;
- }
- textWidget.getDisplay().asyncExec(this);
- }
- }
- }
- }
- }
-
-
- private StackLayout fStackLayout;
- private Composite fParent;
-
- private Composite fViewerComposite;
- private Control fSourceAttachmentForm;
-
- private CompositeActionGroup fContextMenuGroup;
-
- private InputUpdater fInputUpdater= new InputUpdater();
-
- /**
- * The copy action used when there's attached source.
- *
- */
- private IAction fSourceCopyAction;
- /**
- * The Select All action used when there's attached source.
- *
- */
- private IAction fSelectAllAction;
-
- /**
- * StyledText widget used to show the disassembled code.
- * if there's no source.
- *
- *
- */
- private StyledText fNoSourceTextWidget;
-
-
- /**
- * Default constructor.
- */
- public ClassFileEditor() {
- super();
- setDocumentProvider(JavaScriptPlugin.getDefault().getClassFileDocumentProvider());
- setEditorContextMenuId("#ClassFileEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#ReadOnlyJavaScriptRulerContext"); //$NON-NLS-1$
- setOutlinerContextMenuId("#ClassFileOutlinerContext"); //$NON-NLS-1$
- // don't set help contextId, we install our own help context
- }
-
- /*
- * @see AbstractTextEditor#createActions()
- */
- protected void createActions() {
- super.createActions();
-
- setAction(ITextEditorActionConstants.SAVE, null);
- setAction(ITextEditorActionConstants.REVERT_TO_SAVED, null);
-
- fSourceCopyAction= getAction(ITextEditorActionConstants.COPY);
- fSelectAllAction= getAction(ITextEditorActionConstants.SELECT_ALL);
-
- final ActionGroup group= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT, true);
- fActionGroups.addGroup(group);
- fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {group});
-
- /*
- * 1GF82PL: ITPJUI:ALL - Need to be able to add bookmark to class file
- *
- * // replace default action with class file specific ones
- *
- * setAction(ITextEditorActionConstants.BOOKMARK, new AddClassFileMarkerAction("AddBookmark.", this, IMarker.BOOKMARK, true)); //$NON-NLS-1$
- * setAction(ITextEditorActionConstants.ADD_TASK, new AddClassFileMarkerAction("AddTask.", this, IMarker.TASK, false)); //$NON-NLS-1$
- * setAction(ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS, new ClassFileMarkerRulerAction("ManageBookmarks.", getVerticalRuler(), this, IMarker.BOOKMARK, true)); //$NON-NLS-1$
- * setAction(ITextEditorActionConstants.RULER_MANAGE_TASKS, new ClassFileMarkerRulerAction("ManageTasks.", getVerticalRuler(), this, IMarker.TASK, true)); //$NON-NLS-1$
- */
- }
-
- /*
- * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
- */
- public void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
-
- ActionContext context= new ActionContext(getSelectionProvider().getSelection());
- fContextMenuGroup.setContext(context);
- fContextMenuGroup.fillContextMenu(menu);
- fContextMenuGroup.setContext(null);
- }
-
- /*
- * @see JavaEditor#getElementAt(int)
- */
- protected IJavaScriptElement getElementAt(int offset) {
- if (getEditorInput() instanceof IClassFileEditorInput) {
- try {
- IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput();
- return input.getClassFile().getElementAt(offset);
- } catch (JavaScriptModelException x) {
- }
- }
- return null;
- }
-
- /*
- * @see JavaEditor#getCorrespondingElement(IJavaScriptElement)
- */
- protected IJavaScriptElement getCorrespondingElement(IJavaScriptElement element) {
- if (getEditorInput() instanceof IClassFileEditorInput) {
- IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput();
- IJavaScriptElement parent= element.getAncestor(IJavaScriptElement.CLASS_FILE);
- if (input.getClassFile().equals(parent))
- return element;
- }
- return null;
- }
-
- /*
- * 1GEPKT5: ITPJUI:Linux - Source in editor for external classes is editable
- * Removed methods isSaveOnClosedNeeded and isDirty.
- * Added method isEditable.
- */
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#isEditable()
- */
- public boolean isEditable() {
- return false;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#isEditorInputReadOnly()
- *
- */
- public boolean isEditorInputReadOnly() {
- return true;
- }
-
- /**
- * Translates the given editor input into an <code>ExternalClassFileEditorInput</code>
- * if it is a file editor input representing an external class file.
- *
- * @param input the editor input to be transformed if necessary
- * @return the transformed editor input
- */
- protected IEditorInput transformEditorInput(IEditorInput input) {
-
- if (input instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) input).getFile();
- IClassFileEditorInput classFileInput= new ExternalClassFileEditorInput(file);
- if (classFileInput.getClassFile() != null)
- input= classFileInput;
- }
-
- return input;
- }
-
- /*
- * @see AbstractTextEditor#doSetInput(IEditorInput)
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- uninstallOccurrencesFinder();
-
- input= transformEditorInput(input);
- if (!(input instanceof IClassFileEditorInput))
- throw new CoreException(JavaUIStatus.createError(
- IJavaScriptModelStatusConstants.INVALID_RESOURCE_TYPE,
- JavaEditorMessages.ClassFileEditor_error_invalid_input_message,
- null));
-
- JavaScriptModelException e= probeInputForSource(input);
- if (e != null) {
- IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input;
- IClassFile file= classFileEditorInput.getClassFile();
- IJavaScriptProject javaProject= file.getJavaScriptProject();
- if (!javaProject.exists() || !javaProject.isOnIncludepath(file)) {
- throw new CoreException(JavaUIStatus.createError(
- IJavaScriptModelStatusConstants.INVALID_RESOURCE,
- JavaEditorMessages.ClassFileEditor_error_classfile_not_on_classpath,
- null));
- } else {
- throw e;
- }
- }
-
- IDocumentProvider documentProvider= getDocumentProvider();
- if (documentProvider instanceof ClassFileDocumentProvider)
- ((ClassFileDocumentProvider) documentProvider).removeInputChangeListener(this);
-
- super.doSetInput(input);
-
- documentProvider= getDocumentProvider();
- if (documentProvider instanceof ClassFileDocumentProvider)
- ((ClassFileDocumentProvider) documentProvider).addInputChangeListener(this);
-
- verifyInput(getEditorInput());
-
- final IJavaScriptElement inputElement= getInputJavaElement();
-
- Job job= new Job(JavaEditorMessages.OverrideIndicatorManager_intallJob) {
- /*
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- *
- */
- protected IStatus run(IProgressMonitor monitor) {
- JavaScriptUnit ast= JavaScriptPlugin.getDefault().getASTProvider().getAST(inputElement, ASTProvider.WAIT_YES, null);
- if (fOverrideIndicatorManager != null)
- fOverrideIndicatorManager.reconciled(ast, true, monitor);
- if (fSemanticManager != null) {
- SemanticHighlightingReconciler reconciler= fSemanticManager.getReconciler();
- if (reconciler != null)
- reconciler.reconciled(ast, false, monitor);
- }
- if (isMarkingOccurrences())
- installOccurrencesFinder(false);
- return Status.OK_STATUS;
- }
- };
- job.setPriority(Job.DECORATE);
- job.setSystem(true);
- job.schedule();
-
- }
-
- /*
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite parent) {
-
- fParent= new Composite(parent, SWT.NONE);
- fStackLayout= new StackLayout();
- fParent.setLayout(fStackLayout);
-
- fViewerComposite= new Composite(fParent, SWT.NONE);
- fViewerComposite.setLayout(new FillLayout());
-
- super.createPartControl(fViewerComposite);
-
- fStackLayout.topControl= fViewerComposite;
- fParent.layout();
-
- try {
- verifyInput(getEditorInput());
- } catch (CoreException e) {
- String title= JavaEditorMessages.ClassFileEditor_error_title;
- String message= JavaEditorMessages.ClassFileEditor_error_message;
- ExceptionHandler.handle(e, fParent.getShell(), title, message);
- }
- }
-
- private JavaScriptModelException probeInputForSource(IEditorInput input) {
- if (input == null)
- return null;
-
- IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input;
- IClassFile file= classFileEditorInput.getClassFile();
-
- try {
- file.getSourceRange();
- } catch (JavaScriptModelException e) {
- return e;
- }
-
- return null;
- }
-
- /**
- * Checks if the class file input has no source attached. If so, a source attachment form is shown.
- *
- * @param input the editor input
- * @throws JavaScriptModelException if an exception occurs while accessing its corresponding resource
- */
- private void verifyInput(IEditorInput input) throws JavaScriptModelException {
-
- if (fParent == null || input == null)
- return;
-
- IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input;
- IClassFile file= classFileEditorInput.getClassFile();
-
- IAction copyQualifiedName= getAction(IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
-
- boolean wasUsingSourceCopyAction= fSourceCopyAction == getAction(ITextEditorActionConstants.COPY);
-
- // show source attachment form if no source found
- if (file.getSourceRange() == null) {
-
- // dispose old source attachment form
- if (fSourceAttachmentForm != null)
- fSourceAttachmentForm.dispose();
-
- SourceAttachmentForm form= new SourceAttachmentForm(file);
- fSourceAttachmentForm= form.createControl(fParent);
-
- fStackLayout.topControl= fSourceAttachmentForm;
- fParent.layout();
-
- if (fNoSourceTextWidget != null) {
- // Copy action for the no attached source case
- final IAction copyAction= new Action() {
- public void run() {
- fNoSourceTextWidget.copy();
- }
- };
- copyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
- setAction(ITextEditorActionConstants.COPY, copyAction);
- copyAction.setEnabled(fNoSourceTextWidget.getSelectionText().length() > 0);
- fNoSourceTextWidget.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- copyAction.setEnabled(fNoSourceTextWidget.getSelectionText().length() > 0);
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // Select All action for the no attached source case
- final IAction selectAllAction= new Action() {
- public void run() {
- fNoSourceTextWidget.selectAll();
- copyAction.setEnabled(true);
- }
- };
- selectAllAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.SELECT_ALL);
- setAction(ITextEditorActionConstants.SELECT_ALL, selectAllAction);
- copyAction.setEnabled(fNoSourceTextWidget.getSelectionText().length() > 0);
- copyQualifiedName.setEnabled(false);
-
-
- }
-
- } else { // show source viewer
-
- if (fSourceAttachmentForm != null) {
- fSourceAttachmentForm.dispose();
- fSourceAttachmentForm= null;
-
- fStackLayout.topControl= fViewerComposite;
- fParent.layout();
- }
-
- setAction(ITextEditorActionConstants.COPY, fSourceCopyAction);
- setAction(ITextEditorActionConstants.SELECT_ALL, fSelectAllAction);
- copyQualifiedName.setEnabled(true);
-
- }
-
- IAction currentCopyAction= getAction(ITextEditorActionConstants.COPY);
- boolean isUsingSourceCopyAction= fSourceCopyAction == currentCopyAction;
- if (wasUsingSourceCopyAction != isUsingSourceCopyAction) {
- IActionBars actionBars= getEditorSite().getActionBars();
-
- if (isUsingSourceCopyAction) {
- createNavigationActions();
- } else {
- for (int i= 0; i < ACTION_MAP.length; i++) {
- IdMapEntry entry= ACTION_MAP[i];
- actionBars.setGlobalActionHandler(entry.getActionId(), null);
- setAction(entry.getActionId(), null);
- }
- }
-
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, currentCopyAction);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, getAction(ITextEditorActionConstants.SELECT_ALL));
- actionBars.updateActionBars();
- }
-
- }
-
- /*
- * @see ClassFileDocumentProvider.InputChangeListener#inputChanged(IClassFileEditorInput)
- */
- public void inputChanged(IClassFileEditorInput input) {
- fInputUpdater.post(input);
- }
-
- /*
- * @see JavaEditor#createJavaSourceViewer(Composite, IVerticalRuler, int)
- */
- protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles, IPreferenceStore store) {
- return new JavaSourceViewer(parent, ruler, null, false, styles, store) {
-
- public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
- if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester);
- }
-
- public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
- if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester, priority);
- }
- };
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18510
- IDocumentProvider documentProvider= getDocumentProvider();
- if (documentProvider instanceof ClassFileDocumentProvider)
- ((ClassFileDocumentProvider) documentProvider).removeInputChangeListener(this);
- super.dispose();
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- super.setFocus();
-
- if (fSourceAttachmentForm != null && !fSourceAttachmentForm.isDisposed())
- fSourceAttachmentForm.setFocus();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorActionContributor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorActionContributor.java
deleted file mode 100644
index f10f3c70..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorActionContributor.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-public class ClassFileEditorActionContributor extends BasicJavaEditorActionContributor {
-
- public ClassFileEditorActionContributor() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorInputFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorInputFactory.java
deleted file mode 100644
index 7eb84270..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileEditorInputFactory.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-
-/**
- * The factory which is capable of recreating class file editor
- * inputs stored in a memento.
- */
-public class ClassFileEditorInputFactory implements IElementFactory {
-
- public final static String ID= "org.eclipse.wst.jsdt.ui.ClassFileEditorInputFactory"; //$NON-NLS-1$
- public final static String KEY= "org.eclipse.wst.jsdt.ui.ClassFileIdentifier"; //$NON-NLS-1$
-
- public ClassFileEditorInputFactory() {
- }
-
- /**
- * @see IElementFactory#createElement
- */
- public IAdaptable createElement(IMemento memento) {
- String identifier= memento.getString(KEY);
- if (identifier == null)
- return null;
-
- IJavaScriptElement element= JavaScriptCore.create(identifier);
- try {
- if (!element.exists() && element instanceof IClassFile) {
- /*
- * Let's try to find the class file,
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=83221
- */
- IClassFile cf= (IClassFile)element;
- IType type= cf.getType(); // this will work, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=154667
- IJavaScriptProject project= element.getJavaScriptProject();
- if (project != null) {
- type= JavaModelUtil.findType(project, type.getFullyQualifiedName());
- if (type == null)
- return null;
- element= type.getParent();
- }
- }
- return EditorUtility.getEditorInput(element);
- } catch (JavaScriptModelException x) {
- // Don't report but simply return null
- return null;
- }
- }
-
- public static void saveState(IMemento memento, InternalClassFileEditorInput input) {
- IClassFile c= input.getClassFile();
- memento.putString(KEY, c.getHandleIdentifier());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerAnnotationModel.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerAnnotationModel.java
deleted file mode 100644
index b1626588..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerAnnotationModel.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-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.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-/**
- *
- */
-public class ClassFileMarkerAnnotationModel extends AbstractMarkerAnnotationModel implements IResourceChangeListener {
-
- protected IClassFile fClassFile;
- protected IWorkspace fWorkspace;
- protected IResource fMarkerResource;
- protected boolean fChangesApplied;
-
-
- public ClassFileMarkerAnnotationModel(IResource markerResource) {
- super();
- fMarkerResource= markerResource;
- fWorkspace= fMarkerResource.getWorkspace();
- }
-
- public void setClassFile(IClassFile classFile) {
- fClassFile= classFile;
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#isAcceptable
- */
- protected boolean isAcceptable(IMarker marker) {
- try {
- return JavaScriptCore.isReferencedBy(fClassFile, marker);
- } catch (CoreException x) {
- handleCoreException(x, JavaEditorMessages.ClassFileMarkerAnnotationModel_error_isAcceptable);
- return false;
- }
- }
-
- protected boolean isAffected(IMarkerDelta markerDelta) {
- try {
- return JavaScriptCore.isReferencedBy(fClassFile, markerDelta);
- } catch (CoreException x) {
- handleCoreException(x, JavaEditorMessages.ClassFileMarkerAnnotationModel_error_isAffected);
- return false;
- }
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker)
- */
- protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
- return new JavaMarkerAnnotation(marker);
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#listenToMarkerChanges(boolean)
- */
- protected void listenToMarkerChanges(boolean listen) {
- if (listen)
- fWorkspace.addResourceChangeListener(this);
- else
- fWorkspace.removeResourceChangeListener(this);
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#deleteMarkers(IMarker[])
- */
- protected void deleteMarkers(IMarker[] markers) throws CoreException {
- // empty as class files are read only
- }
-
- /**
- * @see AbstractMarkerAnnotationModel#retrieveMarkers()
- */
- protected IMarker[] retrieveMarkers() throws CoreException {
- if (fMarkerResource != null) {
- IMarker[] workspaceMarkers= fWorkspace.getRoot().findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
- IMarker[] resourceMarkers= fMarkerResource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
- int workspaceMarkersLength= workspaceMarkers.length;
- if (workspaceMarkersLength == 0)
- return resourceMarkers;
-
- int resourceMarkersLength= resourceMarkers.length;
- if (resourceMarkersLength == 0)
- return workspaceMarkers;
-
- IMarker[] result= new IMarker[resourceMarkersLength + workspaceMarkersLength];
- System.arraycopy(resourceMarkers, 0, result, 0, resourceMarkersLength);
- System.arraycopy(workspaceMarkers, 0, result, resourceMarkersLength, workspaceMarkersLength);
- return result;
- }
- return null;
- }
-
- private void checkDeltas(IMarkerDelta[] markerDeltas) throws CoreException {
- for (int i= 0; i < markerDeltas.length; i++) {
- if (isAffected(markerDeltas[i])) {
- IMarker marker= markerDeltas[i].getMarker();
- switch (markerDeltas[i].getKind()) {
- case IResourceDelta.ADDED :
- addMarkerAnnotation(marker);
- fChangesApplied= true;
- break;
- case IResourceDelta.REMOVED :
- removeMarkerAnnotation(marker);
- fChangesApplied= true;
- break;
- case IResourceDelta.CHANGED:
- modifyMarkerAnnotation(marker);
- fChangesApplied= true;
- break;
- }
- }
- }
- }
-
- /**
- * @see IResourceChangeListener#resourceChanged
- */
- public void resourceChanged(IResourceChangeEvent e) {
- try {
- IMarkerDelta[] deltas= e.findMarkerDeltas(null, true);
- if (deltas != null) {
- fChangesApplied= false;
- checkDeltas(deltas);
- if (fChangesApplied)
- fireModelChanged();
- }
- } catch (CoreException x) {
- handleCoreException(x, JavaEditorMessages.ClassFileMarkerAnnotationModel_error_resourceChanged);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerRulerAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerRulerAction.java
deleted file mode 100644
index 9fa42e4d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClassFileMarkerRulerAction.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.MarkerRulerAction;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.IResourceLocator;
-
-
-
-class ClassFileMarkerRulerAction extends MarkerRulerAction {
-
-
- public ClassFileMarkerRulerAction(String prefix, IVerticalRuler ruler, ITextEditor editor, String markerType, boolean askForLabel) {
- super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, editor, ruler, markerType, askForLabel);
- }
-
- /**
- * @see MarkerRulerAction#getResource()
- */
- protected IResource getResource() {
-
- IResource resource= null;
-
- IEditorInput input= getTextEditor().getEditorInput();
- if (input instanceof IClassFileEditorInput) {
- IClassFile c= ((IClassFileEditorInput) input).getClassFile();
- IResourceLocator locator= (IResourceLocator) c.getAdapter(IResourceLocator.class);
- if (locator != null) {
- try {
- resource= locator.getContainingResource(c);
- } catch (JavaScriptModelException x) {
- // ignore but should inform
- }
- }
- }
-
- return resource;
- }
-
- /**
- * @see MarkerRulerAction#getInitialAttributes()
- */
- protected Map getInitialAttributes() {
-
- Map attributes= super.getInitialAttributes();
-
- IEditorInput input= getTextEditor().getEditorInput();
- if (input instanceof IClassFileEditorInput) {
- IClassFile classFile= ((IClassFileEditorInput) input).getClassFile();
- JavaScriptCore.addJavaScriptElementMarkerAttributes(attributes, classFile);
- }
-
- return attributes;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClipboardOperationAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClipboardOperationAction.java
deleted file mode 100644
index 88286a64..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ClipboardOperationAction.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.RTFTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ImportRewrite;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.ImportReferencesCollector;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.StubUtility;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-/**
- * Action for cut/copy and paste with support for adding imports on paste.
- */
-public final class ClipboardOperationAction extends TextEditorAction {
-
- public static class ClipboardData {
- private String fOriginHandle;
- private String[] fTypeImports;
- private String[] fStaticImports;
-
- public ClipboardData(IJavaScriptElement origin, String[] typeImports, String[] staticImports) {
- Assert.isNotNull(origin);
- Assert.isNotNull(typeImports);
- Assert.isNotNull(staticImports);
-
- fTypeImports= typeImports;
- fStaticImports= staticImports;
- fOriginHandle= origin.getHandleIdentifier();
- }
-
- public ClipboardData(byte[] bytes) throws IOException {
- DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(bytes));
- try {
- fOriginHandle= dataIn.readUTF();
- fTypeImports= readArray(dataIn);
- fStaticImports= readArray(dataIn);
- } finally {
- dataIn.close();
- }
- }
-
- private static String[] readArray(DataInputStream dataIn) throws IOException {
- int count= dataIn.readInt();
-
- String[] array= new String[count];
- for (int i = 0; i < count; i++) {
- array[i]= dataIn.readUTF();
- }
- return array;
- }
-
- private static void writeArray(DataOutputStream dataOut, String[] array) throws IOException {
- dataOut.writeInt(array.length);
- for (int i = 0; i < array.length; i++) {
- dataOut.writeUTF(array[i]);
- }
- }
-
- public String[] getTypeImports() {
- return fTypeImports;
- }
-
- public String[] getStaticImports() {
- return fStaticImports;
- }
-
- public boolean isFromSame(IJavaScriptElement elem) {
- return fOriginHandle.equals(elem.getHandleIdentifier());
- }
-
- public byte[] serialize() throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(out);
- try {
- dataOut.writeUTF(fOriginHandle);
- writeArray(dataOut, fTypeImports);
- writeArray(dataOut, fStaticImports);
- } finally {
- dataOut.close();
- out.close();
- }
-
- return out.toByteArray();
- }
- }
-
-
- private static class ClipboardTransfer extends ByteArrayTransfer {
-
- private static final String TYPE_NAME = "source-with-imports-transfer-format" + System.currentTimeMillis(); //$NON-NLS-1$
-
- private static final int TYPEID = registerType(TYPE_NAME);
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.dnd.Transfer#getTypeIds()
- */
- protected int[] getTypeIds() {
- return new int[] { TYPEID };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.dnd.Transfer#getTypeNames()
- */
- protected String[] getTypeNames() {
- return new String[] { TYPE_NAME };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)
- */
- protected void javaToNative(Object data, TransferData transferData) {
- if (data instanceof ClipboardData) {
- try {
- super.javaToNative(((ClipboardData) data).serialize(), transferData);
- } catch (IOException e) {
- //it's best to send nothing if there were problems
- }
- }
- }
-
- /* (non-Javadoc)
- * Method declared on Transfer.
- */
- protected Object nativeToJava(TransferData transferData) {
- byte[] bytes = (byte[]) super.nativeToJava(transferData);
- if (bytes != null) {
- try {
- return new ClipboardData(bytes);
- } catch (IOException e) {
- }
- }
- return null;
- }
-
- }
-
- private static final ClipboardTransfer fgTransferInstance = new ClipboardTransfer();
-
- /** The text operation code */
- private int fOperationCode= -1;
- /** The text operation target */
- private ITextOperationTarget fOperationTarget;
-
-
- /**
- * Creates the action.
- */
- public ClipboardOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) {
- super(bundle, prefix, editor);
- fOperationCode= operationCode;
-
- if (operationCode == ITextOperationTarget.CUT) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
- setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT);
- } else if (operationCode == ITextOperationTarget.COPY) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
- setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
- } else if (operationCode == ITextOperationTarget.PASTE) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
- setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE);
- } else {
- Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
- }
- update();
- }
-
- private boolean isReadOnlyOperation() {
- return fOperationCode == ITextOperationTarget.COPY;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- if (fOperationCode == -1 || fOperationTarget == null)
- return;
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- if (!isReadOnlyOperation() && !validateEditorInputState())
- return;
-
- BusyIndicator.showWhile(getDisplay(), new Runnable() {
- public void run() {
- internalDoOperation();
- }
- });
- }
-
- private Shell getShell() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- IWorkbenchPartSite site= editor.getSite();
- Shell shell= site.getShell();
- if (shell != null && !shell.isDisposed()) {
- return shell;
- }
- }
- return null;
- }
-
- private Display getDisplay() {
- Shell shell= getShell();
- if (shell != null) {
- return shell.getDisplay();
- }
- return null;
- }
-
-
- protected final void internalDoOperation() {
- if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_IMPORTS_ON_PASTE)) {
- if (fOperationCode == ITextOperationTarget.PASTE) {
- doPasteWithImportsOperation();
- } else {
- doCutCopyWithImportsOperation();
- }
- } else {
- fOperationTarget.doOperation(fOperationCode);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (!isReadOnlyOperation() && !canModifyEditor()) {
- setEnabled(false);
- return;
- }
-
- ITextEditor editor= getTextEditor();
- if (fOperationTarget == null && editor!= null && fOperationCode != -1)
- fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
-
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
- setEnabled(isEnabled);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- super.setEditor(editor);
- fOperationTarget= null;
- }
-
-
- private void doCutCopyWithImportsOperation() {
- ITextEditor editor= getTextEditor();
- IJavaScriptElement inputElement= (IJavaScriptElement) editor.getEditorInput().getAdapter(IJavaScriptElement.class);
- ISelection selection= editor.getSelectionProvider().getSelection();
-
- Object clipboardData= null;
- if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
- ITextSelection textSelection= (ITextSelection) selection;
- if (isNonTrivialSelection(textSelection)) {
- clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
- }
- }
-
- fOperationTarget.doOperation(fOperationCode);
-
- if (clipboardData != null) {
- Clipboard clipboard= new Clipboard(getDisplay());
- try {
- /*
- * We currently make assumptions about what the styled text widget sets,
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61876
- */
- Object textData= clipboard.getContents(TextTransfer.getInstance());
- Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
-
- ArrayList datas= new ArrayList(3);
- ArrayList transfers= new ArrayList(3);
- if (textData != null) {
- datas.add(textData);
- transfers.add(TextTransfer.getInstance());
- }
- if (rtfData != null) {
- datas.add(rtfData);
- transfers.add(RTFTransfer.getInstance());
- }
-
- /*
- * Don't add if we didn't get any data from the clipboard
- * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=70077
- */
- if (datas.isEmpty())
- return;
-
- datas.add(clipboardData);
- transfers.add(fgTransferInstance);
-
- Transfer[] dataTypes= (Transfer[]) transfers.toArray(new Transfer[transfers.size()]);
- Object[] data= datas.toArray();
- setClipboardContents(clipboard, data, dataTypes);
- } finally {
- clipboard.dispose();
- }
- }
- }
-
- private void setClipboardContents(Clipboard clipboard, Object[] datas, Transfer[] transfers) {
- try {
- clipboard.setContents(datas, transfers);
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
- throw e;
- }
- // silently fail. see e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=65975
- }
- }
-
- private boolean isNonTrivialSelection(ITextSelection selection) {
- if (selection.getLength() < 30) {
- String text= selection.getText();
- if (text != null) {
- for (int i= 0; i < text.length(); i++) {
- if (!Character.isJavaIdentifierPart(text.charAt(i))) {
- return true;
- }
- }
- }
- return false;
- }
- return true;
- }
-
-
- private ClipboardData getClipboardData(IJavaScriptElement inputElement, int offset, int length) {
- JavaScriptUnit astRoot= JavaScriptPlugin.getDefault().getASTProvider().getAST(inputElement, ASTProvider.WAIT_ACTIVE_ONLY, null);
- if (astRoot == null) {
- return null;
- }
-
- // do process import if selection spans over import declaration or package
- List list= astRoot.imports();
- if (!list.isEmpty()) {
- if (offset < ((ASTNode) list.get(list.size() - 1)).getStartPosition()) {
- return null;
- }
- } else if (astRoot.getPackage() != null) {
- if (offset < ((ASTNode) astRoot.getPackage()).getStartPosition()) {
- return null;
- }
- }
-
- ArrayList typeImportsRefs= new ArrayList();
- ArrayList staticImportsRefs= new ArrayList();
-
- ImportReferencesCollector.collect(astRoot, inputElement.getJavaScriptProject(), new Region(offset, length), typeImportsRefs, staticImportsRefs);
-
- if (typeImportsRefs.isEmpty() && staticImportsRefs.isEmpty()) {
- return null;
- }
-
- HashSet namesToImport= new HashSet(typeImportsRefs.size());
- for (int i= 0; i < typeImportsRefs.size(); i++) {
- Name curr= (Name) typeImportsRefs.get(i);
- IBinding binding= curr.resolveBinding();
- if (binding != null && binding.getKind() == IBinding.TYPE) {
- ITypeBinding typeBinding= (ITypeBinding) binding;
- if (typeBinding.isArray()) {
- typeBinding= typeBinding.getElementType();
- }
- if (typeBinding.isTypeVariable() || typeBinding.isCapture() || typeBinding.isWildcardType()) { // can be removed when bug 98473 is fixed
- continue;
- }
-
- if (typeBinding.isMember() || typeBinding.isTopLevel()) {
- String name= Bindings.getRawQualifiedName(typeBinding);
- if (name.length() > 0) {
- namesToImport.add(name);
- }
- }
- }
- }
-
- HashSet staticsToImport= new HashSet(staticImportsRefs.size());
- for (int i= 0; i < staticImportsRefs.size(); i++) {
- Name curr= (Name) staticImportsRefs.get(i);
- IBinding binding= curr.resolveBinding();
- if (binding != null) {
- StringBuffer buf= new StringBuffer(Bindings.getImportName(binding));
- if (binding.getKind() == IBinding.METHOD) {
- buf.append("()"); //$NON-NLS-1$
- }
- staticsToImport.add(buf.toString());
- }
- }
-
-
- if (namesToImport.isEmpty() && staticsToImport.isEmpty()) {
- return null;
- }
-
- String[] typeImports= (String[]) namesToImport.toArray(new String[namesToImport.size()]);
- String[] staticImports= (String[]) staticsToImport.toArray(new String[staticsToImport.size()]);
- return new ClipboardData(inputElement, typeImports, staticImports);
- }
-
-
- private void doPasteWithImportsOperation() {
- ITextEditor editor= getTextEditor();
- IJavaScriptElement inputElement= (IJavaScriptElement) editor.getEditorInput().getAdapter(IJavaScriptElement.class);
-
- Clipboard clipboard= new Clipboard(getDisplay());
- ClipboardData importsData= (ClipboardData) clipboard.getContents(fgTransferInstance);
- if (importsData != null && inputElement instanceof IJavaScriptUnit && !importsData.isFromSame(inputElement)) {
- // combine operation and adding of imports
- IRewriteTarget target= editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null;
- if (target != null) {
- target.beginCompoundChange();
- }
- try {
- fOperationTarget.doOperation(fOperationCode);
- addImports((IJavaScriptUnit) inputElement, importsData);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- } finally {
- if (target != null) {
- target.endCompoundChange();
- }
- }
- } else {
- fOperationTarget.doOperation(fOperationCode);
- }
- }
-
-
- private void addImports(IJavaScriptUnit unit, ClipboardData data) throws CoreException {
- ImportRewrite rewrite= StubUtility.createImportRewrite(unit, true);
- String[] imports= data.getTypeImports();
- for (int i= 0; i < imports.length; i++) {
- rewrite.addImport(imports[i]);
- }
- String[] staticImports= data.getStaticImports();
- for (int i= 0; i < staticImports.length; i++) {
- String name= Signature.getSimpleName(staticImports[i]);
- boolean isField= !name.endsWith("()"); //$NON-NLS-1$
- if (!isField) {
- name= name.substring(0, name.length() - 2);
- }
- String qualifier= Signature.getQualifier(staticImports[i]);
- rewrite.addStaticImport(qualifier, name, isField);
- }
-
- JavaModelUtil.applyEdit(unit, rewrite.rewriteImports(null), false, null);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitAnnotationModelEvent.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitAnnotationModelEvent.java
deleted file mode 100644
index ced261d5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitAnnotationModelEvent.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-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.AnnotationModelEvent;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Event sent out by changes of the compilation unit annotation model.
- */
-public class CompilationUnitAnnotationModelEvent extends AnnotationModelEvent {
-
- private boolean fIncludesProblemMarkerAnnotations;
- private IResource fUnderlyingResource;
-
- /**
- * Constructor for CompilationUnitAnnotationModelEvent.
- * @param model
- * @param underlyingResource The annotation model's underlying resource
- */
- public CompilationUnitAnnotationModelEvent(IAnnotationModel model, IResource underlyingResource) {
- super(model);
- fUnderlyingResource= underlyingResource;
- fIncludesProblemMarkerAnnotations= false;
- }
-
- private void testIfProblemMarker(Annotation annotation) {
- if (fIncludesProblemMarkerAnnotations) {
- return;
- }
- if (annotation instanceof JavaMarkerAnnotation) {
- fIncludesProblemMarkerAnnotations= ((JavaMarkerAnnotation) annotation).isProblem();
- } else if (annotation instanceof MarkerAnnotation) {
- try {
- IMarker marker= ((MarkerAnnotation) annotation).getMarker();
- if (!marker.exists() || marker.isSubtypeOf(IMarker.PROBLEM)) {
- fIncludesProblemMarkerAnnotations= true;
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationAdded(org.eclipse.jface.text.source.Annotation)
- */
- public void annotationAdded(Annotation annotation) {
- super.annotationAdded(annotation);
- testIfProblemMarker(annotation);
- }
-
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation)
- */
- public void annotationRemoved(Annotation annotation) {
- super.annotationRemoved(annotation);
- testIfProblemMarker(annotation);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
- */
- public void annotationRemoved(Annotation annotation, Position position) {
- super.annotationRemoved(annotation, position);
- testIfProblemMarker(annotation);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationChanged(org.eclipse.jface.text.source.Annotation)
- */
- public void annotationChanged(Annotation annotation) {
- testIfProblemMarker(annotation);
- super.annotationChanged(annotation);
- }
-
- /**
- * Returns whether the change included problem marker annotations.
- *
- * @return <code>true</code> if the change included marker annotations
- */
- public boolean includesProblemMarkerAnnotationChanges() {
- return fIncludesProblemMarkerAnnotations;
- }
-
- /**
- * Returns the annotation model's underlying resource
- */
- public IResource getUnderlyingResource() {
- return fUnderlyingResource;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java
deleted file mode 100644
index 29f85fd1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java
+++ /dev/null
@@ -1,1561 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.IEncodedStorage;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFileState;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.quickassist.IQuickFixableAnnotation;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModel;
-import org.eclipse.jface.text.source.AnnotationModelEvent;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelListener;
-import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
-import org.eclipse.jface.text.source.IAnnotationPresentation;
-import org.eclipse.jface.text.source.ImageUtilities;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IURIEditorInput;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.ForwardingDocumentProvider;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-import org.eclipse.wst.jsdt.core.IBuffer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IProblemRequestor;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.IPostSaveListener;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.JavaCorrectionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.text.java.IProblemRequestorExtension;
-import org.eclipse.wst.jsdt.internal.ui.text.spelling.JavaSpellingReconcileStrategy;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-public class CompilationUnitDocumentProvider extends TextFileDocumentProvider implements ICompilationUnitDocumentProvider {
-
- /**
- * Bundle of all required informations to allow working copy management.
- */
- static protected class CompilationUnitInfo extends FileInfo {
- public IJavaScriptUnit fCopy;
- }
-
- /**
- * Annotation representing an <code>IProblem</code>.
- */
- static public class ProblemAnnotation extends Annotation implements IJavaAnnotation, IAnnotationPresentation, IQuickFixableAnnotation {
-
- public static final String SPELLING_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.spelling"; //$NON-NLS-1$
-
- //XXX: To be fully correct these constants should be non-static
- /**
- * The layer in which task problem annotations are located.
- */
- private static final int TASK_LAYER;
- /**
- * The layer in which info problem annotations are located.
- */
- private static final int INFO_LAYER;
- /**
- * The layer in which warning problem annotations representing are located.
- */
- private static final int WARNING_LAYER;
- /**
- * The layer in which error problem annotations representing are located.
- */
- private static final int ERROR_LAYER;
-
- static {
- AnnotationPreferenceLookup lookup= EditorsUI.getAnnotationPreferenceLookup();
- TASK_LAYER= computeLayer("org.eclipse.ui.workbench.texteditor.task", lookup); //$NON-NLS-1$
- INFO_LAYER= computeLayer("org.eclipse.wst.jsdt.ui.info", lookup); //$NON-NLS-1$
- WARNING_LAYER= computeLayer("org.eclipse.wst.jsdt.ui.warning", lookup); //$NON-NLS-1$
- ERROR_LAYER= computeLayer("org.eclipse.wst.jsdt.ui.error", lookup); //$NON-NLS-1$
- }
-
- private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
- Annotation annotation= new Annotation(annotationType, false, null);
- AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
- if (preference != null)
- return preference.getPresentationLayer() + 1;
- else
- return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
- }
-
- private static Image fgQuickFixImage;
- private static Image fgQuickFixErrorImage;
- private static boolean fgQuickFixImagesInitialized= false;
-
- private IJavaScriptUnit fCompilationUnit;
- private List fOverlaids;
- private IProblem fProblem;
- private Image fImage;
- private boolean fQuickFixImagesInitialized= false;
- private int fLayer= IAnnotationAccessExtension.DEFAULT_LAYER;
- private boolean fIsQuickFixable;
- private boolean fIsQuickFixableStateSet= false;
-
-
- public ProblemAnnotation(IProblem problem, IJavaScriptUnit cu) {
-
- fProblem= problem;
- fCompilationUnit= cu;
-
- if (JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID == fProblem.getID()) {
- setType(SPELLING_ANNOTATION_TYPE);
- fLayer= WARNING_LAYER;
- } else if (IProblem.Task == fProblem.getID()) {
- setType(JavaMarkerAnnotation.TASK_ANNOTATION_TYPE);
- fLayer= TASK_LAYER;
- } else if (fProblem.isWarning()) {
- setType(JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE);
- fLayer= WARNING_LAYER;
- } else if (fProblem.isError()) {
- setType(JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE);
- fLayer= ERROR_LAYER;
- } else {
- setType(JavaMarkerAnnotation.INFO_ANNOTATION_TYPE);
- fLayer= INFO_LAYER;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
- */
- public int getLayer() {
- return fLayer;
- }
-
- private void initializeImages() {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18936
- if (!fQuickFixImagesInitialized) {
- if (!isQuickFixableStateSet())
- setQuickFixable(isProblem() && indicateQuixFixableProblems() && JavaCorrectionProcessor.hasCorrections(this)); // no light bulb for tasks
- if (isQuickFixable()) {
- if (!fgQuickFixImagesInitialized) {
- fgQuickFixImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_PROBLEM);
- fgQuickFixErrorImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_ERROR);
- fgQuickFixImagesInitialized= true;
- }
- if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(getType()))
- fImage= fgQuickFixErrorImage;
- else
- fImage= fgQuickFixImage;
- }
- fQuickFixImagesInitialized= true;
- }
- }
-
- private boolean indicateQuixFixableProblems() {
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
- }
-
- /*
- * @see Annotation#paint
- */
- public void paint(GC gc, Canvas canvas, Rectangle r) {
- initializeImages();
- if (fImage != null)
- ImageUtilities.drawImage(fImage, gc, canvas, r, SWT.CENTER, SWT.TOP);
- }
-
- /*
- * @see IJavaAnnotation#getImage(Display)
- */
- public Image getImage(Display display) {
- initializeImages();
- return fImage;
- }
-
- /*
- * @see IJavaAnnotation#getMessage()
- */
- public String getText() {
- return fProblem.getMessage();
- }
-
- /*
- * @see IJavaAnnotation#getArguments()
- */
- public String[] getArguments() {
- return isProblem() ? fProblem.getArguments() : null;
- }
-
- /*
- * @see IJavaAnnotation#getId()
- */
- public int getId() {
- return fProblem.getID();
- }
-
- /*
- * @see IJavaAnnotation#isProblem()
- */
- public boolean isProblem() {
- String type= getType();
- return JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(type) ||
- JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(type) ||
- SPELLING_ANNOTATION_TYPE.equals(type);
- }
-
- /*
- * @see IJavaAnnotation#hasOverlay()
- */
- public boolean hasOverlay() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getOverlay()
- */
- public IJavaAnnotation getOverlay() {
- return null;
- }
-
- /*
- * @see IJavaAnnotation#addOverlaid(IJavaAnnotation)
- */
- public void addOverlaid(IJavaAnnotation annotation) {
- if (fOverlaids == null)
- fOverlaids= new ArrayList(1);
- fOverlaids.add(annotation);
- }
-
- /*
- * @see IJavaAnnotation#removeOverlaid(IJavaAnnotation)
- */
- public void removeOverlaid(IJavaAnnotation annotation) {
- if (fOverlaids != null) {
- fOverlaids.remove(annotation);
- if (fOverlaids.size() == 0)
- fOverlaids= null;
- }
- }
-
- /*
- * @see IJavaAnnotation#getOverlaidIterator()
- */
- public Iterator getOverlaidIterator() {
- if (fOverlaids != null)
- return fOverlaids.iterator();
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
- */
- public IJavaScriptUnit getCompilationUnit() {
- return fCompilationUnit;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getMarkerType()
- */
- public String getMarkerType() {
- if (fProblem instanceof CategorizedProblem)
- return ((CategorizedProblem) fProblem).getMarkerType();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.quickassist.IQuickFixableAnnotation#setQuickFixable(boolean)
- *
- */
- public void setQuickFixable(boolean state) {
- fIsQuickFixable= state;
- fIsQuickFixableStateSet= true;
- }
-
- /*
- * @see org.eclipse.jface.text.quickassist.IQuickFixableAnnotation#isQuickFixableStateSet()
- *
- */
- public boolean isQuickFixableStateSet() {
- return fIsQuickFixableStateSet;
- }
-
- /*
- * @see org.eclipse.jface.text.quickassist.IQuickFixableAnnotation#isQuickFixable()
- *
- */
- public boolean isQuickFixable() {
- Assert.isTrue(isQuickFixableStateSet());
- return fIsQuickFixable;
- }
- }
-
- /**
- * Internal structure for mapping positions to some value.
- * The reason for this specific structure is that positions can
- * change over time. Thus a lookup is based on value and not
- * on hash value.
- */
- protected static class ReverseMap {
-
- static class Entry {
- Position fPosition;
- Object fValue;
- }
-
- private List fList= new ArrayList(2);
- private int fAnchor= 0;
-
- public ReverseMap() {
- }
-
- public Object get(Position position) {
-
- Entry entry;
-
- // behind anchor
- int length= fList.size();
- for (int i= fAnchor; i < length; i++) {
- entry= (Entry) fList.get(i);
- if (entry.fPosition.equals(position)) {
- fAnchor= i;
- return entry.fValue;
- }
- }
-
- // before anchor
- for (int i= 0; i < fAnchor; i++) {
- entry= (Entry) fList.get(i);
- if (entry.fPosition.equals(position)) {
- fAnchor= i;
- return entry.fValue;
- }
- }
-
- return null;
- }
-
- private int getIndex(Position position) {
- Entry entry;
- int length= fList.size();
- for (int i= 0; i < length; i++) {
- entry= (Entry) fList.get(i);
- if (entry.fPosition.equals(position))
- return i;
- }
- return -1;
- }
-
- public void put(Position position, Object value) {
- int index= getIndex(position);
- if (index == -1) {
- Entry entry= new Entry();
- entry.fPosition= position;
- entry.fValue= value;
- fList.add(entry);
- } else {
- Entry entry= (Entry) fList.get(index);
- entry.fValue= value;
- }
- }
-
- public void remove(Position position) {
- int index= getIndex(position);
- if (index > -1)
- fList.remove(index);
- }
-
- public void clear() {
- fList.clear();
- }
- }
-
- /**
- * Annotation model dealing with java marker annotations and temporary problems.
- * Also acts as problem requester for its compilation unit. Initially inactive. Must explicitly be
- * activated.
- */
- protected static class CompilationUnitAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor, IProblemRequestorExtension {
-
- private static class ProblemRequestorState {
- boolean fInsideReportingSequence= false;
- List fReportedProblems;
- }
-
- private ThreadLocal fProblemRequestorState= new ThreadLocal();
- private int fStateCount= 0;
-
- private IJavaScriptUnit fCompilationUnit;
- private List fGeneratedAnnotations= new ArrayList();
- private IProgressMonitor fProgressMonitor;
- private boolean fIsActive= false;
- private boolean fIsHandlingTemporaryProblems;
-
- private ReverseMap fReverseMap= new ReverseMap();
- private List fPreviouslyOverlaid= null;
- private List fCurrentlyOverlaid= new ArrayList();
- private Thread fActiveThread;
-
-
- public CompilationUnitAnnotationModel(IResource resource) {
- super(resource);
- }
-
- public void setCompilationUnit(IJavaScriptUnit unit) {
- fCompilationUnit= unit;
- }
-
- protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
- String markerType= MarkerUtilities.getMarkerType(marker);
- if (markerType != null && markerType.startsWith(JavaMarkerAnnotation.JAVA_MARKER_TYPE_PREFIX))
- return new JavaMarkerAnnotation(marker);
- return super.createMarkerAnnotation(marker);
- }
-
- /*
- * @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
- */
- protected AnnotationModelEvent createAnnotationModelEvent() {
- return new CompilationUnitAnnotationModelEvent(this, getResource());
- }
-
- protected Position createPositionFromProblem(IProblem problem) {
- int start= problem.getSourceStart();
- if (start < 0)
- return null;
-
- int length= problem.getSourceEnd() - problem.getSourceStart() + 1;
- if (length < 0)
- return null;
-
- return new Position(start, length);
- }
-
- /*
- * @see IProblemRequestor#beginReporting()
- */
- public void beginReporting() {
- ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
- if (state == null)
- internalBeginReporting(false);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
- */
- public void beginReportingSequence() {
- ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
- if (state == null)
- internalBeginReporting(true);
- }
-
- /**
- * Sets up the infrastructure necessary for problem reporting.
- *
- * @param insideReportingSequence <code>true</code> if this method
- * call is issued from inside a reporting sequence
- */
- private void internalBeginReporting(boolean insideReportingSequence) {
- if (fCompilationUnit != null /*&& fCompilationUnit.getJavaProject().isOnClasspath(fCompilationUnit)*/) {
- ProblemRequestorState state= new ProblemRequestorState();
- state.fInsideReportingSequence= insideReportingSequence;
- state.fReportedProblems= new ArrayList();
- synchronized (getLockObject()) {
- fProblemRequestorState.set(state);
- ++fStateCount;
- }
- }
- }
-
- /*
- * @see IProblemRequestor#acceptProblem(IProblem)
- */
- public void acceptProblem(IProblem problem) {
- if (fIsHandlingTemporaryProblems || problem.getID() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {
- ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
- if (state != null)
- state.fReportedProblems.add(problem);
- }
- }
-
- /*
- * @see IProblemRequestor#endReporting()
- */
- public void endReporting() {
- ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
- if (state != null && !state.fInsideReportingSequence)
- internalEndReporting(state);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
- */
- public void endReportingSequence() {
- ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
- if (state != null && state.fInsideReportingSequence)
- internalEndReporting(state);
- }
-
- private void internalEndReporting(ProblemRequestorState state) {
- int stateCount= 0;
- synchronized(getLockObject()) {
- -- fStateCount;
- stateCount= fStateCount;
- fProblemRequestorState.set(null);
- }
-
- if (stateCount == 0)
- reportProblems(state.fReportedProblems);
- }
-
- /**
- * Signals the end of problem reporting.
- *
- * @param reportedProblems the problems to report
- */
- private void reportProblems(List reportedProblems) {
- if (fProgressMonitor != null && fProgressMonitor.isCanceled())
- return;
-
- boolean temporaryProblemsChanged= false;
-
- synchronized (getLockObject()) {
-
- boolean isCanceled= false;
-
- fPreviouslyOverlaid= fCurrentlyOverlaid;
- fCurrentlyOverlaid= new ArrayList();
-
- if (fGeneratedAnnotations.size() > 0) {
- temporaryProblemsChanged= true;
- removeAnnotations(fGeneratedAnnotations, false, true);
- fGeneratedAnnotations.clear();
- }
-
- if (reportedProblems != null && reportedProblems.size() > 0) {
-
- Iterator e= reportedProblems.iterator();
- while (e.hasNext()) {
-
- if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
- isCanceled= true;
- break;
- }
-
- IProblem problem= (IProblem) e.next();
- Position position= createPositionFromProblem(problem);
- if (position != null) {
-
- try {
- ProblemAnnotation annotation= new ProblemAnnotation(problem, fCompilationUnit);
- overlayMarkers(position, annotation);
- addAnnotation(annotation, position, false);
- fGeneratedAnnotations.add(annotation);
-
- temporaryProblemsChanged= true;
- } catch (BadLocationException x) {
- // ignore invalid position
- }
- }
- }
- }
-
- removeMarkerOverlays(isCanceled);
- fPreviouslyOverlaid= null;
- }
-
- if (temporaryProblemsChanged)
- fireModelChanged();
- }
-
- private void removeMarkerOverlays(boolean isCanceled) {
- if (isCanceled) {
- fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
- } else if (fPreviouslyOverlaid != null) {
- Iterator e= fPreviouslyOverlaid.iterator();
- while (e.hasNext()) {
- JavaMarkerAnnotation annotation= (JavaMarkerAnnotation) e.next();
- annotation.setOverlay(null);
- }
- }
- }
-
- /**
- * Overlays value with problem annotation.
- *
- * @param value the value
- * @param problemAnnotation
- */
- private void setOverlay(Object value, ProblemAnnotation problemAnnotation) {
- if (value instanceof JavaMarkerAnnotation) {
- JavaMarkerAnnotation annotation= (JavaMarkerAnnotation) value;
- if (annotation.isProblem()) {
- annotation.setOverlay(problemAnnotation);
- fPreviouslyOverlaid.remove(annotation);
- fCurrentlyOverlaid.add(annotation);
- }
- } else {
- }
- }
-
- private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
- Object value= getAnnotations(position);
- if (value instanceof List) {
- List list= (List) value;
- for (Iterator e = list.iterator(); e.hasNext();)
- setOverlay(e.next(), problemAnnotation);
- } else {
- setOverlay(value, problemAnnotation);
- }
- }
-
- /**
- * Tells this annotation model to collect temporary problems from now on.
- */
- private void startCollectingProblems() {
- fGeneratedAnnotations.clear();
- }
-
- /**
- * Tells this annotation model to no longer collect temporary problems.
- */
- private void stopCollectingProblems() {
- if (fGeneratedAnnotations != null)
- removeAnnotations(fGeneratedAnnotations, true, true);
- fGeneratedAnnotations.clear();
- }
-
- /*
- * @see IProblemRequestor#isActive()
- */
- public synchronized boolean isActive() {
- return fIsActive && fActiveThread == Thread.currentThread();
- }
-
- /*
- * @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
- }
-
- /*
- * @see IProblemRequestorExtension#setIsActive(boolean)
- */
- public synchronized void setIsActive(boolean isActive) {
- Assert.isLegal(!isActive || Display.getCurrent() == null); // must not be enabled from UI threads
- fIsActive= isActive;
- if (fIsActive)
- fActiveThread= Thread.currentThread();
- else
- fActiveThread= null;
- }
-
- /*
- * @see IProblemRequestorExtension#setIsHandlingTemporaryProblems(boolean)
- *
- */
- public void setIsHandlingTemporaryProblems(boolean enable) {
- if (fIsHandlingTemporaryProblems != enable) {
- fIsHandlingTemporaryProblems= enable;
- if (fIsHandlingTemporaryProblems)
- startCollectingProblems();
- else
- stopCollectingProblems();
- }
-
- }
-
- private Object getAnnotations(Position position) {
- synchronized (getLockObject()) {
- return fReverseMap.get(position);
- }
- }
-
- /*
- * @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
- */
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
- super.addAnnotation(annotation, position, fireModelChanged);
-
- synchronized (getLockObject()) {
- Object cached= fReverseMap.get(position);
- if (cached == null)
- fReverseMap.put(position, annotation);
- else if (cached instanceof List) {
- List list= (List) cached;
- list.add(annotation);
- } else if (cached instanceof Annotation) {
- List list= new ArrayList(2);
- list.add(cached);
- list.add(annotation);
- fReverseMap.put(position, list);
- }
- }
- }
-
- /*
- * @see AnnotationModel#removeAllAnnotations(boolean)
- */
- protected void removeAllAnnotations(boolean fireModelChanged) {
- super.removeAllAnnotations(fireModelChanged);
- synchronized (getLockObject()) {
- fReverseMap.clear();
- }
- }
-
- /*
- * @see AnnotationModel#removeAnnotation(Annotation, boolean)
- */
- protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
- Position position= getPosition(annotation);
- synchronized (getLockObject()) {
- Object cached= fReverseMap.get(position);
- if (cached instanceof List) {
- List list= (List) cached;
- list.remove(annotation);
- if (list.size() == 1) {
- fReverseMap.put(position, list.get(0));
- list.clear();
- }
- } else if (cached instanceof Annotation) {
- fReverseMap.remove(position);
- }
- }
- super.removeAnnotation(annotation, fireModelChanged);
- }
- }
-
-
- protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
-
- private ListenerList fListenerList;
-
- public GlobalAnnotationModelListener() {
- fListenerList= new ListenerList(ListenerList.IDENTITY);
- }
-
- /**
- * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
- */
- public void modelChanged(IAnnotationModel model) {
- Object[] listeners= fListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ((IAnnotationModelListener) listeners[i]).modelChanged(model);
- }
- }
-
- /**
- * @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
- */
- public void modelChanged(AnnotationModelEvent event) {
- Object[] listeners= fListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- Object curr= listeners[i];
- if (curr instanceof IAnnotationModelListenerExtension) {
- ((IAnnotationModelListenerExtension) curr).modelChanged(event);
- }
- }
- }
-
- public void addListener(IAnnotationModelListener listener) {
- fListenerList.add(listener);
- }
-
- public void removeListener(IAnnotationModelListener listener) {
- fListenerList.remove(listener);
- }
- }
-
- /** Preference key for temporary problems */
- private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS;
-
-
- /** Indicates whether the save has been initialized by this provider */
- private boolean fIsAboutToSave= false;
- /** The save policy used by this provider */
- private ISavePolicy fSavePolicy;
- /** Internal property changed listener */
- private IPropertyChangeListener fPropertyListener;
- /** Annotation model listener added to all created CU annotation models */
- private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
- /**
- * Element information of all connected elements with a fake CU but no file info.
- *
- */
- private final Map fFakeCUMapForMissingInfo= new HashMap();
-
-
- /**
- * Constructor
- */
- public CompilationUnitDocumentProvider() {
-
- IDocumentProvider provider= new TextFileDocumentProvider();
- provider= new ForwardingDocumentProvider(IJavaScriptPartitions.JAVA_PARTITIONING, new JavaDocumentSetupParticipant(), provider);
- setParentDocumentProvider(provider);
-
- fGlobalAnnotationModelListener= new GlobalAnnotationModelListener();
- fPropertyListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (HANDLE_TEMPORARY_PROBLEMS.equals(event.getProperty()))
- enableHandlingTemporaryProblems();
- }
- };
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener);
- }
-
- /**
- * Creates a compilation unit from the given file.
- *
- * @param file the file from which to create the compilation unit
- * @return the fake compilation unit
- */
- protected IJavaScriptUnit createCompilationUnit(IFile file) {
- Object element= JavaScriptCore.create(file);
- if (element instanceof IJavaScriptUnit)
- return (IJavaScriptUnit) element;
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo()
- */
- protected FileInfo createEmptyFileInfo() {
- return new CompilationUnitInfo();
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile)
- */
- protected IAnnotationModel createAnnotationModel(IFile file) {
- return new CompilationUnitAnnotationModel(file);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object)
- */
- protected FileInfo createFileInfo(Object element) throws CoreException {
- IJavaScriptUnit original= null;
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- original= createCompilationUnit(input.getFile());
- if (original == null)
- return null;
- }
-
- FileInfo info= super.createFileInfo(element);
- if (!(info instanceof CompilationUnitInfo))
- return null;
-
- if (original == null)
- original= createFakeCompiltationUnit(element, false);
- if (original == null)
- return null;
-
- CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
- setUpSynchronization(cuInfo);
-
- IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
- if (requestor instanceof IProblemRequestorExtension) {
- IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
- extension.setIsActive(false);
- extension.setIsHandlingTemporaryProblems(isHandlingTemporaryProblems());
- }
-
- if (JavaModelUtil.isPrimary(original))
- original.becomeWorkingCopy(requestor, getProgressMonitor());
- cuInfo.fCopy= original;
-
- if (cuInfo.fModel instanceof CompilationUnitAnnotationModel) {
- CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
- model.setCompilationUnit(cuInfo.fCopy);
- }
-
- if (cuInfo.fModel != null)
- cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);
-
- return cuInfo;
- }
-
- /**
- * Creates a fake compilation unit.
- *
- * @param element the element
- * @param setContents tells whether to read and set the contents to the new CU
- * @return the fake compilation unit
- *
- */
- private IJavaScriptUnit createFakeCompiltationUnit(Object element, boolean setContents) {
- if (element instanceof IStorageEditorInput)
- return createFakeCompiltationUnit((IStorageEditorInput)element, setContents);
- else if (element instanceof IURIEditorInput)
- return createFakeCompiltationUnit((IURIEditorInput)element);
- return null;
- }
-
- /**
- * Creates a fake compilation unit.
- *
- * @param editorInput the storage editor input
- * @param setContents tells whether to read and set the contents to the new CU
- * @return the fake compilation unit
- *
- */
- private IJavaScriptUnit createFakeCompiltationUnit(IStorageEditorInput editorInput, boolean setContents) {
- try {
- final IStorage storage= editorInput.getStorage();
- final IPath storagePath= storage.getFullPath();
- if (storage.getName() == null || storagePath == null)
- return null;
-
- final IPath documentPath;
- if (storage instanceof IFileState)
- documentPath= storagePath.append(Long.toString(((IFileState)storage).getModificationTime()));
- else
- documentPath= storagePath;
-
- WorkingCopyOwner woc= new WorkingCopyOwner() {
- /*
- * @see org.eclipse.wst.jsdt.core.WorkingCopyOwner#createBuffer(org.eclipse.wst.jsdt.core.IJavaScriptUnit)
- *
- */
- public IBuffer createBuffer(IJavaScriptUnit workingCopy) {
- return new DocumentAdapter(workingCopy, documentPath);
- }
- };
-
- IIncludePathEntry[] cpEntries= null;
- IJavaScriptProject jp= findJavaProject(storagePath);
- if (jp != null)
- cpEntries= jp.getResolvedIncludepath(true);
-
- if (cpEntries == null || cpEntries.length == 0)
- cpEntries= new IIncludePathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };
-
- final IJavaScriptUnit cu= woc.newWorkingCopy(storage.getName(), cpEntries, getProgressMonitor());
- if (setContents) {
- int READER_CHUNK_SIZE= 2048;
- int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
-
- String charsetName= null;
- if (storage instanceof IEncodedStorage)
- charsetName= ((IEncodedStorage)storage).getCharset();
- if (charsetName == null)
- charsetName= getDefaultEncoding();
-
- Reader in= null;
- InputStream contents= storage.getContents();
- try {
- in= new BufferedReader(new InputStreamReader(contents, charsetName));
- StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
- char[] readBuffer= new char[READER_CHUNK_SIZE];
- int n;
- n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
- cu.getBuffer().setContents(buffer.toString());
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- return null;
- } finally {
- try {
- if (in != null)
- in.close();
- else
- contents.close();
- } catch (IOException x) {
- }
- }
- }
-
- if (!isModifiable(editorInput))
- JavaModelUtil.reconcile(cu);
-
- return cu;
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex.getStatus());
- return null;
- }
- }
-
- /**
- * Creates a fake compilation unit.
- *
- * @param editorInput the URI editor input
- * @return the fake compilation unit
- *
- */
- private IJavaScriptUnit createFakeCompiltationUnit(IURIEditorInput editorInput) {
- try {
- final URI uri= editorInput.getURI();
- final IFileStore fileStore= EFS.getStore(uri);
- final IPath path= URIUtil.toPath(uri);
- if (fileStore.getName() == null || path == null)
- return null;
-
- WorkingCopyOwner woc= new WorkingCopyOwner() {
- /*
- * @see org.eclipse.wst.jsdt.core.WorkingCopyOwner#createBuffer(org.eclipse.wst.jsdt.core.IJavaScriptUnit)
- *
- */
- public IBuffer createBuffer(IJavaScriptUnit workingCopy) {
- return new DocumentAdapter(workingCopy, path);
- }
- };
-
- IIncludePathEntry[] cpEntries= null;
- IJavaScriptProject jp= findJavaProject(path);
- if (jp != null)
- cpEntries= jp.getResolvedIncludepath(true);
-
- if (cpEntries == null || cpEntries.length == 0)
- cpEntries= new IIncludePathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };
-
- final IJavaScriptUnit cu= woc.newWorkingCopy(fileStore.getName(), cpEntries, getProgressMonitor());
-
- if (!isModifiable(editorInput))
- JavaModelUtil.reconcile(cu);
-
- return cu;
- } catch (CoreException ex) {
- return null;
- }
- }
-
- /**
- * Fuzzy search for Java project in the workspace that matches
- * the given path.
- *
- * @param path the path to match
- * @return the matching Java project or <code>null</code>
- *
- */
- private IJavaScriptProject findJavaProject(IPath path) {
- if (path == null)
- return null;
-
- String[] pathSegments= path.segments();
- IJavaScriptModel model= JavaScriptCore.create(JavaScriptPlugin.getWorkspace().getRoot());
- IJavaScriptProject[] projects;
- try {
- projects= model.getJavaScriptProjects();
- } catch (JavaScriptModelException e) {
- return null; // ignore - use default JRE
- }
- for (int i= 0; i < projects.length; i++) {
- IPath projectPath= projects[i].getProject().getFullPath();
- String projectSegment= projectPath.segments()[0];
- for (int j= 0; j < pathSegments.length; j++)
- if (projectSegment.equals(pathSegments[j]))
- return projects[i];
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo)
- */
- protected void disposeFileInfo(Object element, FileInfo info) {
- if (info instanceof CompilationUnitInfo) {
- CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
-
- try {
- cuInfo.fCopy.discardWorkingCopy();
- } catch (JavaScriptModelException x) {
- handleCoreException(x, x.getMessage());
- }
-
- if (cuInfo.fModel != null)
- cuInfo.fModel.removeAnnotationModelListener(fGlobalAnnotationModelListener);
- }
- super.disposeFileInfo(element, info);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#connect(java.lang.Object)
- *
- */
- public void connect(Object element) throws CoreException {
- super.connect(element);
- if (getFileInfo(element) != null)
- return;
-
- CompilationUnitInfo info= (CompilationUnitInfo)fFakeCUMapForMissingInfo.get(element);
- if (info == null) {
- IJavaScriptUnit cu= createFakeCompiltationUnit(element, true);
- if (cu == null)
- return;
- info= new CompilationUnitInfo();
- info.fCopy= cu;
- info.fElement= element;
- if (element instanceof IStorageEditorInput)
- {
- IStorage storage = ((IStorageEditorInput)element).getStorage();
- info.fModel=new StorageMarkerAnnotationModel(ResourcesPlugin.getWorkspace().getRoot(),storage.getName());
- }
- else
- info.fModel= new AnnotationModel();
- fFakeCUMapForMissingInfo.put(element, info);
- }
- info.fCount++;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#getAnnotationModel(java.lang.Object)
- *
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- IAnnotationModel model= super.getAnnotationModel(element);
- if (model != null)
- return model;
-
- FileInfo info= (FileInfo)fFakeCUMapForMissingInfo.get(element);
- if (info != null) {
- if (info.fModel != null)
- return info.fModel;
- if (info.fTextFileBuffer != null)
- return info.fTextFileBuffer.getAnnotationModel();
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disconnect(java.lang.Object)
- *
- */
- public void disconnect(Object element) {
- CompilationUnitInfo info= (CompilationUnitInfo)fFakeCUMapForMissingInfo.get(element);
- if (info != null) {
- if (info.fCount == 1) {
- fFakeCUMapForMissingInfo.remove(element);
- info.fModel= null;
- // Destroy and unregister fake working copy
- try {
- info.fCopy.discardWorkingCopy();
- } catch (JavaScriptModelException ex) {
- handleCoreException(ex, ex.getMessage());
- }
- } else
- info.fCount--;
- }
- super.disconnect(element);
- }
-
-
- /**
- * Creates and returns a new sub-progress monitor for the
- * given parent monitor.
- *
- * @param monitor the parent progress monitor
- * @param ticks the number of work ticks allocated from the parent monitor
- * @return the new sub-progress monitor
- */
- private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
- if (monitor != null)
- return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
-
- return new NullProgressMonitor();
- }
-
- protected void commitWorkingCopy(IProgressMonitor monitor, Object element, final CompilationUnitInfo info, boolean overwrite) throws CoreException {
-
- if (monitor == null)
- monitor= new NullProgressMonitor();
-
- monitor.beginTask("", 120); //$NON-NLS-1$
-
- try {
- final IProgressMonitor subMonitor1= getSubProgressMonitor(monitor, 50);
-
- try {
- SafeRunner.run(new ISafeRunnable() {
- public void run() {
- try {
- info.fCopy.reconcile(IJavaScriptUnit.NO_AST, false, null, subMonitor1);
- } catch (JavaScriptModelException ex) {
- handleException(ex);
- } catch (OperationCanceledException ex) {
- // do not log this
- }
- }
- public void handleException(Throwable ex) {
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.OK, "Error in JSDT Core during reconcile while saving", ex); //$NON-NLS-1$
- JavaScriptPlugin.getDefault().getLog().log(status);
- }
- });
- } finally {
- subMonitor1.done();
- }
-
- IDocument document= info.fTextFileBuffer.getDocument();
- IResource resource= info.fCopy.getResource();
-
- Assert.isTrue(resource instanceof IFile);
-
- boolean isSynchronized= resource.isSynchronized(IResource.DEPTH_ZERO);
-
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=98327
- * Make sure file gets save in commit() if the underlying file has been deleted */
- if (!isSynchronized && isDeleted(element))
- info.fTextFileBuffer.setDirty(true);
-
- if (!resource.exists()) {
- // underlying resource has been deleted, just recreate file, ignore the rest
- IProgressMonitor subMonitor2= getSubProgressMonitor(monitor, 70);
- try {
- createFileFromDocument(subMonitor2, (IFile) resource, document);
- } finally {
- subMonitor2.done();
- }
- return;
- }
-
- if (fSavePolicy != null)
- fSavePolicy.preSave(info.fCopy);
-
- IProgressMonitor subMonitor3= getSubProgressMonitor(monitor, 50);
- try {
- fIsAboutToSave= true;
- info.fCopy.commitWorkingCopy(isSynchronized || overwrite, subMonitor3);
- notifyPostSaveListeners(info.fCopy, info, getSubProgressMonitor(monitor, 20));
- } 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;
- subMonitor3.done();
- }
-
- // If here, the dirty state of the editor will change to "not dirty".
- // Thus, the state changing flag will be reset.
- if (info.fModel instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
- model.updateMarkers(document);
- }
-
- if (fSavePolicy != null) {
- IJavaScriptUnit unit= fSavePolicy.postSave(info.fCopy);
- if (unit != null && info.fModel instanceof AbstractMarkerAnnotationModel) {
- IResource r= unit.getResource();
- IMarker[] markers= r.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
- if (markers != null && markers.length > 0) {
- AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
- for (int i= 0; i < markers.length; i++)
- model.updateMarker(document, markers[i], null);
- }
- }
- }
- } finally {
- monitor.done();
- }
- }
-
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createSaveOperation(java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException {
- final FileInfo info= getFileInfo(element);
- if (info instanceof CompilationUnitInfo) {
-
- // Delegate handling of non-primary CUs
- IJavaScriptUnit cu= ((CompilationUnitInfo)info).fCopy;
- if (cu != null && !JavaModelUtil.isPrimary(cu))
- return super.createSaveOperation(element, document, overwrite);
-
- if (info.fTextFileBuffer.getDocument() != document) {
- // the info exists, but not for the given document
- // -> saveAs was executed with a target that is already open
- // in another editor
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=85519
- Status status= new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, IStatus.ERROR, JavaEditorMessages.CompilationUnitDocumentProvider_saveAsTargetOpenInEditor, null);
- throw new CoreException(status);
- }
-
- return new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException {
- commitWorkingCopy(monitor, element, (CompilationUnitInfo) info, overwrite);
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- if (info.fElement instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) info.fElement).getFile();
- return computeSchedulingRule(file);
- } else
- return null;
- }
- };
- }
-
- return null;
- }
-
- /**
- * Returns the preference whether handling temporary problems is enabled.
- *
- * @return <code>true</code> if temporary problems are handled
- */
- protected boolean isHandlingTemporaryProblems() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
- }
-
- /**
- * Switches the state of problem acceptance according to the value in the preference store.
- */
- protected void enableHandlingTemporaryProblems() {
- boolean enable= isHandlingTemporaryProblems();
- for (Iterator iter= getFileInfosIterator(); iter.hasNext();) {
- FileInfo info= (FileInfo) iter.next();
- if (info.fModel instanceof IProblemRequestorExtension) {
- IProblemRequestorExtension extension= (IProblemRequestorExtension) info.fModel;
- extension.setIsHandlingTemporaryProblems(enable);
- }
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#setSavePolicy(org.eclipse.wst.jsdt.internal.ui.javaeditor.ISavePolicy)
- */
- public void setSavePolicy(ISavePolicy savePolicy) {
- fSavePolicy= savePolicy;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#addGlobalAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener)
- */
- public void addGlobalAnnotationModelListener(IAnnotationModelListener listener) {
- fGlobalAnnotationModelListener.addListener(listener);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#removeGlobalAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener)
- */
- public void removeGlobalAnnotationModelListener(IAnnotationModelListener listener) {
- fGlobalAnnotationModelListener.removeListener(listener);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#getWorkingCopy(java.lang.Object)
- */
- public IJavaScriptUnit getWorkingCopy(Object element) {
- FileInfo fileInfo= getFileInfo(element);
- if (fileInfo instanceof CompilationUnitInfo) {
- CompilationUnitInfo info= (CompilationUnitInfo)fileInfo;
- return info.fCopy;
- }
- CompilationUnitInfo cuInfo= (CompilationUnitInfo)fFakeCUMapForMissingInfo.get(element);
- if (cuInfo != null)
- return cuInfo.fCopy;
-
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#shutdown()
- */
- public void shutdown() {
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
- Iterator e= getConnectedElementsIterator();
- while (e.hasNext())
- disconnect(e.next());
- fFakeCUMapForMissingInfo.clear();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#saveDocumentContent(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- public void saveDocumentContent(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- if (!fIsAboutToSave)
- return;
- super.saveDocument(monitor, element, document, overwrite);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#createLineTracker(java.lang.Object)
- */
- public ILineTracker createLineTracker(Object element) {
- return new DefaultLineTracker();
- }
-
- /**
- * Notify post save listeners.
- * <p>
- * <strong>Note:</strong> Post save listeners are not
- * allowed to save the file and they must not assumed to be
- * called in the UI thread i.e. if they open a dialog they
- * must ensure it ends up in the UI thread.
- * </p>
- *
- * @param unit the compilation unit
- * @param info compilation unit info
- * @param monitor the progress monitor
- * @throws CoreException
- * @see IPostSaveListener
- *
- */
- protected void notifyPostSaveListeners(final IJavaScriptUnit unit, final CompilationUnitInfo info, final IProgressMonitor monitor) throws CoreException {
- final IBuffer buffer= unit.getBuffer();
- IPostSaveListener[] listeners= JavaScriptPlugin.getDefault().getSaveParticipantRegistry().getEnabledPostSaveListeners(unit.getJavaScriptProject().getProject());
-
- String message= JavaEditorMessages.CompilationUnitDocumentProvider_error_saveParticipantProblem;
- final MultiStatus errorStatus= new MultiStatus(JavaScriptUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, message, null);
-
- monitor.beginTask(JavaEditorMessages.CompilationUnitDocumentProvider_progressNotifyingSaveParticipants, listeners.length * 5);
- try {
- for (int i= 0; i < listeners.length; i++) {
- final IPostSaveListener listener= listeners[i];
- final String participantName= listener.getName();
- SafeRunner.run(new ISafeRunnable() {
- public void run() {
- try {
- long stamp= unit.getResource().getModificationStamp();
-
- listener.saved(unit, getSubProgressMonitor(monitor, 4));
-
- if (stamp != unit.getResource().getModificationStamp()) {
- String msg= Messages.format(JavaEditorMessages.CompilationUnitDocumentProvider_error_saveParticipantSavedFile, participantName);
- errorStatus.add(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, null));
- }
-
- if (buffer.hasUnsavedChanges())
- buffer.save(getSubProgressMonitor(monitor, 1), true);
-
- } catch (CoreException ex) {
- handleException(ex);
- } finally {
- monitor.worked(1);
- }
- }
-
- public void handleException(Throwable ex) {
- String msg= Messages.format("The save participant ''{0}'' caused an exception: {1}", new String[] { listener.getId(), ex.toString()}); //$NON-NLS-1$
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, null));
-
- msg= Messages.format(JavaEditorMessages.CompilationUnitDocumentProvider_error_saveParticipantFailed, new String[] { participantName, ex.toString()});
- errorStatus.add(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, null));
-
- // Revert the changes
- if (info != null && buffer.hasUnsavedChanges()) {
- try {
- info.fTextFileBuffer.revert(getSubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- msg= Messages.format("Error on revert after failure of save participant ''{0}''.", participantName); //$NON-NLS-1$
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, ex);
- JavaScriptPlugin.getDefault().getLog().log(status);
- }
-
- if (info.fModel instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel)info.fModel;
- markerModel.resetMarkers();
- }
- }
-
- // XXX: Work in progress 'Save As' case
-// else if (buffer.hasUnsavedChanges()) {
-// try {
-// buffer.save(getSubProgressMonitor(monitor, 1), true);
-// } catch (JavaScriptModelException e) {
-// message= Messages.format("Error reverting changes after failure of save participant ''{0}''.", participantName); //$NON-NLS-1$
-// IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.OK, message, ex);
-// JavaScriptPlugin.getDefault().getLog().log(status);
-// }
-// }
- }
- });
- }
- } finally {
- monitor.done();
- if (!errorStatus.isOK())
- throw new CoreException(errorStatus);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditor.java
deleted file mode 100644
index fb5cc3d2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditor.java
+++ /dev/null
@@ -1,1711 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-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.ListenerList;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.DocumentCommand;
-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.IRegion;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension7;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TabsToSpacesConverter;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.jface.text.link.ILinkedModeListener;
-import org.eclipse.jface.text.link.LinkedModeModel;
-import org.eclipse.jface.text.link.LinkedModeUI;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
-import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.VerifyEvent;
-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.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.texteditor.ContentAssistAction;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.ResourceAction;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.AddBlockCommentAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.IndentAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.RemoveBlockCommentAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.SurroundWithActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.compare.LocalHistoryActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.text.ContentAssistPreference;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner;
-import org.eclipse.wst.jsdt.internal.ui.text.SmartBackspaceManager;
-import org.eclipse.wst.jsdt.internal.ui.text.Symbols;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingContext;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.CorrectionCommandInstaller;
-import org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-
-/**
- * Java specific text editor.
- */
-public class CompilationUnitEditor extends JavaEditor implements IJavaReconcilingListener {
- private static final boolean CODE_ASSIST_DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.ui/debug/ResultCollector")); //$NON-NLS-1$//$NON-NLS-2$
-
- /**
- * Text operation code for requesting common prefix completion.
- */
- public static final int CONTENTASSIST_COMPLETE_PREFIX= 60;
-
-
- interface ITextConverter {
- void customizeDocumentCommand(IDocument document, DocumentCommand command);
- }
-
- class AdaptedSourceViewer extends JavaSourceViewer {
-
- public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
- super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
- }
-
- public IContentAssistant getContentAssistant() {
- return fContentAssistant;
- }
-
- /*
- * @see ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
-
- if (getTextWidget() == null)
- return;
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- long time= CODE_ASSIST_DEBUG ? System.currentTimeMillis() : 0;
- String msg= fContentAssistant.showPossibleCompletions();
- if (CODE_ASSIST_DEBUG) {
- long delta= System.currentTimeMillis() - time;
- System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$
- }
- setStatusLineErrorMessage(msg);
- return;
- case QUICK_ASSIST:
- /*
- * XXX: We can get rid of this once the SourceViewer has a way to update the status line
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
- */
- msg= fQuickAssistAssistant.showPossibleQuickAssists();
- setStatusLineErrorMessage(msg);
- return;
- }
-
- super.doOperation(operation);
- }
-
- /*
- * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
- if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester);
- }
-
- /*
- * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
- *
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
- if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester, priority);
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext()
- *
- */
- public IFormattingContext createFormattingContext() {
- IFormattingContext context= new CommentFormattingContext();
-
- Map preferences;
- IJavaScriptElement inputJavaElement= getInputJavaElement();
- IJavaScriptProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaScriptProject() : null;
- if (javaProject == null)
- preferences= new HashMap(JavaScriptCore.getOptions());
- else
- preferences= new HashMap(javaProject.getOptions(true));
-
- context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
-
- return context;
- }
- }
-
-
- private class ExitPolicy implements IExitPolicy {
-
- final char fExitCharacter;
- final char fEscapeCharacter;
- final Stack fStack;
- final int fSize;
-
- public ExitPolicy(char exitCharacter, char escapeCharacter, Stack stack) {
- fExitCharacter= exitCharacter;
- fEscapeCharacter= escapeCharacter;
- fStack= stack;
- fSize= fStack.size();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.wst.jsdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
- */
- public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
-
- if (fSize == fStack.size() && !isMasked(offset)) {
- if (event.character == fExitCharacter) {
- BracketLevel level= (BracketLevel) fStack.peek();
- if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
- return null;
- if (level.fSecondPosition.offset == offset && length == 0)
- // don't enter the character if if its the closing peer
- return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
- }
- // when entering an anonymous class between the parenthesis', we don't want
- // to jump after the closing parenthesis when return is pressed
- if (event.character == SWT.CR && offset > 0) {
- IDocument document= getSourceViewer().getDocument();
- try {
- if (document.getChar(offset - 1) == '{')
- return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
- } catch (BadLocationException e) {
- }
- }
- }
- return null;
- }
-
- private boolean isMasked(int offset) {
- IDocument document= getSourceViewer().getDocument();
- try {
- return fEscapeCharacter == document.getChar(offset - 1);
- } catch (BadLocationException e) {
- }
- return false;
- }
- }
-
- private static class BracketLevel {
- int fOffset;
- int fLength;
- LinkedModeUI fUI;
- Position fFirstPosition;
- Position fSecondPosition;
- }
-
- /**
- * Position updater that takes any changes at the borders of a position to not belong to the position.
- *
- *
- */
- private static class ExclusivePositionUpdater implements IPositionUpdater {
-
- /** The position category. */
- private final String fCategory;
-
- /**
- * Creates a new updater for the given <code>category</code>.
- *
- * @param category the new category.
- */
- public ExclusivePositionUpdater(String category) {
- fCategory= category;
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventNewLength= event.getText() == null ? 0 : event.getText().length();
- int deltaLength= eventNewLength - eventOldLength;
-
- try {
- Position[] positions= event.getDocument().getPositions(fCategory);
-
- for (int i= 0; i != positions.length; i++) {
-
- Position position= positions[i];
-
- if (position.isDeleted())
- continue;
-
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
-
- if (offset >= eventOffset + eventOldLength)
- // position comes
- // after change - shift
- position.setOffset(offset + deltaLength);
- else if (end <= eventOffset) {
- // position comes way before change -
- // leave alone
- } else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
- // event completely internal to the position - adjust length
- position.setLength(length + deltaLength);
- } else if (offset < eventOffset) {
- // event extends over end of position - adjust length
- int newEnd= eventOffset;
- position.setLength(newEnd - offset);
- } else if (end > eventOffset + eventOldLength) {
- // event extends from before position into it - adjust offset
- // and length
- // offset becomes end of event, length adjusted accordingly
- int newOffset= eventOffset + eventNewLength;
- position.setOffset(newOffset);
- position.setLength(end - newOffset);
- } else {
- // event consumes the position - delete it
- position.delete();
- }
- }
- } catch (BadPositionCategoryException e) {
- // ignore and return
- }
- }
-
- /**
- * Returns the position category.
- *
- * @return the position category
- */
- public String getCategory() {
- return fCategory;
- }
-
- }
-
- private class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
-
- private boolean fCloseBrackets= true;
- private boolean fCloseStrings= true;
- private boolean fCloseAngularBrackets= true;
- private final String CATEGORY= toString();
- private IPositionUpdater fUpdater= new ExclusivePositionUpdater(CATEGORY);
- private Stack fBracketLevelStack= new Stack();
-
- public void setCloseBracketsEnabled(boolean enabled) {
- fCloseBrackets= enabled;
- }
-
- public void setCloseStringsEnabled(boolean enabled) {
- fCloseStrings= enabled;
- }
-
- public void setCloseAngularBracketsEnabled(boolean enabled) {
- fCloseAngularBrackets= enabled;
- }
-
- private boolean isAngularIntroducer(String identifier) {
- return identifier.length() > 0
- && (Character.isUpperCase(identifier.charAt(0))
- || identifier.startsWith("final") //$NON-NLS-1$
- || identifier.startsWith("public") //$NON-NLS-1$
- || identifier.startsWith("public") //$NON-NLS-1$
- || identifier.startsWith("protected") //$NON-NLS-1$
- || identifier.startsWith("private")); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
-
- // early pruning to slow down normal typing as little as possible
- if (!event.doit || getInsertMode() != SMART_INSERT)
- return;
- switch (event.character) {
- case '(':
- case '<':
- case '[':
- case '\'':
- case '\"':
- break;
- default:
- return;
- }
-
- final ISourceViewer sourceViewer= getSourceViewer();
- IDocument document= sourceViewer.getDocument();
-
- final Point selection= sourceViewer.getSelectedRange();
- final int offset= selection.x;
- final int length= selection.y;
-
- try {
- IRegion startLine= document.getLineInformationOfOffset(offset);
- IRegion endLine= document.getLineInformationOfOffset(offset + length);
-
- JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
- int nextToken= scanner.nextToken(offset + length, endLine.getOffset() + endLine.getLength());
- String next= nextToken == Symbols.TokenEOF ? null : document.get(offset, scanner.getPosition() - offset).trim();
- int prevToken= scanner.previousToken(offset - 1, startLine.getOffset());
- int prevTokenOffset= scanner.getPosition() + 1;
- String previous= prevToken == Symbols.TokenEOF ? null : document.get(prevTokenOffset, offset - prevTokenOffset).trim();
-
- switch (event.character) {
- case '(':
- if (!fCloseBrackets
- || nextToken == Symbols.TokenLPAREN
- || nextToken == Symbols.TokenIDENT
- || next != null && next.length() > 1)
- return;
- break;
-
- case '<':
- if (!(fCloseAngularBrackets && fCloseBrackets)
- || nextToken == Symbols.TokenLESSTHAN
- || prevToken != Symbols.TokenLBRACE
- && prevToken != Symbols.TokenRBRACE
- && prevToken != Symbols.TokenSEMICOLON
- && prevToken != Symbols.TokenSYNCHRONIZED
- && prevToken != Symbols.TokenSTATIC
- && (prevToken != Symbols.TokenIDENT || !isAngularIntroducer(previous))
- && prevToken != Symbols.TokenEOF)
- return;
- break;
-
- case '[':
- if (!fCloseBrackets
- || nextToken == Symbols.TokenIDENT
- || next != null && next.length() > 1)
- return;
- break;
-
- case '\'':
- case '"':
- if (!fCloseStrings
- || nextToken == Symbols.TokenIDENT
- || prevToken == Symbols.TokenIDENT
- || next != null && next.length() > 1
- || previous != null && previous.length() > 1)
- return;
- break;
-
- default:
- return;
- }
-
- ITypedRegion partition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, true);
- if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()))
- return;
-
- if (!validateEditorInputState())
- return;
-
- final char character= event.character;
- final char closingCharacter= getPeerCharacter(character);
- final StringBuffer buffer= new StringBuffer();
- buffer.append(character);
- buffer.append(closingCharacter);
-
- document.replace(offset, length, buffer.toString());
-
-
- BracketLevel level= new BracketLevel();
- fBracketLevelStack.push(level);
-
- LinkedPositionGroup group= new LinkedPositionGroup();
- group.addPosition(new LinkedPosition(document, offset + 1, 0, LinkedPositionGroup.NO_STOP));
-
- LinkedModeModel model= new LinkedModeModel();
- model.addLinkingListener(this);
- model.addGroup(group);
- model.forceInstall();
-
- level.fOffset= offset;
- level.fLength= 2;
-
- // set up position tracking for our magic peers
- if (fBracketLevelStack.size() == 1) {
- document.addPositionCategory(CATEGORY);
- document.addPositionUpdater(fUpdater);
- }
- level.fFirstPosition= new Position(offset, 1);
- level.fSecondPosition= new Position(offset + 1, 1);
- document.addPosition(CATEGORY, level.fFirstPosition);
- document.addPosition(CATEGORY, level.fSecondPosition);
-
- level.fUI= new EditorLinkedModeUI(model, sourceViewer);
- level.fUI.setSimpleMode(true);
- level.fUI.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack));
- level.fUI.setExitPosition(sourceViewer, offset + 2, 0, Integer.MAX_VALUE);
- level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
- level.fUI.enter();
-
-
- IRegion newSelection= level.fUI.getSelectedRegion();
- sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
-
- event.doit= false;
-
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- } catch (BadPositionCategoryException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
- */
- public void left(LinkedModeModel environment, int flags) {
-
- final BracketLevel level= (BracketLevel) fBracketLevelStack.pop();
-
- if (flags != ILinkedModeListener.EXTERNAL_MODIFICATION)
- return;
-
- // remove brackets
- final ISourceViewer sourceViewer= getSourceViewer();
- final IDocument document= sourceViewer.getDocument();
- if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
- extension.registerPostNotificationReplace(null, new IDocumentExtension.IReplace() {
-
- public void perform(IDocument d, IDocumentListener owner) {
- if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0)
- && !level.fSecondPosition.isDeleted
- && level.fSecondPosition.offset == level.fFirstPosition.offset)
- {
- try {
- document.replace(level.fSecondPosition.offset,
- level.fSecondPosition.length,
- ""); //$NON-NLS-1$
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- if (fBracketLevelStack.size() == 0) {
- document.removePositionUpdater(fUpdater);
- try {
- document.removePositionCategory(CATEGORY);
- } catch (BadPositionCategoryException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
- });
- }
-
-
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
- */
- public void suspend(LinkedModeModel environment) {
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
- */
- public void resume(LinkedModeModel environment, int flags) {
- }
- }
-
- /**
- * Remembers data related to the current selection to be able to
- * restore it later.
- *
- *
- */
- private class RememberedSelection {
- /** The remembered selection start. */
- private RememberedOffset fStartOffset= new RememberedOffset();
- /** The remembered selection end. */
- private RememberedOffset fEndOffset= new RememberedOffset();
-
- /**
- * Remember current selection.
- */
- public void remember() {
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257
- * This method may be called inside an asynchronous call posted
- * to the UI thread, so protect against intermediate disposal
- * of the editor.
- */
- ISourceViewer viewer= getSourceViewer();
- if (viewer != null) {
- Point selection= viewer.getSelectedRange();
- int startOffset= selection.x;
- int endOffset= startOffset + selection.y;
-
- fStartOffset.setOffset(startOffset);
- fEndOffset.setOffset(endOffset);
- }
- }
-
- /**
- * Restore remembered selection.
- */
- public void restore() {
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257
- * This method may be called inside an asynchronous call posted
- * to the UI thread, so protect against intermediate disposal
- * of the editor.
- */
- if (getSourceViewer() == null)
- return;
-
- try {
-
- int startOffset, endOffset;
- int revealStartOffset, revealEndOffset;
- if (showsHighlightRangeOnly()) {
- IJavaScriptElement newStartElement= fStartOffset.getElement();
- startOffset= fStartOffset.getRememberedOffset(newStartElement);
- revealStartOffset= fStartOffset.getRevealOffset(newStartElement, startOffset);
- if (revealStartOffset == -1)
- startOffset= -1;
-
- IJavaScriptElement newEndElement= fEndOffset.getElement();
- endOffset= fEndOffset.getRememberedOffset(newEndElement);
- revealEndOffset= fEndOffset.getRevealOffset(newEndElement, endOffset);
- if (revealEndOffset == -1)
- endOffset= -1;
- } else {
- startOffset= fStartOffset.getOffset();
- revealStartOffset= startOffset;
- endOffset= fEndOffset.getOffset();
- revealEndOffset= endOffset;
- }
-
- if (startOffset == -1) {
- startOffset= endOffset; // fallback to caret offset
- revealStartOffset= revealEndOffset;
- }
-
- if (endOffset == -1) {
- endOffset= startOffset; // fallback to other offset
- revealEndOffset= revealStartOffset;
- }
-
- IJavaScriptElement element;
- if (endOffset == -1) {
- // fallback to element selection
- element= fEndOffset.getElement();
- if (element == null)
- element= fStartOffset.getElement();
- if (element != null)
- setSelection(element);
- return;
- }
-
- if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset) && isValidSelection(startOffset, endOffset - startOffset))
- selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset);
- } finally {
- fStartOffset.clear();
- fEndOffset.clear();
- }
- }
-
- private boolean isValidSelection(int offset, int length) {
- IDocumentProvider provider= getDocumentProvider();
- if (provider != null) {
- IDocument document= provider.getDocument(getEditorInput());
- if (document != null) {
- int end= offset + length;
- int documentLength= document.getLength();
- return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength && length >= 0;
- }
- }
- return false;
- }
-
- }
-
- /**
- * Remembers additional data for a given
- * offset to be able restore it later.
- *
- *
- */
- private class RememberedOffset {
- /** Remembered line for the given offset */
- private int fLine;
- /** Remembered column for the given offset*/
- private int fColumn;
- /** Remembered Java element for the given offset*/
- private IJavaScriptElement fElement;
- /** Remembered Java element line for the given offset*/
- private int fElementLine;
-
- /**
- * Store visual properties of the given offset.
- *
- * @param offset Offset in the document
- */
- public void setOffset(int offset) {
- try {
- IDocument document= getSourceViewer().getDocument();
- fLine= document.getLineOfOffset(offset);
- fColumn= offset - document.getLineOffset(fLine);
- fElement= getElementAt(offset, true);
- fElementLine= getElementLine(document, fElement);
- } catch (BadLocationException e) {
- // should not happen
- JavaScriptPlugin.log(e);
- clear();
- } catch (JavaScriptModelException e) {
- // should not happen
- JavaScriptPlugin.log(e.getStatus());
- clear();
- }
- }
-
- /**
- * Computes the element line of a java element (the start of the element, or the line with
- * the element's name range).
- *
- * @param document the displayed document for line information
- * @param element the java element, may be <code>null</code>
- * @return the element's start line, or -1
- * @throws BadLocationException
- * @throws JavaScriptModelException
- *
- */
- private int getElementLine(IDocument document, IJavaScriptElement element) throws BadLocationException, JavaScriptModelException {
- if (element instanceof IMember) {
- ISourceRange range= ((IMember) element).getNameRange();
- if (range != null)
- return document.getLineOfOffset(range.getOffset());
- }
- int elementOffset= getOffset(element);
- if (elementOffset != -1)
- return document.getLineOfOffset(elementOffset);
- return -1;
- }
-
- /**
- * Return offset recomputed from stored visual properties.
- *
- * @return Offset in the document
- */
- public int getOffset() {
- IJavaScriptElement newElement= getElement();
-
- int offset= getRememberedOffset(newElement);
-
- if (offset == -1 || newElement != null && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1)))
- return -1;
-
- return offset;
- }
-
- /**
- * Return offset recomputed from stored visual properties.
- *
- * @param newElement Enclosing element
- * @return Offset in the document
- */
- public int getRememberedOffset(IJavaScriptElement newElement) {
- try {
- IDocument document= getSourceViewer().getDocument();
- int newElementLine= getElementLine(document, newElement);
- int newLine= fLine;
- if (newElementLine != -1 && fElementLine != -1)
- newLine += newElementLine - fElementLine;
-
- if (newLine < 0 || newLine >= document.getNumberOfLines())
- return -1;
- int maxColumn= document.getLineLength(newLine);
- String lineDelimiter= document.getLineDelimiter(newLine);
- if (lineDelimiter != null)
- maxColumn= maxColumn - lineDelimiter.length();
- int offset;
- if (fColumn > maxColumn)
- offset= document.getLineOffset(newLine) + maxColumn;
- else
- offset= document.getLineOffset(newLine) + fColumn;
-
- return offset;
- } catch (BadLocationException e) {
- // should not happen
- JavaScriptPlugin.log(e);
- return -1;
- } catch (JavaScriptModelException e) {
- // should not happen
- JavaScriptPlugin.log(e.getStatus());
- return -1;
- }
- }
-
- /**
- * Returns the offset used to reveal the given element based on the given selection offset.
- * @param element the element
- * @param offset the selection offset
- * @return the offset to reveal the given element based on the given selection offset
- */
- public int getRevealOffset(IJavaScriptElement element, int offset) {
- if (element == null || offset == -1)
- return -1;
-
- if (containsOffset(element, offset)) {
- if (offset > 0) {
- IJavaScriptElement alternateElement= getElementAt(offset, false);
- if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier()))
- return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
- }
- return offset;
- } else if (offset > 0 && containsOffset(element, offset - 1))
- return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
-
- return -1;
- }
-
- /**
- * Return Java element recomputed from stored visual properties.
- *
- * @return Java element
- */
- public IJavaScriptElement getElement() {
- if (fElement == null)
- return null;
-
- return findElement(fElement);
- }
-
- /**
- * Clears the stored position
- */
- public void clear() {
- fLine= -1;
- fColumn= -1;
- fElement= null;
- fElementLine= -1;
- }
-
- /**
- * Does the given Java element contain the given offset?
- * @param element Java element
- * @param offset Offset
- * @return <code>true</code> iff the Java element contains the offset
- */
- private boolean containsOffset(IJavaScriptElement element, int offset) {
- int elementOffset= getOffset(element);
- int elementLength= getLength(element);
- return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) : false;
- }
- /**
- * Returns the offset of the given Java element.
- *
- * @param element Java element
- * @return Offset of the given Java element
- */
- private int getOffset(IJavaScriptElement element) {
- if (element instanceof ISourceReference) {
- ISourceReference sr= (ISourceReference) element;
- try {
- ISourceRange srcRange= sr.getSourceRange();
- if (srcRange != null)
- return srcRange.getOffset();
- } catch (JavaScriptModelException e) {
- }
- }
- return -1;
- }
-
- /**
- * Returns the length of the given Java element.
- *
- * @param element Java element
- * @return Length of the given Java element
- */
- private int getLength(IJavaScriptElement element) {
- if (element instanceof ISourceReference) {
- ISourceReference sr= (ISourceReference) element;
- try {
- ISourceRange srcRange= sr.getSourceRange();
- if (srcRange != null)
- return srcRange.getLength();
- } catch (JavaScriptModelException e) {
- }
- }
- return -1;
- }
-
- /**
- * Returns the updated java element for the old java element.
- *
- * @param element Old Java element
- * @return Updated Java element
- */
- private IJavaScriptElement findElement(IJavaScriptElement element) {
-
- if (element == null)
- return null;
-
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- IJavaScriptUnit unit= manager.getWorkingCopy(getEditorInput());
-
- if (unit != null) {
- try {
- JavaModelUtil.reconcile(unit);
- IJavaScriptElement[] findings= unit.findElements(element);
- if (findings != null && findings.length > 0)
- return findings[0];
-
- } catch (JavaScriptModelException x) {
- JavaScriptPlugin.log(x.getStatus());
- // nothing found, be tolerant and go on
- }
- }
-
- return null;
- }
-
- }
-
- /** Preference key for code formatter tab size */
- private final static String CODE_FORMATTER_TAB_SIZE= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
- /** Preference key for inserting spaces rather than tabs */
- private final static String SPACES_FOR_TABS= DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR;
- /** Preference key for automatically closing strings */
- private final static String CLOSE_STRINGS= PreferenceConstants.EDITOR_CLOSE_STRINGS;
- /** Preference key for automatically closing brackets and parenthesis */
- private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS;
-
-
- /** The editor's save policy */
- protected ISavePolicy fSavePolicy;
- /** Listener to annotation model changes that updates the error tick in the tab image */
- private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
- /**
- * The remembered selection.
- *
- */
- private RememberedSelection fRememberedSelection= new RememberedSelection();
- /** The bracket inserter. */
- private BracketInserter fBracketInserter= new BracketInserter();
-
- /** The standard action groups added to the menu */
- private GenerateActionGroup fGenerateActionGroup;
- private CompositeActionGroup fContextMenuGroup;
-
- private CorrectionCommandInstaller fCorrectionCommands;
-
- /**
- * Reconciling listeners.
- *
- */
- private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
-
- /**
- * Mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898
- * for a description of the problem.
- * <p>
- * XXX remove once the underlying problem (https://bugs.eclipse.org/bugs/show_bug.cgi?id=66176) is solved.
- * </p>
- */
- private final Object fReconcilerLock= new Object();
-
-
-
-
-
- /**
- * Creates a new compilation unit editor.
- */
- public CompilationUnitEditor() {
- super();
- setDocumentProvider(JavaScriptPlugin.getDefault().getCompilationUnitDocumentProvider());
- setEditorContextMenuId("#JavaScriptEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#JavaScriptRulerContext"); //$NON-NLS-1$
- setOutlinerContextMenuId("#JavaScriptOutlinerContext"); //$NON-NLS-1$
- // don't set help contextId, we install our own help context
- fSavePolicy= null;
-
- fJavaEditorErrorTickUpdater= new JavaEditorErrorTickUpdater(this);
- fCorrectionCommands= null;
- }
-
- /*
- * @see AbstractTextEditor#createActions()
- */
- protected void createActions() {
-
- super.createActions();
-
- IAction action= new ContentAssistAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistProposal.", this); //$NON-NLS-1$
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", action); //$NON-NLS-1$
- markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
- setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
- markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.COMMENT);
- setAction("Comment", action); //$NON-NLS-1$
- markAsStateDependentAction("Comment", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.UNCOMMENT);
- setAction("Uncomment", action); //$NON-NLS-1$
- markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
-
- action= new ToggleCommentAction(JavaEditorMessages.getBundleForConstructedKeys(), "ToggleComment.", this); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
- setAction("ToggleComment", action); //$NON-NLS-1$
- markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
- configureToggleCommentAction();
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT);
- setAction("Format", action); //$NON-NLS-1$
- markAsStateDependentAction("Format", true); //$NON-NLS-1$
- markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
-
- action= new AddBlockCommentAction(JavaEditorMessages.getBundleForConstructedKeys(), "AddBlockComment.", this); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
- setAction("AddBlockComment", action); //$NON-NLS-1$
- markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
- markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
-
- action= new RemoveBlockCommentAction(JavaEditorMessages.getBundleForConstructedKeys(), "RemoveBlockComment.", this); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
- setAction("RemoveBlockComment", action); //$NON-NLS-1$
- markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
- markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
-
- action= new IndentAction(JavaEditorMessages.getBundleForConstructedKeys(), "Indent.", this, false); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.INDENT);
- setAction("Indent", action); //$NON-NLS-1$
- markAsStateDependentAction("Indent", true); //$NON-NLS-1$
- markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
-
- action= new IndentAction(JavaEditorMessages.getBundleForConstructedKeys(), "Indent.", this, true); //$NON-NLS-1$
- setAction("IndentOnTab", action); //$NON-NLS-1$
- markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
- markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
-
- // override the text editor actions with indenting move line actions
- JavaMoveLinesAction[] moveLinesActions= JavaMoveLinesAction.createMoveCopyActionSet(JavaEditorMessages.getBundleForConstructedKeys(), this);
- ResourceAction rAction= moveLinesActions[0];
- rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
- rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
- setAction(ITextEditorActionConstants.MOVE_LINE_UP, rAction);
-
- rAction= moveLinesActions[1];
- rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
- rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
- setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, rAction);
-
- rAction= moveLinesActions[2];
- rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
- rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
- setAction(ITextEditorActionConstants.COPY_LINE_UP, rAction);
-
- rAction= moveLinesActions[3];
- rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
- rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
- setAction(ITextEditorActionConstants.COPY_LINE_DOWN, rAction);
-
- if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
- // don't replace Shift Right - have to make sure their enablement is mutually exclusive
-// removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
- setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
- }
-
- fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
- ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT, false);
- ActionGroup surroundWith= new SurroundWithActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
-
- fActionGroups.addGroup(surroundWith);
- fActionGroups.addGroup(rg);
- fActionGroups.addGroup(fGenerateActionGroup);
-
- // We have to keep the context menu group separate to have better control over positioning
- fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {
- fGenerateActionGroup,
- rg,
- surroundWith,
- new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
-
- fCorrectionCommands= new CorrectionCommandInstaller(); // allow shortcuts for quick fix/assist
- fCorrectionCommands.registerCommands(this);
- }
-
- /*
- * @see JavaEditor#getElementAt(int)
- */
- protected IJavaScriptElement getElementAt(int offset) {
- return getElementAt(offset, true);
- }
-
- /**
- * Returns the most narrow element including the given offset. If <code>reconcile</code>
- * is <code>true</code> the editor's input element is reconciled in advance. If it is
- * <code>false</code> this method only returns a result if the editor's input element
- * does not need to be reconciled.
- *
- * @param offset the offset included by the retrieved element
- * @param reconcile <code>true</code> if working copy should be reconciled
- * @return the most narrow element which includes the given offset
- */
- protected IJavaScriptElement getElementAt(int offset, boolean reconcile) {
- IJavaScriptUnit unit= (IJavaScriptUnit)getInputJavaElement();
-
- if (unit != null) {
- try {
- if (reconcile) {
- JavaModelUtil.reconcile(unit);
- return unit.getElementAt(offset);
- } else if (unit.isConsistent())
- return unit.getElementAt(offset);
-
- } catch (JavaScriptModelException x) {
- if (!x.isDoesNotExist())
- JavaScriptPlugin.log(x.getStatus());
- // nothing found, be tolerant and go on
- }
- }
-
- return null;
- }
-
- /*
- * @see JavaEditor#getCorrespondingElement(IJavaScriptElement)
- */
- protected IJavaScriptElement getCorrespondingElement(IJavaScriptElement element) {
- // XXX: With new working copy story: original == working copy.
- // Note that the previous code could result in a reconcile as side effect. Should check if that
- // is still required.
- return element;
- }
-
- /*
- * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
- */
- public void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
-
- ActionContext context= new ActionContext(getSelectionProvider().getSelection());
- fContextMenuGroup.setContext(context);
- fContextMenuGroup.fillContextMenu(menu);
- fContextMenuGroup.setContext(null);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
- IDocumentProvider p= getDocumentProvider();
- if (p instanceof ICompilationUnitDocumentProvider) {
- ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p;
- cp.setSavePolicy(fSavePolicy);
- }
- try {
- super.performSave(overwrite, progressMonitor);
- } finally {
- if (p instanceof ICompilationUnitDocumentProvider) {
- ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p;
- cp.setSavePolicy(null);
- }
- }
- }
-
- /*
- * @see AbstractTextEditor#doSave(IProgressMonitor)
- */
- public void doSave(IProgressMonitor progressMonitor) {
-
- IDocumentProvider p= getDocumentProvider();
- if (p == null) {
- // editor has been closed
- return;
- }
-
- if (p.isDeleted(getEditorInput())) {
-
- if (isSaveAsAllowed()) {
-
- /*
- * 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.
- */
- performSaveAs(progressMonitor);
-
- } else {
-
- /*
- * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
- * Missing resources.
- */
- Shell shell= getSite().getShell();
- MessageDialog.openError(shell, JavaEditorMessages.CompilationUnitEditor_error_saving_title1, JavaEditorMessages.CompilationUnitEditor_error_saving_message1);
- }
-
- } else {
-
- setStatusLineErrorMessage(null);
-
- updateState(getEditorInput());
- validateState(getEditorInput());
-
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- IJavaScriptUnit unit= manager.getWorkingCopy(getEditorInput());
-
- if (unit != null) {
- synchronized (unit) {
- performSave(false, progressMonitor);
- }
- } else
- performSave(false, progressMonitor);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#openSaveErrorDialog(java.lang.String, java.lang.String, org.eclipse.core.runtime.CoreException)
- *
- */
- protected void openSaveErrorDialog(String title, String message, CoreException exception) {
- IStatus status= exception.getStatus();
- if (JavaScriptUI.ID_PLUGIN.equals(status.getPlugin()) && status.getCode() == IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION) {
- int mask= IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR;
- ErrorDialog dialog = new ErrorDialog(getSite().getShell(), title, message, status, mask) {
- protected Control createDialogArea(Composite parent) {
- parent= (Composite)super.createDialogArea(parent);
- Link link= new Link(parent, SWT.NONE);
- link.setText(JavaEditorMessages.CompilationUnitEditor_error_saving_saveParticipant);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.wst.jsdt.ui.preferences.SaveParticipantPreferencePage", null, null).open(); //$NON-NLS-1$
- }
- });
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- link.setLayoutData(gridData);
- return parent;
- }
- };
- dialog.open();
- } else
- super.openSaveErrorDialog(title, message, exception);
- }
-
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /*
- * @see AbstractTextEditor#doSetInput(IEditorInput)
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- super.doSetInput(input);
- configureToggleCommentAction();
- if (fJavaEditorErrorTickUpdater != null)
- fJavaEditorErrorTickUpdater.updateEditorImage(getInputJavaElement());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
- *
- */
- protected void installOverrideIndicator(boolean provideAST) {
- super.installOverrideIndicator(provideAST);
-
- if (fOverrideIndicatorManager == null)
- return;
-
- addReconcileListener(fOverrideIndicatorManager);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
- *
- */
- protected void uninstallOverrideIndicator() {
- if (fOverrideIndicatorManager != null)
- removeReconcileListener(fOverrideIndicatorManager);
- super.uninstallOverrideIndicator();
- }
-
- /**
- * Configures the toggle comment action
- *
- *
- */
- private void configureToggleCommentAction() {
- IAction action= getAction("ToggleComment"); //$NON-NLS-1$
- if (action instanceof ToggleCommentAction) {
- ISourceViewer sourceViewer= getSourceViewer();
- SourceViewerConfiguration configuration= getSourceViewerConfiguration();
- ((ToggleCommentAction)action).configure(sourceViewer, configuration);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#installTabsToSpacesConverter()
- *
- */
- protected void installTabsToSpacesConverter() {
- ISourceViewer sourceViewer= getSourceViewer();
- SourceViewerConfiguration config= getSourceViewerConfiguration();
- if (config != null && sourceViewer instanceof ITextViewerExtension7) {
- int tabWidth= config.getTabWidth(sourceViewer);
- TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
- tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
- IDocumentProvider provider= getDocumentProvider();
- if (provider instanceof ICompilationUnitDocumentProvider) {
- ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
- tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
- } else
- tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
- ((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
- updateIndentPrefixes();
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isTabsToSpacesConversionEnabled()
- *
- */
- protected boolean isTabsToSpacesConversionEnabled() {
- IJavaScriptElement element= getInputJavaElement();
- IJavaScriptProject project= element == null ? null : element.getJavaScriptProject();
- String option;
- if (project == null)
- option= JavaScriptCore.getOption(SPACES_FOR_TABS);
- else
- option= project.getOption(SPACES_FOR_TABS, true);
- return JavaScriptCore.SPACE.equals(option);
- }
-
- public void dispose() {
-
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer instanceof ITextViewerExtension)
- ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
-
- if (fJavaEditorErrorTickUpdater != null) {
- fJavaEditorErrorTickUpdater.dispose();
- fJavaEditorErrorTickUpdater= null;
- }
-
- if (fCorrectionCommands != null) {
- fCorrectionCommands.deregisterCommands();
- fCorrectionCommands= null;
- }
-
- super.dispose();
- }
-
- /*
- * @see AbstractTextEditor#createPartControl(Composite)
- */
- public void createPartControl(Composite parent) {
-
- super.createPartControl(parent);
-
- IPreferenceStore preferenceStore= getPreferenceStore();
- boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
- boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
- boolean closeAngularBrackets= JavaScriptCore.VERSION_1_5.compareTo(preferenceStore.getString(JavaScriptCore.COMPILER_SOURCE)) <= 0;
-
- fBracketInserter.setCloseBracketsEnabled(closeBrackets);
- fBracketInserter.setCloseStringsEnabled(closeStrings);
- fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
-
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer instanceof ITextViewerExtension)
- ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
-
- if (isMarkingOccurrences())
- installOccurrencesFinder(false);
- }
-
- private static char getEscapeCharacter(char character) {
- switch (character) {
- case '"':
- case '\'':
- return '\\';
- default:
- return 0;
- }
- }
-
- private static char getPeerCharacter(char character) {
- switch (character) {
- case '(':
- return ')';
-
- case ')':
- return '(';
-
- case '<':
- return '>';
-
- case '>':
- return '<';
-
- case '[':
- return ']';
-
- case ']':
- return '[';
-
- case '"':
- return character;
-
- case '\'':
- return character;
-
- default:
- throw new IllegalArgumentException();
- }
- }
-
- /*
- * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
- */
- protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
-
- try {
-
- AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
- if (asv != null) {
-
- String p= event.getProperty();
-
- if (CLOSE_BRACKETS.equals(p)) {
- fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p));
- return;
- }
-
- if (CLOSE_STRINGS.equals(p)) {
- fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p));
- return;
- }
-
- if (JavaScriptCore.COMPILER_SOURCE.equals(p)) {
- boolean closeAngularBrackets= JavaScriptCore.VERSION_1_5.compareTo(getPreferenceStore().getString(p)) <= 0;
- fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
- }
-
- if (SPACES_FOR_TABS.equals(p)) {
- if (isTabsToSpacesConversionEnabled())
- installTabsToSpacesConverter();
- else
- uninstallTabsToSpacesConverter();
- return;
- }
-
- if (PreferenceConstants.EDITOR_SMART_TAB.equals(p)) {
- if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
- setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
- } else {
- removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
- }
- }
-
- IContentAssistant c= asv.getContentAssistant();
- if (c instanceof ContentAssistant)
- ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
-
- if (CODE_FORMATTER_TAB_SIZE.equals(p) && isTabsToSpacesConversionEnabled()) {
- uninstallTabsToSpacesConverter();
- installTabsToSpacesConverter();
- }
- }
-
- } finally {
- super.handlePreferenceStoreChanged(event);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
- */
- protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
- return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
- *
- */
- public void aboutToBeReconciled() {
-
- // Notify AST provider
- JavaScriptPlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
-
- // Notify listeners
- Object[] listeners = fReconcilingListeners.getListeners();
- for (int i = 0, length= listeners.length; i < length; ++i)
- ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(JavaScriptUnit, boolean, IProgressMonitor)
- *
- */
- public void reconciled(JavaScriptUnit ast, boolean forced, IProgressMonitor progressMonitor) {
-
- // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=58245
- JavaScriptPlugin javaPlugin= JavaScriptPlugin.getDefault();
- if (javaPlugin == null)
- return;
-
- // Always notify AST provider
- javaPlugin.getASTProvider().reconciled(ast, getInputJavaElement(), progressMonitor);
-
- // Notify listeners
- Object[] listeners = fReconcilingListeners.getListeners();
- for (int i = 0, length= listeners.length; i < length; ++i)
- ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor);
-
- // Update Java Outline page selection
- if (!forced && !progressMonitor.isCanceled()) {
- Shell shell= getSite().getShell();
- if (shell != null && !shell.isDisposed()) {
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- selectionChanged();
- }
- });
- }
- }
- }
-
- /**
- * Tells whether this is the active editor in the active page.
- *
- * @return <code>true</code> if this is the active editor in the active page
- * @see IWorkbenchPage#getActiveEditor
- */
- protected final boolean isActiveEditor() {
- IWorkbenchWindow window= getSite().getWorkbenchWindow();
- IWorkbenchPage page= window.getActivePage();
- if (page == null)
- return false;
- IEditorPart activeEditor= page.getActiveEditor();
- return activeEditor != null && activeEditor.equals(this);
- }
-
- /**
- * Adds the given listener.
- * Has no effect if an identical listener was not already registered.
- *
- * @param listener The reconcile listener to be added
- *
- */
- final void addReconcileListener(IJavaReconcilingListener listener) {
- synchronized (fReconcilingListeners) {
- fReconcilingListeners.add(listener);
- }
- }
-
- /**
- * Removes the given listener.
- * Has no effect if an identical listener was not already registered.
- *
- * @param listener the reconcile listener to be removed
- *
- */
- final void removeReconcileListener(IJavaReconcilingListener listener) {
- synchronized (fReconcilingListeners) {
- fReconcilingListeners.remove(listener);
- }
- }
-
- protected void updateStateDependentActions() {
- super.updateStateDependentActions();
- fGenerateActionGroup.editorStateChanged();
- }
-
- /*
- * @see AbstractTextEditor#rememberSelection()
- */
- protected void rememberSelection() {
- fRememberedSelection.remember();
- }
-
- /*
- * @see AbstractTextEditor#restoreSelection()
- */
- protected void restoreSelection() {
- fRememberedSelection.restore();
- }
-
- /*
- * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
- */
- protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
-
- String oldExtension= ""; //$NON-NLS-1$
- if (originalElement instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) originalElement).getFile();
- if (file != null) {
- String ext= file.getFileExtension();
- if (ext != null)
- oldExtension= ext;
- }
- }
-
- String newExtension= ""; //$NON-NLS-1$
- if (movedElement instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) movedElement).getFile();
- if (file != null)
- newExtension= file.getFileExtension();
- }
-
- return oldExtension.equals(newExtension);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class required) {
- if (SmartBackspaceManager.class.equals(required)) {
- if (getSourceViewer() instanceof JavaSourceViewer) {
- return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager();
- }
- }
-
- return super.getAdapter(required);
- }
-
- /**
- * Returns the mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898
- * for a description of the problem.
- * <p>
- * XXX remove once the underlying problem (https://bugs.eclipse.org/bugs/show_bug.cgi?id=66176) is solved.
- * </p>
- * @return the lock reconcilers may use to synchronize on
- */
- public Object getReconcilerLock() {
- return fReconcilerLock;
- }
-
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor#createNavigationActions()
- */
- protected void createNavigationActions() {
- super.createNavigationActions();
-
- final StyledText textWidget= getSourceViewer().getTextWidget();
-
- IAction action= new DeletePreviousSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD);
- setAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.BS, SWT.NULL);
- markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, true);
-
- action= new DeleteNextSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD);
- setAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.DEL, SWT.NULL);
- markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, true);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java
deleted file mode 100644
index 3ea15a9a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants;
-
-public class CompilationUnitEditorActionContributor extends BasicCompilationUnitEditorActionContributor {
-
- private RetargetTextEditorAction fToggleInsertModeAction;
-
- public CompilationUnitEditorActionContributor() {
- super();
-
- ResourceBundle b= JavaEditorMessages.getBundleForConstructedKeys();
-
- fToggleInsertModeAction= new RetargetTextEditorAction(b, "CompilationUnitEditorActionContributor.ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
- fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
- }
-
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.BasicEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
- super.contributeToMenu(menu);
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
- }
- }
-
- /*
- * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
- super.setActiveEditor(part);
-
- ITextEditor textEditor= null;
- if (part instanceof ITextEditor)
- textEditor= (ITextEditor) part;
-
- // Source menu.
- IActionBars bars= getActionBars();
- bars.setGlobalActionHandler(JdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.FORMAT_ELEMENT, getAction(textEditor, "QuickFormat")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(JdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$
-
- IAction action= getAction(textEditor, ActionFactory.REFRESH.getId());
- bars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), action);
-
- fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompoundEditExitStrategy.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompoundEditExitStrategy.java
deleted file mode 100644
index 583ac955..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompoundEditExitStrategy.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IExecutionListener;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Exit strategy for commands that want to fold repeated execution into one compound edit. See
- * {@link org.eclipse.jface.text.IRewriteTarget#endCompoundChange() IRewriteTarget.endCompoundChange}.
- * As long as a strategy is installed on an {@link ITextViewer}, it will detect the end of a
- * compound operation when any of the following conditions becomes true:
- * <ul>
- * <li>the viewer's text widget loses the keyboard focus</li>
- * <li>the mouse is clicked or double clicked inside the viewer's widget</li>
- * <li>a command other than the ones specified is executed</li>
- * <li>the viewer receives any key events that are not modifier combinations</li>
- * </ul>
- * <p>
- * If the end of a compound edit is detected, any registered {@link ICompoundEditListener}s are
- * notified and the strategy is disarmed (spring-loaded).
- * </p>
- *
- *
- */
-public final class CompoundEditExitStrategy {
- /**
- * Listens for events that may trigger the end of a compound edit.
- */
- private final class EventListener implements MouseListener, FocusListener, VerifyKeyListener, IExecutionListener {
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- // mouse actions end the compound change
- fireEndCompoundEdit();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- // mouse actions end the compound change
- fireEndCompoundEdit();
- }
-
- public void mouseUp(MouseEvent e) {}
-
- public void focusGained(FocusEvent e) {}
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- // losing focus ends the change
- fireEndCompoundEdit();
- }
-
- public void notHandled(String commandId, NotHandledException exception) {}
-
- public void postExecuteFailure(String commandId, ExecutionException exception) {}
-
- public void postExecuteSuccess(String commandId, Object returnValue) {}
-
- /*
- * @see org.eclipse.core.commands.IExecutionListener#preExecute(java.lang.String, org.eclipse.core.commands.ExecutionEvent)
- */
- public void preExecute(String commandId, ExecutionEvent event) {
- // any command other than the known ones end the compound change
- for (int i= 0; i < fCommandIds.length; i++) {
- if (commandId.equals(fCommandIds[i]))
- return;
- }
- fireEndCompoundEdit();
- }
-
- /*
- * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
- // any key press that is not a modifier combo ends the compound change
- final int maskWithoutShift= SWT.MODIFIER_MASK & ~SWT.SHIFT;
- if ((event.keyCode & SWT.MODIFIER_MASK) == 0 && (event.stateMask & maskWithoutShift) == 0)
- fireEndCompoundEdit();
- }
-
- }
-
- private final String[] fCommandIds;
- private final EventListener fEventListener= new EventListener();
- private final ListenerList fListenerList= new ListenerList(ListenerList.IDENTITY);
-
- private ITextViewer fViewer;
- private StyledText fWidgetEventSource;
-
- /**
- * Creates a new strategy, equivalent to calling
- * {@linkplain #CompoundEditExitStrategy(String[]) CompoundEditExitStrategy(new String[] &#x7b; commandId &#x7d;)}.
- *
- * @param commandId the command id of the repeatable command
- */
- public CompoundEditExitStrategy(String commandId) {
- if (commandId == null)
- throw new NullPointerException("commandId"); //$NON-NLS-1$
- fCommandIds= new String[] {commandId};
- }
-
- /**
- * Creates a new strategy, ending upon execution of any command other than the ones
- * specified.
- *
- * @param commandIds the ids of the repeatable commands
- */
- public CompoundEditExitStrategy(String[] commandIds) {
- for (int i= 0; i < commandIds.length; i++) {
- if (commandIds[i] == null)
- throw new NullPointerException("commandIds[" + i + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- fCommandIds= new String[commandIds.length];
- System.arraycopy(commandIds, 0, fCommandIds, 0, commandIds.length);
- }
-
- /**
- * Installs the receiver on <code>viewer</code> and arms it. After this call returns, any
- * registered listeners will be notified if a compound edit ends.
- *
- * @param viewer the viewer to install on
- */
- public void arm(ITextViewer viewer) {
- disarm();
- if (viewer == null)
- throw new NullPointerException("editor"); //$NON-NLS-1$
- fViewer= viewer;
- addListeners(fViewer);
- }
-
- /**
- * Disarms the receiver. After this call returns, any registered listeners will be not be
- * notified any more until <code>install</code> is called again. Note that the listeners are
- * not removed.
- * <p>
- * Note that the receiver is automatically disarmed when the end of a compound edit has
- * been detected and before the listeners are notified.
- * </p>
- */
- public void disarm() {
- if (isInstalled()) {
- removeListeners(fViewer);
- fViewer= null;
- }
- }
-
- private void addListeners(ITextViewer viewer) {
- fWidgetEventSource= viewer.getTextWidget();
- if (fWidgetEventSource != null) {
- fWidgetEventSource.addVerifyKeyListener(fEventListener);
- fWidgetEventSource.addMouseListener(fEventListener);
- fWidgetEventSource.addFocusListener(fEventListener);
- }
-
- ICommandService commandService= (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- if (commandService != null)
- commandService.addExecutionListener(fEventListener);
- }
-
- private void removeListeners(ITextViewer editor) {
- ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- if (commandService != null)
- commandService.removeExecutionListener(fEventListener);
-
- if (fWidgetEventSource != null) {
- fWidgetEventSource.removeFocusListener(fEventListener);
- fWidgetEventSource.removeMouseListener(fEventListener);
- fWidgetEventSource.removeVerifyKeyListener(fEventListener);
- fWidgetEventSource= null;
- }
- }
-
- private boolean isInstalled() {
- return fViewer != null;
- }
-
- private void fireEndCompoundEdit() {
- disarm();
- Object[] listeners= fListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ICompoundEditListener listener= (ICompoundEditListener) listeners[i];
- try {
- listener.endCompoundEdit();
- } catch (Exception e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /**
- * Adds a compound edit listener. Multiple registration is possible. Note that the receiver is
- * automatically disarmed before the listeners are notified.
- *
- * @param listener the new listener
- */
- public void addCompoundListener(ICompoundEditListener listener) {
- fListenerList.add(listener);
- }
-
- /**
- * Removes a compound edit listener. If <code>listener</code> is registered multiple times, an
- * arbitrary instance is removed. If <code>listener</code> is not currently registered,
- * nothing happens.
- *
- * @param listener the listener to be removed.
- */
- public void removeCompoundListener(ICompoundEditListener listener) {
- fListenerList.remove(listener);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ConstructedJavaEditorMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ConstructedJavaEditorMessages.properties
deleted file mode 100644
index 0c4b8a44..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ConstructedJavaEditorMessages.properties
+++ /dev/null
@@ -1,218 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-CompilationUnitEditorActionContributor.ToggleInsertMode.label=Sma&rt Insert Mode
-CompilationUnitEditorActionContributor.ToggleInsertMode.tooltip=Toggle Smart Insert Mode
-CompilationUnitEditorActionContributor.ToggleInsertMode.image=
-CompilationUnitEditorActionContributor.ToggleInsertMode.description= Toggles smart insert mode
-
-JavaOutlinePage.ContextMenu.refactoring.label=&Refactor
-JavaOutlinePage.HideFields.description.checked=Shows Vars
-JavaOutlinePage.HideFields.description.unchecked=Hides Vars
-JavaOutlinePage.HideFields.label=Hide Vars
-JavaOutlinePage.HideFields.tooltip.checked=Show Vars
-JavaOutlinePage.HideFields.tooltip.unchecked=Hide Vars
-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
-
-OpenHierarchy.label=Quick Type &Hierarchy
-OpenHierarchy.dialog.message=&Select the type to open:
-OpenHierarchy.dialog.title=Open Type Hierarchy
-OpenHierarchy.tooltip=Show the Quick Type Hierarchy of the Selected Element
-OpenHierarchy.description=Show the quick type hierarchy of the selected element
-
-OpenOnSelection.label=&Open on Selection
-OpenOnSelection.description=Open an editor on the selected element
-OpenOnSelection.dialog.message=&Select or enter the element to open:
-OpenOnSelection.dialog.title=Open On Selection
-OpenOnSelection.tooltip=Open an Editor on the Selected Element
-
-TogglePresentation.label=Show Source of Selected Element Only
-TogglePresentation.tooltip=Show Source of Selected Element Only
-
-ToggleMarkOccurrencesAction.label= Toggle Mark Occurrences
-ToggleMarkOccurrencesAction.tooltip= Toggle Mark Occurrences
-
-ToggleTextHover.label=Show Text Hover
-ToggleTextHover.tooltip=Show Text Hover
-
-ContentAssistProposal.label=&Default
-ContentAssistProposal.tooltip=Default Content Assist
-ContentAssistProposal.description=Default Content Assist
-
-ContentAssistContextInformation.label=Parameter &Hints
-ContentAssistContextInformation.tooltip=Show Parameter Hints
-ContentAssistContextInformation.description=Show Function Parameter Hints
-
-CorrectionAssistProposal.label=&Quick Fix
-CorrectionAssistProposal.tooltip=Quick Fix
-CorrectionAssistProposal.description=Quick Fix
-
-ShowOutline.label= Quick Out&line
-ShowOutline.tooltip= Shows the Quick Outline of Editor Input
-ShowOutline.description= Shows the quick outline for the editor input
-
-OpenStructure.label= Open Stru&cture
-OpenStructure.tooltip= Opens Structure of Selected Element
-OpenStructure.description= Opens the structure of the selected element
-
-OpenExternalJavadoc.label=Open External Jsdoc
-OpenExternalJavadoc.tooltip=Opens Jsdoc in an External Browser for the Element at the Cursor Position
-OpenExternalJavadoc.description=Opens Jsdoc in an external browser for the element at the cursor position
-
-Comment.label=Co&mment
-Comment.tooltip=Comment the Selected Lines
-Comment.description=Turn the selected lines into JavaScript comments
-
-Uncomment.label=&Uncomment
-Uncomment.tooltip=Uncomment the Selected JavaScript Comment Lines
-Uncomment.description=Uncomment the selected JavaScript comment lines
-
-ToggleComment.label=Togg&le Comment
-ToggleComment.tooltip=Toggle Comment For the Selected Lines
-ToggleComment.description=Toggle comment for the selected lines
-
-AddBlockComment.label=Add &Block Comment
-AddBlockComment.tooltip=Enclose the Selection in a Block Comment
-AddBlockComment.description=Encloses the selection with block comment markers
-
-RemoveBlockComment.label=Remove Bloc&k Comment
-RemoveBlockComment.tooltip=Remove Block Comment Markers Enclosing the Caret
-RemoveBlockComment.description=Removes any block comment markers enclosing the caret
-
-Format.label=&Format
-Format.tooltip=Format the Selected Text
-Format.description=Format the selected text
-
-ShiftRight.label=&Shift Right
-ShiftRight.tooltip=Shift Right
-ShiftRight.description=Shift the selected text to the right
-
-ShiftLeft.label=S&hift Left
-ShiftLeft.tooltip=Shift Left
-ShiftLeft.description=Shift the selected text to the left
-
-Editor.Cut.label=Cu&t
-Editor.Cut.tooltip=Cut
-Editor.Cut.image=
-Editor.Cut.description=Cut
-
-Editor.Copy.label=&Copy
-Editor.Copy.tooltip=Copy
-Editor.Copy.image=
-Editor.Copy.description=Copy
-
-Editor.Paste.label=&Paste
-Editor.Paste.tooltip=Paste
-Editor.Paste.image=
-Editor.Paste.description=Paste
-
-StructureSelectNext.label=&Next Element
-StructureSelectNext.tooltip=Expand Selection to Include Next Sibling
-StructureSelectNext.description=Expand selection to include next sibling
-
-StructureSelectPrevious.label=&Previous Element
-StructureSelectPrevious.tooltip=Expand Selection to Include Previous Sibling
-StructureSelectPrevious.description=Expand selection to include previous sibling
-
-StructureSelectEnclosing.label=&Enclosing Element
-StructureSelectEnclosing.tooltip=Expand Selection to Include Enclosing Element
-StructureSelectEnclosing.description=Expand selection to include enclosing element
-
-StructureSelectHistory.label=&Restore Last Selection
-StructureSelectHistory.tooltip=Restore Last Selection
-StructureSelectHistory.description=Restore last selection
-
-GotoNextMember.label= N&ext Member
-GotoNextMember.tooltip=Move the Caret to the Next Member of the JavaScript file
-GotoNextMember.description=Move the caret to the next member of the JavaScript file
-
-GotoPreviousMember.label= Previ&ous Member
-GotoPreviousMember.tooltip=Move the Caret to the Previous Member of the JavaScript file
-GotoPreviousMember.description=Move the caret to the previous member of the JavaScript file
-
-GotoMatchingBracket.label= Matching &Bracket
-GotoMatchingBracket.tooltip=Go to Matching Bracket
-GotoMatchingBracket.description=Go to Matching Bracket
-
-SourceAttachmentDialog.title=Attachments For ''{0}''
-SourceAttachmentDialog.error.title=Error Attaching Source
-SourceAttachmentDialog.error.message=An error occurred while associating the source
-
-JavaSelectAnnotationRulerAction.QuickFix.label= &Quick Fix
-JavaSelectAnnotationRulerAction.QuickFix.tooltip= Quick Fix
-JavaSelectAnnotationRulerAction.QuickFix.description= Runs Quick Fix on the annotation's line
-JavaSelectAnnotationRulerAction.QuickFix.image=
-
-JavaSelectAnnotationRulerAction.QuickAssist.label= Quick &Assist
-JavaSelectAnnotationRulerAction.QuickAssist.tooltip= Quick Assist
-JavaSelectAnnotationRulerAction.QuickAssist.description= Runs Quick Assist on the annotation's line
-JavaSelectAnnotationRulerAction.QuickAssist.image=
-
-JavaSelectAnnotationRulerAction.GotoAnnotation.label= &Go to Annotation
-JavaSelectAnnotationRulerAction.GotoAnnotation.tooltip= Go to Annotation
-JavaSelectAnnotationRulerAction.GotoAnnotation.description= Selects the annotation in the editor
-JavaSelectAnnotationRulerAction.GotoAnnotation.image=
-
-JavaSelectAnnotationRulerAction.OpenSuperImplementation.label= &Open Super Implementation
-JavaSelectAnnotationRulerAction.OpenSuperImplementation.tooltip= Open Super Implementation
-JavaSelectAnnotationRulerAction.OpenSuperImplementation.description= Opens the super implementation
-JavaSelectAnnotationRulerAction.OpenSuperImplementation.image=
-
-Editor.ChangeEncodingAction.label= Set Encodin&g...
-Editor.ChangeEncodingAction.tooltip= Set Encoding
-Editor.ChangeEncodingAction.image=
-Editor.ChangeEncodingAction.description= Set Encoding
-Editor.ChangeEncodingAction.dialog.title= Set Encoding
-
-Editor.ConvertLineDelimiters.label=C&onvert Line Delimiters To
-
-Editor.ConvertToWindows.label=&Windows
-Editor.ConvertToWindows.tooltip=Converts Line Delimiters to Windows
-Editor.ConvertToWindows.image=
-Editor.ConvertToWindows.description=Converts line delimiters to Windows
-
-Editor.ConvertToUNIX.label=&UNIX
-Editor.ConvertToUNIX.tooltip=Converts Line Delimiters to UNIX
-Editor.ConvertToUNIX.image=
-Editor.ConvertToUNIX.description=Converts line delimiters to UNIX
-
-Editor.ConvertToMac.label=&Mac
-Editor.ConvertToMac.tooltip=Converts line delimiters to Mac
-Editor.ConvertToMac.image=
-Editor.ConvertToMac.description=Converts line delimiters to Mac
-
-Indent.label=Correct &Indentation
-Indent.tooltip=&Indent Current Line to Correct Indentation
-Indent.description=&Indents the current line or selection depending on surrounding source code
-
-Editor.MoveLinesUp.label=Move Lines Up
-Editor.MoveLinesUp.tooltip=Move the Selected Lines Up
-Editor.MoveLinesUp.image=
-Editor.MoveLinesUp.description=Moves the selected lines up
-
-Editor.MoveLinesDown.label=Move Lines Down
-Editor.MoveLinesDown.tooltip=Move the Selected Lines Down
-Editor.MoveLinesDown.image=
-Editor.MoveLinesDown.description=Moves the selected lines down
-
-Editor.ShowInformation.label= Show T&ooltip Description
-Editor.ShowInformation.tooltip= Shows the Tooltip Description
-Editor.ShowInformation.image=
-Editor.ShowInformation.description= Displays information for the current caret location in a sticky hover
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/DocumentAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/DocumentAdapter.java
deleted file mode 100644
index ca0695d5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/DocumentAdapter.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourceAttributes;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.jsdt.core.BufferChangedEvent;
-import org.eclipse.wst.jsdt.core.IBuffer;
-import org.eclipse.wst.jsdt.core.IBufferChangedListener;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-/**
- * 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.
- */
-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 JavaScriptModelException {}
- public void setContents(char[] contents) {}
- public void setContents(String contents) {}
- }
-
-
- /** NULL implementing <code>IBuffer</code> */
- public final static IBuffer NULL= new NullBuffer();
-
-
- /**
- * Run the given runnable in the UI thread.
- *
- * @param runnable the runnable
- *
- */
- private static final void run(Runnable runnable) {
- Display currentDisplay= Display.getCurrent();
- if (currentDisplay != null)
- runnable.run();
- else
- Display.getDefault().syncExec(runnable);
- }
-
-
- /**
- * Executes a document set content call in the UI thread.
- */
- protected class DocumentSetCommand implements Runnable {
-
- private String fContents;
-
- public void run() {
- if (!isClosed())
- fDocument.set(fContents);
- }
-
- public void set(String contents) {
- fContents= contents;
- DocumentAdapter.run(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 {
- if (!isClosed())
- fDocument.replace(fOffset, fLength, fText);
- } catch (BadLocationException x) {
- // ignore
- }
- }
-
- public void replace(int offset, int length, String text) {
- fOffset= offset;
- fLength= length;
- fText= text;
- DocumentAdapter.run(this);
- }
- }
-
-
- private static final boolean DEBUG_LINE_DELIMITERS= true;
-
- private IOpenable fOwner;
- private IFile fFile;
- private ITextFileBuffer fTextFileBuffer;
- private IDocument fDocument;
-
- private DocumentSetCommand fSetCmd= new DocumentSetCommand();
- private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
-
- private Set fLegalLineDelimiters;
-
- private List fBufferListeners= new ArrayList(3);
- private IStatus fStatus;
-
- /*
- *
- */
- private IPath fPath;
-
- /*
- *
- */
- private LocationKind fLocationKind;
-
-
- /**
- * Constructs a new document adapter.
- *
- * @param owner the owner of this buffer
- * @param path the path of the file that backs the buffer
- *
- */
- public DocumentAdapter(IOpenable owner, IPath path) {
- Assert.isLegal(path != null);
-
- fOwner= owner;
- fPath= path;
- fLocationKind= LocationKind.NORMALIZE;
-
- initialize();
- }
-
- /**
- * Constructs a new document adapter.
- *
- * @param owner the owner of this buffer
- * @param file the <code>IFile</code> that backs the buffer
- */
- public DocumentAdapter(IOpenable owner, IFile file) {
-
- fOwner= owner;
- fFile= file;
- fPath= fFile.getFullPath();
- fLocationKind= LocationKind.IFILE;
-
- initialize();
- }
-
- private void initialize() {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- try {
- manager.connect(fPath, fLocationKind, new NullProgressMonitor());
- fTextFileBuffer= manager.getTextFileBuffer(fPath, fLocationKind);
- fDocument= fTextFileBuffer.getDocument();
- } catch (CoreException x) {
- fStatus= x.getStatus();
- fDocument= manager.createEmptyDocument(fPath, fLocationKind);
- if (fDocument instanceof ISynchronizable)
- ((ISynchronizable)fDocument).setLockObject(new Object());
- }
- fDocument.addPrenotifiedDocumentListener(this);
- }
-
- /**
- * Returns the status of this document adapter.
- *
- * @return the status
- */
- public IStatus getStatus() {
- if (fStatus != null)
- return fStatus;
- if (fTextFileBuffer != null)
- return fTextFileBuffer.getStatus();
- return null;
- }
-
- /**
- * Returns the adapted document.
- *
- * @return the adapted document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
- */
- public void addBufferChangedListener(IBufferChangedListener listener) {
- Assert.isNotNull(listener);
- if (!fBufferListeners.contains(listener))
- fBufferListeners.add(listener);
- }
-
- /*
- * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
- */
- public void removeBufferChangedListener(IBufferChangedListener listener) {
- Assert.isNotNull(listener);
- fBufferListeners.remove(listener);
- }
-
- /*
- * @see IBuffer#append(char[])
- */
- public void append(char[] text) {
- append(new String(text));
- }
-
- /*
- * @see IBuffer#append(String)
- */
- public void append(String text) {
- if (DEBUG_LINE_DELIMITERS) {
- validateLineDelimiters(text);
- }
- fReplaceCmd.replace(fDocument.getLength(), 0, text);
- }
-
- /*
- * @see IBuffer#close()
- */
- public void close() {
-
- if (isClosed())
- return;
-
- IDocument d= fDocument;
- fDocument= null;
- d.removePrenotifiedDocumentListener(this);
-
- if (fTextFileBuffer != null) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- try {
- manager.disconnect(fPath, fLocationKind, new NullProgressMonitor());
- } catch (CoreException x) {
- // ignore
- }
- fTextFileBuffer= null;
- }
-
- fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
- fBufferListeners.clear();
- }
-
- /*
- * @see IBuffer#getChar(int)
- */
- public char getChar(int position) {
- try {
- return fDocument.getChar(position);
- } catch (BadLocationException x) {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- /*
- * @see IBuffer#getCharacters()
- */
- public char[] getCharacters() {
- String content= getContents();
- return content == null ? null : content.toCharArray();
- }
-
- /*
- * @see IBuffer#getContents()
- */
- public String getContents() {
- return fDocument.get();
- }
-
- /*
- * @see IBuffer#getLength()
- */
- public int getLength() {
- return fDocument.getLength();
- }
-
- /*
- * @see IBuffer#getOwner()
- */
- public IOpenable getOwner() {
- return fOwner;
- }
-
- /*
- * @see IBuffer#getText(int, int)
- */
- public String getText(int offset, int length) {
- try {
- return fDocument.get(offset, length);
- } catch (BadLocationException x) {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- /*
- * @see IBuffer#getUnderlyingResource()
- */
- public IResource getUnderlyingResource() {
- return fFile;
- }
-
- /*
- * @see IBuffer#hasUnsavedChanges()
- */
- public boolean hasUnsavedChanges() {
- return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
- }
-
- /*
- * @see IBuffer#isClosed()
- */
- public boolean isClosed() {
- return fDocument == null;
- }
-
- /*
- * @see IBuffer#isReadOnly()
- */
- public boolean isReadOnly() {
- if (fTextFileBuffer != null)
- return !fTextFileBuffer.isCommitable();
-
- IResource resource= getUnderlyingResource();
- if (resource == null)
- return true;
-
- final ResourceAttributes attributes= resource.getResourceAttributes();
- return attributes == null ? false : attributes.isReadOnly();
- }
-
- /*
- * @see IBuffer#replace(int, int, char[])
- */
- public void replace(int position, int length, char[] text) {
- replace(position, length, new String(text));
- }
-
- /*
- * @see IBuffer#replace(int, int, String)
- */
- public void replace(int position, int length, String text) {
- if (DEBUG_LINE_DELIMITERS) {
- validateLineDelimiters(text);
- }
- fReplaceCmd.replace(position, length, text);
- }
-
- /*
- * @see IBuffer#save(IProgressMonitor, boolean)
- */
- public void save(IProgressMonitor progress, boolean force) throws JavaScriptModelException {
- try {
- if (fTextFileBuffer != null)
- fTextFileBuffer.commit(progress, force);
- } catch (CoreException e) {
- throw new JavaScriptModelException(e);
- }
- }
-
- /*
- * @see IBuffer#setContents(char[])
- */
- public void setContents(char[] contents) {
- setContents(new String(contents));
- }
-
- /*
- * @see IBuffer#setContents(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
- if (DEBUG_LINE_DELIMITERS) {
- validateLineDelimiters(contents);
- }
-
- if (!contents.equals(fDocument.get()))
- fSetCmd.set(contents);
- }
- }
-
-
- private void validateLineDelimiters(String contents) {
-
- if (fLegalLineDelimiters == null) {
- // collect all line delimiters in the document
- HashSet existingDelimiters= new HashSet();
-
- for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
- try {
- String curr= fDocument.getLineDelimiter(i);
- if (curr != null) {
- existingDelimiters.add(curr);
- }
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- }
- if (existingDelimiters.isEmpty()) {
- return; // first insertion of a line delimiter: no test
- }
- fLegalLineDelimiters= existingDelimiters;
-
- }
-
- DefaultLineTracker tracker= new DefaultLineTracker();
- tracker.set(contents);
-
- int lines= tracker.getNumberOfLines();
- if (lines <= 1)
- return;
-
- for (int i= 0; i < lines; i++) {
- try {
- String curr= tracker.getLineDelimiter(i);
- if (curr != null && !fLegalLineDelimiters.contains(curr)) {
- StringBuffer buf= new StringBuffer("WARNING: javaeditor.DocumentAdapter added new line delimiter to code: "); //$NON-NLS-1$
- for (int k= 0; k < curr.length(); k++) {
- if (k > 0)
- buf.append(' ');
- buf.append((int)curr.charAt(k));
- }
- IStatus status= new Status(IStatus.WARNING, JavaScriptUI.ID_PLUGIN, IStatus.OK, buf.toString(), new Throwable());
- JavaScriptPlugin.log(status);
- }
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /*
- * @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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorHighlightingSynchronizer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorHighlightingSynchronizer.java
deleted file mode 100644
index 4a28e35e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorHighlightingSynchronizer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.link.ILinkedModeListener;
-import org.eclipse.jface.text.link.LinkedModeModel;
-
-
-/**
- * Turns off occurrences highlighting on a java editor until linked mode is
- * left.
- *
- *
- */
-public class EditorHighlightingSynchronizer implements ILinkedModeListener {
-
- private final JavaEditor fEditor;
- private final boolean fWasOccurrencesOn;
-
- /**
- * Creates a new synchronizer.
- *
- * @param editor the java editor the occurrences markers of which will be
- * synchronized with the linked mode
- *
- */
- public EditorHighlightingSynchronizer(JavaEditor editor) {
- Assert.isLegal(editor != null);
- fEditor= editor;
- fWasOccurrencesOn= fEditor.isMarkingOccurrences();
-
- if (fWasOccurrencesOn && !isEditorDisposed())
- fEditor.uninstallOccurrencesFinder();
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
- */
- public void left(LinkedModeModel environment, int flags) {
- if (fWasOccurrencesOn && !isEditorDisposed())
- fEditor.installOccurrencesFinder(true);
- }
-
- /*
- *
- */
- private boolean isEditorDisposed() {
- return fEditor == null || fEditor.getSelectionProvider() == null;
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
- */
- public void suspend(LinkedModeModel environment) {
- }
-
- /*
- * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
- */
- public void resume(LinkedModeModel environment, int flags) {
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorUtility.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorUtility.java
deleted file mode 100644
index 7edcee78..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/EditorUtility.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.ITypeParameter;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * A number of routines for working with JavaElements in editors.
- *
- * Use 'isOpenInEditor' to test if an element is already open in a editor
- * Use 'openInEditor' to force opening an element in a editor
- * With 'getWorkingCopy' you get the working copy (element in the editor) of an element
- */
-public class 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 (JavaScriptModelException x) {
- JavaScriptPlugin.log(x.getStatus());
- }
-
- if (input != null) {
- IWorkbenchPage p= JavaScriptPlugin.getActivePage();
- if (p != null) {
- return p.findEditor(input);
- }
- }
-
- return null;
- }
-
- /**
- * Opens a Java editor for an element such as <code>IJavaScriptElement</code>, <code>IFile</code>, or <code>IStorage</code>.
- * The editor is activated by default.
- *
- * @return an open editor or <code>null</code> if an external editor was opened
- * @throws PartInitException if the editor could not be opened or the input element is not valid
- */
- public static IEditorPart openInEditor(Object inputElement) throws JavaScriptModelException, PartInitException {
- return openInEditor(inputElement, true);
- }
-
- /**
- * Opens the editor currently associated with the given element (IJavaScriptElement, IFile, IStorage...)
- *
- * @return an open editor or <code>null</code> if an external editor was opened
- * @throws PartInitException if the editor could not be opened or the input element is not valid
- */
- public static IEditorPart openInEditor(Object inputElement, boolean activate) throws JavaScriptModelException, PartInitException {
-
- if (inputElement instanceof IFile)
- return openInEditor((IFile) inputElement, activate);
-
- if(inputElement instanceof IJavaScriptElement && ((IJavaScriptElement)inputElement).isVirtual()) {
-
- URI hostElementPath = ((IJavaScriptElement)inputElement).getHostPath();
-
- if(hostElementPath!=null) {
- /* See if we can resolve the URI on the workspace */
- IResource realFile = ((IJavaScriptElement)inputElement).getJavaScriptProject().getProject().getWorkspace().getRoot().getFileForLocation(new Path(hostElementPath.getPath()));
- if(realFile==null || !realFile.exists()) {
- realFile = ((IJavaScriptElement)inputElement).getJavaScriptProject().getProject().getWorkspace().getRoot().findMember(hostElementPath.getPath());
- }
- if(realFile!=null) return openInEditor((IFile)realFile, activate);
- return openInEditor(hostElementPath, activate);
- }
-
- }
-
- /*
- * Support to navigate inside non-primary working copy.
- * For now we only support to navigate inside the currently
- * active editor.
- *
- * XXX: once we have FileStoreEditorInput as API,
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=111887
- * we can fix this code by creating the correct editor input
- * in getEditorInput(Object)
- */
- if (inputElement instanceof IJavaScriptElement) {
- IJavaScriptUnit cu= (IJavaScriptUnit)((IJavaScriptElement)inputElement).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null && !JavaModelUtil.isPrimary(cu)) {
- IWorkbenchPage page= JavaScriptPlugin.getActivePage();
- if (page != null) {
- IEditorPart editor= page.getActiveEditor();
- if (editor != null) {
- IJavaScriptElement editorCU= EditorUtility.getEditorInputJavaElement(editor, false);
- if (cu.equals(editorCU)) {
- if (activate && page.getActivePart() != editor)
- page.activate(editor);
- return editor;
- }
- }
- }
- }
- }
-
- IEditorInput input= getEditorInput(inputElement);
- if (input == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_no_editorInput);
-
- return openInEditor(input, getEditorID(input), activate);
- }
-
- /**
- * Selects a Java Element in an editor
- */
- public static void revealInEditor(IEditorPart part, IJavaScriptElement element) {
- if (element == null)
- return;
-
- if (part instanceof JavaEditor) {
- ((JavaEditor) part).setSelection(element);
- return;
- }
-
- // Support for non-Java editor
- try {
- ISourceRange range= null;
- if (element instanceof IJavaScriptUnit)
- range= null;
- else if (element instanceof IClassFile)
- range= null;
- else if (element instanceof ILocalVariable)
- range= ((ILocalVariable)element).getNameRange();
- else if (element instanceof IMember)
- range= ((IMember)element).getNameRange();
- else if (element instanceof ITypeParameter)
- range= ((ITypeParameter)element).getNameRange();
- else if (element instanceof ISourceReference)
- range= ((ISourceReference)element).getSourceRange();
-
- if (range != null)
- revealInEditor(part, range.getOffset(), range.getLength());
- } catch (JavaScriptModelException e) {
- // don't reveal
- }
- }
-
- /**
- * Selects and reveals the given region in the given editor part.
- */
- public static void revealInEditor(IEditorPart part, IRegion region) {
- if (part != null && region != null)
- revealInEditor(part, region.getOffset(), region.getLength());
- }
-
- /**
- * Selects and reveals the given offset and length in the given editor part.
- */
- public static void revealInEditor(IEditorPart editor, final int offset, final int length) {
- if (editor instanceof ITextEditor) {
- ((ITextEditor)editor).selectAndReveal(offset, length);
- return;
- }
-
- // Support for non-text editor - try IGotoMarker interface
- if (editor instanceof IGotoMarker) {
- final IEditorInput input= editor.getEditorInput();
- if (input instanceof IFileEditorInput) {
- final IGotoMarker gotoMarkerTarget= (IGotoMarker)editor;
- WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- IMarker marker= null;
- try {
- marker= ((IFileEditorInput)input).getFile().createMarker(IMarker.TEXT);
- marker.setAttribute(IMarker.CHAR_START, offset);
- marker.setAttribute(IMarker.CHAR_END, offset + length);
-
- gotoMarkerTarget.gotoMarker(marker);
-
- } finally {
- if (marker != null)
- marker.delete();
- }
- }
- };
-
- try {
- op.run(null);
- } catch (InvocationTargetException ex) {
- // reveal failed
- } catch (InterruptedException e) {
- Assert.isTrue(false, "this operation can not be canceled"); //$NON-NLS-1$
- }
- }
- return;
- }
-
- /*
- * Workaround: send out a text selection
- * XXX: Needs to be improved, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
- */
- if (editor != null && editor.getEditorSite().getSelectionProvider() != null) {
- IEditorSite site= editor.getEditorSite();
- if (site == null)
- return;
-
- ISelectionProvider provider= editor.getEditorSite().getSelectionProvider();
- if (provider == null)
- return;
-
- provider.setSelection(new TextSelection(offset, length));
- }
- }
-
- private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
- if (file == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_file_must_not_be_null);
-
- IWorkbenchPage p= JavaScriptPlugin.getActivePage();
- if (p == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_no_active_WorkbenchPage);
-
- IEditorPart editorPart= IDE.openEditor(p, file, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
-
- private static IEditorPart openInEditor(URI file, boolean activate) throws PartInitException{
- if (file == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_file_must_not_be_null);
-
- IWorkbenchPage p= JavaScriptPlugin.getActivePage();
- if (p == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_no_active_WorkbenchPage);
-
- IEditorDescriptor desc = PlatformUI.getWorkbench().
- getEditorRegistry().getDefaultEditor(file.getPath());
- if(desc==null) {
- throwPartInitException(JavaEditorMessages.EditorUtility_cantFindEditor + file.toString());
- }
- IEditorPart editorPart= IDE.openEditor(p, file, desc.getId(), activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
-
- private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
- Assert.isNotNull(input);
- Assert.isNotNull(editorID);
-
- IWorkbenchPage p= JavaScriptPlugin.getActivePage();
- if (p == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_no_active_WorkbenchPage);
-
- IEditorPart editorPart= p.openEditor(input, editorID, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
-
- private static void throwPartInitException(String message) throws PartInitException {
- IStatus status= new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.OK, message, null);
- throw new PartInitException(status);
- }
-
- private static void initializeHighlightRange(IEditorPart editorPart) {
- if (editorPart instanceof ITextEditor) {
- IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
- boolean enable= toggleAction != null;
- if (enable && editorPart instanceof JavaEditor)
- enable= JavaScriptPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
- else
- enable= enable && toggleAction.isEnabled() && toggleAction.isChecked();
- if (enable) {
- if (toggleAction instanceof TextEditorAction) {
- // Reset the action
- ((TextEditorAction)toggleAction).setEditor(null);
- // Restore the action
- ((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart);
- } else {
- // Uncheck
- toggleAction.run();
- // Check
- toggleAction.run();
- }
- }
- }
- }
-
- private static String getEditorID(IEditorInput input) throws PartInitException {
- Assert.isNotNull(input);
- IEditorDescriptor editorDescriptor;
- if (input instanceof IFileEditorInput)
- editorDescriptor= IDE.getEditorDescriptor(((IFileEditorInput)input).getFile());
- else if (input instanceof InternalClassFileEditorInput )
- return JavaScriptUI.ID_CF_EDITOR;
- else {
- String name= input.getName();
- if (name == null)
- throwPartInitException(JavaEditorMessages.EditorUtility_could_not_find_editorId);
- editorDescriptor= IDE.getEditorDescriptor(name);
- }
- return editorDescriptor.getId();
- }
-
- /**
- * Returns the given editor's input as Java element.
- *
- * @param editor the editor
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- * @return the given editor's input as Java element or <code>null</code> if none
- *
- */
- public static IJavaScriptElement getEditorInputJavaElement(IEditorPart editor, boolean primaryOnly) {
- Assert.isNotNull(editor);
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput == null)
- return null;
-
- IJavaScriptElement je= JavaScriptUI.getEditorInputJavaElement(editorInput);
- if (je != null || primaryOnly)
- return je;
-
- return JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, false);
- }
-
- private static IEditorInput getEditorInput(IJavaScriptElement element) throws JavaScriptModelException {
- while (element != null) {
- if (element instanceof IJavaScriptUnit) {
- IJavaScriptUnit unit= ((IJavaScriptUnit) element).getPrimary();
- IResource resource= unit.getResource();
- if (resource instanceof IFile)
- return new FileEditorInput((IFile) resource);
- }
-
- if (element instanceof IClassFile)
- {
- String elementName = element.getElementName();
- if (Util.isMetadataFileName(elementName))
- {
- IResource resource=element.getResource();
- if (resource instanceof IFile)
- return new FileEditorInput((IFile) resource);
-
- }
- return new InternalClassFileEditorInput((IClassFile) element);
- }
-
- element= element.getParent();
- }
-
- return null;
- }
-
- public static IEditorInput getEditorInput(Object input) throws JavaScriptModelException {
- if (input instanceof IJavaScriptElement)
- return getEditorInput((IJavaScriptElement) input);
-
- if (input instanceof IFile)
- return new FileEditorInput((IFile) input);
-
- if (JavaModelUtil.isOpenableStorage(input))
- return new JarEntryEditorInput((IStorage)input);
-
- return null;
- }
-
- /**
- * If the current active editor edits a java element return it, else
- * return null
- */
- public static IJavaScriptElement getActiveEditorJavaInput() {
- IWorkbenchPage page= JavaScriptPlugin.getActivePage();
- if (page != null) {
- IEditorPart part= page.getActiveEditor();
- if (part != null) {
- IEditorInput editorInput= part.getEditorInput();
- if (editorInput != null) {
- return JavaScriptUI.getEditorInputJavaElement(editorInput);
- }
- }
- }
- return null;
- }
-
- /**
- * Maps the localized modifier name to a code in the same
- * manner as #findModifier.
- *
- * @param modifierName the modifier name
- * @return the SWT modifier bit, or <code>0</code> if no match was found
- *
- */
- public static int findLocalizedModifier(String modifierName) {
- if (modifierName == null)
- return 0;
-
- if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.CTRL)))
- return SWT.CTRL;
- if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT)))
- return SWT.SHIFT;
- if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
- return SWT.ALT;
- if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
- return SWT.COMMAND;
-
- return 0;
- }
-
- /**
- * Returns the modifier string for the given SWT modifier
- * modifier bits.
- *
- * @param stateMask the SWT modifier bits
- * @return the modifier string
- *
- */
- public static String getModifierString(int stateMask) {
- String modifierString= ""; //$NON-NLS-1$
- if ((stateMask & SWT.CTRL) == SWT.CTRL)
- modifierString= appendModifierString(modifierString, SWT.CTRL);
- if ((stateMask & SWT.ALT) == SWT.ALT)
- modifierString= appendModifierString(modifierString, SWT.ALT);
- if ((stateMask & SWT.SHIFT) == SWT.SHIFT)
- modifierString= appendModifierString(modifierString, SWT.SHIFT);
- if ((stateMask & SWT.COMMAND) == SWT.COMMAND)
- modifierString= appendModifierString(modifierString, SWT.COMMAND);
-
- return modifierString;
- }
-
- /**
- * Appends to modifier string of the given SWT modifier bit
- * to the given modifierString.
- *
- * @param modifierString the modifier string
- * @param modifier an int with SWT modifier bit
- * @return the concatenated modifier string
- *
- */
- private static String appendModifierString(String modifierString, int modifier) {
- if (modifierString == null)
- modifierString= ""; //$NON-NLS-1$
- String newModifierString= Action.findModifierString(modifier);
- if (modifierString.length() == 0)
- return newModifierString;
- return Messages.format(JavaEditorMessages.EditorUtility_concatModifierStrings, new String[] {modifierString, newModifierString});
- }
-
- /**
- * Returns the Java project for a given editor input or <code>null</code> if no corresponding
- * Java project exists.
- *
- * @param input the editor input
- * @return the corresponding Java project
- *
- *
- */
- public static IJavaScriptProject getJavaProject(IEditorInput input) {
- IJavaScriptProject jProject= null;
- if (input instanceof IFileEditorInput) {
- IProject project= ((IFileEditorInput)input).getFile().getProject();
- if (project != null) {
- jProject= JavaScriptCore.create(project);
- if (!jProject.exists())
- jProject= null;
- }
- } else if (input instanceof IClassFileEditorInput) {
- jProject= ((IClassFileEditorInput)input).getClassFile().getJavaScriptProject();
- }
- return jProject;
- }
-
- /**
- * Returns an array of all editors that have an unsaved content. If the identical content is
- * presented in more than one editor, only one of those editor parts is part of the result.
- *
- * @return an array of all dirty editor parts.
- *
- */
- public static IEditorPart[] getDirtyEditors() {
- Set inputs= new HashSet();
- List result= new ArrayList(0);
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int x= 0; x < pages.length; x++) {
- IEditorPart[] editors= pages[x].getDirtyEditors();
- for (int z= 0; z < editors.length; z++) {
- IEditorPart ep= editors[z];
- IEditorInput input= ep.getEditorInput();
- if (inputs.add(input))
- result.add(ep);
- }
- }
- }
- return (IEditorPart[])result.toArray(new IEditorPart[result.size()]);
- }
-
- /**
- * Returns the editors to save before performing global Java-related
- * operations.
- *
- * @param saveUnknownEditors <code>true</code> iff editors with unknown buffer management should also be saved
- * @return the editors to save
- *
- */
- public static IEditorPart[] getDirtyEditorsToSave(boolean saveUnknownEditors) {
- Set inputs= new HashSet();
- List result= new ArrayList(0);
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int x= 0; x < pages.length; x++) {
- IEditorPart[] editors= pages[x].getDirtyEditors();
- for (int z= 0; z < editors.length; z++) {
- IEditorPart ep= editors[z];
- IEditorInput input= ep.getEditorInput();
- if (!mustSaveDirtyEditor(ep, input, saveUnknownEditors))
- continue;
-
- if (inputs.add(input))
- result.add(ep);
- }
- }
- }
- return (IEditorPart[])result.toArray(new IEditorPart[result.size()]);
- }
-
- /**
- *
- */
- private static boolean mustSaveDirtyEditor(IEditorPart ep, IEditorInput input, boolean saveUnknownEditors) {
- /*
- * Goal: save all editors that could interfere with refactoring operations.
- *
- * If <code>saveUnknownEditors</code> is <code>false</code>, save all editors
- * for compilation units that are not working copies.
- *
- * If <code>saveUnknownEditors</code> is <code>true</code>, save all editors
- * whose implementation is probably not based on file buffers.
- */
- IResource resource= (IResource) input.getAdapter(IResource.class);
- if (resource == null)
- return saveUnknownEditors;
-
- IJavaScriptElement javaElement= JavaScriptCore.create(resource);
- if (javaElement instanceof IJavaScriptUnit) {
- IJavaScriptUnit cu= (IJavaScriptUnit) javaElement;
- if (!cu.isWorkingCopy()) {
- return true;
- }
- }
-
- if (! (ep instanceof ITextEditor))
- return saveUnknownEditors;
-
- ITextEditor textEditor= (ITextEditor) ep;
- IDocumentProvider documentProvider= textEditor.getDocumentProvider();
- if (! (documentProvider instanceof TextFileDocumentProvider))
- return saveUnknownEditors;
-
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ExternalClassFileEditorInput.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ExternalClassFileEditorInput.java
deleted file mode 100644
index 757e6561..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ExternalClassFileEditorInput.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-/**
- * Editor input for .class files on the file system.
- */
-public class ExternalClassFileEditorInput extends FileEditorInput implements IClassFileEditorInput {
-
- private IClassFile fClassFile;
-
- ExternalClassFileEditorInput(IFile file) {
- super(file);
- refresh();
- }
-
- /*
- * @see IClassFileEditorInput#getClassFile()
- */
- public IClassFile getClassFile() {
- return fClassFile;
- }
-
- /**
- * Refreshes this input element. Workaround for non-updating class file elements.
- */
- public void refresh() {
- Object element= JavaScriptCore.create(getFile());
- if (element instanceof IClassFile)
- fClassFile= (IClassFile) element;
- }
-
- /*
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IClassFile.class)
- return fClassFile;
- return fClassFile.getAdapter(adapter);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/GotoMatchingBracketAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/GotoMatchingBracketAction.java
deleted file mode 100644
index f23a9345..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/GotoMatchingBracketAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-public class GotoMatchingBracketAction extends Action {
-
- public final static String GOTO_MATCHING_BRACKET= "GotoMatchingBracket"; //$NON-NLS-1$
-
- private final JavaEditor fEditor;
-
- public GotoMatchingBracketAction(JavaEditor editor) {
- super(JavaEditorMessages.GotoMatchingBracket_label);
- Assert.isNotNull(editor);
- fEditor= editor;
- setEnabled(true);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_MATCHING_BRACKET_ACTION);
- }
-
- public void run() {
- fEditor.gotoMatchingBracket();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IClassFileEditorInput.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IClassFileEditorInput.java
deleted file mode 100644
index f3d4502a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IClassFileEditorInput.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.core.IClassFile;
-
-
-/**
- * Editor input for class files.
- */
-public interface IClassFileEditorInput extends IEditorInput {
-
- /**
- * Returns the class file acting as input.
- */
- public IClassFile getClassFile();
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompilationUnitDocumentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompilationUnitDocumentProvider.java
deleted file mode 100644
index 9eb57b57..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompilationUnitDocumentProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.source.IAnnotationModelListener;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension2;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension5;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-
-/**
- *
- */
-public interface ICompilationUnitDocumentProvider extends IDocumentProvider, IDocumentProviderExtension2, IDocumentProviderExtension3, IDocumentProviderExtension5 {
-
- /**
- * Shuts down this provider.
- */
- void shutdown();
-
- /**
- * Returns the working copy for the given element.
- *
- * @param element the element
- * @return the working copy for the given element
- */
- IJavaScriptUnit getWorkingCopy(Object element);
-
- /**
- * Saves the content of the given document to the given element. This method has
- * only an effect if it is called when directly or indirectly inside <code>saveDocument</code>.
- *
- * @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
- */
- void saveDocumentContent(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException;
-
- /**
- * Creates a line tracker for the given element. It is of the same kind as the one that would be
- * used for a newly created document for the given element.
- *
- * @param element the element
- * @return a line tracker for the given element
- */
- ILineTracker createLineTracker(Object element);
-
- /**
- * Sets the document provider's save policy.
- *
- * @param savePolicy the save policy
- */
- void setSavePolicy(ISavePolicy savePolicy);
-
- /**
- * Adds a listener that reports changes from all compilation unit annotation models.
- *
- * @param listener the listener
- */
- void addGlobalAnnotationModelListener(IAnnotationModelListener listener);
-
- /**
- * Removes the listener.
- *
- * @param listener the listener
- */
- void removeGlobalAnnotationModelListener(IAnnotationModelListener listener);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompoundEditListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompoundEditListener.java
deleted file mode 100644
index 816b647d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ICompoundEditListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-/**
- * <code>ICompoundEditListener</code>s can be registered with a
- * {@link CompoundEditExitStrategy} to be notified if a compound edit session is ended.
- *
- *
- */
-public interface ICompoundEditListener {
- /**
- * Notifies the receiver that the sending <code>CompoundEditExitStrategy</code> has
- * detected the end of a compound operation.
- */
- void endCompoundEdit();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaAnnotation.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaAnnotation.java
deleted file mode 100644
index ae12d980..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaAnnotation.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.Iterator;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-
-
-/**
- * Interface of annotations representing markers
- * and problems.
- *
- * @see org.eclipse.core.resources.IMarker
- * @see org.eclipse.wst.jsdt.core.compiler.IProblem
- */
-public interface IJavaAnnotation {
-
- /**
- * @see org.eclipse.jface.text.source.Annotation#getType()
- */
- String getType();
-
- /**
- * @see org.eclipse.jface.text.source.Annotation#isPersistent()
- */
- boolean isPersistent();
-
- /**
- * @see org.eclipse.jface.text.source.Annotation#isMarkedDeleted()
- */
- boolean isMarkedDeleted();
-
- /**
- * @see org.eclipse.jface.text.source.Annotation#getText()
- */
- String getText();
-
- /**
- * Returns whether this annotation is overlaid.
- *
- * @return <code>true</code> if overlaid
- */
- boolean hasOverlay();
-
- /**
- * Returns the overlay of this annotation.
- *
- * @return the annotation's overlay
- *
- */
- IJavaAnnotation getOverlay();
-
- /**
- * Returns an iterator for iterating over the
- * annotation which are overlaid by this annotation.
- *
- * @return an iterator over the overlaid annotations
- */
- Iterator getOverlaidIterator();
-
- /**
- * Adds the given annotation to the list of
- * annotations which are overlaid by this annotations.
- *
- * @param annotation the problem annotation
- */
- void addOverlaid(IJavaAnnotation annotation);
-
- /**
- * Removes the given annotation from the list of
- * annotations which are overlaid by this annotation.
- *
- * @param annotation the problem annotation
- */
- void removeOverlaid(IJavaAnnotation annotation);
-
- /**
- * Tells whether this annotation is a problem
- * annotation.
- *
- * @return <code>true</code> if it is a problem annotation
- */
- boolean isProblem();
-
- /**
- * Returns the compilation unit corresponding to the document on which the annotation is set
- * or <code>null</code> if no corresponding compilation unit exists.
- */
- IJavaScriptUnit getCompilationUnit();
-
- /**
- * Returns the problem arguments or <code>null</code> if no problem arguments can be evaluated.
- *
- * @return returns the problem arguments or <code>null</code> if no problem
- * arguments can be evaluated.
- */
- String[] getArguments();
-
- /**
- * Returns the problem id or <code>-1</code> if no problem id can be evaluated.
- *
- * @return returns the problem id or <code>-1</code>
- */
- int getId();
-
- /**
- * Returns the marker type associated to this problem or <code>null<code> if no marker type
- * can be evaluated. See also {@link org.eclipse.wst.jsdt.core.compiler.CategorizedProblem#getMarkerType()}.
- *
- * @return the type of the marker which would be associated to the problem or
- * <code>null<code> if no marker type can be evaluated.
- */
- String getMarkerType();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaEditorActionConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaEditorActionConstants.java
deleted file mode 100644
index 6426a2bc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IJavaEditorActionConstants.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-/**
- * Defines action IDs for private JavaEditor actions.
- */
-public interface IJavaEditorActionConstants {
-
- /**
- * ID of the action to toggle smart typing.
- * Value: <code>"smartTyping"</code>
- *
- */
- public static final String TOGGLE_SMART_TYPING= "smartTyping"; //$NON-NLS-1$
-
- /**
- * ID of the smart typing status item
- * Value: <code>"SmartTyping"</code>
- *
- */
- public static final String STATUS_CATEGORY_SMART_TYPING= "SmartTyping"; //$NON-NLS-1$
-
- /**
- * ID of the action to toggle the style of the presentation.
- */
- public static final String TOGGLE_PRESENTATION= "togglePresentation"; //$NON-NLS-1$
-
- /**
- * ID of the action to copy the qualified name.
- *
- */
- public static final String COPY_QUALIFIED_NAME= "copyQualifiedName"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ISavePolicy.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ISavePolicy.java
deleted file mode 100644
index 1caa1295..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ISavePolicy.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-
-public interface ISavePolicy {
-
- /**
- *
- */
- void preSave(IJavaScriptUnit unit);
-
- /**
- * Returns the compilation unit in which the argument
- * has been changed. If the argument is not changed, the
- * returned result is <code>null</code>.
- */
- IJavaScriptUnit postSave(IJavaScriptUnit unit);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IndentUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IndentUtil.java
deleted file mode 100644
index 81cad8e5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/IndentUtil.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ILineRange;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaIndenter;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-/**
- * Utility that indents a number of lines in a document.
- *
- *
- */
-public final class IndentUtil {
-
- private static final String SLASHES= "//"; //$NON-NLS-1$
-
- /**
- * The result of an indentation operation. The result may be passed to
- * subsequent calls to
- * {@link IndentUtil#indentLines(IDocument, ILineRange, IJavaScriptProject, IndentResult) indentLines}
- * to obtain consistent results with respect to the indentation of
- * line-comments.
- */
- public static final class IndentResult {
- private IndentResult(boolean[] commentLines) {
- commentLinesAtColumnZero= commentLines;
- }
- private boolean[] commentLinesAtColumnZero;
- private boolean hasChanged;
- private int leftmostLine= -1;
- /**
- * Returns <code>true</code> if the indentation operation changed the
- * document, <code>false</code> if not.
- * @return <code>true</code> if the document was changed
- */
- public boolean hasChanged() {
- return hasChanged;
- }
- }
-
- private IndentUtil() {
- // do not instantiate
- }
-
- /**
- * Indents the line range specified by <code>lines</code> in
- * <code>document</code>. The passed Java project may be
- * <code>null</code>, it is used solely to obtain formatter preferences.
- *
- * @param document the document to be changed
- * @param lines the line range to be indented
- * @param project the Java project to get the formatter preferences from, or
- * <code>null</code> if global preferences should be used
- * @param result the result from a previous call to <code>indentLines</code>,
- * in order to maintain comment line properties, or <code>null</code>.
- * Note that the passed result may be changed by the call.
- * @return an indent result that may be queried for changes and can be
- * reused in subsequent indentation operations
- * @throws BadLocationException if <code>lines</code> is not a valid line
- * range on <code>document</code>
- */
- public static IndentResult indentLines(IDocument document, ILineRange lines, IJavaScriptProject project, IndentResult result) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
-
- if (numberOfLines < 1)
- return new IndentResult(null);
-
- result= reuseOrCreateToken(result, numberOfLines);
-
- JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
- JavaIndenter indenter= new JavaIndenter(document, scanner, project);
- boolean changed= false;
- int tabSize= CodeFormatterUtil.getTabWidth(project);
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++) {
- changed |= indentLine(document, line, indenter, scanner, result.commentLinesAtColumnZero, i++, tabSize);
- }
- result.hasChanged= changed;
-
- return result;
- }
-
- /**
- * Shifts the line range specified by <code>lines</code> in
- * <code>document</code>. The amount that the lines get shifted
- * are determined by the first line in the range, all subsequent
- * lines are adjusted accordingly. The passed Java project may be
- * <code>null</code>, it is used solely to obtain formatter
- * preferences.
- *
- * @param document the document to be changed
- * @param lines the line range to be shifted
- * @param project the Java project to get the formatter preferences
- * from, or <code>null</code> if global preferences should
- * be used
- * @param result the result from a previous call to
- * <code>shiftLines</code>, in order to maintain comment
- * line properties, or <code>null</code>. Note that the
- * passed result may be changed by the call.
- * @return an indent result that may be queried for changes and can
- * be reused in subsequent indentation operations
- * @throws BadLocationException if <code>lines</code> is not a
- * valid line range on <code>document</code>
- */
- public static IndentResult shiftLines(IDocument document, ILineRange lines, IJavaScriptProject project, IndentResult result) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
-
- if (numberOfLines < 1)
- return new IndentResult(null);
-
- result= reuseOrCreateToken(result, numberOfLines);
- result.hasChanged= false;
-
- JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
- JavaIndenter indenter= new JavaIndenter(document, scanner, project);
-
- String current= getCurrentIndent(document, lines.getStartLine());
- StringBuffer correct= indenter.computeIndentation(document.getLineOffset(lines.getStartLine()));
- if (correct == null)
- return result; // bail out
-
- int tabSize= CodeFormatterUtil.getTabWidth(project);
- StringBuffer addition= new StringBuffer();
- int difference= subtractIndent(correct, current, addition, tabSize);
-
- if (difference == 0)
- return result;
-
- if (result.leftmostLine == -1)
- result.leftmostLine= getLeftMostLine(document, lines, tabSize);
-
- int maxReduction= computeVisualLength(getCurrentIndent(document, result.leftmostLine + lines.getStartLine()), tabSize);
-
- if (difference > 0) {
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
- addIndent(document, line, addition, result.commentLinesAtColumnZero, i++);
- } else {
- int reduction= Math.min(-difference, maxReduction);
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
- cutIndent(document, line, reduction, tabSize, result.commentLinesAtColumnZero, i++);
- }
-
- result.hasChanged= true;
-
- return result;
-
- }
-
- /**
- * Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
- * Leaves leading comment signs alone.
- *
- * @param document the document
- * @param line the line
- * @param indent the indentation to insert
- * @param commentlines
- * @throws BadLocationException on concurrent document modification
- */
- private static void addIndent(IDocument document, int line, CharSequence indent, boolean[] commentlines, int relative) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int insert= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
-
- // go behind line comments
- if (!commentlines[relative]) {
- while (insert < endOffset - 2 && document.get(insert, 2).equals(SLASHES))
- insert += 2;
- }
-
- // insert indent
- document.replace(insert, 0, indent.toString());
- }
-
- /**
- * Cuts the visual equivalent of <code>toDelete</code> characters out of the
- * indentation of line <code>line</code> in <code>document</code>. Leaves
- * leading comment signs alone.
- *
- * @param document the document
- * @param line the line
- * @param toDelete the number of space equivalents to delete.
- * @throws BadLocationException on concurrent document modification
- */
- private static void cutIndent(IDocument document, int line, int toDelete, int tabSize, boolean[] commentLines, int relative) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int from= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
-
- // go behind line comments
- while (from < endOffset - 2 && document.get(from, 2).equals(SLASHES))
- from += 2;
-
- int to= from;
- while (toDelete > 0 && to < endOffset) {
- char ch= document.getChar(to);
- if (!Character.isWhitespace(ch))
- break;
- toDelete -= computeVisualLength(ch, tabSize);
- if (toDelete >= 0)
- to++;
- else
- break;
- }
-
- if (endOffset > to + 1 && document.get(to, 2).equals(SLASHES))
- commentLines[relative]= true;
-
- document.replace(from, to - from, null);
- }
-
- /**
- * Computes the difference of two indentations and returns the difference in
- * length of current and correct. If the return value is positive, <code>addition</code>
- * is initialized with a substring of that length of <code>correct</code>.
- *
- * @param correct the correct indentation
- * @param current the current indentation (migth contain non-whitespace)
- * @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
- * @return the difference in lenght of <code>correct</code> and <code>current</code>
- */
- private static int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference, int tabSize) {
- int c1= computeVisualLength(correct, tabSize);
- int c2= computeVisualLength(current, tabSize);
- int diff= c1 - c2;
- if (diff <= 0)
- return diff;
-
- difference.setLength(0);
- int len= 0, i= 0;
- while (len < diff) {
- char c= correct.charAt(i++);
- difference.append(c);
- len += computeVisualLength(c, tabSize);
- }
-
-
- return diff;
- }
-
- private static int computeVisualLength(char ch, int tabSize) {
- if (ch == '\t')
- return tabSize;
- else
- return 1;
- }
-
- /**
- * Returns the visual length of a given <code>CharSequence</code> taking into
- * account the visual tabulator length.
- *
- * @param seq the string to measure
- * @return the visual length of <code>seq</code>
- */
- private static int computeVisualLength(CharSequence seq, int tablen) {
- int size= 0;
-
- for (int i= 0; i < seq.length(); i++) {
- char ch= seq.charAt(i);
- if (ch == '\t') {
- if (tablen != 0)
- size += tablen - size % tablen;
- // else: size stays the same
- } else {
- size++;
- }
- }
- return size;
- }
-
- /**
- * Returns the indentation of the line <code>line</code> in <code>document</code>.
- * The returned string may contain pairs of leading slashes that are considered
- * part of the indentation. The space before the asterix in a javadoc-like
- * comment is not considered part of the indentation.
- *
- * @param document the document
- * @param line the line
- * @return the indentation of <code>line</code> in <code>document</code>
- * @throws BadLocationException if the document is changed concurrently
- */
- private static String getCurrentIndent(IDocument document, int line) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int from= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
-
- // go behind line comments
- int to= from;
- while (to < endOffset - 2 && document.get(to, 2).equals(SLASHES))
- to += 2;
-
- while (to < endOffset) {
- char ch= document.getChar(to);
- if (!Character.isWhitespace(ch))
- break;
- to++;
- }
-
- // don't count the space before javadoc like, asterix-style comment lines
- if (to > from && to < endOffset - 1 && document.get(to - 1, 2).equals(" *")) { //$NON-NLS-1$
- String type= TextUtilities.getContentType(document, IJavaScriptPartitions.JAVA_PARTITIONING, to, true);
- if (type.equals(IJavaScriptPartitions.JAVA_DOC) || type.equals(IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT))
- to--;
- }
-
- return document.get(from, to - from);
- }
-
- private static int getLeftMostLine(IDocument document, ILineRange lines, int tabSize) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
- int first= lines.getStartLine();
- int minLine= -1;
- int minIndent= Integer.MAX_VALUE;
- for (int line= 0; line < numberOfLines; line++) {
- int length= computeVisualLength(getCurrentIndent(document, line + first), tabSize);
- if (length < minIndent) {
- minIndent= length;
- minLine= line;
- }
- }
- return minLine;
- }
-
- private static IndentResult reuseOrCreateToken(IndentResult token, int numberOfLines) {
- if (token == null)
- token= new IndentResult(new boolean[numberOfLines]);
- else if (token.commentLinesAtColumnZero == null)
- token.commentLinesAtColumnZero= new boolean[numberOfLines];
- else if (token.commentLinesAtColumnZero.length != numberOfLines) {
- boolean[] commentBooleans= new boolean[numberOfLines];
- System.arraycopy(token.commentLinesAtColumnZero, 0, commentBooleans, 0, Math.min(numberOfLines, token.commentLinesAtColumnZero.length));
- token.commentLinesAtColumnZero= commentBooleans;
- }
- return token;
- }
-
- /**
- * Indents a single line using the java heuristic scanner. Javadoc and multi
- * line comments are indented as specified by the
- * <code>JavaDocAutoIndentStrategy</code>.
- *
- * @param document the document
- * @param line the line to be indented
- * @param indenter the java indenter
- * @param scanner the heuristic scanner
- * @param commentLines the indent token comment booleans
- * @param lineIndex the zero-based line index
- * @return <code>true</code> if the document was modified,
- * <code>false</code> if not
- * @throws BadLocationException if the document got changed concurrently
- */
- private static boolean indentLine(IDocument document, int line, JavaIndenter indenter, JavaHeuristicScanner scanner, boolean[] commentLines, int lineIndex, int tabSize) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- final int offset= currentLine.getOffset();
- int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
-
- String indent= null;
- if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, false);
- String type= partition.getType();
- if (type.equals(IJavaScriptPartitions.JAVA_DOC) || type.equals(IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT)) {
- indent= computeJavadocIndent(document, line, scanner, startingPartition);
- } else if (!commentLines[lineIndex] && startingPartition.getOffset() == offset && startingPartition.getType().equals(IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT)) {
- return false;
- }
- }
-
- // standard java indentation
- if (indent == null) {
- StringBuffer computed= indenter.computeIndentation(offset);
- if (computed != null)
- indent= computed.toString();
- else
- indent= new String();
- }
-
- // change document:
- // get current white space
- int lineLength= currentLine.getLength();
- int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
- if (end == JavaHeuristicScanner.NOT_FOUND)
- end= offset + lineLength;
- int length= end - offset;
- String currentIndent= document.get(offset, length);
-
- // memorize the fact that a line is a single line comment (but not at column 0) and should be treated like code
- // as opposed to commented out code, which should keep its slashes at column 0
- if (length > 0) {
- ITypedRegion partition= TextUtilities.getPartition(document, IJavaScriptPartitions.JAVA_PARTITIONING, end, false);
- if (partition.getOffset() == end && IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT.equals(partition.getType())) {
- commentLines[lineIndex]= true;
- }
- }
-
- // only change the document if it is a real change
- if (!indent.equals(currentIndent)) {
- document.replace(offset, length, indent);
- return true;
- }
-
- return false;
- }
-
- /**
- * Computes and returns the indentation for a javadoc line. The line
- * must be inside a javadoc comment.
- *
- * @param document the document
- * @param line the line in document
- * @param scanner the scanner
- * @param partition the comment partition
- * @return the indent, or <code>null</code> if not computable
- * @throws BadLocationException
- */
- private static String computeJavadocIndent(IDocument document, int line, JavaHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
- if (line == 0) // impossible - the first line is never inside a javadoc comment
- return null;
-
- // don't make any assumptions if the line does not start with \s*\* - it might be
- // commented out code, for which we don't want to change the indent
- final IRegion lineInfo= document.getLineInformation(line);
- final int lineStart= lineInfo.getOffset();
- final int lineLength= lineInfo.getLength();
- final int lineEnd= lineStart + lineLength;
- int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
- if (nonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
- if (nonWS == JavaHeuristicScanner.NOT_FOUND)
- return document.get(lineStart, lineLength);
- return document.get(lineStart, nonWS - lineStart);
- }
-
- // take the indent from the previous line and reuse
- IRegion previousLine= document.getLineInformation(line - 1);
- int previousLineStart= previousLine.getOffset();
- int previousLineLength= previousLine.getLength();
- int previousLineEnd= previousLineStart + previousLineLength;
-
- StringBuffer buf= new StringBuffer();
- int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
- if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
- // align with the comment start if the previous line is not an asterix line
- previousLine= document.getLineInformationOfOffset(partition.getOffset());
- previousLineStart= previousLine.getOffset();
- previousLineLength= previousLine.getLength();
- previousLineEnd= previousLineStart + previousLineLength;
- previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
- if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND)
- previousLineNonWS= previousLineEnd;
-
- // add the initial space
- // TODO this may be controlled by a formatter preference in the future
- buf.append(' ');
- }
-
- String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
- buf.insert(0, indentation);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/InternalClassFileEditorInput.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/InternalClassFileEditorInput.java
deleted file mode 100644
index 137644f8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/InternalClassFileEditorInput.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-
-/**
- * Class file considered as editor input.
- */
-public class InternalClassFileEditorInput implements IClassFileEditorInput, IPersistableElement {
-
- private IClassFile fClassFile;
-
- public InternalClassFileEditorInput(IClassFile classFile) {
- fClassFile= classFile;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof InternalClassFileEditorInput))
- return false;
- InternalClassFileEditorInput other= (InternalClassFileEditorInput) obj;
- return fClassFile.equals(other.fClassFile);
- }
-
- /*
- * @see Object#hashCode
- */
- public int hashCode() {
- return fClassFile.hashCode();
- }
-
- /*
- * @see IClassFileEditorInput#getClassFile()
- */
- public IClassFile getClassFile() {
- return fClassFile;
- }
-
- /*
- * @see IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return this;
- }
-
- /*
- * @see IEditorInput#getName()
- */
- public String getName() {
- return fClassFile.getDisplayName();
- }
-
- /*
- * @see IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return fClassFile.getType().getFullyQualifiedName();
- }
-
- /*
- * @see IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- try {
- if (fClassFile.isClass())
- return JavaPluginImages.DESC_OBJS_CFILECLASS;
- return JavaPluginImages.DESC_OBJS_CFILEINT;
- } catch (JavaScriptModelException e) {
- // fall through
- }
- return JavaPluginImages.DESC_OBJS_CFILE;
- }
-
- /*
- * @see IEditorInput#exists()
- */
- public boolean exists() {
- return fClassFile.exists();
- }
-
- /*
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IClassFile.class)
- return fClassFile;
- return fClassFile.getAdapter(adapter);
- }
-
- /*
- * @see IPersistableElement#saveState(IMemento)
- */
- public void saveState(IMemento memento) {
- ClassFileEditorInputFactory.saveState(memento, this);
- }
-
- /*
- * @see IPersistableElement#getFactoryId()
- */
- public String getFactoryId() {
- return ClassFileEditorInputFactory.ID;
- }
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JarEntryEditorInput.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JarEntryEditorInput.java
deleted file mode 100644
index 4093e790..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JarEntryEditorInput.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-
-
-/**
- * An EditorInput for a JarEntryFile.
- */
-public class JarEntryEditorInput implements IStorageEditorInput {
-
- private IStorage fJarEntryFile;
-
- public JarEntryEditorInput(IStorage jarEntryFile) {
- fJarEntryFile= jarEntryFile;
- }
-
- /*
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof JarEntryEditorInput))
- return false;
- JarEntryEditorInput other= (JarEntryEditorInput) obj;
- return fJarEntryFile.equals(other.fJarEntryFile);
- }
-
- /*
- * @see IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /*
- * @see IEditorInput#getName()
- */
- public String getName() {
- return fJarEntryFile.getName();
- }
-
- /*
- * @see IEditorInput#getContentType()
- */
- public String getContentType() {
- return fJarEntryFile.getFullPath().getFileExtension();
- }
-
- /*
- * @see IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- if (fJarEntryFile instanceof IJarEntryResource) {
- IJarEntryResource jarEntry= (IJarEntryResource)fJarEntryFile;
- IPackageFragmentRoot root= jarEntry.getPackageFragmentRoot();
- IPath fullPath= root.getPath().append(fJarEntryFile.getFullPath());
- if (root.isExternal())
- return fullPath.toOSString();
- return fullPath.toString();
-
- }
-
- IPath fullPath= fJarEntryFile.getFullPath();
- if (fullPath == null)
- return null;
- return fullPath.toString();
- }
-
- /*
- * @see IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
- return registry.getImageDescriptor(getContentType());
- }
-
- /*
- * @see IEditorInput#exists()
- */
- public boolean exists() {
- // JAR entries can't be deleted
- return true;
- }
-
- /*
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- /*
- * see IStorageEditorInput#getStorage()
- */
- public IStorage getStorage() {
- return fJarEntryFile;
- }
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationImageProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationImageProvider.java
deleted file mode 100644
index 5315ff0a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationImageProvider.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IAnnotationImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.JavaCorrectionProcessor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Image provider for annotations based on Java problem markers.
- *
- *
- */
-public class JavaAnnotationImageProvider implements IAnnotationImageProvider {
-
- private final static int NO_IMAGE= 0;
- private final static int GRAY_IMAGE= 1;
- private final static int OVERLAY_IMAGE= 2;
- private final static int QUICKFIX_IMAGE= 3;
- private final static int QUICKFIX_ERROR_IMAGE= 4;
-
-
- private static Image fgQuickFixImage;
- private static Image fgQuickFixErrorImage;
- private static ImageRegistry fgImageRegistry;
-
- private boolean fShowQuickFixIcon;
- private int fCachedImageType;
- private Image fCachedImage;
-
-
- public JavaAnnotationImageProvider() {
- fShowQuickFixIcon= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
- */
- public Image getManagedImage(Annotation annotation) {
- if (annotation instanceof IJavaAnnotation) {
- IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation;
- int imageType= getImageType(javaAnnotation);
- return getImage(javaAnnotation, imageType, Display.getCurrent());
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
- */
- public String getImageDescriptorId(Annotation annotation) {
- // unmanaged images are not supported
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
- */
- public ImageDescriptor getImageDescriptor(String symbolicName) {
- // unmanaged images are not supported
- return null;
- }
-
-
- private boolean showQuickFix(IJavaAnnotation annotation) {
- return fShowQuickFixIcon && annotation.isProblem() && JavaCorrectionProcessor.hasCorrections((Annotation) annotation);
- }
-
- private Image getQuickFixImage() {
- if (fgQuickFixImage == null)
- fgQuickFixImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_PROBLEM);
- return fgQuickFixImage;
- }
-
- private Image getQuickFixErrorImage() {
- if (fgQuickFixErrorImage == null)
- fgQuickFixErrorImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_ERROR);
- return fgQuickFixErrorImage;
- }
-
- private ImageRegistry getImageRegistry(Display display) {
- if (fgImageRegistry == null)
- fgImageRegistry= new ImageRegistry(display);
- return fgImageRegistry;
- }
-
- private int getImageType(IJavaAnnotation annotation) {
- int imageType= NO_IMAGE;
- if (annotation.hasOverlay())
- imageType= OVERLAY_IMAGE;
- else if (!annotation.isMarkedDeleted()) {
- if (showQuickFix(annotation))
- imageType= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType()) ? QUICKFIX_ERROR_IMAGE : QUICKFIX_IMAGE;
- } else {
- imageType= GRAY_IMAGE;
- }
- return imageType;
- }
-
- private Image getImage(IJavaAnnotation annotation, int imageType, Display display) {
- if ((imageType == QUICKFIX_IMAGE || imageType == QUICKFIX_ERROR_IMAGE) && fCachedImageType == imageType)
- return fCachedImage;
-
- Image image= null;
- switch (imageType) {
- case OVERLAY_IMAGE:
- IJavaAnnotation overlay= annotation.getOverlay();
- image= getManagedImage((Annotation) overlay);
- fCachedImageType= -1;
- break;
- case QUICKFIX_IMAGE:
- image= getQuickFixImage();
- fCachedImageType= imageType;
- fCachedImage= image;
- break;
- case QUICKFIX_ERROR_IMAGE:
- image= getQuickFixErrorImage();
- fCachedImageType= imageType;
- fCachedImage= image;
- break;
- case GRAY_IMAGE: {
- ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages();
- String annotationType= annotation.getType();
- if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotationType)) {
- image= sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- } else if (JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(annotationType)) {
- image= sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- } else if (JavaMarkerAnnotation.INFO_ANNOTATION_TYPE.equals(annotationType)) {
- image= sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
- }
- if (image != null) {
- ImageRegistry registry= getImageRegistry(display);
- String key= Integer.toString(image.hashCode());
- Image grayImage= registry.get(key);
- if (grayImage == null) {
- grayImage= new Image(display, image, SWT.IMAGE_GRAY);
- registry.put(key, grayImage);
- }
- image= grayImage;
- }
- fCachedImageType= -1;
- break;
- }
- }
-
- return image;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationIterator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationIterator.java
deleted file mode 100644
index ec9e67f4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaAnnotationIterator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-
-/**
- * Filters problems based on their types.
- */
-public class JavaAnnotationIterator implements Iterator {
-
- private Iterator fIterator;
- private Annotation fNext;
- private boolean fSkipIrrelevants;
- private boolean fReturnAllAnnotations;
-
- /**
- * Equivalent to <code>JavaAnnotationIterator(model, skipIrrelevants, false)</code>.
- */
- public JavaAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants) {
- this(model, skipIrrelevants, false);
- }
-
- /**
- * Returns a new JavaAnnotationIterator.
- * @param model the annotation model
- * @param skipIrrelevants whether to skip irrelevant annotations
- * @param returnAllAnnotations Whether to return non IJavaAnnotations as well
- */
- public JavaAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants, boolean returnAllAnnotations) {
- fReturnAllAnnotations= returnAllAnnotations;
- if (model != null)
- fIterator= model.getAnnotationIterator();
- else
- fIterator= Collections.EMPTY_LIST.iterator();
- fSkipIrrelevants= skipIrrelevants;
- skip();
- }
-
- private void skip() {
- while (fIterator.hasNext()) {
- Annotation next= (Annotation) fIterator.next();
- if (next instanceof IJavaAnnotation) {
- if (fSkipIrrelevants) {
- if (!next.isMarkedDeleted()) {
- fNext= next;
- return;
- }
- } else {
- fNext= next;
- return;
- }
- } else if (fReturnAllAnnotations) {
- fNext= 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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaDocumentSetupParticipant.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaDocumentSetupParticipant.java
deleted file mode 100644
index 5a147033..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaDocumentSetupParticipant.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-/**
- * The document setup participant for JDT.
- */
-public class JavaDocumentSetupParticipant implements IDocumentSetupParticipant {
-
- public JavaDocumentSetupParticipant() {
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
- */
- public void setup(IDocument document) {
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditor.java
deleted file mode 100644
index 4eee7def..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditor.java
+++ /dev/null
@@ -1,3612 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.text.CharacterIterator;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.operations.IOperationApprover;
-import org.eclipse.core.commands.operations.IUndoContext;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.help.IContextProvider;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension4;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ISelectionValidator;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.link.LinkedModeModel;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.reconciler.IReconciler;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationRulerColumn;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.ICharacterPairMatcher;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.ISourceViewerExtension2;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.jface.text.source.LineChangeHover;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.text.source.projection.ProjectionSupport;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-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.SWT;
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.editors.text.DefaultEncodingSupport;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.IEncodingSupport;
-import org.eclipse.ui.operations.NonLocalUndoUserApprover;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
-import org.eclipse.ui.texteditor.TextNavigationAction;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.ui.views.contentoutline.ContentOutline;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IImportContainer;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.ITypeParameter;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.core.util.IModifierConstants;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.CopyQualifiedNameAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.FoldingActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.GoToNextPreviousMemberAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.SelectionHistory;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectEnclosingAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectHistoryAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectNextAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectPreviousAction;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions.StructureSelectionAction;
-import org.eclipse.wst.jsdt.internal.ui.search.BreakContinueTargetFinder;
-import org.eclipse.wst.jsdt.internal.ui.search.ExceptionOccurrencesFinder;
-import org.eclipse.wst.jsdt.internal.ui.search.ImplementOccurrencesFinder;
-import org.eclipse.wst.jsdt.internal.ui.search.MethodExitsFinder;
-import org.eclipse.wst.jsdt.internal.ui.search.OccurrencesFinder;
-import org.eclipse.wst.jsdt.internal.ui.text.DocumentCharacterIterator;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaChangeHover;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaPairMatcher;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordIterator;
-import org.eclipse.wst.jsdt.internal.ui.text.PreferencesAdapter;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaExpandHover;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.SourceViewerInformationControl;
-import org.eclipse.wst.jsdt.internal.ui.util.JavaUIHelp;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ISelectionListenerWithAST;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenEditorActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.ShowInPackageViewAction;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-import org.eclipse.wst.jsdt.ui.text.folding.IJavaFoldingStructureProvider;
-import org.eclipse.wst.jsdt.ui.text.folding.IJavaFoldingStructureProviderExtension;
-import org.osgi.service.prefs.BackingStoreException;
-
-import com.ibm.icu.text.BreakIterator;
-
-/**
- * Java specific text editor.
- */
-public abstract class JavaEditor extends AbstractDecoratedTextEditor implements IViewPartInputProvider {
-
- /**
- * Internal implementation class for a change listener.
- *
- */
- protected abstract class AbstractSelectionChangedListener implements ISelectionChangedListener {
-
- /**
- * Installs this selection changed listener with the given selection provider. If
- * the selection provider is a post selection provider, post selection changed
- * events are the preferred choice, otherwise normal selection changed events
- * are requested.
- *
- * @param selectionProvider
- */
- public void install(ISelectionProvider selectionProvider) {
- if (selectionProvider == null)
- return;
-
- if (selectionProvider instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider;
- provider.addPostSelectionChangedListener(this);
- } else {
- selectionProvider.addSelectionChangedListener(this);
- }
- }
-
- /**
- * Removes this selection changed listener from the given selection provider.
- *
- * @param selectionProvider the selection provider
- */
- public void uninstall(ISelectionProvider selectionProvider) {
- if (selectionProvider == null)
- return;
-
- if (selectionProvider instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider;
- provider.removePostSelectionChangedListener(this);
- } else {
- selectionProvider.removeSelectionChangedListener(this);
- }
- }
- }
-
- /**
- * Updates the Java outline page selection and this editor's range indicator.
- *
- *
- */
- private class EditorSelectionChangedListener extends AbstractSelectionChangedListener {
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56161
- JavaEditor.this.selectionChanged();
- }
- }
-
- /**
- * Updates the selection in the editor's widget with the selection of the outline page.
- */
- class OutlineSelectionChangedListener extends AbstractSelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(event);
- }
- }
-
-
- /**
- * Adapts an options {@link IEclipsePreferences} to {@link org.eclipse.jface.preference.IPreferenceStore}.
- * <p>
- * This preference store is read-only i.e. write access
- * throws an {@link java.lang.UnsupportedOperationException}.
- * </p>
- *
- *
- */
- private static class EclipsePreferencesAdapter implements IPreferenceStore {
-
- /**
- * Preference change listener. Listens for events preferences
- * fires a {@link org.eclipse.jface.util.PropertyChangeEvent}
- * on this adapter with arguments from the received event.
- */
- private class PreferenceChangeListener implements IEclipsePreferences.IPreferenceChangeListener {
-
- /**
- * {@inheritDoc}
- */
- public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
- if (Display.getCurrent() == null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
- }
- });
- } else {
- firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
- }
- }
- }
-
- /** Listeners on on this adapter */
- private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
-
- /** Listener on the node */
- private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
-
- /** wrapped node */
- private final IScopeContext fContext;
- private final String fQualifier;
-
- /**
- * Initialize with the node to wrap
- *
- * @param context the context to access
- * @param qualifier the qualifier
- */
- public EclipsePreferencesAdapter(IScopeContext context, String qualifier) {
- fContext= context;
- fQualifier= qualifier;
- }
-
- private IEclipsePreferences getNode() {
- return fContext.getNode(fQualifier);
- }
-
- /**
- * {@inheritDoc}
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if (fListeners.size() == 0)
- getNode().addPreferenceChangeListener(fListener);
- fListeners.add(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fListeners.remove(listener);
- if (fListeners.size() == 0) {
- getNode().removePreferenceChangeListener(fListener);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean contains(String name) {
- return getNode().get(name, null) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++)
- ((IPropertyChangeListener) listeners[i]).propertyChange(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getBoolean(String name) {
- return getNode().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getDefaultBoolean(String name) {
- return BOOLEAN_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDefaultDouble(String name) {
- return DOUBLE_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public float getDefaultFloat(String name) {
- return FLOAT_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getDefaultInt(String name) {
- return INT_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public long getDefaultLong(String name) {
- return LONG_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDefaultString(String name) {
- return STRING_DEFAULT_DEFAULT;
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDouble(String name) {
- return getNode().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public float getFloat(String name) {
- return getNode().getFloat(name, FLOAT_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public int getInt(String name) {
- return getNode().getInt(name, INT_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public long getLong(String name) {
- return getNode().getLong(name, LONG_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getString(String name) {
- return getNode().get(name, STRING_DEFAULT_DEFAULT);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDefault(String name) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean needsSaving() {
- try {
- return getNode().keys().length > 0;
- } catch (BackingStoreException e) {
- // ignore
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void putValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, String defaultObject) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setToDefault(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- }
-
-
- /**
- * Cancels the occurrences finder job upon document changes.
- *
- *
- */
- class OccurrencesFinderJobCanceler implements IDocumentListener, ITextInputListener {
-
- public void install() {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer == null)
- return;
-
- StyledText text= sourceViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- sourceViewer.addTextInputListener(this);
-
- IDocument document= sourceViewer.getDocument();
- if (document != null)
- document.addDocumentListener(this);
- }
-
- public void uninstall() {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer != null)
- sourceViewer.removeTextInputListener(this);
-
- IDocumentProvider documentProvider= getDocumentProvider();
- if (documentProvider != null) {
- IDocument document= documentProvider.getDocument(getEditorInput());
- if (document != null)
- document.removeDocumentListener(this);
- }
- }
-
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- if (fOccurrencesFinderJob != null)
- fOccurrencesFinderJob.doCancel();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput == null)
- return;
-
- oldInput.removeDocumentListener(this);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput == null)
- return;
- newInput.addDocumentListener(this);
- }
- }
-
- /**
- * This action implements smart home.
- *
- * Instead of going to the start of a line it does the following:
- *
- * - if smart home/end is enabled and the caret is after the line's first non-whitespace then the caret is moved directly before it, taking JavaDoc and multi-line comments into account.
- * - if the caret is before the line's first non-whitespace the caret is moved to the beginning of the line
- * - if the caret is at the beginning of the line see first case.
- *
- *
- */
- protected class SmartLineStartAction extends LineStartAction {
-
- /**
- * Creates a new smart line start action
- *
- * @param textWidget the styled text widget
- * @param doSelect a boolean flag which tells if the text up to the beginning of the line should be selected
- */
- public SmartLineStartAction(final StyledText textWidget, final boolean doSelect) {
- super(textWidget, doSelect);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor.LineStartAction#getLineStartPosition(java.lang.String, int, java.lang.String)
- */
- protected int getLineStartPosition(final IDocument document, final String line, final int length, final int offset) {
-
- String type= IDocument.DEFAULT_CONTENT_TYPE;
- try {
- type= TextUtilities.getContentType(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, true);
- } catch (BadLocationException exception) {
- // Should not happen
- }
-
- int index= super.getLineStartPosition(document, line, length, offset);
- if (type.equals(IJavaScriptPartitions.JAVA_DOC) || type.equals(IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT)) {
- if (index < length - 1 && line.charAt(index) == '*' && line.charAt(index + 1) != '/') {
- do {
- ++index;
- } while (index < length && Character.isWhitespace(line.charAt(index)));
- }
- } else {
- if (index < length - 1 && line.charAt(index) == '/' && line.charAt(index + 1) == '/') {
- index++;
- do {
- ++index;
- } while (index < length && Character.isWhitespace(line.charAt(index)));
- }
- }
- return index;
- }
- }
-
- /**
- * Text navigation action to navigate to the next sub-word.
- *
- *
- */
- protected abstract class NextSubWordAction extends TextNavigationAction {
-
- protected JavaWordIterator fIterator= new JavaWordIterator();
-
- /**
- * Creates a new next sub-word action.
- *
- * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
- */
- protected NextSubWordAction(int code) {
- super(getSourceViewer().getTextWidget(), code);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- // Check whether we are in a java code partition and the preference is enabled
- final IPreferenceStore store= getPreferenceStore();
- if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) {
- super.run();
- return;
- }
-
- final ISourceViewer viewer= getSourceViewer();
- final IDocument document= viewer.getDocument();
- fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
- int position= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
- if (position == -1)
- return;
-
- int next= findNextPosition(position);
- if (next != BreakIterator.DONE) {
- setCaretPosition(next);
- getTextWidget().showSelection();
- fireSelectionChanged();
- }
-
- }
-
- /**
- * Finds the next position after the given position.
- *
- * @param position the current position
- * @return the next position
- */
- protected int findNextPosition(int position) {
- ISourceViewer viewer= getSourceViewer();
- int widget= -1;
- int next= position;
- while (next != BreakIterator.DONE && widget == -1) { // TODO: optimize
- next= fIterator.following(next);
- if (next != BreakIterator.DONE)
- widget= modelOffset2WidgetOffset(viewer, next);
- }
-
- IDocument document= viewer.getDocument();
- LinkedModeModel model= LinkedModeModel.getModel(document, position);
- if (model != null) {
- LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
- if (linkedPosition != null) {
- int linkedPositionEnd= linkedPosition.getOffset() + linkedPosition.getLength();
- if (position != linkedPositionEnd && linkedPositionEnd < next)
- next= linkedPositionEnd;
- } else {
- LinkedPosition nextLinkedPosition= model.findPosition(new LinkedPosition(document, next, 0));
- if (nextLinkedPosition != null) {
- int nextLinkedPositionOffset= nextLinkedPosition.getOffset();
- if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next)
- next= nextLinkedPositionOffset;
- }
- }
- }
-
- return next;
- }
-
- /**
- * Sets the caret position to the sub-word boundary given with <code>position</code>.
- *
- * @param position Position where the action should move the caret
- */
- protected abstract void setCaretPosition(int position);
- }
-
- /**
- * Text navigation action to navigate to the next sub-word.
- *
- *
- */
- protected class NavigateNextSubWordAction extends NextSubWordAction {
-
- /**
- * Creates a new navigate next sub-word action.
- */
- public NavigateNextSubWordAction() {
- super(ST.WORD_NEXT);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(final int position) {
- getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
- }
- }
-
- /**
- * Text operation action to delete the next sub-word.
- *
- *
- */
- protected class DeleteNextSubWordAction extends NextSubWordAction implements IUpdate {
-
- /**
- * Creates a new delete next sub-word action.
- */
- public DeleteNextSubWordAction() {
- super(ST.DELETE_WORD_NEXT);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(final int position) {
- if (!validateEditorInputState())
- return;
-
- final ISourceViewer viewer= getSourceViewer();
- final int caret, length;
- Point selection= viewer.getSelectedRange();
- if (selection.y != 0) {
- caret= selection.x;
- length= selection.y;
- } else {
- caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
- length= position - caret;
- }
-
- try {
- viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
- } catch (BadLocationException exception) {
- // Should not happen
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- setEnabled(isEditorInputModifiable());
- }
- }
-
- /**
- * Text operation action to select the next sub-word.
- *
- *
- */
- protected class SelectNextSubWordAction extends NextSubWordAction {
-
- /**
- * Creates a new select next sub-word action.
- */
- public SelectNextSubWordAction() {
- super(ST.SELECT_WORD_NEXT);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(final int position) {
- final ISourceViewer viewer= getSourceViewer();
-
- final StyledText text= viewer.getTextWidget();
- if (text != null && !text.isDisposed()) {
-
- final Point selection= text.getSelection();
- final int caret= text.getCaretOffset();
- final int offset= modelOffset2WidgetOffset(viewer, position);
-
- if (caret == selection.x)
- text.setSelectionRange(selection.y, offset - selection.y);
- else
- text.setSelectionRange(selection.x, offset - selection.x);
- }
- }
- }
-
- /**
- * Text navigation action to navigate to the previous sub-word.
- *
- *
- */
- protected abstract class PreviousSubWordAction extends TextNavigationAction {
-
- protected JavaWordIterator fIterator= new JavaWordIterator();
-
- /**
- * Creates a new previous sub-word action.
- *
- * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
- */
- protected PreviousSubWordAction(final int code) {
- super(getSourceViewer().getTextWidget(), code);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- // Check whether we are in a java code partition and the preference is enabled
- final IPreferenceStore store= getPreferenceStore();
- if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) {
- super.run();
- return;
- }
-
- final ISourceViewer viewer= getSourceViewer();
- final IDocument document= viewer.getDocument();
- fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
- int position= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
- if (position == -1)
- return;
-
- int previous= findPreviousPosition(position);
- if (previous != BreakIterator.DONE) {
- setCaretPosition(previous);
- getTextWidget().showSelection();
- fireSelectionChanged();
- }
-
- }
-
- /**
- * Finds the previous position before the given position.
- *
- * @param position the current position
- * @return the previous position
- */
- protected int findPreviousPosition(int position) {
- ISourceViewer viewer= getSourceViewer();
- int widget= -1;
- int previous= position;
- while (previous != BreakIterator.DONE && widget == -1) { // TODO: optimize
- previous= fIterator.preceding(previous);
- if (previous != BreakIterator.DONE)
- widget= modelOffset2WidgetOffset(viewer, previous);
- }
-
- IDocument document= viewer.getDocument();
- LinkedModeModel model= LinkedModeModel.getModel(document, position);
- if (model != null) {
- LinkedPosition linkedPosition= model.findPosition(new LinkedPosition(document, position, 0));
- if (linkedPosition != null) {
- int linkedPositionOffset= linkedPosition.getOffset();
- if (position != linkedPositionOffset && previous < linkedPositionOffset)
- previous= linkedPositionOffset;
- } else {
- LinkedPosition previousLinkedPosition= model.findPosition(new LinkedPosition(document, previous, 0));
- if (previousLinkedPosition != null) {
- int previousLinkedPositionEnd= previousLinkedPosition.getOffset() + previousLinkedPosition.getLength();
- if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd)
- previous= previousLinkedPositionEnd;
- }
- }
- }
-
- return previous;
- }
-
- /**
- * Sets the caret position to the sub-word boundary given with <code>position</code>.
- *
- * @param position Position where the action should move the caret
- */
- protected abstract void setCaretPosition(int position);
- }
-
- /**
- * Text navigation action to navigate to the previous sub-word.
- *
- *
- */
- protected class NavigatePreviousSubWordAction extends PreviousSubWordAction {
-
- /**
- * Creates a new navigate previous sub-word action.
- */
- public NavigatePreviousSubWordAction() {
- super(ST.WORD_PREVIOUS);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(final int position) {
- getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
- }
- }
-
- /**
- * Text operation action to delete the previous sub-word.
- *
- *
- */
- protected class DeletePreviousSubWordAction extends PreviousSubWordAction implements IUpdate {
-
- /**
- * Creates a new delete previous sub-word action.
- */
- public DeletePreviousSubWordAction() {
- super(ST.DELETE_WORD_PREVIOUS);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(int position) {
- if (!validateEditorInputState())
- return;
-
- final int length;
- final ISourceViewer viewer= getSourceViewer();
- Point selection= viewer.getSelectedRange();
- if (selection.y != 0) {
- position= selection.x;
- length= selection.y;
- } else {
- length= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()) - position;
- }
-
- try {
- viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
- } catch (BadLocationException exception) {
- // Should not happen
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- setEnabled(isEditorInputModifiable());
- }
- }
-
- /**
- * Text operation action to select the previous sub-word.
- *
- *
- */
- protected class SelectPreviousSubWordAction extends PreviousSubWordAction {
-
- /**
- * Creates a new select previous sub-word action.
- */
- public SelectPreviousSubWordAction() {
- super(ST.SELECT_WORD_PREVIOUS);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int)
- */
- protected void setCaretPosition(final int position) {
- final ISourceViewer viewer= getSourceViewer();
-
- final StyledText text= viewer.getTextWidget();
- if (text != null && !text.isDisposed()) {
-
- final Point selection= text.getSelection();
- final int caret= text.getCaretOffset();
- final int offset= modelOffset2WidgetOffset(viewer, position);
-
- if (caret == selection.x)
- text.setSelectionRange(selection.y, offset - selection.y);
- else
- text.setSelectionRange(selection.x, offset - selection.x);
- }
- }
- }
-
- /**
- * Format element action to format the enclosing java element.
- * <p>
- * The format element action works as follows:
- * <ul>
- * <li>If there is no selection and the caret is positioned on a Java element,
- * only this element is formatted. If the element has some accompanying comment,
- * then the comment is formatted as well.</li>
- * <li>If the selection spans one or more partitions of the document, then all
- * partitions covered by the selection are entirely formatted.</li>
- * <p>
- * Partitions at the end of the selection are not completed, except for comments.
- *
- *
- */
- protected class FormatElementAction extends Action implements IUpdate {
-
- /*
- *
- */
- FormatElementAction() {
- setEnabled(isEditorInputModifiable());
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
-
- final JavaSourceViewer viewer= (JavaSourceViewer) getSourceViewer();
- if (viewer.isEditable()) {
-
- final Point selection= viewer.rememberSelection();
- try {
- viewer.setRedraw(false);
-
- final String type= TextUtilities.getContentType(viewer.getDocument(), IJavaScriptPartitions.JAVA_PARTITIONING, selection.x, true);
- if (type.equals(IDocument.DEFAULT_CONTENT_TYPE) && selection.y == 0) {
-
- try {
- final IJavaScriptElement element= getElementAt(selection.x, true);
- if (element != null && element.exists()) {
-
- final int kind= element.getElementType();
- if (kind == IJavaScriptElement.TYPE || kind == IJavaScriptElement.METHOD || kind == IJavaScriptElement.INITIALIZER) {
-
- final ISourceReference reference= (ISourceReference)element;
- final ISourceRange range= reference.getSourceRange();
-
- if (range != null) {
- viewer.setSelectedRange(range.getOffset(), range.getLength());
- viewer.doOperation(ISourceViewer.FORMAT);
- }
- }
- }
- } catch (JavaScriptModelException exception) {
- // Should not happen
- }
- } else {
- viewer.setSelectedRange(selection.x, 1);
- viewer.doOperation(ISourceViewer.FORMAT);
- }
- } catch (BadLocationException exception) {
- // Can not happen
- } finally {
-
- viewer.setRedraw(true);
- viewer.restoreSelection();
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- *
- */
- public void update() {
- setEnabled(isEditorInputModifiable());
- }
- }
-
- /**
- * Internal activation listener.
- *
- */
- private class ActivationListener implements IWindowListener {
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
- *
- */
- public void windowActivated(IWorkbenchWindow window) {
- if (window == getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && isActivePart()) {
- fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection();
- updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, JavaScriptPlugin.getDefault().getASTProvider().getAST(getInputJavaElement(), ASTProvider.WAIT_NO, getProgressMonitor()));
- }
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
- *
- */
- public void windowDeactivated(IWorkbenchWindow window) {
- if (window == getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && isActivePart())
- removeOccurrenceAnnotations();
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
- *
- */
- public void windowClosed(IWorkbenchWindow window) {
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
- *
- */
- public void windowOpened(IWorkbenchWindow window) {
- }
- }
-
- /**
- * Runner that will toggle folding either instantly (if the editor is
- * visible) or the next time it becomes visible. If a runner is started when
- * there is already one registered, the registered one is canceled as
- * toggling folding twice is a no-op.
- * <p>
- * The access to the fFoldingRunner field is not thread-safe, it is assumed
- * that <code>runWhenNextVisible</code> is only called from the UI thread.
- * </p>
- *
- *
- */
- private final class ToggleFoldingRunner implements IPartListener2 {
- /**
- * The workbench page we registered the part listener with, or
- * <code>null</code>.
- */
- private IWorkbenchPage fPage;
-
- /**
- * Does the actual toggling of projection.
- */
- private void toggleFolding() {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer instanceof ProjectionViewer) {
- ProjectionViewer pv= (ProjectionViewer) sourceViewer;
- if (pv.isProjectionMode() != isFoldingEnabled()) {
- if (pv.canDoOperation(ProjectionViewer.TOGGLE))
- pv.doOperation(ProjectionViewer.TOGGLE);
- }
- }
- }
-
- /**
- * Makes sure that the editor's folding state is correct the next time
- * it becomes visible. If it already is visible, it toggles the folding
- * state. If not, it either registers a part listener to toggle folding
- * when the editor becomes visible, or cancels an already registered
- * runner.
- */
- public void runWhenNextVisible() {
- // if there is one already: toggling twice is the identity
- if (fFoldingRunner != null) {
- fFoldingRunner.cancel();
- return;
- }
- IWorkbenchPartSite site= getSite();
- if (site != null) {
- IWorkbenchPage page= site.getPage();
- if (!page.isPartVisible(JavaEditor.this)) {
- // if we're not visible - defer until visible
- fPage= page;
- fFoldingRunner= this;
- page.addPartListener(this);
- return;
- }
- }
- // we're visible - run now
- toggleFolding();
- }
-
- /**
- * Remove the listener and clear the field.
- */
- private void cancel() {
- if (fPage != null) {
- fPage.removePartListener(this);
- fPage= null;
- }
- if (fFoldingRunner == this)
- fFoldingRunner= null;
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partVisible(IWorkbenchPartReference partRef) {
- if (JavaEditor.this.equals(partRef.getPart(false))) {
- cancel();
- toggleFolding();
- }
- }
-
- /*
- * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partClosed(IWorkbenchPartReference partRef) {
- if (JavaEditor.this.equals(partRef.getPart(false))) {
- cancel();
- }
- }
-
- public void partActivated(IWorkbenchPartReference partRef) {}
- public void partBroughtToTop(IWorkbenchPartReference partRef) {}
- public void partDeactivated(IWorkbenchPartReference partRef) {}
- public void partOpened(IWorkbenchPartReference partRef) {}
- public void partHidden(IWorkbenchPartReference partRef) {}
- public void partInputChanged(IWorkbenchPartReference partRef) {}
- }
-
- /** Preference key for matching brackets */
- protected final static String MATCHING_BRACKETS= PreferenceConstants.EDITOR_MATCHING_BRACKETS;
- /** Preference key for matching brackets color */
- protected final static String MATCHING_BRACKETS_COLOR= PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
-
- protected final static char[] BRACKETS= { '{', '}', '(', ')', '[', ']', '<', '>' };
-
- /** The outline page */
- protected JavaOutlinePage fOutlinePage;
- /** Outliner context menu Id */
- protected String fOutlinerContextMenuId;
- /**
- * The editor selection changed listener.
- *
- *
- */
- private EditorSelectionChangedListener fEditorSelectionChangedListener;
- /** The selection changed listener */
- protected AbstractSelectionChangedListener fOutlineSelectionChangedListener= new OutlineSelectionChangedListener();
- /** The editor's bracket matcher */
- protected JavaPairMatcher fBracketMatcher= new JavaPairMatcher(BRACKETS);
- /** This editor's encoding support */
- private DefaultEncodingSupport fEncodingSupport;
- /** History for structure select action */
- private SelectionHistory fSelectionHistory;
- protected CompositeActionGroup fActionGroups;
-
- /**
- * The action group for folding.
- *
- *
- */
- private FoldingActionGroup fFoldingGroup;
-
- private CompositeActionGroup fContextMenuGroup;
- /**
- * Holds the current occurrence annotations.
- *
- */
- private Annotation[] fOccurrenceAnnotations= null;
- /**
- * Tells whether all occurrences of the element at the
- * current caret location are automatically marked in
- * this editor.
- *
- */
- private boolean fMarkOccurrenceAnnotations;
- /**
- * Tells whether the occurrence annotations are sticky
- * i.e. whether they stay even if there's no valid Java
- * element at the current caret position.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fStickyOccurrenceAnnotations;
- /**
- * Tells whether to mark type occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkTypeOccurrences;
- /**
- * Tells whether to mark method occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkMethodOccurrences;
- /**
- * Tells whether to mark constant occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkConstantOccurrences;
- /**
- * Tells whether to mark field occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkFieldOccurrences;
- /**
- * Tells whether to mark local variable occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkLocalVariableypeOccurrences;
- /**
- * Tells whether to mark exception occurrences in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkExceptions;
- /**
- * Tells whether to mark method exits in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkMethodExitPoints;
-
- /**
- * Tells whether to mark targets of <code>break</code> and <code>continue</code> statements in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkBreakContinueTargets;
-
- /**
- * Tells whether to mark implementors in this editor.
- * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
- *
- */
- private boolean fMarkImplementors;
- /**
- * The selection used when forcing occurrence marking
- * through code.
- *
- */
- private ISelection fForcedMarkOccurrencesSelection;
- /**
- * The document modification stamp at the time when the last
- * occurrence marking took place.
- *
- */
- private long fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
- /**
- * The region of the word under the caret used to when
- * computing the current occurrence markings.
- *
- */
- private IRegion fMarkOccurrenceTargetRegion;
-
- /**
- * The internal shell activation listener for updating occurrences.
- *
- */
- private ActivationListener fActivationListener= new ActivationListener();
- private ISelectionListenerWithAST fPostSelectionListenerWithAST;
- private OccurrencesFinderJob fOccurrencesFinderJob;
- /** The occurrences finder job canceler */
- private OccurrencesFinderJobCanceler fOccurrencesFinderJobCanceler;
- /**
- * This editor's projection support
- *
- */
- private ProjectionSupport fProjectionSupport;
- /**
- * This editor's projection model updater
- *
- */
- private IJavaFoldingStructureProvider fProjectionModelUpdater;
- /**
- * The override and implements indicator manager for this editor.
- *
- */
- protected OverrideIndicatorManager fOverrideIndicatorManager;
- /**
- * Semantic highlighting manager
- * , protected as of 3.3
- */
- protected SemanticHighlightingManager fSemanticManager;
- /**
- * The folding runner.
- *
- */
- private ToggleFoldingRunner fFoldingRunner;
-
- /**
- * Tells whether the selection changed event is caused
- * by a call to {@link #gotoAnnotation(boolean)}.
- *
- *
- */
- private boolean fSelectionChangedViaGotoAnnotation;
- /**
- * The cached selected range.
- *
- * @see ITextViewer#getSelectedRange()
- *
- */
- private Point fCachedSelectedRange;
-
-
- /**
- * Returns the most narrow java element including the given offset.
- *
- * @param offset the offset inside of the requested element
- * @return the most narrow java element
- */
- abstract protected IJavaScriptElement getElementAt(int offset);
-
- /**
- * Returns the java element of this editor's input corresponding to the given IJavaScriptElement.
- *
- * @param element the java element
- * @return the corresponding Java element
- */
- abstract protected IJavaScriptElement getCorrespondingElement(IJavaScriptElement element);
-
- /**
- * Default constructor.
- */
- public JavaEditor() {
- super();
- }
-
- /**
- * Sets the input of the editor's outline page.
- *
- * @param page the Java outline page
- * @param input the editor input
- */
- protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
- if (page == null)
- return;
-
- IJavaScriptElement je= getInputJavaElement();
- if (je != null && je.exists())
- page.setInput(je);
- else
- page.setInput(null);
-
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeKeyBindingScopes()
- */
- protected void initializeKeyBindingScopes() {
- setKeyBindingScopes(new String[] { "org.eclipse.wst.jsdt.ui.javascriptViewScope" }); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
- */
- protected void initializeEditor() {
- IPreferenceStore store= createCombinedPreferenceStore(null);
- setPreferenceStore(store);
- setSourceViewerConfiguration(createJavaSourceViewerConfiguration());
- fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
- fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
- fMarkTypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES);
- fMarkMethodOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES);
- fMarkConstantOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES);
- fMarkFieldOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES);
- fMarkLocalVariableypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES);
- fMarkExceptions= store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES);
- fMarkImplementors= store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS);
- fMarkMethodExitPoints= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS);
- fMarkBreakContinueTargets= store.getBoolean(PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS);
- }
-
- /**
- * Returns a new Java source viewer configuration.
- *
- * @return a new <code>JavaScriptSourceViewerConfiguration</code>
- *
- */
- protected JavaScriptSourceViewerConfiguration createJavaSourceViewerConfiguration() {
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- return new JavaScriptSourceViewerConfiguration(textTools.getColorManager(), getPreferenceStore(), this, IJavaScriptPartitions.JAVA_PARTITIONING);
- }
-
- /*
- * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
- */
- protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
-
- IPreferenceStore store= getPreferenceStore();
- ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
-
- JavaUIHelp.setHelp(this, viewer.getTextWidget(), IJavaHelpContextIds.JAVA_EDITOR);
-
- JavaSourceViewer javaSourceViewer= null;
- if (viewer instanceof JavaSourceViewer)
- javaSourceViewer= (JavaSourceViewer)viewer;
-
- /*
- * This is a performance optimization to reduce the computation of
- * the text presentation triggered by {@link #setVisibleDocument(IDocument)}
- */
- if (javaSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
- javaSourceViewer.prepareDelayedProjection();
-
- ProjectionViewer projectionViewer= (ProjectionViewer)viewer;
- fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
- fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
- fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
- fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell shell) {
- return new SourceViewerInformationControl(shell, SWT.TOOL | SWT.NO_TRIM | getOrientation(), SWT.NONE, EditorsUI.getTooltipAffordanceString());
- }
- });
- fProjectionSupport.setInformationPresenterControlCreator(new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell shell) {
- int shellStyle= SWT.RESIZE | SWT.TOOL | getOrientation();
- int style= SWT.V_SCROLL | SWT.H_SCROLL;
- return new SourceViewerInformationControl(shell, shellStyle, style);
- }
- });
- fProjectionSupport.install();
-
- fProjectionModelUpdater= JavaScriptPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
- if (fProjectionModelUpdater != null)
- fProjectionModelUpdater.install(this, projectionViewer);
-
- // ensure source viewer decoration support has been created and configured
- getSourceViewerDecorationSupport(viewer);
-
- return viewer;
- }
-
- public final ISourceViewer getViewer() {
- return getSourceViewer();
- }
-
- /*
- * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
- */
- protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
- return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
- }
-
- /*
- * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
- */
- protected boolean affectsTextPresentation(PropertyChangeEvent event) {
- return ((JavaScriptSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event) || super.affectsTextPresentation(event);
- }
-
- /**
- * Creates and returns the preference store for this Java editor with the given input.
- *
- * @param input The editor input for which to create the preference store
- * @return the preference store for this editor
- *
- *
- */
- private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
- List stores= new ArrayList(3);
-
- IJavaScriptProject project= EditorUtility.getJavaProject(input);
- if (project != null) {
- stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), JavaScriptCore.PLUGIN_ID));
- }
-
- stores.add(JavaScriptPlugin.getDefault().getPreferenceStore());
- stores.add(new PreferencesAdapter(JavaScriptCore.getPlugin().getPluginPreferences()));
- stores.add(EditorsUI.getPreferenceStore());
-
- return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
- }
-
- /**
- * Sets the outliner's context menu ID.
- *
- * @param menuId the menu ID
- */
- protected void setOutlinerContextMenuId(String menuId) {
- fOutlinerContextMenuId= menuId;
- }
-
- /**
- * Returns the standard action group of this editor.
- *
- * @return returns this editor's standard action group
- */
- protected ActionGroup getActionGroup() {
- return fActionGroups;
- }
-
- /*
- * @see AbstractTextEditor#editorContextMenuAboutToShow
- */
- public void editorContextMenuAboutToShow(IMenuManager menu) {
-
- super.editorContextMenuAboutToShow(menu);
- menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
-
- ActionContext context= new ActionContext(getSelectionProvider().getSelection());
- fContextMenuGroup.setContext(context);
- fContextMenuGroup.fillContextMenu(menu);
- fContextMenuGroup.setContext(null);
-
- // Quick views
- IAction action= getAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
- action= getAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
-
- }
-
- /**
- * Creates the outline page used with this editor.
- *
- * @return the created Java outline page
- */
- protected JavaOutlinePage createOutlinePage() {
- JavaOutlinePage page= new JavaOutlinePage(fOutlinerContextMenuId, this);
- fOutlineSelectionChangedListener.install(page);
- setOutlinePageInput(page, getEditorInput());
- return page;
- }
-
- /**
- * Informs the editor that its outliner has been closed.
- */
- public void outlinePageClosed() {
- if (fOutlinePage != null) {
- fOutlineSelectionChangedListener.uninstall(fOutlinePage);
- fOutlinePage= null;
- resetHighlightRange();
- }
- }
-
- /**
- * Synchronizes the outliner selection with the given element
- * position in the editor.
- *
- * @param element the java element to select
- */
- protected void synchronizeOutlinePage(ISourceReference element) {
- synchronizeOutlinePage(element, true);
- }
-
- /**
- * Synchronizes the outliner selection with the given element
- * position in the editor.
- *
- * @param element the java element to select
- * @param checkIfOutlinePageActive <code>true</code> if check for active outline page needs to be done
- */
- protected void synchronizeOutlinePage(ISourceReference element, boolean checkIfOutlinePageActive) {
- if (fOutlinePage != null && element != null && !(checkIfOutlinePageActive && isJavaOutlinePageActive())) {
- fOutlineSelectionChangedListener.uninstall(fOutlinePage);
- fOutlinePage.select(element);
- fOutlineSelectionChangedListener.install(fOutlinePage);
- }
- }
-
- /**
- * Synchronizes the outliner selection with the actual cursor
- * position in the editor.
- */
- public void synchronizeOutlinePageSelection() {
- synchronizeOutlinePage(computeHighlightRangeSourceReference());
- }
-
- /*
- * @see AbstractTextEditor#getAdapter(Class)
- */
- public Object getAdapter(Class required) {
-
- if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null)
- fOutlinePage= createOutlinePage();
- return fOutlinePage;
- }
-
- if (IEncodingSupport.class.equals(required))
- return fEncodingSupport;
-
- if (required == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
-
- if (required == IShowInSource.class) {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(getEditorInput(), null) {
- /*
- * @see org.eclipse.ui.part.ShowInContext#getSelection()
- *
- */
- public ISelection getSelection() {
- IJavaScriptElement je= null;
- try {
- je= SelectionConverter.getElementAtOffset(JavaEditor.this);
- if (je==null)
- return null;
- return new StructuredSelection(je);
- } catch (JavaScriptModelException ex) {
- return null;
- }
- }
- };
- }
- };
- }
-
- if (required == IJavaFoldingStructureProvider.class)
- return fProjectionModelUpdater;
-
- if (fProjectionSupport != null) {
- Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), required);
- if (adapter != null)
- return adapter;
- }
-
- if (required == IContextProvider.class)
- return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR);
-
- return super.getAdapter(required);
- }
-
- /**
- * React to changed selection.
- *
- *
- */
- protected void selectionChanged() {
- if (getSelectionProvider() == null)
- return;
- ISourceReference element= computeHighlightRangeSourceReference();
- if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
- synchronizeOutlinePage(element);
- setSelection(element, false);
- if (!fSelectionChangedViaGotoAnnotation)
- updateStatusLine();
- fSelectionChangedViaGotoAnnotation= false;
- }
-
- protected void setSelection(ISourceReference reference, boolean moveCursor) {
- if (getSelectionProvider() == null)
- return;
-
- ISelection selection= getSelectionProvider().getSelection();
- if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection) selection;
- // PR 39995: [navigation] Forward history cleared after going back in navigation history:
- // mark only in navigation history if the cursor is being moved (which it isn't if
- // this is called from a PostSelectionEvent that should only update the magnet)
- if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0))
- markInNavigationHistory();
- }
-
- if (reference != null) {
-
- StyledText textWidget= null;
-
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer != null)
- textWidget= sourceViewer.getTextWidget();
-
- if (textWidget == null)
- return;
-
- try {
- ISourceRange range= null;
- if (reference instanceof ILocalVariable) {
- IJavaScriptElement je= ((ILocalVariable)reference).getParent();
- if (je instanceof ISourceReference)
- range= ((ISourceReference)je).getSourceRange();
- } else
- range= reference.getSourceRange();
-
- if (range == null)
- return;
-
- int offset= range.getOffset();
- int length= range.getLength();
-
- if (offset < 0 || length < 0)
- return;
-
- setHighlightRange(offset, length, moveCursor);
-
- if (!moveCursor)
- return;
-
- offset= -1;
- length= -1;
-
- if (reference instanceof IMember) {
- range= ((IMember) reference).getNameRange();
- if (range != null) {
- offset= range.getOffset();
- length= range.getLength();
- }
- } else if (reference instanceof ITypeParameter) {
- range= ((ITypeParameter) reference).getNameRange();
- if (range != null) {
- offset= range.getOffset();
- length= range.getLength();
- }
- } else if (reference instanceof ILocalVariable) {
- range= ((ILocalVariable)reference).getNameRange();
- if (range != null) {
- offset= range.getOffset();
- length= range.getLength();
- }
- } else if (reference instanceof IImportDeclaration) {
- String content= reference.getSource();
- if (content != null) {
- int start= content.indexOf("import") + 6; //$NON-NLS-1$
- while (start < content.length() && content.charAt(start) == ' ')
- start++;
-
- int end= content.indexOf(';');
- do {
- end--;
- } while (end >= 0 && content.charAt(end) == ' ');
-
- offset= range.getOffset() + start;
- length= end - start + 1;
- } else {
- // fallback
- offset= range.getOffset();
- length= range.getLength();
- }
- } else if (reference instanceof IPackageDeclaration) {
- String name= ((IPackageDeclaration) reference).getElementName();
- if (name != null && name.length() > 0) {
- String content= reference.getSource();
- if (content != null) {
- int packageKeyWordIndex = content.lastIndexOf("package"); //$NON-NLS-1$
- if (packageKeyWordIndex != -1) {
- offset= range.getOffset() + content.indexOf(name, packageKeyWordIndex + 7);
- length= name.length();
- }
- }
- }
- }
-
- if (offset > -1 && length > 0) {
-
- try {
- textWidget.setRedraw(false);
- sourceViewer.revealRange(offset, length);
- sourceViewer.setSelectedRange(offset, length);
- } finally {
- textWidget.setRedraw(true);
- }
-
- markInNavigationHistory();
- }
-
- } catch (JavaScriptModelException x) {
- } catch (IllegalArgumentException x) {
- }
-
- } else if (moveCursor) {
- resetHighlightRange();
- markInNavigationHistory();
- }
- }
-
- public void setSelection(IJavaScriptElement element) {
-
- if (element == null || element instanceof IJavaScriptUnit || element instanceof IClassFile) {
- /*
- * If the element is an IJavaScriptUnit this unit is either the input
- * of this editor or not being displayed. In both cases, nothing should
- * happened. (http://dev.eclipse.org/bugs/show_bug.cgi?id=5128)
- */
- return;
- }
-
- IJavaScriptElement corresponding= getCorrespondingElement(element);
- if (corresponding instanceof ISourceReference) {
- ISourceReference reference= (ISourceReference) corresponding;
- // set highlight range
- setSelection(reference, true);
- // set outliner selection
- if (fOutlinePage != null) {
- fOutlineSelectionChangedListener.uninstall(fOutlinePage);
- fOutlinePage.select(reference);
- fOutlineSelectionChangedListener.install(fOutlinePage);
- }
- }
- }
-
- protected void doSelectionChanged(SelectionChangedEvent event) {
-
- ISourceReference reference= null;
-
- ISelection selection= event.getSelection();
- Iterator iter= ((IStructuredSelection) selection).iterator();
- while (iter.hasNext()) {
- Object o= iter.next();
- if (o instanceof ISourceReference) {
- reference= (ISourceReference) o;
- break;
- }
- }
- if (!isActivePart() && JavaScriptPlugin.getActivePage() != null)
- JavaScriptPlugin.getActivePage().bringToTop(this);
-
- setSelection(reference, !isActivePart());
-
- ISelectionProvider selectionProvider= getSelectionProvider();
- if (selectionProvider == null )
- return;
-
- ISelection textSelection= selectionProvider.getSelection();
- if (!(textSelection instanceof ITextSelection))
- return;
-
- JavaScriptUnit ast= JavaScriptPlugin.getDefault().getASTProvider().getAST(getInputJavaElement(), ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor());
- if (ast != null) {
- fForcedMarkOccurrencesSelection= textSelection;
- updateOccurrenceAnnotations((ITextSelection)textSelection, ast);
- }
-
- }
-
- /*
- * @see AbstractTextEditor#adjustHighlightRange(int, int)
- */
- protected void adjustHighlightRange(int offset, int length) {
-
- try {
-
- IJavaScriptElement element= getElementAt(offset, false);
- while (element instanceof ISourceReference) {
- ISourceRange range= ((ISourceReference) element).getSourceRange();
- if (range != null && offset < range.getOffset() + range.getLength() && range.getOffset() < offset + length) {
-
- ISourceViewer viewer= getSourceViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- extension.exposeModelRange(new Region(range.getOffset(), range.getLength()));
- }
-
- setHighlightRange(range.getOffset(), range.getLength(), true);
- if (fOutlinePage != null) {
- fOutlineSelectionChangedListener.uninstall(fOutlinePage);
- fOutlinePage.select((ISourceReference) element);
- fOutlineSelectionChangedListener.install(fOutlinePage);
- }
-
- return;
- }
- element= element.getParent();
- }
-
- } catch (JavaScriptModelException x) {
- JavaScriptPlugin.log(x.getStatus());
- }
-
- ISourceViewer viewer= getSourceViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- extension.exposeModelRange(new Region(offset, length));
- } else {
- resetHighlightRange();
- }
-
- }
-
- protected boolean isActivePart() {
- IWorkbenchPart part= getActivePart();
- return part != null && part.equals(this);
- }
-
- private boolean isJavaOutlinePageActive() {
- IWorkbenchPart part= getActivePart();
- return part instanceof ContentOutline && ((ContentOutline)part).getCurrentPage() == fOutlinePage;
- }
-
- private IWorkbenchPart getActivePart() {
- IWorkbenchWindow window= getSite().getWorkbenchWindow();
- IPartService service= window.getPartService();
- IWorkbenchPart part= service.getActivePart();
- return part;
- }
-
- /*
- * @see StatusTextEditor#getStatusHeader(IStatus)
- */
- protected String getStatusHeader(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusHeader(status);
- if (message != null)
- return message;
- }
- return super.getStatusHeader(status);
- }
-
- /*
- * @see StatusTextEditor#getStatusBanner(IStatus)
- */
- protected String getStatusBanner(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusBanner(status);
- if (message != null)
- return message;
- }
- return super.getStatusBanner(status);
- }
-
- /*
- * @see StatusTextEditor#getStatusMessage(IStatus)
- */
- protected String getStatusMessage(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusMessage(status);
- if (message != null)
- return message;
- }
- return super.getStatusMessage(status);
- }
-
- /*
- * @see AbstractTextEditor#doSetInput
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- ISourceViewer sourceViewer= getSourceViewer();
- if (!(sourceViewer instanceof ISourceViewerExtension2)) {
- setPreferenceStore(createCombinedPreferenceStore(input));
- internalDoSetInput(input);
- return;
- }
-
- // uninstall & unregister preference store listener
- getSourceViewerDecorationSupport(sourceViewer).uninstall();
- ((ISourceViewerExtension2)sourceViewer).unconfigure();
-
- setPreferenceStore(createCombinedPreferenceStore(input));
-
- // install & register preference store listener
- sourceViewer.configure(getSourceViewerConfiguration());
- getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore());
-
- internalDoSetInput(input);
- }
-
- private void internalDoSetInput(IEditorInput input) throws CoreException {
- ISourceViewer sourceViewer= getSourceViewer();
- JavaSourceViewer javaSourceViewer= null;
- if (sourceViewer instanceof JavaSourceViewer)
- javaSourceViewer= (JavaSourceViewer)sourceViewer;
-
- IPreferenceStore store= getPreferenceStore();
- if (javaSourceViewer != null && isFoldingEnabled() &&(store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
- javaSourceViewer.prepareDelayedProjection();
-
- super.doSetInput(input);
-
- if (javaSourceViewer != null && javaSourceViewer.getReconciler() == null) {
- IReconciler reconciler= getSourceViewerConfiguration().getReconciler(javaSourceViewer);
- if (reconciler != null) {
- reconciler.install(javaSourceViewer);
- javaSourceViewer.setReconciler(reconciler);
- }
- }
-
- if (fEncodingSupport != null)
- fEncodingSupport.reset();
-
- setOutlinePageInput(fOutlinePage, input);
-
- if (isShowingOverrideIndicators())
- installOverrideIndicator(false);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)
- *
- */
- protected void setPreferenceStore(IPreferenceStore store) {
- super.setPreferenceStore(store);
- if (getSourceViewerConfiguration() instanceof JavaScriptSourceViewerConfiguration) {
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- setSourceViewerConfiguration(new JavaScriptSourceViewerConfiguration(textTools.getColorManager(), store, this, IJavaScriptPartitions.JAVA_PARTITIONING));
- }
- if (getSourceViewer() instanceof JavaSourceViewer)
- ((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);
- }
-
- /*
- * @see IWorkbenchPart#dispose()
- */
- public void dispose() {
-
- if (fProjectionModelUpdater != null) {
- fProjectionModelUpdater.uninstall();
- fProjectionModelUpdater= null;
- }
-
- if (fProjectionSupport != null) {
- fProjectionSupport.dispose();
- fProjectionSupport= null;
- }
-
- // cancel possible running computation
- fMarkOccurrenceAnnotations= false;
- uninstallOccurrencesFinder();
-
- uninstallOverrideIndicator();
-
- uninstallSemanticHighlighting();
-
- if (fActivationListener != null) {
- PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
- fActivationListener= null;
- }
-
- if (fEncodingSupport != null) {
- fEncodingSupport.dispose();
- fEncodingSupport= null;
- }
-
- if (fBracketMatcher != null) {
- fBracketMatcher.dispose();
- fBracketMatcher= null;
- }
-
- if (fSelectionHistory != null) {
- fSelectionHistory.dispose();
- fSelectionHistory= null;
- }
-
- if (fEditorSelectionChangedListener != null) {
- fEditorSelectionChangedListener.uninstall(getSelectionProvider());
- fEditorSelectionChangedListener= null;
- }
-
- if (fActionGroups != null) {
- fActionGroups.dispose();
- fActionGroups= null;
- }
-
- super.dispose();
- }
-
- protected void createActions() {
- installEncodingSupport();
-
- super.createActions();
-
- ActionGroup oeg, ovg, jsg;
- fActionGroups= new CompositeActionGroup(new ActionGroup[] {
- oeg= new OpenEditorActionGroup(this),
- ovg= new OpenViewActionGroup(this),
- jsg= new JavaSearchActionGroup(this)
- });
- fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {oeg, ovg, jsg});
-
- fFoldingGroup= new FoldingActionGroup(this, getViewer());
-
- Action action= new GotoMatchingBracketAction(this);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
- setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(),"ShowOutline.", this, JavaSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);
- setAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE, action);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.SHOW_OUTLINE_ACTION);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(),"OpenStructure.", this, JavaSourceViewer.OPEN_STRUCTURE, true); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE);
- setAction(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE, action);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.OPEN_STRUCTURE_ACTION);
-
- action= new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(),"OpenHierarchy.", this, JavaSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);
- setAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, action);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.OPEN_HIERARCHY_ACTION);
-
- fSelectionHistory= new SelectionHistory(this);
-
- action= new StructureSelectEnclosingAction(this, fSelectionHistory);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_ENCLOSING);
- setAction(StructureSelectionAction.ENCLOSING, action);
-
- action= new StructureSelectNextAction(this, fSelectionHistory);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT);
- setAction(StructureSelectionAction.NEXT, action);
-
- action= new StructureSelectPreviousAction(this, fSelectionHistory);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_PREVIOUS);
- setAction(StructureSelectionAction.PREVIOUS, action);
-
- StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory);
- historyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST);
- setAction(StructureSelectionAction.HISTORY, historyAction);
- fSelectionHistory.setHistoryAction(historyAction);
-
- action= GoToNextPreviousMemberAction.newGoToNextMemberAction(this);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
- setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
-
- action= GoToNextPreviousMemberAction.newGoToPreviousMemberAction(this);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
- setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
-
- action= new FormatElementAction();
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.QUICK_FORMAT);
- setAction("QuickFormat", action); //$NON-NLS-1$
- markAsStateDependentAction("QuickFormat", true); //$NON-NLS-1$
-
- action= new RemoveOccurrenceAnnotations(this);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
- setAction("RemoveOccurrenceAnnotations", action); //$NON-NLS-1$
-
- // add annotation actions for roll-over expand hover
- action= new JavaSelectMarkerRulerAction2(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
- setAction("AnnotationAction", action); //$NON-NLS-1$
-
- action= new ShowInPackageViewAction(this);
- action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_IN_PACKAGE_VIEW);
- setAction("ShowInPackageView", action); //$NON-NLS-1$
-
-
- // replace cut/copy paste actions with a version that implement 'add imports on paste'
-
- action= new ClipboardOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.Cut.", this, ITextOperationTarget.CUT); //$NON-NLS-1$
- setAction(ITextEditorActionConstants.CUT, action);
-
- action= new ClipboardOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.Copy.", this, ITextOperationTarget.COPY); //$NON-NLS-1$
- setAction(ITextEditorActionConstants.COPY, action);
-
- action= new ClipboardOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.Paste.", this, ITextOperationTarget.PASTE); //$NON-NLS-1$
- setAction(ITextEditorActionConstants.PASTE, action);
-
- action= new CopyQualifiedNameAction(this);
- setAction(IJavaEditorActionConstants.COPY_QUALIFIED_NAME, action);
- }
-
- /**
- * Installs the encoding support on the given text editor.
- * <p>
- * Subclasses may override to install their own encoding
- * support or to disable the default encoding support.
- * </p>
- *
- */
- protected void installEncodingSupport() {
- fEncodingSupport= new DefaultEncodingSupport();
- fEncodingSupport.initialize(this);
- }
-
-
- public void updatedTitleImage(Image image) {
- setTitleImage(image);
- }
-
- /*
- * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
- */
- protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
-
- String property= event.getProperty();
-
- if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
- /*
- * Ignore tab setting since we rely on the formatter preferences.
- * We do this outside the try-finally block to avoid that EDITOR_TAB_WIDTH
- * is handled by the sub-class (AbstractDecoratedTextEditor).
- */
- return;
- }
-
- try {
-
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer == null)
- return;
-
- if (isJavaEditorHoverProperty(property))
- updateHoverBehavior();
-
- boolean newBooleanValue= false;
- Object newValue= event.getNewValue();
- if (newValue != null)
- newBooleanValue= Boolean.valueOf(newValue.toString()).booleanValue();
-
- if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
- if (newBooleanValue)
- selectionChanged();
- return;
- }
-
- if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
- if (newBooleanValue != fMarkOccurrenceAnnotations) {
- fMarkOccurrenceAnnotations= newBooleanValue;
- if (!fMarkOccurrenceAnnotations)
- uninstallOccurrencesFinder();
- else
- installOccurrencesFinder(true);
- }
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES.equals(property)) {
- fMarkTypeOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES.equals(property)) {
- fMarkMethodOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES.equals(property)) {
- fMarkConstantOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES.equals(property)) {
- fMarkFieldOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES.equals(property)) {
- fMarkLocalVariableypeOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES.equals(property)) {
- fMarkExceptions= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS.equals(property)) {
- fMarkMethodExitPoints= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS.equals(property)) {
- fMarkBreakContinueTargets= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_IMPLEMENTORS.equals(property)) {
- fMarkImplementors= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
- fStickyOccurrenceAnnotations= newBooleanValue;
- return;
- }
- if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) {
- if (isSemanticHighlightingEnabled())
- installSemanticHighlighting();
- else
- uninstallSemanticHighlighting();
- return;
- }
-
- if (JavaScriptCore.COMPILER_SOURCE.equals(property)) {
- if (event.getNewValue() instanceof String)
- fBracketMatcher.setSourceVersion((String) event.getNewValue());
- // fall through as others are interested in source change as well.
- }
-
- ((JavaScriptSourceViewerConfiguration)getSourceViewerConfiguration()).handlePropertyChangeEvent(event);
-
- if (affectsOverrideIndicatorAnnotations(event)) {
- if (isShowingOverrideIndicators()) {
- if (fOverrideIndicatorManager == null)
- installOverrideIndicator(true);
- } else {
- if (fOverrideIndicatorManager != null)
- uninstallOverrideIndicator();
- }
- return;
- }
-
- if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
- if (sourceViewer instanceof ProjectionViewer) {
- ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
- if (fProjectionModelUpdater != null)
- fProjectionModelUpdater.uninstall();
- // either freshly enabled or provider changed
- fProjectionModelUpdater= JavaScriptPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
- if (fProjectionModelUpdater != null) {
- fProjectionModelUpdater.install(this, projectionViewer);
- }
- }
- return;
- }
-
- if (DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)
- || DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(property)
- || DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)) {
- StyledText textWidget= sourceViewer.getTextWidget();
- int tabWidth= getSourceViewerConfiguration().getTabWidth(sourceViewer);
- if (textWidget.getTabs() != tabWidth)
- textWidget.setTabs(tabWidth);
- return;
- }
-
- if (PreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) {
- if (sourceViewer instanceof ProjectionViewer) {
- new ToggleFoldingRunner().runWhenNextVisible();
- }
- return;
- }
-
- } finally {
- super.handlePreferenceStoreChanged(event);
- }
-
- if (AbstractDecoratedTextEditorPreferenceConstants.SHOW_RANGE_INDICATOR.equals(property)) {
- // superclass already installed the range indicator
- Object newValue= event.getNewValue();
- ISourceViewer viewer= getSourceViewer();
- if (newValue != null && viewer != null) {
- if (Boolean.valueOf(newValue.toString()).booleanValue()) {
- // adjust the highlightrange in order to get the magnet right after changing the selection
- Point selection= viewer.getSelectedRange();
- adjustHighlightRange(selection.x, selection.y);
- }
- }
-
- }
- }
-
- /**
- * Initializes the given viewer's colors.
- *
- * @param viewer the viewer to be initialized
- *
- */
- protected void initializeViewerColors(ISourceViewer viewer) {
- // is handled by JavaSourceViewer
- }
-
- private boolean isJavaEditorHoverProperty(String property) {
- return PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
- */
- protected void updatePropertyDependentActions() {
- super.updatePropertyDependentActions();
- if (fEncodingSupport != null)
- fEncodingSupport.reset();
- }
-
- /*
- * Update the hovering behavior depending on the preferences.
- */
- private void updateHoverBehavior() {
- SourceViewerConfiguration configuration= getSourceViewerConfiguration();
- String[] types= configuration.getConfiguredContentTypes(getSourceViewer());
-
- for (int i= 0; i < types.length; i++) {
-
- String t= types[i];
-
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer instanceof ITextViewerExtension2) {
- // Remove existing hovers
- ((ITextViewerExtension2)sourceViewer).removeTextHovers(t);
-
- int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
-
- if (stateMasks != null) {
- for (int j= 0; j < stateMasks.length; j++) {
- int stateMask= stateMasks[j];
- ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask);
- ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask);
- }
- } else {
- ITextHover textHover= configuration.getTextHover(sourceViewer, t);
- ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
- } else
- sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- return getEditorInput().getAdapter(IJavaScriptElement.class);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetSelection(ISelection)
- */
- protected void doSetSelection(ISelection selection) {
- super.doSetSelection(selection);
- synchronizeOutlinePageSelection();
- }
-
- boolean isFoldingEnabled() {
- return JavaScriptPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
- }
-
- /*
- * @see org.eclipse.ui.part.WorkbenchPart#getOrientation()
- *
- */
- public int getOrientation() {
- return SWT.LEFT_TO_RIGHT; //Java editors are always left to right by default
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
-
- fEditorSelectionChangedListener= new EditorSelectionChangedListener();
- fEditorSelectionChangedListener.install(getSelectionProvider());
-
- if (isSemanticHighlightingEnabled())
- installSemanticHighlighting();
-
- PlatformUI.getWorkbench().addWindowListener(fActivationListener);
- }
-
- protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
-
- fBracketMatcher.setSourceVersion(getPreferenceStore().getString(JavaScriptCore.COMPILER_SOURCE));
- support.setCharacterPairMatcher(fBracketMatcher);
- support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
-
- super.configureSourceViewerDecorationSupport(support);
- }
-
- /**
- * Returns the lock object for the given annotation model.
- *
- * @param annotationModel the annotation model
- * @return the annotation model's lock object
- *
- */
- private Object getLockObject(IAnnotationModel annotationModel) {
- if (annotationModel instanceof ISynchronizable) {
- Object lock= ((ISynchronizable)annotationModel).getLockObject();
- if (lock != null)
- return lock;
- }
- return annotationModel;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#updateMarkerViews(org.eclipse.jface.text.source.Annotation)
- *
- */
- protected void updateMarkerViews(Annotation annotation) {
- if (annotation instanceof IJavaAnnotation) {
- Iterator e= ((IJavaAnnotation) annotation).getOverlaidIterator();
- if (e != null) {
- while (e.hasNext()) {
- Object o= e.next();
- if (o instanceof MarkerAnnotation) {
- super.updateMarkerViews((MarkerAnnotation)o);
- return;
- }
- }
- }
- return;
- }
- super.updateMarkerViews(annotation);
- }
-
- /**
- * Finds and marks occurrence annotations.
- *
- *
- */
- class OccurrencesFinderJob extends Job {
-
- private IDocument fDocument;
- private ISelection fSelection;
- private ISelectionValidator fPostSelectionValidator;
- private boolean fCanceled= false;
- private IProgressMonitor fProgressMonitor;
- private Position[] fPositions;
-
- public OccurrencesFinderJob(IDocument document, Position[] positions, ISelection selection) {
- super(JavaEditorMessages.JavaEditor_markOccurrences_job_name);
- fDocument= document;
- fSelection= selection;
- fPositions= positions;
-
- if (getSelectionProvider() instanceof ISelectionValidator)
- fPostSelectionValidator= (ISelectionValidator)getSelectionProvider();
- }
-
- // cannot use cancel() because it is declared final
- void doCancel() {
- fCanceled= true;
- cancel();
- }
-
- private boolean isCanceled() {
- return fCanceled || fProgressMonitor.isCanceled()
- || fPostSelectionValidator != null && !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection)
- || LinkedModeModel.hasInstalledModel(fDocument);
- }
-
- /*
- * @see Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus run(IProgressMonitor progressMonitor) {
-
- fProgressMonitor= progressMonitor;
-
- if (isCanceled())
- return Status.CANCEL_STATUS;
-
- ITextViewer textViewer= getViewer();
- if (textViewer == null)
- return Status.CANCEL_STATUS;
-
- IDocument document= textViewer.getDocument();
- if (document == null)
- return Status.CANCEL_STATUS;
-
- IDocumentProvider documentProvider= getDocumentProvider();
- if (documentProvider == null)
- return Status.CANCEL_STATUS;
-
- IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
- if (annotationModel == null)
- return Status.CANCEL_STATUS;
-
- // Add occurrence annotations
- int length= fPositions.length;
- Map annotationMap= new HashMap(length);
- for (int i= 0; i < length; i++) {
-
- if (isCanceled())
- return Status.CANCEL_STATUS;
-
- String message;
- Position position= fPositions[i];
-
- // Create & add annotation
- try {
- message= document.get(position.offset, position.length);
- } catch (BadLocationException ex) {
- // Skip this match
- continue;
- }
- annotationMap.put(
- new Annotation("org.eclipse.wst.jsdt.ui.occurrences", false, message), //$NON-NLS-1$
- position);
- }
-
- if (isCanceled())
- return Status.CANCEL_STATUS;
-
- synchronized (getLockObject(annotationModel)) {
- if (annotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
- } else {
- removeOccurrenceAnnotations();
- Iterator iter= annotationMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry mapEntry= (Map.Entry)iter.next();
- annotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue());
- }
- }
- fOccurrenceAnnotations= (Annotation[])annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
- }
-
- return Status.OK_STATUS;
- }
- }
-
- /**
- * Updates the occurrences annotations based
- * on the current selection.
- *
- * @param selection the text selection
- * @param astRoot the compilation unit AST
- *
- */
- protected void updateOccurrenceAnnotations(ITextSelection selection, JavaScriptUnit astRoot) {
-
- if (fOccurrencesFinderJob != null)
- fOccurrencesFinderJob.cancel();
-
- if (!fMarkOccurrenceAnnotations)
- return;
-
- if (astRoot == null || selection == null)
- return;
-
- IDocument document= getSourceViewer().getDocument();
- if (document == null)
- return;
-
- if (document instanceof IDocumentExtension4) {
- int offset= selection.getOffset();
- long currentModificationStamp= ((IDocumentExtension4)document).getModificationStamp();
- IRegion markOccurrenceTargetRegion= fMarkOccurrenceTargetRegion;
- if (markOccurrenceTargetRegion != null && currentModificationStamp == fMarkOccurrenceModificationStamp) {
- if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
- return;
- }
- fMarkOccurrenceTargetRegion= JavaWordFinder.findWord(document, offset);
- fMarkOccurrenceModificationStamp= currentModificationStamp;
- }
-
- List matches= null;
-
- ASTNode selectedNode= NodeFinder.perform(astRoot, selection.getOffset(), selection.getLength());
-
- if (fMarkExceptions || fMarkTypeOccurrences) {
- ExceptionOccurrencesFinder exceptionFinder= new ExceptionOccurrencesFinder();
- String message= exceptionFinder.initialize(astRoot, selectedNode);
- if (message == null) {
- matches= exceptionFinder.perform();
- if (!fMarkExceptions && !matches.isEmpty())
- matches.clear();
- }
- }
-
- if ((matches == null || matches.isEmpty()) && (fMarkMethodExitPoints || fMarkTypeOccurrences)) {
- MethodExitsFinder finder= new MethodExitsFinder();
- String message= finder.initialize(astRoot, selectedNode);
- if (message == null) {
- matches= finder.perform();
- if (!fMarkMethodExitPoints && !matches.isEmpty())
- matches.clear();
- }
- }
-
- if ((matches == null || matches.isEmpty()) && (fMarkBreakContinueTargets || fMarkTypeOccurrences)) {
- BreakContinueTargetFinder finder= new BreakContinueTargetFinder();
- String message= finder.initialize(astRoot, selectedNode);
- if (message == null) {
- matches= finder.perform();
- if (!fMarkBreakContinueTargets && !matches.isEmpty())
- matches.clear();
- }
- }
-
- if ((matches == null || matches.isEmpty()) && (fMarkImplementors || fMarkTypeOccurrences)) {
- ImplementOccurrencesFinder finder= new ImplementOccurrencesFinder();
- String message= finder.initialize(astRoot, selectedNode);
- if (message == null) {
- matches= finder.perform();
- if (!fMarkImplementors && !matches.isEmpty())
- matches.clear();
- }
- }
-
- if (matches == null) {
- IBinding binding= null;
- if (selectedNode instanceof Name)
- binding= ((Name)selectedNode).resolveBinding();
-
- if (binding != null && markOccurrencesOfType(binding)) {
- // Find the matches && extract positions so we can forget the AST
- OccurrencesFinder finder = new OccurrencesFinder(binding);
- String message= finder.initialize(astRoot, selectedNode);
- if (message == null)
- matches= finder.perform();
- }
- }
-
- if (matches == null || matches.size() == 0) {
- if (!fStickyOccurrenceAnnotations)
- removeOccurrenceAnnotations();
- return;
- }
-
- Position[] positions= new Position[matches.size()];
- int i= 0;
- for (Iterator each= matches.iterator(); each.hasNext();) {
- ASTNode currentNode= (ASTNode)each.next();
- positions[i++]= new Position(currentNode.getStartPosition(), currentNode.getLength());
- }
-
- fOccurrencesFinderJob= new OccurrencesFinderJob(document, positions, selection);
- //fOccurrencesFinderJob.setPriority(Job.DECORATE);
- //fOccurrencesFinderJob.setSystem(true);
- //fOccurrencesFinderJob.schedule();
- fOccurrencesFinderJob.run(new NullProgressMonitor());
- }
-
- protected void installOccurrencesFinder(boolean forceUpdate) {
- fMarkOccurrenceAnnotations= true;
-
- fPostSelectionListenerWithAST= new ISelectionListenerWithAST() {
- public void selectionChanged(IEditorPart part, ITextSelection selection, JavaScriptUnit astRoot) {
- updateOccurrenceAnnotations(selection, astRoot);
- }
- };
- SelectionListenerWithASTManager.getDefault().addListener(this, fPostSelectionListenerWithAST);
- if (forceUpdate && getSelectionProvider() != null) {
- fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection();
- updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, JavaScriptPlugin.getDefault().getASTProvider().getAST(getInputJavaElement(), ASTProvider.WAIT_NO, getProgressMonitor()));
- }
-
- if (fOccurrencesFinderJobCanceler == null) {
- fOccurrencesFinderJobCanceler= new OccurrencesFinderJobCanceler();
- fOccurrencesFinderJobCanceler.install();
- }
- }
-
- protected void uninstallOccurrencesFinder() {
- fMarkOccurrenceAnnotations= false;
-
- if (fOccurrencesFinderJob != null) {
- fOccurrencesFinderJob.cancel();
- fOccurrencesFinderJob= null;
- }
-
- if (fOccurrencesFinderJobCanceler != null) {
- fOccurrencesFinderJobCanceler.uninstall();
- fOccurrencesFinderJobCanceler= null;
- }
-
- if (fPostSelectionListenerWithAST != null) {
- SelectionListenerWithASTManager.getDefault().removeListener(this, fPostSelectionListenerWithAST);
- fPostSelectionListenerWithAST= null;
- }
-
- removeOccurrenceAnnotations();
- }
-
- protected boolean isMarkingOccurrences() {
- IPreferenceStore store= getPreferenceStore();
- return store != null && store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
- }
-
- boolean markOccurrencesOfType(IBinding binding) {
-
- if (binding == null)
- return false;
-
- int kind= binding.getKind();
-
- if (fMarkTypeOccurrences && kind == IBinding.TYPE)
- return true;
-
- if (fMarkMethodOccurrences && kind == IBinding.METHOD)
- return true;
-
- if (kind == IBinding.VARIABLE) {
- IVariableBinding variableBinding= (IVariableBinding)binding;
- if (variableBinding.isField()) {
- int constantModifier= IModifierConstants.ACC_STATIC | IModifierConstants.ACC_FINAL;
- boolean isConstant= (variableBinding.getModifiers() & constantModifier) == constantModifier;
- if (isConstant)
- return fMarkConstantOccurrences;
- else
- return fMarkFieldOccurrences;
- }
-
- return fMarkLocalVariableypeOccurrences;
- }
-
- return false;
- }
-
- void removeOccurrenceAnnotations() {
- fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
- fMarkOccurrenceTargetRegion= null;
-
- IDocumentProvider documentProvider= getDocumentProvider();
- if (documentProvider == null)
- return;
-
- IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
- if (annotationModel == null || fOccurrenceAnnotations == null)
- return;
-
- synchronized (getLockObject(annotationModel)) {
- if (annotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
- } else {
- for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
- annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
- }
- fOccurrenceAnnotations= null;
- }
- }
-
- protected void uninstallOverrideIndicator() {
- if (fOverrideIndicatorManager != null) {
- fOverrideIndicatorManager.removeAnnotations();
- fOverrideIndicatorManager= null;
- }
- }
-
- protected void installOverrideIndicator(boolean provideAST) {
- uninstallOverrideIndicator();
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
- final IJavaScriptElement inputElement= getInputJavaElement();
-
- if (model == null || inputElement == null)
- return;
-
- fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, null);
-
- if (provideAST) {
- JavaScriptUnit ast= JavaScriptPlugin.getDefault().getASTProvider().getAST(inputElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor());
- fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor());
- }
- }
-
- /**
- * Tells whether override indicators are shown.
- *
- * @return <code>true</code> if the override indicators are shown
- *
- */
- protected boolean isShowingOverrideIndicators() {
- AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
- IPreferenceStore store= getPreferenceStore();
- return getBoolean(store, preference.getHighlightPreferenceKey())
- || getBoolean(store, preference.getVerticalRulerPreferenceKey())
- || getBoolean(store, preference.getOverviewRulerPreferenceKey())
- || getBoolean(store, preference.getTextPreferenceKey());
- }
-
- /**
- * Returns the boolean preference for the given key.
- *
- * @param store the preference store
- * @param key the preference key
- * @return <code>true</code> if the key exists in the store and its value is <code>true</code>
- *
- */
- private boolean getBoolean(IPreferenceStore store, String key) {
- return key != null && store.getBoolean(key);
- }
-
- /**
- * Determines whether the preference change encoded by the given event
- * changes the override indication.
- *
- * @param event the event to be investigated
- * @return <code>true</code> if event causes a change
- *
- */
- protected boolean affectsOverrideIndicatorAnnotations(PropertyChangeEvent event) {
- String key= event.getProperty();
- AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
- if (key == null || preference == null)
- return false;
-
- return key.equals(preference.getHighlightPreferenceKey())
- || key.equals(preference.getVerticalRulerPreferenceKey())
- || key.equals(preference.getOverviewRulerPreferenceKey())
- || key.equals(preference.getTextPreferenceKey());
- }
-
- /**
- * @return <code>true</code> if Semantic Highlighting is enabled.
- *
- *
- */
- private boolean isSemanticHighlightingEnabled() {
- return SemanticHighlightings.isEnabled(getPreferenceStore());
- }
-
- /**
- * Install Semantic Highlighting.
- *
- *
- */
- private void installSemanticHighlighting() {
- if (fSemanticManager == null) {
- fSemanticManager= new SemanticHighlightingManager();
- fSemanticManager.install(this, (JavaSourceViewer) getSourceViewer(), JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), getPreferenceStore());
- }
- }
-
- /**
- * Uninstall Semantic Highlighting.
- *
- *
- */
- private void uninstallSemanticHighlighting() {
- if (fSemanticManager != null) {
- fSemanticManager.uninstall();
- fSemanticManager= null;
- }
- }
-
- /**
- * Returns the Java element wrapped by this editors input.
- *
- * @return the Java element wrapped by this editors input.
- *
- */
- protected IJavaScriptElement getInputJavaElement() {
- return EditorUtility.getEditorInputJavaElement(this, false);
- }
-
- protected void updateStatusLine() {
- ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
- Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
- setStatusLineErrorMessage(null);
- setStatusLineMessage(null);
- if (annotation != null) {
- updateMarkerViews(annotation);
- if (annotation instanceof IJavaAnnotation && ((IJavaAnnotation) annotation).isProblem())
- setStatusLineMessage(annotation.getText());
- }
- }
-
- /**
- * Jumps to the matching bracket.
- */
- public void gotoMatchingBracket() {
-
- ISourceViewer sourceViewer= getSourceViewer();
- IDocument document= sourceViewer.getDocument();
- if (document == null)
- return;
-
- IRegion selection= getSignedSelection(sourceViewer);
-
- int selectionLength= Math.abs(selection.getLength());
- if (selectionLength > 1) {
- setStatusLineErrorMessage(JavaEditorMessages.GotoMatchingBracket_error_invalidSelection);
- sourceViewer.getTextWidget().getDisplay().beep();
- return;
- }
-
- // #26314
- int sourceCaretOffset= selection.getOffset() + selection.getLength();
- if (isSurroundedByBrackets(document, sourceCaretOffset))
- sourceCaretOffset -= selection.getLength();
-
- IRegion region= fBracketMatcher.match(document, sourceCaretOffset);
- if (region == null) {
- setStatusLineErrorMessage(JavaEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
- sourceViewer.getTextWidget().getDisplay().beep();
- return;
- }
-
- int offset= region.getOffset();
- int length= region.getLength();
-
- if (length < 1)
- return;
-
- int anchor= fBracketMatcher.getAnchor();
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
- int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
-
- boolean visible= false;
- if (sourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
- visible= (extension.modelOffset2WidgetOffset(targetOffset) > -1);
- } else {
- IRegion visibleRegion= sourceViewer.getVisibleRegion();
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
- visible= (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
- }
-
- if (!visible) {
- setStatusLineErrorMessage(JavaEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
- sourceViewer.getTextWidget().getDisplay().beep();
- return;
- }
-
- if (selection.getLength() < 0)
- targetOffset -= selection.getLength();
-
- sourceViewer.setSelectedRange(targetOffset, selection.getLength());
- sourceViewer.revealRange(targetOffset, selection.getLength());
- }
-
- /**
- * Returns the signed current selection.
- * The length will be negative if the resulting selection
- * is right-to-left (RtoL).
- * <p>
- * The selection offset is model based.
- * </p>
- *
- * @param sourceViewer the source viewer
- * @return a region denoting the current signed selection, for a resulting RtoL selections length is < 0
- */
- protected IRegion getSignedSelection(ISourceViewer sourceViewer) {
- StyledText text= sourceViewer.getTextWidget();
- Point selection= text.getSelectionRange();
-
- if (text.getCaretOffset() == selection.x) {
- selection.x= selection.x + selection.y;
- selection.y= -selection.y;
- }
-
- selection.x= widgetOffset2ModelOffset(sourceViewer, selection.x);
-
- return new Region(selection.x, selection.y);
- }
-
- /**
- * Returns the cached selected range, which allows
- * to query it from a non-UI thread.
- * <p>
- * The result might be outdated if queried from a non-UI thread.</em></p>
- *
- * @return the caret offset in the master document
- * @see ITextViewer#getSelectedRange()
- *
- */
- public Point getCachedSelectedRange() {
- return fCachedSelectedRange;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleCursorPositionChanged()
- *
- */
- protected void handleCursorPositionChanged() {
- super.handleCursorPositionChanged();
- fCachedSelectedRange= getViewer().getSelectedRange();
- }
-
- private static boolean isBracket(char character) {
- for (int i= 0; i != BRACKETS.length; ++i)
- if (character == BRACKETS[i])
- return true;
- return false;
- }
-
- private static boolean isSurroundedByBrackets(IDocument document, int offset) {
- if (offset == 0 || offset == document.getLength())
- return false;
-
- try {
- return
- isBracket(document.getChar(offset - 1)) &&
- isBracket(document.getChar(offset));
-
- } catch (BadLocationException e) {
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Overrides the default implementation to handle {@link IJavaAnnotation}.
- * </p>
- *
- * @param offset the region offset
- * @param length the region length
- * @param forward <code>true</code> for forwards, <code>false</code> for backward
- * @param annotationPosition the position of the found annotation
- * @return the found annotation
- *
- */
- protected Annotation findAnnotation(final int offset, final int length, boolean forward, Position annotationPosition) {
-
- Annotation nextAnnotation= null;
- Position nextAnnotationPosition= null;
- Annotation containingAnnotation= null;
- Position containingAnnotationPosition= null;
- boolean currentAnnotation= false;
-
- IDocument document= getDocumentProvider().getDocument(getEditorInput());
- int endOfDocument= document.getLength();
- int distance= Integer.MAX_VALUE;
-
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
- Iterator e= new JavaAnnotationIterator(model, true, true);
- while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
- if ((a instanceof IJavaAnnotation) && ((IJavaAnnotation)a).hasOverlay() || !isNavigationTarget(a))
- continue;
-
- Position p= model.getPosition(a);
- if (p == null)
- continue;
-
- if (forward && p.offset == offset || !forward && p.offset + p.getLength() == offset + length) {// || p.includes(offset)) {
- if (containingAnnotation == null || (forward && p.length >= containingAnnotationPosition.length || !forward && p.length >= containingAnnotationPosition.length)) {
- containingAnnotation= a;
- containingAnnotationPosition= p;
- currentAnnotation= p.length == length;
- }
- } else {
- int currentDistance= 0;
-
- if (forward) {
- currentDistance= p.getOffset() - offset;
- if (currentDistance < 0)
- currentDistance= endOfDocument + currentDistance;
-
- if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
- distance= currentDistance;
- nextAnnotation= a;
- nextAnnotationPosition= p;
- }
- } else {
- currentDistance= offset + length - (p.getOffset() + p.length);
- if (currentDistance < 0)
- currentDistance= endOfDocument + currentDistance;
-
- if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
- distance= currentDistance;
- nextAnnotation= a;
- nextAnnotationPosition= p;
- }
- }
- }
- }
- if (containingAnnotationPosition != null && (!currentAnnotation || nextAnnotation == null)) {
- annotationPosition.setOffset(containingAnnotationPosition.getOffset());
- annotationPosition.setLength(containingAnnotationPosition.getLength());
- return containingAnnotation;
- }
- if (nextAnnotationPosition != null) {
- annotationPosition.setOffset(nextAnnotationPosition.getOffset());
- annotationPosition.setLength(nextAnnotationPosition.getLength());
- }
-
- return nextAnnotation;
- }
-
- /**
- * Returns the annotation overlapping with the given range or <code>null</code>.
- *
- * @param offset the region offset
- * @param length the region length
- * @return the found annotation or <code>null</code>
- *
- */
- private Annotation getAnnotation(int offset, int length) {
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
- Iterator e= new JavaAnnotationIterator(model, true, false);
- while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
- Position p= model.getPosition(a);
- if (p != null && p.overlapsWith(offset, length))
- return a;
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#gotoAnnotation(boolean)
- *
- */
- public Annotation gotoAnnotation(boolean forward) {
- fSelectionChangedViaGotoAnnotation= true;
- return super.gotoAnnotation(forward);
- }
-
- /**
- * Computes and returns the source reference that includes the caret and
- * serves as provider for the outline page selection and the editor range
- * indication.
- *
- * @return the computed source reference
- *
- */
- protected ISourceReference computeHighlightRangeSourceReference() {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer == null)
- return null;
-
- StyledText styledText= sourceViewer.getTextWidget();
- if (styledText == null)
- return null;
-
- int caret= 0;
- if (sourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)sourceViewer;
- caret= extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
- } else {
- int offset= sourceViewer.getVisibleRegion().getOffset();
- caret= offset + styledText.getCaretOffset();
- }
-
- IJavaScriptElement element= getElementAt(caret, false);
-
- if ( !(element instanceof ISourceReference))
- return null;
-
- if (element.getElementType() == IJavaScriptElement.IMPORT_DECLARATION) {
-
- IImportDeclaration declaration= (IImportDeclaration) element;
- IImportContainer container= (IImportContainer) declaration.getParent();
- ISourceRange srcRange= null;
-
- try {
- srcRange= container.getSourceRange();
- } catch (JavaScriptModelException e) {
- }
-
- if (srcRange != null && srcRange.getOffset() == caret)
- return container;
- }
-
- return (ISourceReference) element;
- }
-
- /**
- * Returns the most narrow java element including the given offset.
- *
- * @param offset the offset inside of the requested element
- * @param reconcile <code>true</code> if editor input should be reconciled in advance
- * @return the most narrow java element
- *
- */
- protected IJavaScriptElement getElementAt(int offset, boolean reconcile) {
- return getElementAt(offset);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createChangeHover()
- */
- protected LineChangeHover createChangeHover() {
- return new JavaChangeHover(IJavaScriptPartitions.JAVA_PARTITIONING, getOrientation());
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#createNavigationActions()
- */
- protected void createNavigationActions() {
- super.createNavigationActions();
-
- final StyledText textWidget= getSourceViewer().getTextWidget();
-
- IAction action= new SmartLineStartAction(textWidget, false);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_START);
- setAction(ITextEditorActionDefinitionIds.LINE_START, action);
-
- action= new SmartLineStartAction(textWidget, true);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_START);
- setAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, action);
-
- action= new NavigatePreviousSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
- setAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_LEFT, SWT.NULL);
-
- action= new NavigateNextSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_NEXT);
- setAction(ITextEditorActionDefinitionIds.WORD_NEXT, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_RIGHT, SWT.NULL);
-
- action= new SelectPreviousSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS);
- setAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_LEFT, SWT.NULL);
-
- action= new SelectNextSubWordAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT);
- setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action);
- textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createAnnotationRulerColumn(org.eclipse.jface.text.source.CompositeRuler)
- *
- */
- protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) {
- if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
- return super.createAnnotationRulerColumn(ruler);
-
- AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
- column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- // for now: just invoke ruler double click action
- triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
- }
-
- private void triggerAction(String actionID) {
- IAction action= getAction(actionID);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- // hack to propagate line change
- if (action instanceof ISelectionListener) {
- ((ISelectionListener)action).selectionChanged(null, null);
- }
- if (action.isEnabled())
- action.run();
- }
- }
-
- }));
-
- return column;
- }
-
- /**
- * Returns the folding action group, or <code>null</code> if there is none.
- *
- * @return the folding action group, or <code>null</code> if there is none
- *
- */
- protected FoldingActionGroup getFoldingActionGroup() {
- return fFoldingGroup;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#performRevert()
- */
- protected void performRevert() {
- ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
- projectionViewer.setRedraw(false);
- try {
-
- boolean projectionMode= projectionViewer.isProjectionMode();
- if (projectionMode) {
- projectionViewer.disableProjection();
- if (fProjectionModelUpdater != null)
- fProjectionModelUpdater.uninstall();
- }
-
- super.performRevert();
-
- if (projectionMode) {
- if (fProjectionModelUpdater != null)
- fProjectionModelUpdater.install(this, projectionViewer);
- projectionViewer.enableProjection();
- }
-
- } finally {
- projectionViewer.setRedraw(true);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- protected void rulerContextMenuAboutToShow(IMenuManager menu) {
- super.rulerContextMenuAboutToShow(menu);
- IMenuManager foldingMenu= new MenuManager(JavaEditorMessages.Editor_FoldingMenu_name, "projection"); //$NON-NLS-1$
- menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
-
- IAction action= getAction("FoldingToggle"); //$NON-NLS-1$
- foldingMenu.add(action);
- action= getAction("FoldingExpandAll"); //$NON-NLS-1$
- foldingMenu.add(action);
- action= getAction("FoldingCollapseAll"); //$NON-NLS-1$
- foldingMenu.add(action);
- action= getAction("FoldingRestore"); //$NON-NLS-1$
- foldingMenu.add(action);
- action= getAction("FoldingCollapseMembers"); //$NON-NLS-1$
- foldingMenu.add(action);
- action= getAction("FoldingCollapseComments"); //$NON-NLS-1$
- foldingMenu.add(action);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages()
- *
- */
- protected String[] collectContextMenuPreferencePages() {
- String[] inheritedPages= super.collectContextMenuPreferencePages();
- int length= 10;
- String[] result= new String[inheritedPages.length + length];
- result[0]= "org.eclipse.wst.jsdt.ui.preferences.JavaEditorPreferencePage"; //$NON-NLS-1$
- result[1]= "org.eclipse.wst.jsdt.ui.preferences.JavaTemplatePreferencePage"; //$NON-NLS-1$
- result[2]= "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
- result[3]= "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferenceAdvanced"; //$NON-NLS-1$
- result[4]= "org.eclipse.wst.jsdt.ui.preferences.JavaEditorHoverPreferencePage"; //$NON-NLS-1$
- result[5]= "org.eclipse.wst.jsdt.ui.preferences.JavaEditorColoringPreferencePage"; //$NON-NLS-1$
- result[6]= "org.eclipse.wst.jsdt.ui.preferences.FoldingPreferencePage"; //$NON-NLS-1$
- result[7]= "org.eclipse.wst.jsdt.ui.preferences.MarkOccurrencesPreferencePage"; //$NON-NLS-1$
- result[8]= "org.eclipse.wst.jsdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$
- result[9]= "org.eclipse.wst.jsdt.ui.preferences.SaveParticipantPreferencePage"; //$NON-NLS-1$
- System.arraycopy(inheritedPages, 0, result, length, inheritedPages.length);
- return result;
- }
-
- /*
- * @see AbstractTextEditor#getUndoRedoOperationApprover(IUndoContext)
- *
- */
- protected IOperationApprover getUndoRedoOperationApprover(IUndoContext undoContext) {
- // since IResource is a more general way to compare java elements, we
- // use this as the preferred class for comparing objects.
- return new NonLocalUndoUserApprover(undoContext, this, new Object [] { getInputJavaElement() }, IResource.class);
- }
-
- /**
- * Resets the foldings structure according to the folding
- * preferences.
- *
- *
- */
- public void resetProjection() {
- if (fProjectionModelUpdater != null) {
- fProjectionModelUpdater.initialize();
- }
- }
-
- /**
- * Collapses all foldable members if supported by the folding
- * structure provider.
- *
- *
- */
- public void collapseMembers() {
- if (fProjectionModelUpdater instanceof IJavaFoldingStructureProviderExtension) {
- IJavaFoldingStructureProviderExtension extension= (IJavaFoldingStructureProviderExtension) fProjectionModelUpdater;
- extension.collapseMembers();
- }
- }
-
- /**
- * Collapses all foldable comments if supported by the folding
- * structure provider.
- *
- *
- */
- public void collapseComments() {
- if (fProjectionModelUpdater instanceof IJavaFoldingStructureProviderExtension) {
- IJavaFoldingStructureProviderExtension extension= (IJavaFoldingStructureProviderExtension) fProjectionModelUpdater;
- extension.collapseComments();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java
deleted file mode 100644
index feb21c73..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.IProblemChangedListener;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator;
-
-/**
- * The <code>JavaEditorErrorTickUpdater</code> will register as a IProblemChangedListener
- * to listen on problem changes of the editor's input. It updates the title images when the annotation
- * model changed.
- */
-public class JavaEditorErrorTickUpdater implements IProblemChangedListener {
-
- private JavaEditor fJavaEditor;
- private JavaUILabelProvider fLabelProvider;
-
- public JavaEditorErrorTickUpdater(JavaEditor editor) {
- Assert.isNotNull(editor);
- fJavaEditor= editor;
- fLabelProvider= new JavaUILabelProvider(0, JavaElementImageProvider.SMALL_ICONS);
- fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
- JavaScriptPlugin.getDefault().getProblemMarkerManager().addListener(this);
- }
-
- /* (non-Javadoc)
- * @see IProblemChangedListener#problemsChanged(IResource[], boolean)
- */
- public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
- if (!isMarkerChange)
- return;
-
- IEditorInput input= fJavaEditor.getEditorInput();
- if (input != null) { // might run async, tests needed
- IJavaScriptElement jelement= (IJavaScriptElement) input.getAdapter(IJavaScriptElement.class);
- if (jelement != null) {
- IResource resource= jelement.getResource();
- for (int i = 0; i < changedResources.length; i++) {
- if (changedResources[i].equals(resource)) {
- updateEditorImage(jelement);
- }
- }
- }
- }
- }
-
- public void updateEditorImage(IJavaScriptElement jelement) {
- Image titleImage= fJavaEditor.getTitleImage();
- if (titleImage == null) {
- return;
- }
- Image newImage;
- if (jelement instanceof IJavaScriptUnit && !jelement.getJavaScriptProject().isOnIncludepath(jelement))
- newImage= fLabelProvider.getImage(jelement.getResource());
- else
- newImage= fLabelProvider.getImage(jelement);
- if (titleImage != newImage) {
- postImageChange(newImage);
- }
- }
-
- private void postImageChange(final Image newImage) {
- Shell shell= fJavaEditor.getEditorSite().getShell();
- if (shell != null && !shell.isDisposed()) {
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- fJavaEditor.updatedTitleImage(newImage);
- }
- });
- }
- }
-
- public void dispose() {
- fLabelProvider.dispose();
- JavaScriptPlugin.getDefault().getProblemMarkerManager().removeListener(this);
- }
-
-
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.java
deleted file mode 100644
index f1b0741a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-final class JavaEditorMessages extends NLS {
-
- private static final String BUNDLE_FOR_CONSTRUCTED_KEYS= "org.eclipse.wst.jsdt.internal.ui.javaeditor.ConstructedJavaEditorMessages";//$NON-NLS-1$
- private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
-
- /**
- * Returns the message bundle which contains constructed keys.
- *
- *
- * @return the message bundle
- */
- public static ResourceBundle getBundleForConstructedKeys() {
- return fgBundleForConstructedKeys;
- }
-
- private static final String BUNDLE_NAME= JavaEditorMessages.class.getName();
-
-
- private JavaEditorMessages() {
- // Do not instantiate
- }
-
- public static String AddImportOnSelection_label;
- public static String AddImportOnSelection_tooltip;
- public static String AddImportOnSelection_description;
- public static String AddImportOnSelection_error_title;
- public static String AddImportOnSelection_dialog_title;
- public static String AddImportOnSelection_dialog_message;
- public static String ClassFileEditor_error_classfile_not_on_classpath;
- public static String ClassFileEditor_error_invalid_input_message;
- public static String ClassFileEditor_error_title;
- public static String ClassFileEditor_error_message;
-// public static String ClassFileEditor_SourceAttachmentForm_cannotconfigure;
-// public static String ClassFileEditor_SourceAttachmentForm_notsupported;
-// public static String ClassFileEditor_SourceAttachmentForm_readonly;
- public static String ClassFileMarkerAnnotationModel_error_isAcceptable;
- public static String ClassFileMarkerAnnotationModel_error_isAffected;
- public static String ClassFileMarkerAnnotationModel_error_resourceChanged;
- public static String CompilationUnitDocumentProvider_progressNotifyingSaveParticipants;
- public static String CompilationUnitDocumentProvider_error_saveParticipantProblem;
- public static String CompilationUnitDocumentProvider_error_saveParticipantSavedFile;
- public static String CompilationUnitDocumentProvider_error_saveParticipantFailed;
- public static String CompilationUnitEditor_error_saving_message1;
- public static String CompilationUnitEditor_error_saving_title1;
- public static String CompilationUnitEditor_error_saving_saveParticipant;
- public static String EditorUtility_cantFindEditor;
- public static String EditorUtility_could_not_find_editorId;
- public static String EditorUtility_file_must_not_be_null;
- public static String EditorUtility_no_active_WorkbenchPage;
- public static String EditorUtility_no_editorInput;
- public static String JavaOutlinePage_Sort_label;
- public static String JavaOutlinePage_Sort_tooltip;
- public static String JavaOutlinePage_Sort_description;
- public static String JavaOutlinePage_GoIntoTopLevelType_label;
- public static String JavaOutlinePage_GoIntoTopLevelType_tooltip;
- public static String JavaOutlinePage_GoIntoTopLevelType_description;
- public static String JavaOutlinePage_error_NoTopLevelType;
- public static String ToggleComment_error_title;
- public static String ToggleComment_error_message;
- public static String ContentAssistProposal_label;
- public static String Editor_FoldingMenu_name;
- public static String CompilationUnitDocumentProvider_saveAsTargetOpenInEditor;
- public static String ClassFileDocumentProvider_error_createElementInfo;
- public static String ExpandSelectionMenu_label;
- public static String GotoMatchingBracket_label;
- public static String GotoMatchingBracket_error_invalidSelection;
- public static String GotoMatchingBracket_error_noMatchingBracket;
- public static String GotoMatchingBracket_error_bracketOutsideSelectedElement;
- public static String SourceAttachmentForm_title;
- public static String SourceAttachmentForm_heading;
- public static String SourceAttachmentForm_message_noSource;
-// public static String SourceAttachmentForm_message_noSourceAttachment;
-// public static String SourceAttachmentForm_message_pressButtonToAttach;
-// public static String SourceAttachmentForm_message_noSourceInAttachment;
-// public static String SourceAttachmentForm_message_pressButtonToChange;
-// public static String SourceAttachmentForm_button_attachSource;
-// public static String SourceAttachmentForm_button_changeAttachedSource;
-// public static String SourceAttachmentForm_error_title;
-// public static String SourceAttachmentForm_error_message;
- public static String SourceAttachmentForm_attach_error_title;
- public static String SourceAttachmentForm_attach_error_message;
- public static String EditorUtility_concatModifierStrings;
- public static String OverrideIndicatorManager_implements;
- public static String OverrideIndicatorManager_intallJob;
- public static String OverrideIndicatorManager_overrides;
- public static String OverrideIndicatorManager_open_error_title;
- public static String OverrideIndicatorManager_open_error_message;
- public static String OverrideIndicatorManager_open_error_messageHasLogEntry;
- public static String SemanticHighlighting_job;
- public static String SemanticHighlighting_methodDeclaration;
- public static String SemanticHighlighting_localVariableDeclaration;
- public static String SemanticHighlighting_localVariable;
- public static String SemanticHighlighting_parameterVariable;
- public static String SemanticHighlighting_deprecatedMember;
- public static String SemanticHighlighting_method;
- public static String SemanticHighlighting_objectInitializer;
- public static String JavaEditor_markOccurrences_job_name;
- public static String Editor_OpenPropertiesFile_error_keyNotFound;
- public static String Editor_OpenPropertiesFile_error_fileNotFound_dialogMessage;
- public static String Editor_OpenPropertiesFile_error_openEditor_dialogMessage;
- public static String Editor_MoveLines_IllegalMove_status;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JavaEditorMessages.class);
- }
-
- public static String BasicEditorActionContributor_specific_content_assist_menu;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.properties
deleted file mode 100644
index f391e4e5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaEditorMessages.properties
+++ /dev/null
@@ -1,115 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-AddImportOnSelection_label=A&dd Import
-AddImportOnSelection_tooltip=Create Import Statement on Selection
-AddImportOnSelection_description=Create import statement on selection
-
-AddImportOnSelection_error_title=Add Import
-
-AddImportOnSelection_dialog_title=Add Import
-AddImportOnSelection_dialog_message=&Choose element to generate an import statement for:
-
-ClassFileEditor_error_classfile_not_on_classpath=The class file is not on the classpath
-#ClassFileEditor_SourceAttachmentForm_cannotconfigure=The JAR of this javaScript file belongs to container ''{0}'' can not be configured.
-#ClassFileEditor_SourceAttachmentForm_notsupported=The JAR of this javaScript file belongs to container ''{0}'' which does not support the attachment of sources to its entries.
-ClassFileEditor_error_invalid_input_message=The Class File Viewer cannot handle the given input.
-#ClassFileEditor_SourceAttachmentForm_readonly=The JAR of this javaScript file belongs to container ''{0}'' which does not allow modifications to source attachments on its entries.
-ClassFileEditor_error_title=Error Creating Editor
-ClassFileEditor_error_message=An error occurred while creating the class file editor.
-
-ClassFileMarkerAnnotationModel_error_isAcceptable=ClassFileMarkerAnnotationModel.isAcceptable
-ClassFileMarkerAnnotationModel_error_isAffected=ClassFileMarkerAnnotationModel.isAffected
-ClassFileMarkerAnnotationModel_error_resourceChanged=ClassFileMarkerAnnotationModel.resourceChanged
-
-CompilationUnitEditor_error_saving_message1=File has been deleted or is not accessible.
-CompilationUnitEditor_error_saving_title1=Cannot Save
-CompilationUnitEditor_error_saving_saveParticipant=To avoid this, disable the corresponding participants on the <a>Save Actions</a> preference page.
-
-JavaOutlinePage_Sort_label=Sort
-JavaOutlinePage_Sort_tooltip=Sort
-JavaOutlinePage_Sort_description=Enable Sorting
-JavaOutlinePage_GoIntoTopLevelType_label=Go Into Top Level Type
-JavaOutlinePage_GoIntoTopLevelType_tooltip=Go Into Top Level Type
-JavaOutlinePage_GoIntoTopLevelType_description=Show children of top level type only
-JavaOutlinePage_error_NoTopLevelType=Top level type not defined
-
-ToggleComment_error_title=Toggle Comment
-ToggleComment_error_message=An error occurred while toggling comments.
-
-ContentAssistProposal_label=&Default
-BasicEditorActionContributor_specific_content_assist_menu=Co&ntent Assist
-
-Editor_FoldingMenu_name=F&olding
-
-CompilationUnitDocumentProvider_saveAsTargetOpenInEditor=Target file is already open in another editor.
-CompilationUnitDocumentProvider_progressNotifyingSaveParticipants=Notifying save participants
-CompilationUnitDocumentProvider_error_saveParticipantProblem=A save participant caused problems.
-CompilationUnitDocumentProvider_error_saveParticipantSavedFile=The save participant ''{0}'' spuriously saved the file.
-CompilationUnitDocumentProvider_error_saveParticipantFailed=The save participant ''{0}'' caused an exception: {1}. See the error Log for details.
-
-ClassFileDocumentProvider_error_createElementInfo=ClassFileDocumentProvider.createElementInfo
-
-
-
-
-ExpandSelectionMenu_label=E&xpand Selection To
-
-
-GotoMatchingBracket_label= Matching &Bracket
-GotoMatchingBracket_error_invalidSelection=No bracket selected
-GotoMatchingBracket_error_noMatchingBracket=No matching bracket found
-GotoMatchingBracket_error_bracketOutsideSelectedElement=Matching bracket is outside the selected element
-
-SourceAttachmentForm_title=Class File Editor
-SourceAttachmentForm_heading=Source not found
-SourceAttachmentForm_message_noSource=There is no source file attached to the javascript file {0}.
-#SourceAttachmentForm_message_noSourceAttachment=The jar file {0} has no source attachment.
-#SourceAttachmentForm_message_pressButtonToAttach=You can attach the source by clicking Attach Source below:
-#SourceAttachmentForm_message_noSourceInAttachment=The source attachment does not contain the source for the file {0}.
-#SourceAttachmentForm_message_pressButtonToChange=You can change the source attachment by clicking Change Attached Source below:
-#SourceAttachmentForm_button_attachSource=&Attach Source...
-#SourceAttachmentForm_button_changeAttachedSource=&Change Attached Source...
-#SourceAttachmentForm_error_title=Error Opening Source Attachment Form
-#SourceAttachmentForm_error_message=An error occurred while opening the source attachment form
-SourceAttachmentForm_attach_error_title=Error Attaching Source
-SourceAttachmentForm_attach_error_message=An error occurred while applying the source attachment
-
-EditorUtility_concatModifierStrings= {0} + {1}
-EditorUtility_no_editorInput=Could not get an editor input for the given element
-EditorUtility_cantFindEditor=Can't find Editor for file:
-EditorUtility_file_must_not_be_null=File must not be null
-EditorUtility_no_active_WorkbenchPage=No active workbench page
-EditorUtility_could_not_find_editorId=Cannot find an editor ID for the given editor input
-
-OverrideIndicatorManager_implements= implements {0}
-OverrideIndicatorManager_intallJob= Override indicator installation job
-OverrideIndicatorManager_overrides= overrides {0}
-OverrideIndicatorManager_open_error_title= Open Declaring Function
-OverrideIndicatorManager_open_error_message= Could not open the super implementation.
-OverrideIndicatorManager_open_error_messageHasLogEntry= Could not open the super implementation.\nSee the error log for details.
-
-SemanticHighlighting_job= Semantic Highlighting Job
-SemanticHighlighting_methodDeclaration= Function declarations
-SemanticHighlighting_localVariableDeclaration= Local variable declarations
-SemanticHighlighting_localVariable= Local variable references
-SemanticHighlighting_parameterVariable= Parameter variables
-SemanticHighlighting_deprecatedMember= Deprecated members
-SemanticHighlighting_method= Functions
-SemanticHighlighting_objectInitializer = Object initializer
-
-JavaEditor_markOccurrences_job_name= Occurrences Marker
-
-Editor_OpenPropertiesFile_error_keyNotFound= The key "{0}" is not defined in this properties file
-Editor_OpenPropertiesFile_error_fileNotFound_dialogMessage= Could not determine properties file
-Editor_OpenPropertiesFile_error_openEditor_dialogMessage= Could not open the properties file editor for: {0}
-
-Editor_MoveLines_IllegalMove_status= Move not possible - Uncheck "Show Source of Selected Element Only" to see the entire document
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlink.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlink.java
deleted file mode 100644
index 769b1b89..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlink.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-
-
-/**
- * Java element hyperlink.
- *
- *
- */
-public class JavaElementHyperlink implements IHyperlink {
-
- private final IRegion fRegion;
- private final IAction fOpenAction;
-
-
- /**
- * Creates a new Java element hyperlink.
- */
- public JavaElementHyperlink(IRegion region, IAction openAction) {
- Assert.isNotNull(openAction);
- Assert.isNotNull(region);
-
- fRegion= region;
- fOpenAction= openAction;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
- *
- */
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#open()
- *
- */
- public void open() {
- fOpenAction.run();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
- *
- */
- public String getTypeLabel() {
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
- *
- */
- public String getHyperlinkText() {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java
deleted file mode 100644
index 1e9e5f09..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.ICodeAssist;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
-
-
-/**
- * Java element hyperlink detector.
- *
- *
- */
-public class JavaElementHyperlinkDetector extends AbstractHyperlinkDetector {
-
- /*
- * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean)
- */
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
- if (region == null || !(textEditor instanceof JavaEditor))
- return null;
-
- IAction openAction= textEditor.getAction("OpenEditor"); //$NON-NLS-1$
- if (openAction == null)
- return null;
-
- int offset= region.getOffset();
-
- IJavaScriptElement input= EditorUtility.getEditorInputJavaElement(textEditor, false);
- if (input == null)
- return null;
-
- try {
- IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- IRegion wordRegion= JavaWordFinder.findWord(document, offset);
- if (wordRegion == null)
- return null;
-
- IJavaScriptElement[] elements= null;
- elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
- if (elements != null && elements.length > 0)
- return new IHyperlink[] {new JavaElementHyperlink(wordRegion, openAction)};
- } catch (JavaScriptModelException e) {
- return null;
- }
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMarkerAnnotation.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMarkerAnnotation.java
deleted file mode 100644
index 967e66bf..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMarkerAnnotation.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.wst.jsdt.core.CorrectionEngine;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModelMarker;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-
-public class JavaMarkerAnnotation extends MarkerAnnotation implements IJavaAnnotation {
-
- public static final String JAVA_MARKER_TYPE_PREFIX= "org.eclipse.wst.jsdt"; //$NON-NLS-1$
- public static final String ERROR_ANNOTATION_TYPE= "org.eclipse.wst.jsdt.ui.error"; //$NON-NLS-1$
- public static final String WARNING_ANNOTATION_TYPE= "org.eclipse.wst.jsdt.ui.warning"; //$NON-NLS-1$
- public static final String INFO_ANNOTATION_TYPE= "org.eclipse.wst.jsdt.ui.info"; //$NON-NLS-1$
- public static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
-
- private IJavaAnnotation fOverlay;
-
-
- public JavaMarkerAnnotation(IMarker marker) {
- super(marker);
- }
-
- /*
- * @see IJavaAnnotation#getArguments()
- */
- public String[] getArguments() {
- IMarker marker= getMarker();
- if (marker != null && marker.exists() && isProblem())
- return CorrectionEngine.getProblemArguments(marker);
- return null;
- }
-
- /*
- * @see IJavaAnnotation#getId()
- */
- public int getId() {
- IMarker marker= getMarker();
- if (marker == null || !marker.exists())
- return -1;
-
- if (isProblem())
- return marker.getAttribute(IJavaScriptModelMarker.ID, -1);
-
-// if (TASK_ANNOTATION_TYPE.equals(getAnnotationType())) {
-// try {
-// if (marker.isSubtypeOf(IJavaScriptModelMarker.TASK_MARKER)) {
-// return IProblem.Task;
-// }
-// } catch (CoreException e) {
-// JavaScriptPlugin.log(e); // should no happen, we test for marker.exists
-// }
-// }
-
- return -1;
- }
-
- /*
- * @see IJavaAnnotation#isProblem()
- */
- public boolean isProblem() {
- String type= getType();
- return WARNING_ANNOTATION_TYPE.equals(type) || ERROR_ANNOTATION_TYPE.equals(type);
- }
-
- /**
- * Overlays this annotation with the given javaAnnotation.
- *
- * @param javaAnnotation annotation that is overlaid by this annotation
- */
- public void setOverlay(IJavaAnnotation javaAnnotation) {
- if (fOverlay != null)
- fOverlay.removeOverlaid(this);
-
- fOverlay= javaAnnotation;
- if (!isMarkedDeleted())
- markDeleted(fOverlay != null);
-
- if (fOverlay != null)
- fOverlay.addOverlaid(this);
- }
-
- /*
- * @see IJavaAnnotation#hasOverlay()
- */
- public boolean hasOverlay() {
- return fOverlay != null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getOverlay()
- */
- public IJavaAnnotation getOverlay() {
- return fOverlay;
- }
-
- /*
- * @see IJavaAnnotation#addOverlaid(IJavaAnnotation)
- */
- public void addOverlaid(IJavaAnnotation annotation) {
- // not supported
- }
-
- /*
- * @see IJavaAnnotation#removeOverlaid(IJavaAnnotation)
- */
- public void removeOverlaid(IJavaAnnotation annotation) {
- // not supported
- }
-
- /*
- * @see IJavaAnnotation#getOverlaidIterator()
- */
- public Iterator getOverlaidIterator() {
- // not supported
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
- */
- public IJavaScriptUnit getCompilationUnit() {
- IJavaScriptElement element= JavaScriptCore.create(getMarker().getResource());
- if (element instanceof IJavaScriptUnit) {
- return (IJavaScriptUnit)element;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IJavaAnnotation#getMarkerType()
- */
- public String getMarkerType() {
- IMarker marker= getMarker();
- if (marker == null || !marker.exists())
- return null;
-
- return MarkerUtilities.getMarkerType(getMarker());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMoveLinesAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMoveLinesAction.java
deleted file mode 100644
index 1751adb2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaMoveLinesAction.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ILineRange;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.LineRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IndentUtil.IndentResult;
-
-/**
- * Action for moving selected lines in a Java editor.
- *
- */
-public class JavaMoveLinesAction extends TextEditorAction {
-
- /**
- * State shared by the Move / Copy lines action quadruple.
- *
- */
- private static final class SharedState {
- /** The compilation unit editor that all four actions operate on. */
- public CompilationUnitEditor fEditor;
- /**
- * The indent token shared by all four actions.
- */
- public IndentResult fResult= null;
- /**
- * Set to true before modifying the document, to false after.
- */
- boolean fIsChanging= false;
-
- /** <code>true</code> if a compound move / copy is going on. */
- private boolean fEditInProgress= false;
- /** The exit strategy that will detect the ending of a compound edit */
- private final CompoundEditExitStrategy fExitStrategy;
-
- public SharedState(CompilationUnitEditor editor) {
- fEditor= editor;
- fExitStrategy= new CompoundEditExitStrategy(new String[] {ITextEditorActionDefinitionIds.MOVE_LINES_UP, ITextEditorActionDefinitionIds.MOVE_LINES_DOWN, ITextEditorActionDefinitionIds.COPY_LINES_UP, ITextEditorActionDefinitionIds.COPY_LINES_DOWN});
- fExitStrategy.addCompoundListener(new ICompoundEditListener() {
- public void endCompoundEdit() {
- SharedState.this.endCompoundEdit();
- }
- });
- }
-
- /**
- * Ends the compound change.
- */
- public void beginCompoundEdit() {
- if (fEditInProgress || fEditor == null)
- return;
-
- fEditInProgress= true;
-
- fExitStrategy.arm(fEditor.getViewer());
-
- IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class);
- if (target != null) {
- target.beginCompoundChange();
- }
- }
- /**
- * Ends the compound change.
- */
- public void endCompoundEdit() {
- if (!fEditInProgress || fEditor == null)
- return;
-
- fExitStrategy.disarm();
-
- IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class);
- if (target != null) {
- target.endCompoundChange();
- }
-
- fResult= null;
- fEditInProgress= false;
- }
- }
-
- /* keys */
-
- /** Key for status message upon illegal move. <p>Value {@value}</p> */
-
- /* state variables - define what this action does */
-
- /** <code>true</code> if lines are shifted upwards, <code>false</code> otherwise. */
- private final boolean fUpwards;
- /** <code>true</code> if lines are to be copied instead of moved. */
- private final boolean fCopy;
- /** The shared state of the move/copy action quadruple. */
- private final SharedState fSharedState;
-
- /**
- * Creates the quadruple of move and copy actions. The returned array contains
- * the actions in the following order:
- * [0] move up
- * [1] move down
- * [2] copy up (duplicate)
- * [3] copy down (duplicate & select)
- * @param bundle the resource bundle
- * @param editor the editor
- * @return the quadruple of actions
- */
- public static JavaMoveLinesAction[] createMoveCopyActionSet(ResourceBundle bundle, CompilationUnitEditor editor) {
- SharedState state= new SharedState(editor);
- JavaMoveLinesAction[] actions= new JavaMoveLinesAction[4];
- actions[0]= new JavaMoveLinesAction(bundle, "Editor.MoveLinesUp.", true, false, state); //$NON-NLS-1$
- actions[1]= new JavaMoveLinesAction(bundle, "Editor.MoveLinesDown.", false, false, state); //$NON-NLS-1$
- actions[2]= new JavaMoveLinesAction(bundle, "Editor.CopyLineUp.", true, true, state); //$NON-NLS-1$
- actions[3]= new JavaMoveLinesAction(bundle, "Editor.CopyLineDown.", false, true, state); //$NON-NLS-1$
- return actions;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- Assert.isTrue(editor instanceof CompilationUnitEditor);
- super.setEditor(editor);
- if (fSharedState != null)
- fSharedState.fEditor= (CompilationUnitEditor) editor;
- }
-
- /**
- * Creates and initializes the action for the given text editor.
- * The action configures its visual representation from the given resource
- * bundle.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none
- * @param upwards <code>true</code>if the selected lines should be moved upwards,
- * <code>false</code> if downwards
- * @param copy if <code>true</code>, the action will copy lines instead of moving them
- * @param state the shared state
- * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
- */
- private JavaMoveLinesAction(ResourceBundle bundle, String prefix, boolean upwards, boolean copy, SharedState state) {
- super(bundle, prefix, state.fEditor);
- fUpwards= upwards;
- fCopy= copy;
- fSharedState= state;
- update();
- }
-
- /**
- * Checks if <code>selection</code> is contained by the visible region of <code>viewer</code>.
- * As a special case, a selection is considered contained even if it extends over the visible
- * region, but the extension stays on a partially contained line and contains only white space.
- *
- * @param selection the selection to be checked
- * @param viewer the viewer displaying a visible region of <code>selection</code>'s document.
- * @return <code>true</code>, if <code>selection</code> is contained, <code>false</code> otherwise.
- */
- private boolean containedByVisibleRegion(ITextSelection selection, ISourceViewer viewer) {
- int min= selection.getOffset();
- int max= min + selection.getLength();
- IDocument document= viewer.getDocument();
-
- IRegion visible;
- if (viewer instanceof ITextViewerExtension5)
- visible= ((ITextViewerExtension5) viewer).getModelCoverage();
- else
- visible= viewer.getVisibleRegion();
-
- int visOffset= visible.getOffset();
- try {
- if (visOffset > min) {
- if (document.getLineOfOffset(visOffset) != selection.getStartLine())
- return false;
- if (!isWhitespace(document.get(min, visOffset - min))) {
- showStatus();
- return false;
- }
- }
- int visEnd= visOffset + visible.getLength();
- if (visEnd < max) {
- if (document.getLineOfOffset(visEnd) != selection.getEndLine())
- return false;
- if (!isWhitespace(document.get(visEnd, max - visEnd))) {
- showStatus();
- return false;
- }
- }
- return true;
- } catch (BadLocationException e) {
- }
- return false;
- }
-
- /**
- * Given a selection on a document, computes the lines fully or partially covered by
- * <code>selection</code>. A line in the document is considered covered if
- * <code>selection</code> comprises any characters on it, including the terminating delimiter.
- * <p>Note that the last line in a selection is not considered covered if the selection only
- * comprises the line delimiter at its beginning (that is considered part of the second last
- * line).
- * As a special case, if the selection is empty, a line is considered covered if the caret is
- * at any position in the line, including between the delimiter and the start of the line. The
- * line containing the delimiter is not considered covered in that case.
- * </p>
- *
- * @param document the document <code>selection</code> refers to
- * @param selection a selection on <code>document</code>
- * @param viewer the <code>ISourceViewer</code> displaying <code>document</code>
- * @return a selection describing the range of lines (partially) covered by
- * <code>selection</code>, without any terminating line delimiters
- * @throws BadLocationException if the selection is out of bounds (when the underlying document has changed during the call)
- */
- private ITextSelection getMovingSelection(IDocument document, ITextSelection selection, ISourceViewer viewer) throws BadLocationException {
- int low= document.getLineOffset(selection.getStartLine());
- int endLine= selection.getEndLine();
- int high= document.getLineOffset(endLine) + document.getLineLength(endLine);
-
- // get everything up to last line without its delimiter
- String delim= document.getLineDelimiter(endLine);
- if (delim != null)
- high -= delim.length();
-
- return new TextSelection(document, low, high - low);
- }
-
- /**
- * Computes the region of the skipped line given the text block to be moved. If
- * <code>fUpwards</code> is <code>true</code>, the line above <code>selection</code>
- * is selected, otherwise the line below.
- *
- * @param document the document <code>selection</code> refers to
- * @param selection the selection on <code>document</code> that will be moved.
- * @return the region comprising the line that <code>selection</code> will be moved over, without its terminating delimiter.
- */
- private ITextSelection getSkippedLine(IDocument document, ITextSelection selection) {
- int skippedLineN= (fUpwards ? selection.getStartLine() - 1 : selection.getEndLine() + 1);
- if (skippedLineN > document.getNumberOfLines() || (!fCopy && (skippedLineN < 0 || skippedLineN == document.getNumberOfLines())))
- return null;
- try {
- if (fCopy && skippedLineN == -1)
- skippedLineN= 0;
- IRegion line= document.getLineInformation(skippedLineN);
- return new TextSelection(document, line.getOffset(), line.getLength());
- } catch (BadLocationException e) {
- // only happens on concurrent modifications
- return null;
- }
- }
-
- /**
- * Checks for white space in a string.
- *
- * @param string the string to be checked or <code>null</code>
- * @return <code>true</code> if <code>string</code> contains only white space or is
- * <code>null</code>, <code>false</code> otherwise
- */
- private boolean isWhitespace(String string) {
- return string == null ? true : string.trim().length() == 0;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void runWithEvent(Event event) {
-
- // get involved objects
- if (fSharedState.fEditor == null)
- return;
-
- if (!validateEditorInputState())
- return;
-
- ISourceViewer viewer= fSharedState.fEditor.getViewer();
- if (viewer == null)
- return;
-
- IDocument document= viewer.getDocument();
- if (document == null)
- return;
-
- StyledText widget= viewer.getTextWidget();
- if (widget == null)
- return;
-
- // get selection
- Point p= viewer.getSelectedRange();
- if (p == null)
- return;
-
- ITextSelection sel= new TextSelection(document, p.x, p.y);
-
- ITextSelection skippedLine= getSkippedLine(document, sel);
- if (skippedLine == null)
- return;
-
- try {
-
- ITextSelection movingArea= getMovingSelection(document, sel, viewer);
-
- // if either the skipped line or the moving lines are outside the widget's
- // visible area, bail out
- if (!containedByVisibleRegion(movingArea, viewer) || !containedByVisibleRegion(skippedLine, viewer))
- return;
-
- // get the content to be moved around: the moving (selected) area and the skipped line
- String moving= movingArea.getText();
- String skipped= skippedLine.getText();
- if (moving == null || skipped == null || document.getLength() == 0)
- return;
-
- String delim;
- String insertion;
- int offset;
- if (fUpwards) {
- delim= document.getLineDelimiter(skippedLine.getEndLine());
- if (fCopy) {
- delim= TextUtilities.getDefaultLineDelimiter(document);
- insertion= moving + delim;
- offset= movingArea.getOffset();
- } else {
- Assert.isNotNull(delim);
- insertion= moving + delim + skipped;
- offset= skippedLine.getOffset();
- }
- } else {
- delim= document.getLineDelimiter(movingArea.getEndLine());
- if (fCopy) {
- if (delim == null) {
- delim= TextUtilities.getDefaultLineDelimiter(document);
- insertion= delim + moving;
- } else
- insertion= moving + delim;
- offset= skippedLine.getOffset();
- } else {
- Assert.isNotNull(delim);
- insertion= skipped + delim + moving;
- offset= movingArea.getOffset();
- }
- }
- int lenght= fCopy ? 0 : insertion.length();
-
- // modify the document
- ILineRange selectionBefore= getLineRange(document, movingArea);
-
- if (fCopy)
- fSharedState.endCompoundEdit();
- fSharedState.beginCompoundEdit();
- fSharedState.fIsChanging= true;
-
- document.replace(offset, lenght, insertion);
-
- ILineRange selectionAfter;
- if (fUpwards && fCopy)
- selectionAfter= selectionBefore;
- else if (fUpwards)
- selectionAfter= new LineRange(selectionBefore.getStartLine() - 1, selectionBefore.getNumberOfLines());
- else if (fCopy)
- selectionAfter= new LineRange(selectionBefore.getStartLine() + selectionBefore.getNumberOfLines(), selectionBefore.getNumberOfLines());
- else
- selectionAfter= new LineRange(selectionBefore.getStartLine() + 1, selectionBefore.getNumberOfLines());
-
- fSharedState.fResult= IndentUtil.indentLines(document, selectionAfter, getProject(), fSharedState.fResult);
-
- // move the selection along
- IRegion region= getRegion(document, selectionAfter);
- selectAndReveal(viewer, region.getOffset(), region.getLength());
-
- } catch (BadLocationException x) {
- // won't happen without concurrent modification - bail out
- return;
- } finally {
- fSharedState.fIsChanging= false;
- if (fCopy)
- fSharedState.endCompoundEdit();
- }
- }
-
- private IJavaScriptProject getProject() {
- IEditorInput editorInput= fSharedState.fEditor.getEditorInput();
- IJavaScriptUnit unit= JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
- if (unit != null)
- return unit.getJavaScriptProject();
- return null;
- }
-
- private ILineRange getLineRange(IDocument document, ITextSelection selection) throws BadLocationException {
- final int offset= selection.getOffset();
- int startLine= document.getLineOfOffset(offset);
- int endOffset= offset + selection.getLength();
- int endLine= document.getLineOfOffset(endOffset);
- final int nLines= endLine - startLine + 1;
- return new LineRange(startLine, nLines);
- }
-
- private IRegion getRegion(IDocument document, ILineRange lineRange) throws BadLocationException {
- final int startLine= lineRange.getStartLine();
- int offset= document.getLineOffset(startLine);
- final int numberOfLines= lineRange.getNumberOfLines();
- if (numberOfLines < 1)
- return new Region(offset, 0);
- int endLine= startLine + numberOfLines - 1;
- int endOffset= document.getLineOffset(endLine) + document.getLineLength(endLine);
- return new Region(offset, endOffset - offset);
- }
-
- /**
- * Performs similar to AbstractTextEditor.selectAndReveal, but does not update
- * the viewers highlight area.
- *
- * @param viewer the viewer that we want to select on
- * @param offset the offset of the selection
- * @param length the length of the selection
- */
- private void selectAndReveal(ITextViewer viewer, int offset, int length) {
- // invert selection to avoid jumping to the end of the selection in st.showSelection()
- viewer.setSelectedRange(offset + length, -length);
- //viewer.revealRange(offset, length); // will trigger jumping
- StyledText st= viewer.getTextWidget();
- if (st != null)
- st.showSelection(); // only minimal scrolling
- }
-
- /**
- * Displays information in the status line why a line move is not possible
- */
- private void showStatus() {
- IEditorStatusLine status= (IEditorStatusLine) fSharedState.fEditor.getAdapter(IEditorStatusLine.class);
- if (status == null)
- return;
- status.setMessage(false, JavaEditorMessages.Editor_MoveLines_IllegalMove_status, null);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (isEnabled())
- setEnabled(canModifyEditor());
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaOutlinePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaOutlinePage.java
deleted file mode 100644
index ca40f858..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaOutlinePage.java
+++ /dev/null
@@ -1,1387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-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.text.ITextSelection;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-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.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.model.WorkbenchAdapter;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTarget;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IInitializer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.actions.AbstractToggleLinkingAction;
-import org.eclipse.wst.jsdt.internal.ui.actions.CategoryFilterActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.dnd.DelegatingDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.preferences.MembersOrderPreferenceCache;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.SourcePositionComparator;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator.ProblemsLabelChangedEvent;
-import org.eclipse.wst.jsdt.ui.actions.CCPActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.MemberFilterActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-
-/**
- * The content outline page of the Java editor. The viewer implements a proprietary
- * update mechanism based on Java model deltas. It does not react on domain changes.
- * It is specified to show the content of ICompilationUnits and IClassFiles.
- * Publishes its context menu under <code>JavaScriptPlugin.getDefault().getPluginId() + ".outline"</code>.
- */
-public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdaptable , IPostSelectionProvider {
-
- static Object[] NO_CHILDREN= new Object[0];
-
- /**
- * The element change listener of the java outline viewer.
- * @see IElementChangedListener
- */
- protected class ElementChangedListener implements IElementChangedListener {
-
- public void elementChanged(final ElementChangedEvent e) {
-
- if (getControl() == null)
- return;
-
- Display d= getControl().getDisplay();
- if (d != null) {
- d.asyncExec(new Runnable() {
- public void run() {
- IJavaScriptUnit cu= (IJavaScriptUnit) fInput;
- IJavaScriptElement base= cu;
- if (fTopLevelTypeOnly) {
- base= cu.findPrimaryType();
- if (base == null) {
- if (fOutlineViewer != null)
- fOutlineViewer.refresh(true);
- return;
- }
- }
- IJavaScriptElementDelta delta= findElement(base, e.getDelta());
- if (delta != null && fOutlineViewer != null) {
- fOutlineViewer.reconcile(delta);
- }
- }
- });
- }
- }
-
- private boolean isPossibleStructuralChange(IJavaScriptElementDelta cuDelta) {
- if (cuDelta.getKind() != IJavaScriptElementDelta.CHANGED) {
- return true; // add or remove
- }
- int flags= cuDelta.getFlags();
- if ((flags & IJavaScriptElementDelta.F_CHILDREN) != 0) {
- return true;
- }
- return (flags & (IJavaScriptElementDelta.F_CONTENT | IJavaScriptElementDelta.F_FINE_GRAINED)) == IJavaScriptElementDelta.F_CONTENT;
- }
-
- protected IJavaScriptElementDelta findElement(IJavaScriptElement unit, IJavaScriptElementDelta delta) {
-
- if (delta == null || unit == null)
- return null;
-
- IJavaScriptElement element= delta.getElement();
-
- if (unit.equals(element)) {
- if (isPossibleStructuralChange(delta)) {
- return delta;
- }
- return null;
- }
-
-
- if (element.getElementType() > IJavaScriptElement.CLASS_FILE)
- return null;
-
- IJavaScriptElementDelta[] children= delta.getAffectedChildren();
- if (children == null || children.length == 0)
- return null;
-
- for (int i= 0; i < children.length; i++) {
- IJavaScriptElementDelta d= findElement(unit, children[i]);
- if (d != null)
- return d;
- }
-
- return null;
- }
- }
-
- static class NoClassElement extends WorkbenchAdapter implements IAdaptable {
- /*
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return JavaEditorMessages.JavaOutlinePage_error_NoTopLevelType;
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class clas) {
- if (clas == IWorkbenchAdapter.class)
- return this;
- return null;
- }
- }
-
- /**
- * Content provider for the children of an IJavaScriptUnit or
- * an IClassFile
- * @see ITreeContentProvider
- */
- protected class ChildrenProvider implements ITreeContentProvider {
-
- private Object[] NO_CLASS= new Object[] {new NoClassElement()};
- private ElementChangedListener fListener;
-
- protected boolean matches(IJavaScriptElement element) {
- if (element.getElementType() == IJavaScriptElement.PACKAGE_DECLARATION)
- return true;
- if (element.getElementType() == IJavaScriptElement.METHOD) {
- String name= element.getElementName();
- return (name != null && name.indexOf('<') >= 0);
- }
-
- //@GINO: Anonymous Filter top level anonymous
- if (element.getElementType() == IJavaScriptElement.TYPE && element.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT ) {
-
- IType type = (IType)element;
- try {
- return type.isAnonymous();
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- return false;
- }
-
- protected IJavaScriptElement[] filter(IJavaScriptElement[] children) {
- boolean initializers= false;
- for (int i= 0; i < children.length; i++) {
- if (matches(children[i])) {
- initializers= true;
- break;
- }
- }
-
- if (!initializers)
- return children;
-
- Vector v= new Vector();
- for (int i= 0; i < children.length; i++) {
- if (matches(children[i]))
- continue;
- v.addElement(children[i]);
- }
-
- IJavaScriptElement[] result= new IJavaScriptElement[v.size()];
- v.copyInto(result);
- return result;
- }
-
- public Object[] getChildren(Object parent) {
- if (parent instanceof IParent) {
- IParent c= (IParent) parent;
- try {
- return filter(c.getChildren());
- } catch (JavaScriptModelException x) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
- // don't log NotExist exceptions as this is a valid case
- // since we might have been posted and the element
- // removed in the meantime.
- if (JavaScriptPlugin.isDebug() || !x.isDoesNotExist())
- JavaScriptPlugin.log(x);
- }
- }
- return NO_CHILDREN;
- }
-
- public Object[] getElements(Object parent) {
- if (fTopLevelTypeOnly) {
- if (parent instanceof ITypeRoot) {
- try {
- IType type= ((ITypeRoot) parent).findPrimaryType();
- return type != null ? type.getChildren() : NO_CLASS;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
- return getChildren(parent);
- }
-
- public Object getParent(Object child) {
- if (child instanceof IJavaScriptElement) {
- IJavaScriptElement e= (IJavaScriptElement) child;
- return e.getParent();
- }
- return null;
- }
-
- public boolean hasChildren(Object parent) {
- if (parent instanceof IParent) {
- IParent c= (IParent) parent;
- try {
- IJavaScriptElement[] children= filter(c.getChildren());
- return (children != null && children.length > 0);
- } catch (JavaScriptModelException x) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
- // don't log NotExist exceptions as this is a valid case
- // since we might have been posted and the element
- // removed in the meantime.
- if (JavaScriptPlugin.isDebug() || !x.isDoesNotExist())
- JavaScriptPlugin.log(x);
- }
- }
- return false;
- }
-
- public boolean isDeleted(Object o) {
- return false;
- }
-
- public void dispose() {
- if (fListener != null) {
- JavaScriptCore.removeElementChangedListener(fListener);
- fListener= null;
- }
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- boolean isCU= (newInput instanceof IJavaScriptUnit);
-
- if (isCU && fListener == null) {
- fListener= new ElementChangedListener();
- JavaScriptCore.addElementChangedListener(fListener);
- } else if (!isCU && fListener != null) {
- JavaScriptCore.removeElementChangedListener(fListener);
- fListener= null;
- }
- }
- }
-
- /**
- * The tree viewer used for displaying the outline.
- *
- * @see TreeViewer
- */
- protected class JavaOutlineViewer extends TreeViewer {
-
- /**
- * Indicates an item which has been reused. At the point of
- * its reuse it has been expanded. This field is used to
- * communicate between <code>internalExpandToLevel</code> and
- * <code>reuseTreeItem</code>.
- */
- private Item fReusedExpandedItem;
- private boolean fReorderedMembers;
- private boolean fForceFireSelectionChanged;
-
- public JavaOutlineViewer(Tree tree) {
- super(tree);
- setAutoExpandLevel(ALL_LEVELS);
- setUseHashlookup(true);
- }
-
- /**
- * Investigates the given element change event and if affected
- * incrementally updates the Java outline.
- *
- * @param delta the Java element delta used to reconcile the Java outline
- */
- public void reconcile(IJavaScriptElementDelta delta) {
- fReorderedMembers= false;
- fForceFireSelectionChanged= false;
- if (getComparator() == null) {
- if (fTopLevelTypeOnly
- && delta.getElement() instanceof IType
- && (delta.getKind() & IJavaScriptElementDelta.ADDED) != 0)
- {
- refresh(true);
-
- } else {
- Widget w= findItem(fInput);
- if (w != null && !w.isDisposed())
- update(w, delta);
- if (fForceFireSelectionChanged)
- fireSelectionChanged(new SelectionChangedEvent(getSite().getSelectionProvider(), this.getSelection()));
- if (fReorderedMembers) {
- refresh(false);
- fReorderedMembers= false;
- }
- }
- } else {
- // just for now
- refresh(true);
- }
- }
-
- /*
- * @see TreeViewer#internalExpandToLevel
- */
- protected void internalExpandToLevel(Widget node, int level) {
- if (node instanceof Item) {
- Item i= (Item) node;
- if (i.getData() instanceof IJavaScriptElement) {
- IJavaScriptElement je= (IJavaScriptElement) i.getData();
- if (je.getElementType() == IJavaScriptElement.IMPORT_CONTAINER || isInnerType(je)) {
- if (i != fReusedExpandedItem) {
- setExpanded(i, false);
- return;
- }
- }
- }
- }
- super.internalExpandToLevel(node, level);
- }
-
- protected void reuseTreeItem(Item item, Object element) {
-
- // remove children
- Item[] c= getChildren(item);
- if (c != null && c.length > 0) {
-
- if (getExpanded(item))
- fReusedExpandedItem= item;
-
- for (int k= 0; k < c.length; k++) {
- if (c[k].getData() != null)
- disassociate(c[k]);
- c[k].dispose();
- }
- }
-
- updateItem(item, element);
- updatePlus(item, element);
- internalExpandToLevel(item, ALL_LEVELS);
-
- fReusedExpandedItem= null;
- fForceFireSelectionChanged= true;
- }
-
- protected boolean mustUpdateParent(IJavaScriptElementDelta delta, IJavaScriptElement element) {
- if (element instanceof IFunction) {
- if ((delta.getKind() & IJavaScriptElementDelta.ADDED) != 0) {
- try {
- return ((IFunction)element).isMainMethod();
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e.getStatus());
- }
- }
- return "main".equals(element.getElementName()); //$NON-NLS-1$
- }
- return false;
- }
-
- /*
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
- */
- public boolean isExpandable(Object element) {
- if (hasFilters()) {
- return getFilteredChildren(element).length > 0;
- }
- return super.isExpandable(element);
- }
-
- protected ISourceRange getSourceRange(IJavaScriptElement element) throws JavaScriptModelException {
- if (element instanceof ISourceReference)
- return ((ISourceReference) element).getSourceRange();
- if (element instanceof IMember && !(element instanceof IInitializer))
- return ((IMember) element).getNameRange();
- return null;
- }
-
- protected boolean overlaps(ISourceRange range, int start, int end) {
- return start <= (range.getOffset() + range.getLength() - 1) && range.getOffset() <= end;
- }
-
- protected boolean filtered(IJavaScriptElement parent, IJavaScriptElement child) {
-
- Object[] result= new Object[] { child };
- ViewerFilter[] filters= getFilters();
- for (int i= 0; i < filters.length; i++) {
- result= filters[i].filter(this, parent, result);
- if (result.length == 0)
- return true;
- }
-
- return false;
- }
-
- protected void update(Widget w, IJavaScriptElementDelta delta) {
-
- Item item;
-
- IJavaScriptElement parent= delta.getElement();
- IJavaScriptElementDelta[] affected= delta.getAffectedChildren();
- Item[] children= getChildren(w);
-
- boolean doUpdateParent= false;
- boolean doUpdateParentsPlus= false;
-
- Vector deletions= new Vector();
- Vector additions= new Vector();
-
- for (int i= 0; i < affected.length; i++) {
- IJavaScriptElementDelta affectedDelta= affected[i];
- IJavaScriptElement affectedElement= affectedDelta.getElement();
- int status= affected[i].getKind();
-
- // find tree item with affected element
- int j;
- for (j= 0; j < children.length; j++)
- if (affectedElement.equals(children[j].getData()))
- break;
-
- if (j == children.length) {
- // remove from collapsed parent
- if ((status & IJavaScriptElementDelta.REMOVED) != 0) {
- doUpdateParentsPlus= true;
- continue;
- }
- // addition
- if ((status & IJavaScriptElementDelta.CHANGED) != 0 &&
- (affectedDelta.getFlags() & IJavaScriptElementDelta.F_MODIFIERS) != 0 &&
- !filtered(parent, affectedElement))
- {
- additions.addElement(affectedDelta);
- }
- continue;
- }
-
- item= children[j];
-
- // removed
- if ((status & IJavaScriptElementDelta.REMOVED) != 0) {
- deletions.addElement(item);
- doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
-
- // changed
- } else if ((status & IJavaScriptElementDelta.CHANGED) != 0) {
- int change= affectedDelta.getFlags();
- doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
-
- if ((change & IJavaScriptElementDelta.F_MODIFIERS) != 0) {
- if (filtered(parent, affectedElement))
- deletions.addElement(item);
- else
- updateItem(item, affectedElement);
- }
-
- if ((change & IJavaScriptElementDelta.F_CONTENT) != 0)
- updateItem(item, affectedElement);
-
- if ((change & IJavaScriptElementDelta.F_CATEGORIES) != 0)
- updateItem(item, affectedElement);
-
- if ((change & IJavaScriptElementDelta.F_CHILDREN) != 0)
- update(item, affectedDelta);
-
- if ((change & IJavaScriptElementDelta.F_REORDER) != 0)
- fReorderedMembers= true;
- }
- }
-
- // find all elements to add
- IJavaScriptElementDelta[] add= delta.getAddedChildren();
- if (additions.size() > 0) {
- IJavaScriptElementDelta[] tmp= new IJavaScriptElementDelta[add.length + additions.size()];
- System.arraycopy(add, 0, tmp, 0, add.length);
- for (int i= 0; i < additions.size(); i++)
- tmp[i + add.length]= (IJavaScriptElementDelta) additions.elementAt(i);
- add= tmp;
- }
-
- // add at the right position
- go2: for (int i= 0; i < add.length; i++) {
-
- try {
-
- IJavaScriptElement e= add[i].getElement();
- if (filtered(parent, e))
- continue go2;
-
- doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e);
- ISourceRange rng= getSourceRange(e);
- int start= rng.getOffset();
- int end= start + rng.getLength() - 1;
- int nameOffset= Integer.MAX_VALUE;
- if (e instanceof IField) {
- ISourceRange nameRange= ((IField) e).getNameRange();
- if (nameRange != null)
- nameOffset= nameRange.getOffset();
- }
-
- Item last= null;
- item= null;
- children= getChildren(w);
-
- for (int j= 0; j < children.length; j++) {
- item= children[j];
- IJavaScriptElement r= (IJavaScriptElement) item.getData();
-
- if (r == null) {
- // parent node collapsed and not be opened before -> do nothing
- continue go2;
- }
-
-
- try {
- rng= getSourceRange(r);
-
- // multi-field declarations always start at
- // the same offset. They also have the same
- // end offset if the field sequence is terminated
- // with a semicolon. If not, the source range
- // ends behind the identifier / initializer
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51851
- boolean multiFieldDeclaration=
- r.getElementType() == IJavaScriptElement.FIELD
- && e.getElementType() == IJavaScriptElement.FIELD
- && rng.getOffset() == start;
-
- // elements are inserted by occurrence
- // however, multi-field declarations have
- // equal source ranges offsets, therefore we
- // compare name-range offsets.
- boolean multiFieldOrderBefore= false;
- if (multiFieldDeclaration) {
- if (r instanceof IField) {
- ISourceRange nameRange= ((IField) r).getNameRange();
- if (nameRange != null) {
- if (nameRange.getOffset() > nameOffset)
- multiFieldOrderBefore= true;
- }
- }
- }
-
- if (!multiFieldDeclaration && overlaps(rng, start, end)) {
-
- // be tolerant if the delta is not correct, or if
- // the tree has been updated other than by a delta
- reuseTreeItem(item, e);
- continue go2;
-
- } else if (multiFieldOrderBefore || rng.getOffset() > start) {
-
- if (last != null && deletions.contains(last)) {
- // reuse item
- deletions.removeElement(last);
- reuseTreeItem(last, e);
- } else {
- // nothing to reuse
- createTreeItem(w, e, j);
- }
- continue go2;
- }
-
- } catch (JavaScriptModelException x) {
- // stumbled over deleted element
- }
-
- last= item;
- }
-
- // add at the end of the list
- if (last != null && deletions.contains(last)) {
- // reuse item
- deletions.removeElement(last);
- reuseTreeItem(last, e);
- } else {
- // nothing to reuse
- createTreeItem(w, e, -1);
- }
-
- } catch (JavaScriptModelException x) {
- // the element to be added is not present -> don't add it
- }
- }
-
-
- // remove items which haven't been reused
- Enumeration e= deletions.elements();
- while (e.hasMoreElements()) {
- item= (Item) e.nextElement();
- disassociate(item);
- item.dispose();
- }
-
- if (doUpdateParent)
- updateItem(w, delta.getElement());
- if (!doUpdateParent && doUpdateParentsPlus && w instanceof Item)
- updatePlus((Item)w, delta.getElement());
- }
-
-
-
- /*
- * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
- */
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object input= getInput();
- if (event instanceof ProblemsLabelChangedEvent) {
- ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event;
- if (e.isMarkerChange() && input instanceof IJavaScriptUnit) {
- return; // marker changes can be ignored
- }
- }
- // look if the underlying resource changed
- Object[] changed= event.getElements();
- if (changed != null) {
- IResource resource= getUnderlyingResource();
- if (resource != null) {
- for (int i= 0; i < changed.length; i++) {
- if (changed[i] != null && changed[i].equals(resource)) {
- // change event to a full refresh
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource());
- break;
- }
- }
- }
- }
- super.handleLabelProviderChanged(event);
- }
-
- private IResource getUnderlyingResource() {
- Object input= getInput();
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cu= (IJavaScriptUnit) input;
- cu= cu.getPrimary();
- return cu.getResource();
- } else if (input instanceof IClassFile) {
- return ((IClassFile) input).getResource();
- }
- return null;
- }
-
-
- }
-
- class LexicalSortingAction extends Action {
-
- private JavaScriptElementComparator fComparator= new JavaScriptElementComparator();
- private SourcePositionComparator fSourcePositonComparator= new SourcePositionComparator();
-
- public LexicalSortingAction() {
- super();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
- setText(JavaEditorMessages.JavaOutlinePage_Sort_label);
- JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
- setToolTipText(JavaEditorMessages.JavaOutlinePage_Sort_tooltip);
- setDescription(JavaEditorMessages.JavaOutlinePage_Sort_description);
-
- boolean checked= JavaScriptPlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$
- valueChanged(checked, false);
- }
-
- public void run() {
- valueChanged(isChecked(), true);
- }
-
- private void valueChanged(final boolean on, boolean store) {
- setChecked(on);
- BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- if (on)
- fOutlineViewer.setComparator(fComparator);
- else
- fOutlineViewer.setComparator(fSourcePositonComparator);
- }
- });
-
- if (store)
- JavaScriptPlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$
- }
- }
-
- class ClassOnlyAction extends Action {
-
- public ClassOnlyAction() {
- super();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
- setText(JavaEditorMessages.JavaOutlinePage_GoIntoTopLevelType_label);
- setToolTipText(JavaEditorMessages.JavaOutlinePage_GoIntoTopLevelType_tooltip);
- setDescription(JavaEditorMessages.JavaOutlinePage_GoIntoTopLevelType_description);
- JavaPluginImages.setLocalImageDescriptors(this, "gointo_toplevel_type.gif"); //$NON-NLS-1$
-
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- boolean showclass= preferenceStore.getBoolean("GoIntoTopLevelTypeAction.isChecked"); //$NON-NLS-1$
- setTopLevelTypeOnly(showclass);
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- setTopLevelTypeOnly(!fTopLevelTypeOnly);
- }
-
- private void setTopLevelTypeOnly(boolean show) {
- fTopLevelTypeOnly= show;
- setChecked(show);
- fOutlineViewer.refresh(false);
-
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
- }
- }
-
- /**
- * This action toggles whether this Java Outline page links
- * its selection to the active editor.
- *
- *
- */
- public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- JavaOutlinePage fJavaOutlinePage;
-
- /**
- * Constructs a new action.
- *
- * @param outlinePage the Java outline page
- */
- public ToggleLinkingAction(JavaOutlinePage outlinePage) {
- boolean isLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
- setChecked(isLinkingEnabled);
- fJavaOutlinePage= outlinePage;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, isChecked());
- if (isChecked() && fEditor != null)
- fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
- }
-
- }
-
- /**
- * Empty selection provider.
- *
- *
- */
- private static final class EmptySelectionProvider implements ISelectionProvider {
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
- public ISelection getSelection() {
- return StructuredSelection.EMPTY;
- }
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- }
- public void setSelection(ISelection selection) {
- }
- }
-
-
- /** A flag to show contents of top level type only */
- private boolean fTopLevelTypeOnly;
-
- private IJavaScriptElement fInput;
- private String fContextMenuID;
- private Menu fMenu;
- private JavaOutlineViewer fOutlineViewer;
- private JavaEditor fEditor;
-
- private MemberFilterActionGroup fMemberFilterActionGroup;
-
- private ListenerList fSelectionChangedListeners= new ListenerList(ListenerList.IDENTITY);
- private ListenerList fPostSelectionChangedListeners= new ListenerList(ListenerList.IDENTITY);
- private Hashtable fActions= new Hashtable();
-
- private TogglePresentationAction fTogglePresentation;
-
- private ToggleLinkingAction fToggleLinkingAction;
-
- private CompositeActionGroup fActionGroups;
-
- private IPropertyChangeListener fPropertyChangeListener;
- /**
- * Custom filter action group.
- *
- */
- private CustomFiltersActionGroup fCustomFiltersActionGroup;
- /**
- * Category filter action group.
- *
- */
- private CategoryFilterActionGroup fCategoryFilterActionGroup;
-
- public JavaOutlinePage(String contextMenuID, JavaEditor editor) {
- super();
-
- Assert.isNotNull(editor);
-
- fContextMenuID= contextMenuID;
- fEditor= editor;
-
- fTogglePresentation= new TogglePresentationAction();
- fTogglePresentation.setEditor(editor);
-
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doPropertyChange(event);
- }
- };
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
- }
-
- /* (non-Javadoc)
- * Method declared on Page
- */
- public void init(IPageSite pageSite) {
- super.init(pageSite);
- }
-
- private void doPropertyChange(PropertyChangeEvent event) {
- if (fOutlineViewer != null) {
- if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
- fOutlineViewer.refresh(false);
- }
- }
- }
-
- /*
- * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener)
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- if (fOutlineViewer != null)
- fOutlineViewer.addSelectionChangedListener(listener);
- else
- fSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- if (fOutlineViewer != null)
- fOutlineViewer.removeSelectionChangedListener(listener);
- else
- fSelectionChangedListeners.remove(listener);
- }
-
- /*
- * @see ISelectionProvider#setSelection(ISelection)
- */
- public void setSelection(ISelection selection) {
- if (fOutlineViewer != null)
- fOutlineViewer.setSelection(selection);
- }
-
- /*
- * @see ISelectionProvider#getSelection()
- */
- public ISelection getSelection() {
- if (fOutlineViewer == null)
- return StructuredSelection.EMPTY;
- return fOutlineViewer.getSelection();
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- if (fOutlineViewer != null)
- fOutlineViewer.addPostSelectionChangedListener(listener);
- else
- fPostSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- if (fOutlineViewer != null)
- fOutlineViewer.removePostSelectionChangedListener(listener);
- else
- fPostSelectionChangedListeners.remove(listener);
- }
-
- private void registerToolbarActions(IActionBars actionBars) {
- IToolBarManager toolBarManager= actionBars.getToolBarManager();
- toolBarManager.add(new LexicalSortingAction());
-
- fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "org.eclipse.wst.jsdt.ui.JavaOutlinePage"); //$NON-NLS-1$
- fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
-
- fCustomFiltersActionGroup.fillActionBars(actionBars);
-
- IMenuManager viewMenuManager= actionBars.getMenuManager();
- viewMenuManager.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
-
- fToggleLinkingAction= new ToggleLinkingAction(this);
- // viewMenuManager.add(new ClassOnlyAction());
- viewMenuManager.add(fToggleLinkingAction);
-
- fCategoryFilterActionGroup= new CategoryFilterActionGroup(fOutlineViewer, "org.eclipse.wst.jsdt.ui.JavaOutlinePage", new IJavaScriptElement[] {fInput}); //$NON-NLS-1$
- fCategoryFilterActionGroup.contributeToViewMenu(viewMenuManager);
- }
-
- /*
- * @see IPage#createControl
- */
- public void createControl(Composite parent) {
-
- Tree tree= new Tree(parent, SWT.MULTI);
-
- AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.ALL_CATEGORY,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
- );
-
- fOutlineViewer= new JavaOutlineViewer(tree);
- ColoredViewersManager.install(fOutlineViewer);
- initDragAndDrop();
- fOutlineViewer.setContentProvider(new ChildrenProvider());
- fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(lprovider));
-
- Object[] listeners= fSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- fSelectionChangedListeners.remove(listeners[i]);
- fOutlineViewer.addSelectionChangedListener((ISelectionChangedListener) listeners[i]);
- }
-
- listeners= fPostSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- fPostSelectionChangedListeners.remove(listeners[i]);
- fOutlineViewer.addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]);
- }
-
- MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager m) {
- contextMenuAboutToShow(m);
- }
- });
- fMenu= manager.createContextMenu(tree);
- tree.setMenu(fMenu);
-
- IPageSite site= getSite();
- site.registerContextMenu(JavaScriptPlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$
-
- updateSelectionProvider(site);
-
- // we must create the groups after we have set the selection provider to the site
- fActionGroups= new CompositeActionGroup(new ActionGroup[] {
- new OpenViewActionGroup(this),
- new CCPActionGroup(this),
- new GenerateActionGroup(this),
- new RefactorActionGroup(this),
- new JavaSearchActionGroup(this)});
-
- // register global actions
- IActionBars actionBars= site.getActionBars();
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fEditor.getAction(ITextEditorActionConstants.UNDO));
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fEditor.getAction(ITextEditorActionConstants.REDO));
-
- IAction action= fEditor.getAction(ITextEditorActionConstants.NEXT);
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
- action= fEditor.getAction(ITextEditorActionConstants.PREVIOUS);
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
-
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
-
- fActionGroups.fillActionBars(actionBars);
-
- IStatusLineManager statusLineManager= actionBars.getStatusLineManager();
- if (statusLineManager != null) {
- StatusBarUpdater updater= new StatusBarUpdater(statusLineManager);
- fOutlineViewer.addPostSelectionChangedListener(updater);
- }
- // Custom filter group
- fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.eclipse.wst.jsdt.ui.JavaOutlinePage", fOutlineViewer); //$NON-NLS-1$
-
- registerToolbarActions(actionBars);
-
- fOutlineViewer.setInput(fInput);
- }
-
- /*
- *
- */
- private void updateSelectionProvider(IPageSite site) {
- ISelectionProvider provider= fOutlineViewer;
- if (fInput != null) {
- IJavaScriptUnit cu= (IJavaScriptUnit)fInput.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null && !JavaModelUtil.isPrimary(cu))
- provider= new EmptySelectionProvider();
- }
- site.setSelectionProvider(provider);
- }
-
- public void dispose() {
-
- if (fEditor == null)
- return;
-
- if (fMemberFilterActionGroup != null) {
- fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
- }
-
- if (fCategoryFilterActionGroup != null) {
- fCategoryFilterActionGroup.dispose();
- fCategoryFilterActionGroup= null;
- }
-
- if (fCustomFiltersActionGroup != null) {
- fCustomFiltersActionGroup.dispose();
- fCustomFiltersActionGroup= null;
- }
-
-
- fEditor.outlinePageClosed();
- fEditor= null;
-
- fSelectionChangedListeners.clear();
- fSelectionChangedListeners= null;
-
- fPostSelectionChangedListeners.clear();
- fPostSelectionChangedListeners= null;
-
- if (fPropertyChangeListener != null) {
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener= null;
- }
-
- if (fMenu != null && !fMenu.isDisposed()) {
- fMenu.dispose();
- fMenu= null;
- }
-
- if (fActionGroups != null)
- fActionGroups.dispose();
-
- fTogglePresentation.setEditor(null);
-
- fOutlineViewer= null;
-
- super.dispose();
- }
-
- public Control getControl() {
- if (fOutlineViewer != null)
- return fOutlineViewer.getControl();
- return null;
- }
-
- public void setInput(IJavaScriptElement inputElement) {
- fInput= inputElement;
- if (fOutlineViewer != null) {
- fOutlineViewer.setInput(fInput);
- updateSelectionProvider(getSite());
- }
- if (fCategoryFilterActionGroup != null)
- fCategoryFilterActionGroup.setInput(new IJavaScriptElement[] {fInput});
- }
-
- public void select(ISourceReference reference) {
- if (fOutlineViewer != null) {
-
- ISelection s= fOutlineViewer.getSelection();
- if (s instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) s;
- List elements= ss.toList();
- if (!elements.contains(reference)) {
- s= (reference == null ? StructuredSelection.EMPTY : new StructuredSelection(reference));
- fOutlineViewer.setSelection(s, true);
- }
- }
- }
- }
-
- public void setAction(String actionID, IAction action) {
- Assert.isNotNull(actionID);
- if (action == null)
- fActions.remove(actionID);
- else
- fActions.put(actionID, action);
- }
-
- public IAction getAction(String actionID) {
- Assert.isNotNull(actionID);
- return (IAction) fActions.get(actionID);
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { JavaScriptUI.ID_PACKAGES };
- }
-
- };
- }
- if (key == IShowInTarget.class) {
- return getShowInTarget();
- }
-
- return null;
- }
-
- /**
- * Convenience method to add the action installed under the given actionID to the
- * specified group of the menu.
- *
- * @param menu the menu manager
- * @param group the group to which to add the action
- * @param actionID the ID of the new action
- */
- protected void addAction(IMenuManager menu, String group, String actionID) {
- IAction action= getAction(actionID);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
-
- if (action.isEnabled()) {
- IMenuManager subMenu= menu.findMenuUsingPath(group);
- if (subMenu != null)
- subMenu.add(action);
- else
- menu.appendToGroup(group, action);
- }
- }
- }
-
- protected void contextMenuAboutToShow(IMenuManager menu) {
-
- JavaScriptPlugin.createStandardGroups(menu);
-
- IStructuredSelection selection= (IStructuredSelection)getSelection();
- fActionGroups.setContext(new ActionContext(selection));
- fActionGroups.fillContextMenu(menu);
- }
-
- /*
- * @see Page#setFocus()
- */
- public void setFocus() {
- if (fOutlineViewer != null)
- fOutlineViewer.getControl().setFocus();
- }
-
- /**
- * Checks whether a given Java element is an inner type.
- *
- * @param element the java element
- * @return <code>true</code> iff the given element is an inner type
- */
- private boolean isInnerType(IJavaScriptElement element) {
-
- if (element != null && element.getElementType() == IJavaScriptElement.TYPE) {
- IType type= (IType)element;
- try {
- return type.isMember();
- } catch (JavaScriptModelException e) {
- IJavaScriptElement parent= type.getParent();
- if (parent != null) {
- int parentElementType= parent.getElementType();
- return (parentElementType != IJavaScriptElement.JAVASCRIPT_UNIT && parentElementType != IJavaScriptElement.CLASS_FILE);
- }
- }
- }
-
- return false;
- }
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- *
- * @return the {@link IShowInSource}
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
- /**
- * Returns the <code>IShowInTarget</code> for this view.
- *
- * @return the {@link IShowInTarget}
- */
- protected IShowInTarget getShowInTarget() {
- return new IShowInTarget() {
- public boolean show(ShowInContext context) {
- ISelection sel= context.getSelection();
- if (sel instanceof ITextSelection) {
- ITextSelection tsel= (ITextSelection) sel;
- int offset= tsel.getOffset();
- IJavaScriptElement element= fEditor.getElementAt(offset);
- if (element != null) {
- setSelection(new StructuredSelection(element));
- return true;
- }
- } else if (sel instanceof IStructuredSelection) {
- setSelection(sel);
- return true;
- }
- return false;
- }
- };
- }
-
- private void initDragAndDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getInstance()
- };
-
- // Drop Adapter
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fOutlineViewer)
- };
- fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
-
- // Drag Adapter
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fOutlineViewer)
- };
- fOutlineViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fOutlineViewer, dragListeners));
- }
-
- /**
- * Returns whether only the contents of the top level type is to be shown.
- *
- * @return <code>true</code> if only the contents of the top level type is to be shown.
- *
- */
- protected final boolean isTopLevelTypeOnly() {
- return fTopLevelTypeOnly;
- }
-
- /**
- * Returns the <code>JavaOutlineViewer</code> of this view.
- *
- * @return the {@link JavaOutlineViewer}
- *
- */
- protected final JavaOutlineViewer getOutlineViewer() {
- return fOutlineViewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java
deleted file mode 100644
index e702726b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.Iterator;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension;
-import org.eclipse.ui.texteditor.SelectMarkerRulerAction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.JavaCorrectionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Action which gets triggered when selecting (annotations) in the vertical ruler.
- *
- * <p>
- * Was originally called >code>JavaSelectMarkerRulerAction</code>.
- * </p>
- */
-public class JavaSelectAnnotationRulerAction extends SelectMarkerRulerAction {
-
- private ITextEditor fTextEditor;
- private Position fPosition;
- private Annotation fAnnotation;
- private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
- private IPreferenceStore fStore;
- private boolean fHasCorrection;
- private ResourceBundle fBundle;
-
- public JavaSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) {
- super(bundle, prefix, editor, ruler);
- fBundle= bundle;
- fTextEditor= editor;
-
- fAnnotationPreferenceLookup= EditorsUI.getAnnotationPreferenceLookup();
- fStore= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
- }
-
- public void run() {
- if (fStore.getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
- return;
-
- runWithEvent(null);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
- *
- */
- public void runWithEvent(Event event) {
- if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
- ((OverrideIndicatorManager.OverrideIndicator)fAnnotation).open();
- return;
- }
-
- if (fHasCorrection) {
- ITextOperationTarget operation= (ITextOperationTarget) fTextEditor.getAdapter(ITextOperationTarget.class);
- final int opCode= ISourceViewer.QUICK_ASSIST;
- if (operation != null && operation.canDoOperation(opCode)) {
- fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
- operation.doOperation(opCode);
- }
- return;
- }
-
- super.run();
- }
-
- public void update() {
- findJavaAnnotation();
- setEnabled(true); // super.update() might change this later
-
- if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
- initialize(fBundle, "JavaSelectAnnotationRulerAction.OpenSuperImplementation."); //$NON-NLS-1$
- return;
- }
- if (fHasCorrection) {
- if (fAnnotation instanceof AssistAnnotation)
- initialize(fBundle, "JavaSelectAnnotationRulerAction.QuickAssist."); //$NON-NLS-1$
- else
- initialize(fBundle, "JavaSelectAnnotationRulerAction.QuickFix."); //$NON-NLS-1$
- return;
- }
-
- initialize(fBundle, "JavaSelectAnnotationRulerAction.GotoAnnotation."); //$NON-NLS-1$;
- super.update();
- }
-
- private void findJavaAnnotation() {
- fPosition= null;
- fAnnotation= null;
- fHasCorrection= false;
-
- AbstractMarkerAnnotationModel model= getAnnotationModel();
- IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();
-
- IDocument document= getDocument();
- if (model == null)
- return ;
-
- boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
-
- Iterator iter= model.getAnnotationIterator();
- int layer= Integer.MIN_VALUE;
-
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
- if (annotation.isMarkedDeleted())
- continue;
-
- int annotationLayer= layer;
- if (annotationAccess != null) {
- annotationLayer= annotationAccess.getLayer(annotation);
- if (annotationLayer < layer)
- continue;
- }
-
- Position position= model.getPosition(annotation);
- if (!includesRulerLine(position, document))
- continue;
-
- boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
- if (!isReadOnly
- && (
- ((hasAssistLightbulb && annotation instanceof AssistAnnotation)
- || JavaCorrectionProcessor.hasCorrections(annotation)))) {
- fPosition= position;
- fAnnotation= annotation;
- fHasCorrection= true;
- layer= annotationLayer;
- continue;
- } else {
- AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
- if (preference == null)
- continue;
-
- String key= preference.getVerticalRulerPreferenceKey();
- if (key == null)
- continue;
-
- if (fStore.getBoolean(key)) {
- fPosition= position;
- fAnnotation= annotation;
- fHasCorrection= false;
- layer= annotationLayer;
- }
- }
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectMarkerRulerAction2.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectMarkerRulerAction2.java
deleted file mode 100644
index fd6cd759..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectMarkerRulerAction2.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.VerticalRulerEvent;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.SelectAnnotationRulerAction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.JavaCorrectionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaExpandHover;
-
-/**
- * A special select marker ruler action which activates quick fix if clicked on a quick fixable problem.
- */
-public class JavaSelectMarkerRulerAction2 extends SelectAnnotationRulerAction {
-
- public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
- */
- public void annotationDefaultSelected(VerticalRulerEvent event) {
- Annotation annotation= event.getSelectedAnnotation();
- IAnnotationModel model= getAnnotationModel();
-
- if (isOverrideIndicator(annotation)) {
- ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
- return;
- }
-
- if (isBreakpoint(annotation))
- triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
-
- Position position= model.getPosition(annotation);
- if (position == null)
- return;
-
- if (isQuickFixTarget(annotation)) {
- ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
- final int opCode= ISourceViewer.QUICK_ASSIST;
- if (operation != null && operation.canDoOperation(opCode)) {
- getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
- operation.doOperation(opCode);
- return;
- }
- }
-
- // default:
- super.annotationDefaultSelected(event);
- }
-
- /**
- * Tells whether the given annotation is an override annotation.
- *
- * @param annotation the annotation
- * @return <code>true</code> iff the annotation is an override annotation
- */
- private boolean isOverrideIndicator(Annotation annotation) {
- return annotation instanceof OverrideIndicatorManager.OverrideIndicator;
- }
-
- /**
- * Checks whether the given annotation is a breakpoint annotation.
- *
- * @param annotation
- * @return <code>true</code> if the annotation is a breakpoint annotation
- */
- private boolean isBreakpoint(Annotation annotation) {
- return annotation.getType().equals("org.eclipse.debug.core.breakpoint") || annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
- }
-
- private boolean isQuickFixTarget(Annotation a) {
- return JavaCorrectionProcessor.hasCorrections(a) || a instanceof AssistAnnotation;
- }
-
- private void triggerAction(String actionID) {
- IAction action= getTextEditor().getAction(actionID);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- // hack to propagate line change
- if (action instanceof ISelectionListener) {
- ((ISelectionListener)action).selectionChanged(null, null);
- }
- if (action.isEnabled())
- action.run();
- }
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectRulerAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectRulerAction.java
deleted file mode 100644
index c7affd4a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSelectRulerAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class JavaSelectRulerAction extends AbstractRulerActionDelegate {
-
- /*
- * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
- */
- protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
- return new JavaSelectAnnotationRulerAction(JavaEditorMessages.getBundleForConstructedKeys(), "JavaSelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSourceViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSourceViewer.java
deleted file mode 100644
index 09085a15..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaSourceViewer.java
+++ /dev/null
@@ -1,630 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextPresentationListener;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.reconciler.IReconciler;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BidiSegmentEvent;
-import org.eclipse.swt.custom.BidiSegmentListener;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.text.SmartBackspaceManager;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingContext;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-
-
-public class JavaSourceViewer extends ProjectionViewer implements IPropertyChangeListener {
-
- /**
- * Text operation code for requesting the outline for the current input.
- */
- public static final int SHOW_OUTLINE= 51;
-
- /**
- * Text operation code for requesting the outline for the element at the current position.
- */
- public static final int OPEN_STRUCTURE= 52;
-
- /**
- * Text operation code for requesting the hierarchy for the current input.
- */
- public static final int SHOW_HIERARCHY= 53;
-
- private IInformationPresenter fOutlinePresenter;
- private IInformationPresenter fStructurePresenter;
- private IInformationPresenter fHierarchyPresenter;
-
- /**
- * This viewer's foreground color.
- *
- */
- private Color fForegroundColor;
- /**
- * The viewer's background color.
- *
- */
- private Color fBackgroundColor;
- /**
- * This viewer's selection foreground color.
- *
- */
- private Color fSelectionForegroundColor;
- /**
- * The viewer's selection background color.
- *
- */
- private Color fSelectionBackgroundColor;
- /**
- * The preference store.
- *
- *
- */
- private IPreferenceStore fPreferenceStore;
- /**
- * Is this source viewer configured?
- *
- *
- */
- private boolean fIsConfigured;
- /**
- * The backspace manager of this viewer.
- *
- *
- */
- private SmartBackspaceManager fBackspaceManager;
-
- /**
- * Whether to delay setting the visual document until the projection has been computed.
- * <p>
- * Added for performance optimization.
- * </p>
- * @see #prepareDelayedProjection()
- *
- */
- private boolean fIsSetVisibleDocumentDelayed= false;
-
- public JavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
- super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
- setPreferenceStore(store);
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext()
- *
- */
- public IFormattingContext createFormattingContext() {
-
- // it's ok to use instance preferences here as subclasses replace
- // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer)
- IFormattingContext context= new CommentFormattingContext();
- Map map= new HashMap(JavaScriptCore.getOptions());
- context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map);
-
- return context;
- }
-
- /*
- * @see ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
- if (getTextWidget() == null)
- return;
-
- switch (operation) {
- case SHOW_OUTLINE:
- if (fOutlinePresenter != null)
- fOutlinePresenter.showInformation();
- return;
- case OPEN_STRUCTURE:
- if (fStructurePresenter != null)
- fStructurePresenter.showInformation();
- return;
- case SHOW_HIERARCHY:
- if (fHierarchyPresenter != null)
- fHierarchyPresenter.showInformation();
- return;
- }
-
- super.doOperation(operation);
- }
-
- /*
- * @see ITextOperationTarget#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
- if (operation == SHOW_OUTLINE)
- return fOutlinePresenter != null;
- if (operation == OPEN_STRUCTURE)
- return fStructurePresenter != null;
- if (operation == SHOW_HIERARCHY)
- return fHierarchyPresenter != null;
-
- return super.canDoOperation(operation);
- }
-
- /*
- * @see ISourceViewer#configure(SourceViewerConfiguration)
- */
- public void configure(SourceViewerConfiguration configuration) {
-
- /*
- * Prevent access to colors disposed in unconfigure(), see:
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53641
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86177
- */
- StyledText textWidget= getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- Color foregroundColor= textWidget.getForeground();
- if (foregroundColor != null && foregroundColor.isDisposed())
- textWidget.setForeground(null);
- Color backgroundColor= textWidget.getBackground();
- if (backgroundColor != null && backgroundColor.isDisposed())
- textWidget.setBackground(null);
- }
-
- super.configure(configuration);
- if (configuration instanceof JavaScriptSourceViewerConfiguration) {
- JavaScriptSourceViewerConfiguration javaSVCconfiguration= (JavaScriptSourceViewerConfiguration)configuration;
- fOutlinePresenter= javaSVCconfiguration.getOutlinePresenter(this, false);
- if (fOutlinePresenter != null)
- fOutlinePresenter.install(this);
-
- fStructurePresenter= javaSVCconfiguration.getOutlinePresenter(this, true);
- if (fStructurePresenter != null)
- fStructurePresenter.install(this);
-
- fHierarchyPresenter= javaSVCconfiguration.getHierarchyPresenter(this, true);
- if (fHierarchyPresenter != null)
- fHierarchyPresenter.install(this);
-
- }
-
- if (fPreferenceStore != null) {
- fPreferenceStore.addPropertyChangeListener(this);
- initializeViewerColors();
- }
-
- fIsConfigured= true;
- }
-
-
- protected void initializeViewerColors() {
- if (fPreferenceStore != null) {
-
- StyledText styledText= getTextWidget();
-
- // ----------- foreground color --------------------
- Color color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
- styledText.setForeground(color);
-
- if (fForegroundColor != null)
- fForegroundColor.dispose();
-
- fForegroundColor= color;
-
- // ---------- background color ----------------------
- color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
- styledText.setBackground(color);
-
- if (fBackgroundColor != null)
- fBackgroundColor.dispose();
-
- fBackgroundColor= color;
-
- // ----------- selection foreground color --------------------
- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
- ? null
- : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, styledText.getDisplay());
- styledText.setSelectionForeground(color);
-
- if (fSelectionForegroundColor != null)
- fSelectionForegroundColor.dispose();
-
- fSelectionForegroundColor= color;
-
- // ---------- selection background color ----------------------
- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
- ? null
- : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, styledText.getDisplay());
- styledText.setSelectionBackground(color);
-
- if (fSelectionBackgroundColor != null)
- fSelectionBackgroundColor.dispose();
-
- fSelectionBackgroundColor= color;
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- *
- * @param store the store to read from
- * @param key the key used for the lookup in the preference store
- * @param display the display used create the color
- * @return the created color according to the specification in the preference store
- *
- */
- 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;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure()
- *
- */
- public void unconfigure() {
- if (fOutlinePresenter != null) {
- fOutlinePresenter.uninstall();
- fOutlinePresenter= null;
- }
- if (fStructurePresenter != null) {
- fStructurePresenter.uninstall();
- fStructurePresenter= null;
- }
- if (fHierarchyPresenter != null) {
- fHierarchyPresenter.uninstall();
- fHierarchyPresenter= null;
- }
- if (fForegroundColor != null) {
- fForegroundColor.dispose();
- fForegroundColor= null;
- }
- if (fBackgroundColor != null) {
- fBackgroundColor.dispose();
- fBackgroundColor= null;
- }
-
- if (fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(this);
-
- super.unconfigure();
-
- fIsConfigured= false;
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#rememberSelection()
- */
- public Point rememberSelection() {
- return super.rememberSelection();
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#restoreSelection()
- */
- public void restoreSelection() {
- super.restoreSelection();
- }
-
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
- || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
- || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
- || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property))
- {
- initializeViewerColors();
- }
- }
-
- /**
- * Sets the preference store on this viewer.
- *
- * @param store the preference store
- *
- *
- */
- public void setPreferenceStore(IPreferenceStore store) {
- if (fIsConfigured && fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(this);
-
- fPreferenceStore= store;
-
- if (fIsConfigured && fPreferenceStore != null) {
- fPreferenceStore.addPropertyChangeListener(this);
- initializeViewerColors();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextViewer#resetVisibleRegion()
- *
- */
- public void resetVisibleRegion() {
- super.resetVisibleRegion();
- // re-enable folding if ProjectionViewer failed to due so
- if (fPreferenceStore != null && fPreferenceStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED) && !isProjectionMode())
- enableProjection();
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#createControl(org.eclipse.swt.widgets.Composite, int)
- */
- protected void createControl(Composite parent, int styles) {
-
- // Use LEFT_TO_RIGHT unless otherwise specified.
- if ((styles & SWT.RIGHT_TO_LEFT) == 0 && (styles & SWT.LEFT_TO_RIGHT) == 0)
- styles |= SWT.LEFT_TO_RIGHT;
-
- super.createControl(parent, styles);
-
- fBackspaceManager= new SmartBackspaceManager();
- fBackspaceManager.install(this);
-
- StyledText text= getTextWidget();
- text.addBidiSegmentListener(new BidiSegmentListener() {
- public void lineGetSegments(BidiSegmentEvent event) {
- if (redraws())
- event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
- }
- });
- }
-
- /**
- * Returns the backspace manager for this viewer.
- *
- * @return the backspace manager for this viewer, or <code>null</code> if
- * there is none
- *
- */
- public SmartBackspaceManager getBackspaceManager() {
- return fBackspaceManager;
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#handleDispose()
- */
- protected void handleDispose() {
- if (fBackspaceManager != null) {
- fBackspaceManager.uninstall();
- fBackspaceManager= null;
- }
-
- super.handleDispose();
- }
-
- /**
- * Prepends the text presentation listener at the beginning of the viewer's
- * list of text presentation listeners. If the listener is already registered
- * with the viewer this call moves the listener to the beginning of
- * the list.
- *
- * @param listener the text presentation listener
- *
- */
- public void prependTextPresentationListener(ITextPresentationListener listener) {
-
- Assert.isNotNull(listener);
-
- if (fTextPresentationListeners == null)
- fTextPresentationListeners= new ArrayList();
-
- fTextPresentationListeners.remove(listener);
- fTextPresentationListeners.add(0, listener);
- }
-
- /**
- * Sets the given reconciler.
- *
- * @param reconciler the reconciler
- *
- */
- void setReconciler(IReconciler reconciler) {
- fReconciler= reconciler;
- }
-
- /**
- * Returns the reconciler.
- *
- * @return the reconciler or <code>null</code> if not set
- *
- */
- IReconciler getReconciler() {
- return fReconciler;
- }
-
- /**
- * Returns a segmentation of the given line appropriate for BIDI rendering. The default
- * implementation returns only the string literals of a java code line as segments.
- *
- * @param widgetLineOffset the offset of the line
- * @param line the content of the line
- * @return the line's BIDI segmentation
- */
- protected int[] getBidiLineSegments(int widgetLineOffset, String line) {
- if (line != null && line.length() > 0) {
- int lineOffset= widgetOffset2ModelOffset(widgetLineOffset);
- try {
- return getBidiLineSegments(getDocument(), lineOffset);
- } catch (BadLocationException x) {
- return null; // don't segment line in this case
- }
- }
- return null;
- }
-
- /**
- * Returns a segmentation of the line of the given document appropriate for
- * BIDI rendering. The default implementation returns only the string literals of a java code
- * line as segments.
- *
- * @param document the document
- * @param lineOffset the offset of the line
- * @return the line's BIDI segmentation
- * @throws BadLocationException in case lineOffset is not valid in document
- */
- protected static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException {
-
- if (document == null)
- return null;
-
- IRegion line= document.getLineInformationOfOffset(lineOffset);
- ITypedRegion[] linePartitioning= TextUtilities.computePartitioning(document, IJavaScriptPartitions.JAVA_PARTITIONING, lineOffset, line.getLength(), false);
-
- List segmentation= new ArrayList();
- for (int i= 0; i < linePartitioning.length; i++) {
- if (IJavaScriptPartitions.JAVA_STRING.equals(linePartitioning[i].getType()))
- segmentation.add(linePartitioning[i]);
- }
-
-
- if (segmentation.size() == 0)
- return null;
-
- int size= segmentation.size();
- int[] segments= new int[size * 2 + 1];
-
- int j= 0;
- for (int i= 0; i < size; i++) {
- ITypedRegion segment= (ITypedRegion) segmentation.get(i);
-
- if (i == 0)
- segments[j++]= 0;
-
- int offset= segment.getOffset() - lineOffset;
- if (offset > segments[j - 1])
- segments[j++]= offset;
-
- if (offset + segment.getLength() >= line.getLength())
- break;
-
- segments[j++]= offset + segment.getLength();
- }
-
- if (j < segments.length) {
- int[] result= new int[j];
- System.arraycopy(segments, 0, result, 0, j);
- segments= result;
- }
-
- return segments;
- }
-
- /**
- * Delays setting the visual document until after the projection has been computed.
- * This method must only be called before the document is set on the viewer.
- * <p>
- * This is a performance optimization to reduce the computation of
- * the text presentation triggered by <code>setVisibleDocument(IDocument)</code>.
- * </p>
- *
- * @see #setVisibleDocument(IDocument)
- *
- */
- void prepareDelayedProjection() {
- Assert.isTrue(!fIsSetVisibleDocumentDelayed);
- fIsSetVisibleDocumentDelayed= true;
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * This is a performance optimization to reduce the computation of
- * the text presentation triggered by {@link #setVisibleDocument(IDocument)}
- * </p>
- * @see #prepareDelayedProjection()
- *
- */
- protected void setVisibleDocument(IDocument document) {
- if (fIsSetVisibleDocumentDelayed) {
- fIsSetVisibleDocumentDelayed= false;
- IDocument previous= getVisibleDocument();
- enableProjection(); // will set the visible document if anything is folded
- IDocument current= getVisibleDocument();
- // if the visible document was not replaced, continue as usual
- if (current != null && current != previous)
- return;
- }
-
- super.setVisibleDocument(document);
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Performance optimization: since we know at this place
- * that none of the clients expects the given range to be
- * untouched we reuse the given range as return value.
- * </p>
- */
- protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
- IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
- if (region != null) {
- // don't clone the style range, but simply reuse it.
- range.start= region.getOffset();
- range.length= region.getLength();
- return range;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaTextSelection.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaTextSelection.java
deleted file mode 100644
index ed1f305b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/JavaTextSelection.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.wst.jsdt.internal.corext.dom.Selection;
-import org.eclipse.wst.jsdt.internal.corext.dom.SelectionAnalyzer;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-
-/**
- * A special text selection that gives access to the resolved and
- * enclosing element.
- */
-public class JavaTextSelection extends TextSelection {
-
- private IJavaScriptElement fElement;
- private IJavaScriptElement[] fResolvedElements;
-
- private boolean fEnclosingElementRequested;
- private IJavaScriptElement fEnclosingElement;
-
- private boolean fPartialASTRequested;
- private JavaScriptUnit fPartialAST;
-
- private boolean fNodesRequested;
- private ASTNode[] fSelectedNodes;
- private ASTNode fCoveringNode;
-
- private boolean fInMethodBodyRequested;
- private boolean fInMethodBody;
-
- private boolean fInClassInitializerRequested;
- private boolean fInClassInitializer;
-
- private boolean fInVariableInitializerRequested;
- private boolean fInVariableInitializer;
-
- /**
- * Creates a new text selection at the given offset and length.
- */
- public JavaTextSelection(IJavaScriptElement element, IDocument document, int offset, int length) {
- super(document, offset, length);
- fElement= element;
- }
-
- /**
- * Resolves the <code>IJavaScriptElement</code>s at the current offset. Returns
- * an empty array if the string under the offset doesn't resolve to a
- * <code>IJavaScriptElement</code>.
- *
- * @return the resolved java elements at the current offset
- * @throws JavaScriptModelException passed from the underlying code resolve API
- */
- public IJavaScriptElement[] resolveElementAtOffset() throws JavaScriptModelException {
- if (fResolvedElements != null)
- return fResolvedElements;
- // long start= System.currentTimeMillis();
- fResolvedElements= SelectionConverter.codeResolve(fElement, this);
- // System.out.println("Time resolving element: " + (System.currentTimeMillis() - start));
- return fResolvedElements;
- }
-
- public IJavaScriptElement resolveEnclosingElement() throws JavaScriptModelException {
- if (fEnclosingElementRequested)
- return fEnclosingElement;
- fEnclosingElementRequested= true;
- fEnclosingElement= SelectionConverter.resolveEnclosingElement(fElement, this);
- return fEnclosingElement;
- }
-
- public JavaScriptUnit resolvePartialAstAtOffset() {
- if (fPartialASTRequested)
- return fPartialAST;
- fPartialASTRequested= true;
- if (! (fElement instanceof IJavaScriptUnit))
- return null;
- // long start= System.currentTimeMillis();
- fPartialAST= JavaScriptPlugin.getDefault().getASTProvider().getAST(fElement, ASTProvider.WAIT_YES, null);
- // System.out.println("Time requesting partial AST: " + (System.currentTimeMillis() - start));
- return fPartialAST;
- }
-
- public ASTNode[] resolveSelectedNodes() {
- if (fNodesRequested)
- return fSelectedNodes;
- fNodesRequested= true;
- JavaScriptUnit root= resolvePartialAstAtOffset();
- if (root == null)
- return null;
- Selection ds= Selection.createFromStartLength(getOffset(), getLength());
- SelectionAnalyzer analyzer= new SelectionAnalyzer(ds, false);
- root.accept(analyzer);
- fSelectedNodes= analyzer.getSelectedNodes();
- fCoveringNode= analyzer.getLastCoveringNode();
- return fSelectedNodes;
- }
-
- public ASTNode resolveCoveringNode() {
- if (fNodesRequested)
- return fCoveringNode;
- resolveSelectedNodes();
- return fCoveringNode;
- }
-
- public boolean resolveInMethodBody() {
- if (fInMethodBodyRequested)
- return fInMethodBody;
- fInMethodBodyRequested= true;
- resolveSelectedNodes();
- ASTNode node= getStartNode();
- if (node == null) {
- fInMethodBody= true;
- } else {
- while (node != null) {
- int nodeType= node.getNodeType();
- if (nodeType == ASTNode.BLOCK && node.getParent() instanceof BodyDeclaration) {
- fInMethodBody= node.getParent().getNodeType() == ASTNode.FUNCTION_DECLARATION;
- break;
- } else if (nodeType == ASTNode.ANONYMOUS_CLASS_DECLARATION) {
- fInMethodBody= false;
- break;
- }
- node= node.getParent();
- }
- }
- return fInMethodBody;
- }
-
- public boolean resolveInClassInitializer() {
- if (fInClassInitializerRequested)
- return fInClassInitializer;
- fInClassInitializerRequested= true;
- resolveSelectedNodes();
- ASTNode node= getStartNode();
- if (node == null) {
- fInClassInitializer= true;
- } else {
- while (node != null) {
- int nodeType= node.getNodeType();
- if (node instanceof AbstractTypeDeclaration) {
- fInClassInitializer= false;
- break;
- } else if (nodeType == ASTNode.ANONYMOUS_CLASS_DECLARATION) {
- fInClassInitializer= false;
- break;
- } else if (nodeType == ASTNode.INITIALIZER) {
- fInClassInitializer= true;
- break;
- }
- node= node.getParent();
- }
- }
- return fInClassInitializer;
- }
-
- public boolean resolveInVariableInitializer() {
- if (fInVariableInitializerRequested)
- return fInVariableInitializer;
- fInVariableInitializerRequested= true;
- resolveSelectedNodes();
- ASTNode node= getStartNode();
- ASTNode last= null;
- while (node != null) {
- int nodeType= node.getNodeType();
- if (node instanceof AbstractTypeDeclaration) {
- fInVariableInitializer= false;
- break;
- } else if (nodeType == ASTNode.ANONYMOUS_CLASS_DECLARATION) {
- fInVariableInitializer= false;
- break;
- } else if (nodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT &&
- ((VariableDeclarationFragment)node).getInitializer() == last) {
- fInVariableInitializer= true;
- break;
- } else if (nodeType == ASTNode.SINGLE_VARIABLE_DECLARATION &&
- ((SingleVariableDeclaration)node).getInitializer() == last) {
- fInVariableInitializer= true;
- break;
- }
- last= node;
- node= node.getParent();
- }
- return fInVariableInitializer;
- }
-
- private ASTNode getStartNode() {
- if (fSelectedNodes != null && fSelectedNodes.length > 0)
- return fSelectedNodes[0];
- else
- return fCoveringNode;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlink.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlink.java
deleted file mode 100644
index d4c785b5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlink.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.AccessorClassReference;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSHintHelper;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-
-
-/**
- * NLS key hyperlink.
- *
- *
- */
-public class NLSKeyHyperlink implements IHyperlink {
-
- private IRegion fRegion;
- private AccessorClassReference fAccessorClassReference;
- private IEditorPart fEditor;
- private final String fKeyName;
-
-
- /**
- * Creates a new NLS key hyperlink.
- *
- * @param region
- * @param keyName
- * @param ref
- * @param editor the editor which contains the hyperlink
- */
- public NLSKeyHyperlink(IRegion region, String keyName, AccessorClassReference ref, IEditorPart editor) {
- Assert.isNotNull(region);
- Assert.isNotNull(keyName);
- Assert.isNotNull(ref);
- Assert.isNotNull(editor);
-
- fRegion= region;
- fKeyName= keyName;
- fAccessorClassReference= ref;
- fEditor= editor;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
- */
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#open()
- */
- public void open() {
- IStorage propertiesFile= null;
- try {
- ITypeBinding typeBinding= fAccessorClassReference.getBinding();
- propertiesFile= NLSHintHelper.getResourceBundle(typeBinding.getJavaElement().getJavaScriptProject(), fAccessorClassReference);
- } catch (JavaScriptModelException e) {
- // Don't open the file
- }
- if (propertiesFile == null) {
- showErrorInStatusLine(fEditor, JavaEditorMessages.Editor_OpenPropertiesFile_error_fileNotFound_dialogMessage);
- return;
- }
-
- IEditorPart editor;
- try {
- editor= EditorUtility.openInEditor(propertiesFile, true);
- } catch (PartInitException e) {
- handleOpenPropertiesFileFailed(propertiesFile);
- return;
- } catch (JavaScriptModelException e) {
- handleOpenPropertiesFileFailed(propertiesFile);
- return;
- }
-
-// // Reveal the key in the properties file
-// if (editor instanceof ITextEditor) {
-// IRegion region= null;
-// boolean found= false;
-//
-// // Find key in document
-// IEditorInput editorInput= editor.getEditorInput();
-// IDocument document= ((ITextEditor)editor).getDocumentProvider().getDocument(editorInput);
-// if (document != null) {
-// FindReplaceDocumentAdapter finder= new FindReplaceDocumentAdapter(document);
-// PropertyKeyHyperlinkDetector detector= new PropertyKeyHyperlinkDetector();
-// detector.setContext(editor);
-// String key= PropertyFileDocumentModel.unwindEscapeChars(fKeyName);
-// int offset= document.getLength() - 1;
-// try {
-// while (!found && offset >= 0) {
-// region= finder.find(offset, key, false, true, false, false);
-// if (region == null)
-// offset= -1;
-// else {
-// // test whether it's the key
-// IHyperlink[] hyperlinks= detector.detectHyperlinks(null, region, false);
-// if (hyperlinks != null) {
-// for (int i= 0; i < hyperlinks.length; i++) {
-// IRegion hyperlinkRegion= hyperlinks[i].getHyperlinkRegion();
-// found= key.equals(document.get(hyperlinkRegion.getOffset(), hyperlinkRegion.getLength()));
-// }
-// } else if (document instanceof IDocumentExtension3) {
-// // Fall back: test using properties file partitioning
-// ITypedRegion partition= null;
-// partition= ((IDocumentExtension3)document).getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, region.getOffset(), false);
-// found= IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
-// && key.equals(document.get(partition.getOffset(), partition.getLength()).trim());
-// }
-// // Prevent endless loop (panic code, shouldn't be needed)
-// if (offset == region.getOffset())
-// offset= -1;
-// else
-// offset= region.getOffset();
-// }
-// }
-// } catch (BadLocationException ex) {
-// found= false;
-// } catch (BadPartitioningException e1) {
-// found= false;
-// }
-// }
-// if (found)
-// EditorUtility.revealInEditor(editor, region);
-// else {
-// EditorUtility.revealInEditor(editor, 0, 0);
-// showErrorInStatusLine(editor, Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_error_keyNotFound, fKeyName));
-// }
-// }
- }
-
- private void showErrorInStatusLine(IEditorPart editor, final String message) {
- final Display display= fEditor.getSite().getShell().getDisplay();
- display.beep();
- final IEditorStatusLine statusLine= (IEditorStatusLine)editor.getAdapter(IEditorStatusLine.class);
- if (statusLine != null) {
- display.asyncExec(new Runnable() {
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
- statusLine.setMessage(true, message, null);
- }
- });
- }
- }
-
- private void handleOpenPropertiesFileFailed(IStorage propertiesFile) {
- showErrorInStatusLine(fEditor, Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_error_openEditor_dialogMessage, propertiesFile.getFullPath().toOSString()));
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java
deleted file mode 100644
index 7d942ec5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.QualifiedName;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.StringLiteral;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.AccessorClassReference;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSHintHelper;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-/**
- * NLS hyperlink detector.
- *
- *
- */
-public class NLSKeyHyperlinkDetector extends AbstractHyperlinkDetector {
-
-
- /*
- * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean)
- */
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
- if (region == null || textEditor == null || canShowMultipleHyperlinks)
- return null;
-
- IEditorSite site= textEditor.getEditorSite();
- if (site == null)
- return null;
-
- IJavaScriptElement javaElement= getInputJavaElement(textEditor);
- if (javaElement == null)
- return null;
-
- JavaScriptUnit ast= JavaScriptPlugin.getDefault().getASTProvider().getAST(javaElement, ASTProvider.WAIT_NO, null);
- if (ast == null)
- return null;
-
- ASTNode node= NodeFinder.perform(ast, region.getOffset(), 1);
- if (!(node instanceof StringLiteral) && !(node instanceof SimpleName))
- return null;
-
- if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY)
- return null;
-
- IRegion nlsKeyRegion= new Region(node.getStartPosition(), node.getLength());
- AccessorClassReference ref= NLSHintHelper.getAccessorClassReference(ast, nlsKeyRegion);
- if (ref == null)
- return null;
- String keyName= null;
- if (node instanceof StringLiteral) {
- keyName= ((StringLiteral)node).getLiteralValue();
- } else {
- keyName= ((SimpleName)node).getIdentifier();
- }
- if (keyName != null)
- return new IHyperlink[] {new NLSKeyHyperlink(nlsKeyRegion, keyName, ref, textEditor)};
-
- return null;
- }
-
- private IJavaScriptElement getInputJavaElement(ITextEditor editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IClassFileEditorInput)
- return ((IClassFileEditorInput)editorInput).getClassFile();
-
- if (editor instanceof CompilationUnitEditor)
- return JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorImageProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorImageProvider.java
deleted file mode 100644
index 3fb2f17d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorImageProvider.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.texteditor.IAnnotationImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Image provider for {@link org.eclipse.wst.jsdt.internal.ui.javaeditor.OverrideIndicatorManager.OverrideIndicator} annotations.
- *
- *
- */
-public class OverrideIndicatorImageProvider implements IAnnotationImageProvider {
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
- */
- private static final String OVERRIDE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_OVERRIDES"; //$NON-NLS-1$
- private static final String OVERWRITE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_IMPLEMENTS"; //$NON-NLS-1$
- public Image getManagedImage(Annotation annotation) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
- */
- public String getImageDescriptorId(Annotation annotation) {
- if (!isImageProviderFor(annotation))
- return null;
-
- if (isOverwriting(annotation))
- return OVERWRITE_IMG_DESC_ID;
- else
- return OVERRIDE_IMG_DESC_ID;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
- */
- public ImageDescriptor getImageDescriptor(String imageDescritporId) {
- if (OVERWRITE_IMG_DESC_ID.equals(imageDescritporId))
- return JavaPluginImages.DESC_OBJ_IMPLEMENTS;
- else if (OVERRIDE_IMG_DESC_ID.equals(imageDescritporId))
- return JavaPluginImages.DESC_OBJ_OVERRIDES;
-
- return null;
- }
-
- private boolean isImageProviderFor(Annotation annotation) {
- return annotation != null && OverrideIndicatorManager.ANNOTATION_TYPE.equals(annotation.getType());
- }
-
- private boolean isOverwriting(Annotation annotation) {
- return ((OverrideIndicatorManager.OverrideIndicator)annotation).isOverwriteIndicator();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorManager.java
deleted file mode 100644
index 2f36a80a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/OverrideIndicatorManager.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Manages the override and overwrite indicators for
- * the given Java element and annotation model.
- *
- *
- */
-class OverrideIndicatorManager implements IJavaReconcilingListener {
-
- /**
- * Overwrite and override indicator annotation.
- *
- *
- */
- class OverrideIndicator extends Annotation {
-
- private boolean fIsOverwriteIndicator;
- private String fAstNodeKey;
-
- /**
- * Creates a new override annotation.
- *
- * @param isOverwriteIndicator <code>true</code> if this annotation is
- * an overwrite indicator, <code>false</code> otherwise
- * @param text the text associated with this annotation
- * @param key the method binding key
- *
- */
- OverrideIndicator(boolean isOverwriteIndicator, String text, String key) {
- super(ANNOTATION_TYPE, false, text);
- fIsOverwriteIndicator= isOverwriteIndicator;
- fAstNodeKey= key;
- }
-
- /**
- * Tells whether this is an overwrite or an override indicator.
- *
- * @return <code>true</code> if this is an overwrite indicator
- */
- public boolean isOverwriteIndicator() {
- return fIsOverwriteIndicator;
- }
-
- /**
- * Opens and reveals the defining method.
- */
- public void open() {
- JavaScriptUnit ast= ASTProvider.getASTProvider().getAST(fJavaElement, ASTProvider.WAIT_ACTIVE_ONLY, null);
- if (ast != null) {
- ASTNode node= ast.findDeclaringNode(fAstNodeKey);
- if (node instanceof FunctionDeclaration) {
- try {
- IFunctionBinding methodBinding= ((FunctionDeclaration)node).resolveBinding();
- IFunctionBinding definingMethodBinding= Bindings.findOverriddenMethod(methodBinding, true);
- if (definingMethodBinding != null) {
- IJavaScriptElement definingMethod= definingMethodBinding.getJavaElement();
- if (definingMethod != null) {
- JavaScriptUI.openInEditor(definingMethod, true, true);
- return;
- }
- }
- } catch (CoreException e) {
- ExceptionHandler.handle(e, JavaEditorMessages.OverrideIndicatorManager_open_error_title, JavaEditorMessages.OverrideIndicatorManager_open_error_messageHasLogEntry);
- return;
- }
- }
- }
- String title= JavaEditorMessages.OverrideIndicatorManager_open_error_title;
- String message= JavaEditorMessages.OverrideIndicatorManager_open_error_message;
- MessageDialog.openError(JavaScriptPlugin.getActiveWorkbenchShell(), title, message);
- }
- }
-
- static final String ANNOTATION_TYPE= "org.eclipse.wst.jsdt.ui.overrideIndicator"; //$NON-NLS-1$
-
- private IAnnotationModel fAnnotationModel;
- private Object fAnnotationModelLockObject;
- private Annotation[] fOverrideAnnotations;
- private IJavaScriptElement fJavaElement;
-
-
- public OverrideIndicatorManager(IAnnotationModel annotationModel, IJavaScriptElement javaElement, JavaScriptUnit ast) {
- Assert.isNotNull(annotationModel);
- Assert.isNotNull(javaElement);
-
- fJavaElement= javaElement;
- fAnnotationModel=annotationModel;
- fAnnotationModelLockObject= getLockObject(fAnnotationModel);
-
- updateAnnotations(ast, new NullProgressMonitor());
- }
-
- /**
- * Returns the lock object for the given annotation model.
- *
- * @param annotationModel the annotation model
- * @return the annotation model's lock object
- *
- */
- private Object getLockObject(IAnnotationModel annotationModel) {
- if (annotationModel instanceof ISynchronizable) {
- Object lock= ((ISynchronizable)annotationModel).getLockObject();
- if (lock != null)
- return lock;
- }
- return annotationModel;
- }
-
- /**
- * Updates the override and implements annotations based
- * on the given AST.
- *
- * @param ast the compilation unit AST
- * @param progressMonitor the progress monitor
- *
- */
- protected void updateAnnotations(JavaScriptUnit ast, IProgressMonitor progressMonitor) {
-
- if (ast == null || progressMonitor.isCanceled())
- return;
-
- final Map annotationMap= new HashMap(50);
-
- ast.accept(new ASTVisitor(false) {
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.FunctionDeclaration)
- */
- public boolean visit(FunctionDeclaration node) {
- IFunctionBinding binding= node.resolveBinding();
- if (binding != null) {
- IFunctionBinding definingMethod= Bindings.findOverriddenMethod(binding, true);
- if (definingMethod != null) {
-
- ITypeBinding definingType= definingMethod.getDeclaringClass();
- String qualifiedMethodName= definingType.getQualifiedName() + "." + binding.getName(); //$NON-NLS-1$
-
- boolean isImplements= JdtFlags.isAbstract(definingMethod);
- String text;
- if (isImplements)
- text= Messages.format(JavaEditorMessages.OverrideIndicatorManager_implements, qualifiedMethodName);
- else
- text= Messages.format(JavaEditorMessages.OverrideIndicatorManager_overrides, qualifiedMethodName);
-
- SimpleName name= node.getName();
- Position position= new Position(name.getStartPosition(), name.getLength());
-
- annotationMap.put(
- new OverrideIndicator(isImplements, text, binding.getKey()),
- position);
-
- }
- }
- return true;
- }
- });
-
- if (progressMonitor.isCanceled())
- return;
-
- synchronized (fAnnotationModelLockObject) {
- if (fAnnotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, annotationMap);
- } else {
- removeAnnotations();
- Iterator iter= annotationMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry mapEntry= (Map.Entry)iter.next();
- fAnnotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue());
- }
- }
- fOverrideAnnotations= (Annotation[])annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
- }
- }
-
- /**
- * Removes all override indicators from this manager's annotation model.
- */
- void removeAnnotations() {
- if (fOverrideAnnotations == null)
- return;
-
- synchronized (fAnnotationModelLockObject) {
- if (fAnnotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null);
- } else {
- for (int i= 0, length= fOverrideAnnotations.length; i < length; i++)
- fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]);
- }
- fOverrideAnnotations= null;
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
- */
- public void aboutToBeReconciled() {
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(JavaScriptUnit, boolean, IProgressMonitor)
- */
- public void reconciled(JavaScriptUnit ast, boolean forced, IProgressMonitor progressMonitor) {
- updateAnnotations(ast, progressMonitor);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/RemoveOccurrenceAnnotations.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/RemoveOccurrenceAnnotations.java
deleted file mode 100644
index 39beaa7e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/RemoveOccurrenceAnnotations.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * Remove occurrence annotations action.
- *
- *
- */
-class RemoveOccurrenceAnnotations extends Action {
-
- /** The Java editor to which this actions belongs. */
- private final JavaEditor fEditor;
-
- /**
- * Creates this action.
- *
- * @param editor the Java editor for which to remove the occurrence annotations
- */
- RemoveOccurrenceAnnotations(JavaEditor editor) {
- fEditor = editor;
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- fEditor.removeOccurrenceAnnotations();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlighting.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlighting.java
deleted file mode 100644
index deb1e381..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlighting.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.resource.ColorRegistry;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Semantic highlighting
- */
-public abstract class SemanticHighlighting {
-
- /**
- * @return the preference key, will be augmented by a prefix and a suffix for each preference
- */
- public abstract String getPreferenceKey();
-
- /**
- * @return the default default text color
- *
- */
- public abstract RGB getDefaultDefaultTextColor();
-
- /**
- * @return the default default text color
- */
- public RGB getDefaultTextColor() {
- return findRGB(PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(),
- getThemeColorKey(),
- getDefaultDefaultTextColor());
- }
-
- /**
- * @return <code>true</code> if the text attribute bold is set by default
- */
- public abstract boolean isBoldByDefault();
-
- /**
- * @return <code>true</code> if the text attribute italic is set by default
- */
- public abstract boolean isItalicByDefault();
-
- /**
- * @return <code>true</code> if the text attribute strikethrough is set by default
- *
- */
- public boolean isStrikethroughByDefault() {
- return false;
- }
-
- /**
- * @return <code>true</code> if the text attribute underline is set by default
- *
- */
- public boolean isUnderlineByDefault() {
- return false;
- }
-
- /**
- * @return <code>true</code> if the text attribute italic is enabled by default
- */
- public abstract boolean isEnabledByDefault();
-
- /**
- * @return the display name
- */
- public abstract String getDisplayName();
-
- /**
- * Returns <code>true</code> iff the semantic highlighting consumes the semantic token.
- * <p>
- * NOTE: Implementors are not allowed to keep a reference on the token or on any object
- * retrieved from the token.
- * </p>
- *
- * @param token the semantic token for a {@link org.eclipse.wst.jsdt.core.dom.SimpleName}
- * @return <code>true</code> iff the semantic highlighting consumes the semantic token
- */
- public abstract boolean consumes(SemanticToken token);
-
- /**
- * Returns <code>true</code> iff the semantic highlighting consumes the
- * semantic token.
- * <p>
- * NOTE: Implementors are not allowed to keep a reference on the token or on
- * any object retrieved from the token.
- * </p>
- * @param token the semantic token for a
- * {@link org.eclipse.wst.jsdt.core.dom.NumberLiteral},
- * {@link org.eclipse.wst.jsdt.core.dom.BooleanLiteral} or
- * {@link org.eclipse.wst.jsdt.core.dom.CharacterLiteral}
- * @return <code>true</code> iff the semantic highlighting consumes the
- * semantic token
- */
- public boolean consumesLiteral(SemanticToken token) {
- return false;
- }
-
- private String getThemeColorKey() {
- return JavaScriptUI.ID_PLUGIN + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /**
- * Returns the RGB for the given key in the given color registry.
- *
- * @param registry the color registry
- * @param key the key for the constant in the registry
- * @param defaultRGB the default RGB if no entry is found
- * @return RGB the RGB
- *
- */
- private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) {
- RGB rgb= registry.getRGB(key);
- if (rgb != null)
- return rgb;
- return defaultRGB;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingManager.java
deleted file mode 100644
index 187537cc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingManager.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.StringConverter;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaPresentationReconciler;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IColorManagerExtension;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-/**
- * Semantic highlighting manager
- *
- *
- */
-public class SemanticHighlightingManager implements IPropertyChangeListener {
-
- /**
- * Highlighting.
- */
- static class Highlighting { // TODO: rename to HighlightingStyle
-
- /** Text attribute */
- private TextAttribute fTextAttribute;
- /** Enabled state */
- private boolean fIsEnabled;
-
- /**
- * Initialize with the given text attribute.
- * @param textAttribute The text attribute
- * @param isEnabled the enabled state
- */
- public Highlighting(TextAttribute textAttribute, boolean isEnabled) {
- setTextAttribute(textAttribute);
- setEnabled(isEnabled);
- }
-
- /**
- * @return Returns the text attribute.
- */
- public TextAttribute getTextAttribute() {
- return fTextAttribute;
- }
-
- /**
- * @param textAttribute The background to set.
- */
- public void setTextAttribute(TextAttribute textAttribute) {
- fTextAttribute= textAttribute;
- }
-
- /**
- * @return the enabled state
- */
- public boolean isEnabled() {
- return fIsEnabled;
- }
-
- /**
- * @param isEnabled the new enabled state
- */
- public void setEnabled(boolean isEnabled) {
- fIsEnabled= isEnabled;
- }
- }
-
- /**
- * Highlighted Positions.
- */
- static class HighlightedPosition extends Position {
-
- /** Highlighting of the position */
- private Highlighting fStyle;
-
- /** Lock object */
- private Object fLock;
-
- /**
- * Initialize the styled positions with the given offset, length and foreground color.
- *
- * @param offset The position offset
- * @param length The position length
- * @param highlighting The position's highlighting
- * @param lock The lock object
- */
- public HighlightedPosition(int offset, int length, Highlighting highlighting, Object lock) {
- super(offset, length);
- fStyle= highlighting;
- fLock= lock;
- }
-
- /**
- * @return Returns a corresponding style range.
- */
- public StyleRange createStyleRange() {
- int len= 0;
- if (fStyle.isEnabled())
- len= getLength();
-
- TextAttribute textAttribute= fStyle.getTextAttribute();
- int style= textAttribute.getStyle();
- int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
- StyleRange styleRange= new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle);
- styleRange.strikeout= (style & TextAttribute.STRIKETHROUGH) != 0;
- styleRange.underline= (style & TextAttribute.UNDERLINE) != 0;
-
- return styleRange;
- }
-
- /**
- * Uses reference equality for the highlighting.
- *
- * @param off The offset
- * @param len The length
- * @param highlighting The highlighting
- * @return <code>true</code> iff the given offset, length and highlighting are equal to the internal ones.
- */
- public boolean isEqual(int off, int len, Highlighting highlighting) {
- synchronized (fLock) {
- return !isDeleted() && getOffset() == off && getLength() == len && fStyle == highlighting;
- }
- }
-
- /**
- * Is this position contained in the given range (inclusive)? Synchronizes on position updater.
- *
- * @param off The range offset
- * @param len The range length
- * @return <code>true</code> iff this position is not delete and contained in the given range.
- */
- public boolean isContained(int off, int len) {
- synchronized (fLock) {
- return !isDeleted() && off <= getOffset() && off + len >= getOffset() + getLength();
- }
- }
-
- public void update(int off, int len) {
- synchronized (fLock) {
- super.setOffset(off);
- super.setLength(len);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.Position#setLength(int)
- */
- public void setLength(int length) {
- synchronized (fLock) {
- super.setLength(length);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.Position#setOffset(int)
- */
- public void setOffset(int offset) {
- synchronized (fLock) {
- super.setOffset(offset);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.Position#delete()
- */
- public void delete() {
- synchronized (fLock) {
- super.delete();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.Position#undelete()
- */
- public void undelete() {
- synchronized (fLock) {
- super.undelete();
- }
- }
-
- /**
- * @return Returns the highlighting.
- */
- public Highlighting getHighlighting() {
- return fStyle;
- }
- }
-
- /**
- * Highlighted ranges.
- */
- public static class HighlightedRange extends Region {
- /** The highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}. */
- private String fKey;
-
- /**
- * Initialize with the given offset, length and highlighting key.
- *
- * @param offset
- * @param length
- * @param key the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
- */
- public HighlightedRange(int offset, int length, String key) {
- super(offset, length);
- fKey= key;
- }
-
- /**
- * @return the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
- */
- public String getKey() {
- return fKey;
- }
-
- /*
- * @see org.eclipse.jface.text.Region#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- return super.equals(o) && o instanceof HighlightedRange && fKey.equals(((HighlightedRange)o).getKey());
- }
-
- /*
- * @see org.eclipse.jface.text.Region#hashCode()
- */
- public int hashCode() {
- return super.hashCode() | fKey.hashCode();
- }
- }
-
- /** Semantic highlighting presenter */
- private SemanticHighlightingPresenter fPresenter;
- /** Semantic highlighting reconciler */
- private SemanticHighlightingReconciler fReconciler;
-
- /** Semantic highlightings */
- private SemanticHighlighting[] fSemanticHighlightings;
- /** Highlightings */
- private Highlighting[] fHighlightings;
-
- /** The editor */
- private JavaEditor fEditor;
- /** The source viewer */
- private JavaSourceViewer fSourceViewer;
- /** The color manager */
- private IColorManager fColorManager;
- /** The preference store */
- private IPreferenceStore fPreferenceStore;
- /** The source viewer configuration */
- private JavaScriptSourceViewerConfiguration fConfiguration;
- /** The presentation reconciler */
- private JavaPresentationReconciler fPresentationReconciler;
-
- /** The hard-coded ranges */
- private HighlightedRange[][] fHardcodedRanges;
-
- /**
- * Install the semantic highlighting on the given editor infrastructure
- *
- * @param editor The Java editor
- * @param sourceViewer The source viewer
- * @param colorManager The color manager
- * @param preferenceStore The preference store
- */
- public void install(JavaEditor editor, JavaSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore) {
- fEditor= editor;
- fSourceViewer= sourceViewer;
- fColorManager= colorManager;
- fPreferenceStore= preferenceStore;
- if (fEditor != null) {
- fConfiguration= editor.createJavaSourceViewerConfiguration();
- fPresentationReconciler= (JavaPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer);
- } else {
- fConfiguration= null;
- fPresentationReconciler= null;
- }
-
- fPreferenceStore.addPropertyChangeListener(this);
-
- if (isEnabled())
- enable();
- }
-
- /**
- * Install the semantic highlighting on the given source viewer infrastructure. No reconciliation will be performed.
- *
- * @param sourceViewer the source viewer
- * @param colorManager the color manager
- * @param preferenceStore the preference store
- * @param hardcodedRanges the hard-coded ranges to be highlighted
- */
- public void install(JavaSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore, HighlightedRange[][] hardcodedRanges) {
- fHardcodedRanges= hardcodedRanges;
- install(null, sourceViewer, colorManager, preferenceStore);
- }
-
- /**
- * Enable semantic highlighting.
- */
- private void enable() {
- initializeHighlightings();
-
- fPresenter= new SemanticHighlightingPresenter();
- fPresenter.install(fSourceViewer, fPresentationReconciler);
-
- if (fEditor != null) {
- fReconciler= new SemanticHighlightingReconciler();
- fReconciler.install(fEditor, fSourceViewer, fPresenter, fSemanticHighlightings, fHighlightings);
- } else {
- fPresenter.updatePresentation(null, createHardcodedPositions(), new HighlightedPosition[0]);
- }
- }
-
- /**
- * Computes the hard-coded positions from the hard-coded ranges
- *
- * @return the hard-coded positions
- */
- private HighlightedPosition[] createHardcodedPositions() {
- List positions= new ArrayList();
- for (int i= 0; i < fHardcodedRanges.length; i++) {
- HighlightedRange range= null;
- Highlighting hl= null;
- for (int j= 0; j < fHardcodedRanges[i].length; j++ ) {
- hl= getHighlighting(fHardcodedRanges[i][j].getKey());
- if (hl.isEnabled()) {
- range= fHardcodedRanges[i][j];
- break;
- }
- }
-
- if (range != null)
- positions.add(fPresenter.createHighlightedPosition(range.getOffset(), range.getLength(), hl));
- }
- return (HighlightedPosition[]) positions.toArray(new HighlightedPosition[positions.size()]);
- }
-
- /**
- * Returns the highlighting corresponding to the given key.
- *
- * @param key the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
- * @return the corresponding highlighting
- */
- private Highlighting getHighlighting(String key) {
- for (int i= 0; i < fSemanticHighlightings.length; i++) {
- SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
- if (key.equals(semanticHighlighting.getPreferenceKey()))
- return fHighlightings[i];
- }
- return null;
- }
-
- /**
- * Uninstall the semantic highlighting
- */
- public void uninstall() {
- disable();
-
- if (fPreferenceStore != null) {
- fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore= null;
- }
-
- fEditor= null;
- fSourceViewer= null;
- fColorManager= null;
- fConfiguration= null;
- fPresentationReconciler= null;
- fHardcodedRanges= null;
- }
-
- /**
- * Disable semantic highlighting.
- */
- private void disable() {
- if (fReconciler != null) {
- fReconciler.uninstall();
- fReconciler= null;
- }
-
- if (fPresenter != null) {
- fPresenter.uninstall();
- fPresenter= null;
- }
-
- if (fSemanticHighlightings != null)
- disposeHighlightings();
- }
-
- /**
- * @return <code>true</code> iff semantic highlighting is enabled in the preferences
- */
- private boolean isEnabled() {
- return SemanticHighlightings.isEnabled(fPreferenceStore);
- }
-
- /**
- * Initialize semantic highlightings.
- */
- private void initializeHighlightings() {
- fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
- fHighlightings= new Highlighting[fSemanticHighlightings.length];
-
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
- String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
- addColor(colorKey);
-
- String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
- int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
-
- String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
- if (fPreferenceStore.getBoolean(italicKey))
- style |= SWT.ITALIC;
-
- String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
- if (fPreferenceStore.getBoolean(strikethroughKey))
- style |= TextAttribute.STRIKETHROUGH;
-
- String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
- if (fPreferenceStore.getBoolean(underlineKey))
- style |= TextAttribute.UNDERLINE;
-
- boolean isEnabled= fPreferenceStore.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting));
-
- fHighlightings[i]= new Highlighting(new TextAttribute(fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)), null, style), isEnabled);
- }
- }
-
- /**
- * Dispose the semantic highlightings.
- */
- private void disposeHighlightings() {
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
- removeColor(SemanticHighlightings.getColorPreferenceKey(fSemanticHighlightings[i]));
-
- fSemanticHighlightings= null;
- fHighlightings= null;
- }
-
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- handlePropertyChangeEvent(event);
- }
-
- /**
- * Handle the given property change event
- *
- * @param event The event
- */
- private void handlePropertyChangeEvent(PropertyChangeEvent event) {
- if (fPreferenceStore == null)
- return; // Uninstalled during event notification
-
- if (fConfiguration != null)
- fConfiguration.handlePropertyChangeEvent(event);
-
- if (SemanticHighlightings.affectsEnablement(fPreferenceStore, event)) {
- if (isEnabled())
- enable();
- else
- disable();
- }
-
- if (!isEnabled())
- return;
-
- boolean refreshNeeded= false;
-
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
-
- String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
- if (colorKey.equals(event.getProperty())) {
- adaptToTextForegroundChange(fHighlightings[i], event);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
-
- String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
- if (boldKey.equals(event.getProperty())) {
- adaptToTextStyleChange(fHighlightings[i], event, SWT.BOLD);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
-
- String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
- if (italicKey.equals(event.getProperty())) {
- adaptToTextStyleChange(fHighlightings[i], event, SWT.ITALIC);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
-
- String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
- if (strikethroughKey.equals(event.getProperty())) {
- adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.STRIKETHROUGH);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
-
- String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
- if (underlineKey.equals(event.getProperty())) {
- adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.UNDERLINE);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
-
- String enabledKey= SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting);
- if (enabledKey.equals(event.getProperty())) {
- adaptToEnablementChange(fHighlightings[i], event);
- fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
- continue;
- }
- }
-
- if (refreshNeeded && fReconciler != null)
- fReconciler.refresh();
- }
-
- private void adaptToEnablementChange(Highlighting highlighting, PropertyChangeEvent event) {
- Object value= event.getNewValue();
- boolean eventValue;
- if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
- else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
- else
- eventValue= false;
- highlighting.setEnabled(eventValue);
- }
-
- private void adaptToTextForegroundChange(Highlighting highlighting, 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();
- Color color= fColorManager.getColor(property);
-
- if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
- ext.unbindColor(property);
- ext.bindColor(property, rgb);
- color= fColorManager.getColor(property);
- }
-
- TextAttribute oldAttr= highlighting.getTextAttribute();
- highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
- }
- }
-
- private void adaptToTextStyleChange(Highlighting highlighting, PropertyChangeEvent event, int styleAttribute) {
- boolean eventValue= false;
- Object value= event.getNewValue();
- if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
- else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
-
- TextAttribute oldAttr= highlighting.getTextAttribute();
- boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
-
- if (activeValue != eventValue)
- highlighting.setTextAttribute(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
- }
-
- private void addColor(String colorKey) {
- if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
- RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
- if (fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
- ext.unbindColor(colorKey);
- ext.bindColor(colorKey, rgb);
- }
- }
- }
-
- private void removeColor(String colorKey) {
- if (fColorManager instanceof IColorManagerExtension)
- ((IColorManagerExtension) fColorManager).unbindColor(colorKey);
- }
-
- /**
- * Returns this hightlighter's reconciler.
- *
- * @return the semantic highlighter reconciler or <code>null</code> if none
- *
- */
- public SemanticHighlightingReconciler getReconciler() {
- return fReconciler;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java
deleted file mode 100644
index b0054bc5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java
+++ /dev/null
@@ -1,772 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-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.IDocumentListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextPresentationListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager.HighlightedPosition;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager.Highlighting;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaPresentationReconciler;
-
-
-/**
- * Semantic highlighting presenter - UI thread implementation.
- *
- *
- */
-public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
-
- /**
- * Semantic highlighting position updater.
- */
- private class HighlightingPositionUpdater implements IPositionUpdater {
-
- /** The position category. */
- private final String fCategory;
-
- /**
- * Creates a new updater for the given <code>category</code>.
- *
- * @param category the new category.
- */
- public HighlightingPositionUpdater(String category) {
- fCategory= category;
- }
-
- /*
- * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
- */
- public void update(DocumentEvent event) {
-
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventEnd= eventOffset + eventOldLength;
-
- try {
- Position[] positions= event.getDocument().getPositions(fCategory);
-
- for (int i= 0; i != positions.length; i++) {
-
- HighlightedPosition position= (HighlightedPosition) positions[i];
-
- // Also update deleted positions because they get deleted by the background thread and removed/invalidated only in the UI runnable
-// if (position.isDeleted())
-// continue;
-
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
-
- if (offset > eventEnd)
- updateWithPrecedingEvent(position, event);
- else if (end < eventOffset)
- updateWithSucceedingEvent(position, event);
- else if (offset <= eventOffset && end >= eventEnd)
- updateWithIncludedEvent(position, event);
- else if (offset <= eventOffset)
- updateWithOverEndEvent(position, event);
- else if (end >= eventEnd)
- updateWithOverStartEvent(position, event);
- else
- updateWithIncludingEvent(position, event);
- }
- } catch (BadPositionCategoryException e) {
- // ignore and return
- }
- }
-
- /**
- * Update the given position with the given event. The event precedes the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithPrecedingEvent(HighlightedPosition position, DocumentEvent event) {
- String newText= event.getText();
- int eventNewLength= newText != null ? newText.length() : 0;
- int deltaLength= eventNewLength - event.getLength();
-
- position.setOffset(position.getOffset() + deltaLength);
- }
-
- /**
- * Update the given position with the given event. The event succeeds the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithSucceedingEvent(HighlightedPosition position, DocumentEvent event) {
- }
-
- /**
- * Update the given position with the given event. The event is included by the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithIncludedEvent(HighlightedPosition position, DocumentEvent event) {
- int eventOffset= event.getOffset();
- String newText= event.getText();
- if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
-
- int deltaLength= eventNewLength - event.getLength();
-
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
-
- int includedLength= 0;
- while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
- includedLength++;
- if (includedLength == eventNewLength)
- position.setLength(length + deltaLength);
- else {
- int newLeftLength= eventOffset - offset + includedLength;
-
- int excludedLength= eventNewLength;
- while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
- excludedLength--;
- int newRightOffset= eventOffset + excludedLength;
- int newRightLength= end + deltaLength - newRightOffset;
-
- if (newRightLength == 0) {
- position.setLength(newLeftLength);
- } else {
- if (newLeftLength == 0) {
- position.update(newRightOffset, newRightLength);
- } else {
- position.setLength(newLeftLength);
- addPositionFromUI(newRightOffset, newRightLength, position.getHighlighting());
- }
- }
- }
- }
-
- /**
- * Update the given position with the given event. The event overlaps with the end of the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithOverEndEvent(HighlightedPosition position, DocumentEvent event) {
- String newText= event.getText();
- if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
-
- int includedLength= 0;
- while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
- includedLength++;
- position.setLength(event.getOffset() - position.getOffset() + includedLength);
- }
-
- /**
- * Update the given position with the given event. The event overlaps with the start of the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithOverStartEvent(HighlightedPosition position, DocumentEvent event) {
- int eventOffset= event.getOffset();
- int eventEnd= eventOffset + event.getLength();
-
- String newText= event.getText();
- if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
-
- int excludedLength= eventNewLength;
- while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
- excludedLength--;
- int deleted= eventEnd - position.getOffset();
- int inserted= eventNewLength - excludedLength;
- position.update(eventOffset + excludedLength, position.getLength() - deleted + inserted);
- }
-
- /**
- * Update the given position with the given event. The event includes the position.
- *
- * @param position The position
- * @param event The event
- */
- private void updateWithIncludingEvent(HighlightedPosition position, DocumentEvent event) {
- position.delete();
- position.update(event.getOffset(), 0);
- }
- }
-
- /** Position updater */
- private IPositionUpdater fPositionUpdater= new HighlightingPositionUpdater(getPositionCategory());
-
- /** The source viewer this semantic highlighting reconciler is installed on */
- private JavaSourceViewer fSourceViewer;
- /** The background presentation reconciler */
- private JavaPresentationReconciler fPresentationReconciler;
-
- /** UI's current highlighted positions - can contain <code>null</code> elements */
- private List fPositions= new ArrayList();
- /** UI position lock */
- private Object fPositionLock= new Object();
-
- /** <code>true</code> iff the current reconcile is canceled. */
- private boolean fIsCanceled= false;
-
- /**
- * Creates and returns a new highlighted position with the given offset, length and highlighting.
- * <p>
- * NOTE: Also called from background thread.
- * </p>
- *
- * @param offset The offset
- * @param length The length
- * @param highlighting The highlighting
- * @return The new highlighted position
- */
- public HighlightedPosition createHighlightedPosition(int offset, int length, Highlighting highlighting) {
- // TODO: reuse deleted positions
- return new HighlightedPosition(offset, length, highlighting, fPositionUpdater);
- }
-
- /**
- * Adds all current positions to the given list.
- * <p>
- * NOTE: Called from background thread.
- * </p>
- *
- * @param list The list
- */
- public void addAllPositions(List list) {
- synchronized (fPositionLock) {
- list.addAll(fPositions);
- }
- }
-
- /**
- * Create a text presentation in the background.
- * <p>
- * NOTE: Called from background thread.
- * </p>
- *
- * @param addedPositions the added positions
- * @param removedPositions the removed positions
- * @return the text presentation or <code>null</code>, if reconciliation should be canceled
- */
- public TextPresentation createPresentation(List addedPositions, List removedPositions) {
- JavaSourceViewer sourceViewer= fSourceViewer;
- JavaPresentationReconciler presentationReconciler= fPresentationReconciler;
- if (sourceViewer == null || presentationReconciler == null)
- return null;
-
- if (isCanceled())
- return null;
-
- IDocument document= sourceViewer.getDocument();
- if (document == null)
- return null;
-
- int minStart= Integer.MAX_VALUE;
- int maxEnd= Integer.MIN_VALUE;
- for (int i= 0, n= removedPositions.size(); i < n; i++) {
- Position position= (Position) removedPositions.get(i);
- int offset= position.getOffset();
- minStart= Math.min(minStart, offset);
- maxEnd= Math.max(maxEnd, offset + position.getLength());
- }
- for (int i= 0, n= addedPositions.size(); i < n; i++) {
- Position position= (Position) addedPositions.get(i);
- int offset= position.getOffset();
- minStart= Math.min(minStart, offset);
- maxEnd= Math.max(maxEnd, offset + position.getLength());
- }
-
- if (minStart < maxEnd)
- try {
- return presentationReconciler.createRepairDescription(new Region(minStart, maxEnd - minStart), document);
- } catch (RuntimeException e) {
- // Assume concurrent modification from UI thread
- }
-
- return null;
- }
-
- /**
- * Create a runnable for updating the presentation.
- * <p>
- * NOTE: Called from background thread.
- * </p>
- * @param textPresentation the text presentation
- * @param addedPositions the added positions
- * @param removedPositions the removed positions
- * @return the runnable or <code>null</code>, if reconciliation should be canceled
- */
- public Runnable createUpdateRunnable(final TextPresentation textPresentation, List addedPositions, List removedPositions) {
- if (fSourceViewer == null || textPresentation == null)
- return null;
-
- // TODO: do clustering of positions and post multiple fast runnables
- final HighlightedPosition[] added= new SemanticHighlightingManager.HighlightedPosition[addedPositions.size()];
- addedPositions.toArray(added);
- final SemanticHighlightingManager.HighlightedPosition[] removed= new SemanticHighlightingManager.HighlightedPosition[removedPositions.size()];
- removedPositions.toArray(removed);
-
- if (isCanceled())
- return null;
-
- Runnable runnable= new Runnable() {
- public void run() {
- updatePresentation(textPresentation, added, removed);
- }
- };
- return runnable;
- }
-
- /**
- * Invalidate the presentation of the positions based on the given added positions and the existing deleted positions.
- * Also unregisters the deleted positions from the document and patches the positions of this presenter.
- * <p>
- * NOTE: Indirectly called from background thread by UI runnable.
- * </p>
- * @param textPresentation the text presentation or <code>null</code>, if the presentation should computed in the UI thread
- * @param addedPositions the added positions
- * @param removedPositions the removed positions
- */
- public void updatePresentation(TextPresentation textPresentation, HighlightedPosition[] addedPositions, HighlightedPosition[] removedPositions) {
- if (fSourceViewer == null)
- return;
-
-// checkOrdering("added positions: ", Arrays.asList(addedPositions)); //$NON-NLS-1$
-// checkOrdering("removed positions: ", Arrays.asList(removedPositions)); //$NON-NLS-1$
-// checkOrdering("old positions: ", fPositions); //$NON-NLS-1$
-
- // TODO: double-check consistency with document.getPositions(...)
- // TODO: reuse removed positions
- if (isCanceled())
- return;
-
- IDocument document= fSourceViewer.getDocument();
- if (document == null)
- return;
-
- String positionCategory= getPositionCategory();
-
- List removedPositionsList= Arrays.asList(removedPositions);
-
- try {
- synchronized (fPositionLock) {
- List oldPositions= fPositions;
- int newSize= Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10);
-
- /*
- * The following loop is a kind of merge sort: it merges two List<Position>, each
- * sorted by position.offset, into one new list. The first of the two is the
- * previous list of positions (oldPositions), from which any deleted positions get
- * removed on the fly. The second of two is the list of added positions. The result
- * is stored in newPositions.
- */
- List newPositions= new ArrayList(newSize);
- Position position= null;
- Position addedPosition= null;
- for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length; i < n || position != null || j < m || addedPosition != null;) {
- // loop variant: i + j < old(i + j)
-
- // a) find the next non-deleted Position from the old list
- while (position == null && i < n) {
- position= (Position) oldPositions.get(i++);
- if (position.isDeleted() || contain(removedPositionsList, position)) {
- document.removePosition(positionCategory, position);
- position= null;
- }
- }
-
- // b) find the next Position from the added list
- if (addedPosition == null && j < m) {
- addedPosition= addedPositions[j++];
- document.addPosition(positionCategory, addedPosition);
- }
-
- // c) merge: add the next of position/addedPosition with the lower offset
- if (position != null) {
- if (addedPosition != null)
- if (position.getOffset() <= addedPosition.getOffset()) {
- newPositions.add(position);
- position= null;
- } else {
- newPositions.add(addedPosition);
- addedPosition= null;
- }
- else {
- newPositions.add(position);
- position= null;
- }
- } else if (addedPosition != null) {
- newPositions.add(addedPosition);
- addedPosition= null;
- }
- }
- fPositions= newPositions;
- }
- } catch (BadPositionCategoryException e) {
- // Should not happen
- JavaScriptPlugin.log(e);
- } catch (BadLocationException e) {
- // Should not happen
- JavaScriptPlugin.log(e);
- }
-// checkOrdering("new positions: ", fPositions); //$NON-NLS-1$
-
- if (textPresentation != null)
- fSourceViewer.changeTextPresentation(textPresentation, false);
- else
- fSourceViewer.invalidateTextPresentation();
- }
-
-// private void checkOrdering(String s, List positions) {
-// Position previous= null;
-// for (int i= 0, n= positions.size(); i < n; i++) {
-// Position current= (Position) positions.get(i);
-// if (previous != null && previous.getOffset() + previous.getLength() > current.getOffset())
-// return;
-// }
-// }
-
- /**
- * Returns <code>true</code> iff the positions contain the position.
- * @param positions the positions, must be ordered by offset but may overlap
- * @param position the position
- * @return <code>true</code> iff the positions contain the position
- */
- private boolean contain(List positions, Position position) {
- return indexOf(positions, position) != -1;
- }
-
- /**
- * Returns index of the position in the positions, <code>-1</code> if not found.
- * @param positions the positions, must be ordered by offset but may overlap
- * @param position the position
- * @return the index
- */
- private int indexOf(List positions, Position position) {
- int index= computeIndexAtOffset(positions, position.getOffset());
- int size= positions.size();
- while (index < size) {
- if (positions.get(index) == position)
- return index;
- index++;
- }
- return -1;
- }
-
- /**
- * Insert the given position in <code>fPositions</code>, s.t. the offsets remain in linear order.
- *
- * @param position The position for insertion
- */
- private void insertPosition(Position position) {
- int i= computeIndexAfterOffset(fPositions, position.getOffset());
- fPositions.add(i, position);
- }
-
- /**
- * Returns the index of the first position with an offset greater than the given offset.
- *
- * @param positions the positions, must be ordered by offset and must not overlap
- * @param offset the offset
- * @return the index of the last position with an offset greater than the given offset
- */
- private int computeIndexAfterOffset(List positions, int offset) {
- int i= -1;
- int j= positions.size();
- while (j - i > 1) {
- int k= (i + j) >> 1;
- Position position= (Position) positions.get(k);
- if (position.getOffset() > offset)
- j= k;
- else
- i= k;
- }
- return j;
- }
-
- /**
- * Returns the index of the first position with an offset equal or greater than the given offset.
- *
- * @param positions the positions, must be ordered by offset and must not overlap
- * @param offset the offset
- * @return the index of the last position with an offset equal or greater than the given offset
- */
- private int computeIndexAtOffset(List positions, int offset) {
- int i= -1;
- int j= positions.size();
- while (j - i > 1) {
- int k= (i + j) >> 1;
- Position position= (Position) positions.get(k);
- if (position.getOffset() >= offset)
- j= k;
- else
- i= k;
- }
- return j;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
- */
- public void applyTextPresentation(TextPresentation textPresentation) {
- IRegion region= textPresentation.getExtent();
- int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
- if (n - i > 2) {
- List ranges= new ArrayList(n - i);
- for (; i < n; i++) {
- HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
- if (!position.isDeleted())
- ranges.add(position.createStyleRange());
- }
- StyleRange[] array= new StyleRange[ranges.size()];
- array= (StyleRange[]) ranges.toArray(array);
- textPresentation.replaceStyleRanges(array);
- } else {
- for (; i < n; i++) {
- HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
- if (!position.isDeleted())
- textPresentation.replaceStyleRange(position.createStyleRange());
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- setCanceled(true);
- releaseDocument(oldInput);
- resetState();
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- manageDocument(newInput);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- setCanceled(true);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- }
-
- /**
- * @return Returns <code>true</code> iff the current reconcile is canceled.
- * <p>
- * NOTE: Also called from background thread.
- * </p>
- */
- public boolean isCanceled() {
- IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
- if (document == null)
- return fIsCanceled;
-
- synchronized (getLockObject(document)) {
- return fIsCanceled;
- }
- }
-
- /**
- * Set whether or not the current reconcile is canceled.
- *
- * @param isCanceled <code>true</code> iff the current reconcile is canceled
- */
- public void setCanceled(boolean isCanceled) {
- IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
- if (document == null) {
- fIsCanceled= isCanceled;
- return;
- }
-
- synchronized (getLockObject(document)) {
- fIsCanceled= isCanceled;
- }
- }
-
- /**
- * @param document the document
- * @return the document's lock object
- */
- private Object getLockObject(IDocument document) {
- if (document instanceof ISynchronizable) {
- Object lock= ((ISynchronizable)document).getLockObject();
- if (lock != null)
- return lock;
- }
- return document;
- }
-
- /**
- * Install this presenter on the given source viewer and background presentation
- * reconciler.
- *
- * @param sourceViewer the source viewer
- * @param backgroundPresentationReconciler the background presentation reconciler,
- * can be <code>null</code>, in that case {@link SemanticHighlightingPresenter#createPresentation(List, List)}
- * should not be called
- */
- public void install(JavaSourceViewer sourceViewer, JavaPresentationReconciler backgroundPresentationReconciler) {
- fSourceViewer= sourceViewer;
- fPresentationReconciler= backgroundPresentationReconciler;
-
- fSourceViewer.prependTextPresentationListener(this);
- fSourceViewer.addTextInputListener(this);
- manageDocument(fSourceViewer.getDocument());
- }
-
- /**
- * Uninstall this presenter.
- */
- public void uninstall() {
- setCanceled(true);
-
- if (fSourceViewer != null) {
- fSourceViewer.removeTextPresentationListener(this);
- releaseDocument(fSourceViewer.getDocument());
- invalidateTextPresentation();
- resetState();
-
- fSourceViewer.removeTextInputListener(this);
- fSourceViewer= null;
- }
- }
-
- /**
- * Invalidate text presentation of positions with the given highlighting.
- *
- * @param highlighting The highlighting
- */
- public void highlightingStyleChanged(Highlighting highlighting) {
- for (int i= 0, n= fPositions.size(); i < n; i++) {
- HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
- if (position.getHighlighting() == highlighting)
- fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
- }
- }
-
- /**
- * Invalidate text presentation of all positions.
- */
- private void invalidateTextPresentation() {
- for (int i= 0, n= fPositions.size(); i < n; i++) {
- Position position= (Position) fPositions.get(i);
- fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
- }
- }
-
- /**
- * Add a position with the given range and highlighting unconditionally, only from UI thread.
- * The position will also be registered on the document. The text presentation is not invalidated.
- *
- * @param offset The range offset
- * @param length The range length
- * @param highlighting
- */
- private void addPositionFromUI(int offset, int length, Highlighting highlighting) {
- Position position= createHighlightedPosition(offset, length, highlighting);
- synchronized (fPositionLock) {
- insertPosition(position);
- }
-
- IDocument document= fSourceViewer.getDocument();
- if (document == null)
- return;
- String positionCategory= getPositionCategory();
- try {
- document.addPosition(positionCategory, position);
- } catch (BadLocationException e) {
- // Should not happen
- JavaScriptPlugin.log(e);
- } catch (BadPositionCategoryException e) {
- // Should not happen
- JavaScriptPlugin.log(e);
- }
- }
-
- /**
- * Reset to initial state.
- */
- private void resetState() {
- synchronized (fPositionLock) {
- fPositions.clear();
- }
- }
-
- /**
- * Start managing the given document.
- *
- * @param document The document
- */
- private void manageDocument(IDocument document) {
- if (document != null) {
- document.addPositionCategory(getPositionCategory());
- document.addPositionUpdater(fPositionUpdater);
- document.addDocumentListener(this);
- }
- }
-
- /**
- * Stop managing the given document.
- *
- * @param document The document
- */
- private void releaseDocument(IDocument document) {
- if (document != null) {
- document.removeDocumentListener(this);
- document.removePositionUpdater(fPositionUpdater);
- try {
- document.removePositionCategory(getPositionCategory());
- } catch (BadPositionCategoryException e) {
- // Should not happen
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- /**
- * @return The semantic reconciler position's category.
- */
- private String getPositionCategory() {
- return toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java
deleted file mode 100644
index 860f2e69..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
-import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.Expression;
-import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
-import org.eclipse.wst.jsdt.core.dom.RegularExpressionLiteral;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.internal.corext.dom.GenericVisitor;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager.HighlightedPosition;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager.Highlighting;
-import org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener;
-
-
-/**
- * Semantic highlighting reconciler - Background thread implementation.
- *
- *
- */
-public class SemanticHighlightingReconciler implements IJavaReconcilingListener, ITextInputListener {
-
- /**
- * Collects positions from the AST.
- */
- private class PositionCollector extends GenericVisitor {
-
- /** The semantic token */
- private SemanticToken fToken= new SemanticToken();
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.dom.GenericVisitor#visitNode(org.eclipse.wst.jsdt.core.dom.ASTNode)
- */
- protected boolean visitNode(ASTNode node) {
- if ((node.getFlags() & ASTNode.MALFORMED) == ASTNode.MALFORMED) {
- retainPositions(node.getStartPosition(), node.getLength());
- return false;
- }
- return true;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.BooleanLiteral)
- */
- public boolean visit(BooleanLiteral node) {
- return visitLiteral(node);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.CharacterLiteral)
- */
- public boolean visit(CharacterLiteral node) {
- return visitLiteral(node);
- }
-
- public boolean visit(RegularExpressionLiteral node) {
- return visitLiteral(node);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.NumberLiteral)
- */
- public boolean visit(NumberLiteral node) {
- return visitLiteral(node);
- }
-
- private boolean visitLiteral(Expression node) {
- fToken.update(node);
- for (int i= 0, n= fJobSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumesLiteral(fToken)) {
- int offset= node.getStartPosition();
- int length= node.getLength();
- if (offset > -1 && length > 0)
- addPosition(offset, length, fJobHighlightings[i]);
- break;
- }
- }
- fToken.clear();
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.SimpleName)
- */
- public boolean visit(SimpleName node) {
- fToken.update(node);
- for (int i= 0, n= fJobSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) {
- int offset= node.getStartPosition();
- int length= node.getLength();
- if (offset > -1 && length > 0)
- addPosition(offset, length, fJobHighlightings[i]);
- break;
- }
- }
- fToken.clear();
- return false;
- }
-
- /**
- * Add a position with the given range and highlighting iff it does not exist already.
- * @param offset The range offset
- * @param length The range length
- * @param highlighting The highlighting
- */
- private void addPosition(int offset, int length, Highlighting highlighting) {
- boolean isExisting= false;
- // TODO: use binary search
- for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
- HighlightedPosition position= (HighlightedPosition) fRemovedPositions.get(i);
- if (position == null)
- continue;
- if (position.isEqual(offset, length, highlighting)) {
- isExisting= true;
- fRemovedPositions.set(i, null);
- fNOfRemovedPositions--;
- break;
- }
- }
-
- if (!isExisting) {
- Position position= fJobPresenter.createHighlightedPosition(offset, length, highlighting);
- fAddedPositions.add(position);
- }
- }
-
- /**
- * Retain the positions completely contained in the given range.
- * @param offset The range offset
- * @param length The range length
- */
- private void retainPositions(int offset, int length) {
- // TODO: use binary search
- for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
- HighlightedPosition position= (HighlightedPosition) fRemovedPositions.get(i);
- if (position != null && position.isContained(offset, length)) {
- fRemovedPositions.set(i, null);
- fNOfRemovedPositions--;
- }
- }
- }
- }
-
- /** Position collector */
- private PositionCollector fCollector= new PositionCollector();
-
- /** The Java editor this semantic highlighting reconciler is installed on */
- private JavaEditor fEditor;
- /** The source viewer this semantic highlighting reconciler is installed on */
- private ISourceViewer fSourceViewer;
- /** The semantic highlighting presenter */
- private SemanticHighlightingPresenter fPresenter;
- /** Semantic highlightings */
- private SemanticHighlighting[] fSemanticHighlightings;
- /** Highlightings */
- private Highlighting[] fHighlightings;
-
- /** Background job's added highlighted positions */
- private List fAddedPositions= new ArrayList();
- /** Background job's removed highlighted positions */
- private List fRemovedPositions= new ArrayList();
- /** Number of removed positions */
- private int fNOfRemovedPositions;
-
- /** Background job */
- private Job fJob;
- /** Background job lock */
- private final Object fJobLock= new Object();
- /**
- * Reconcile operation lock.
- *
- */
- private final Object fReconcileLock= new Object();
- /**
- * <code>true</code> if any thread is executing
- * <code>reconcile</code>, <code>false</code> otherwise.
- *
- */
- private boolean fIsReconciling= false;
-
- /** The semantic highlighting presenter - cache for background thread, only valid during {@link #reconciled(JavaScriptUnit, boolean, IProgressMonitor)} */
- private SemanticHighlightingPresenter fJobPresenter;
- /** Semantic highlightings - cache for background thread, only valid during {@link #reconciled(JavaScriptUnit, boolean, IProgressMonitor)} */
- private SemanticHighlighting[] fJobSemanticHighlightings;
- /** Highlightings - cache for background thread, only valid during {@link #reconciled(JavaScriptUnit, boolean, IProgressMonitor)} */
- private Highlighting[] fJobHighlightings;
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
- */
- public void aboutToBeReconciled() {
- // Do nothing
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(JavaScriptUnit, boolean, IProgressMonitor)
- */
- public void reconciled(JavaScriptUnit ast, boolean forced, IProgressMonitor progressMonitor) {
- // ensure at most one thread can be reconciling at any time
- synchronized (fReconcileLock) {
- if (fIsReconciling)
- return;
- else
- fIsReconciling= true;
- }
- fJobPresenter= fPresenter;
- fJobSemanticHighlightings= fSemanticHighlightings;
- fJobHighlightings= fHighlightings;
-
- try {
- if (fJobPresenter == null || fJobSemanticHighlightings == null || fJobHighlightings == null)
- return;
-
- fJobPresenter.setCanceled(progressMonitor.isCanceled());
-
- if (ast == null || fJobPresenter.isCanceled())
- return;
-
- ASTNode[] subtrees= getAffectedSubtrees(ast);
- if (subtrees.length == 0)
- return;
-
- startReconcilingPositions();
-
- if (!fJobPresenter.isCanceled())
- reconcilePositions(subtrees);
-
- TextPresentation textPresentation= null;
- if (!fJobPresenter.isCanceled())
- textPresentation= fJobPresenter.createPresentation(fAddedPositions, fRemovedPositions);
-
- if (!fJobPresenter.isCanceled())
- updatePresentation(textPresentation, fAddedPositions, fRemovedPositions);
-
- stopReconcilingPositions();
- } finally {
- fJobPresenter= null;
- fJobSemanticHighlightings= null;
- fJobHighlightings= null;
- synchronized (fReconcileLock) {
- fIsReconciling= false;
- }
- }
- }
-
- /**
- * @param node Root node
- * @return Array of subtrees that may be affected by past document changes
- */
- private ASTNode[] getAffectedSubtrees(ASTNode node) {
- // TODO: only return nodes which are affected by document changes - would require an 'anchor' concept for taking distant effects into account
- return new ASTNode[] { node };
- }
-
- /**
- * Start reconciling positions.
- */
- private void startReconcilingPositions() {
- fJobPresenter.addAllPositions(fRemovedPositions);
- fNOfRemovedPositions= fRemovedPositions.size();
- }
-
- /**
- * Reconcile positions based on the AST subtrees
- *
- * @param subtrees the AST subtrees
- */
- private void reconcilePositions(ASTNode[] subtrees) {
- // FIXME: remove positions not covered by subtrees
- for (int i= 0, n= subtrees.length; i < n; i++)
- subtrees[i].accept(fCollector);
- List oldPositions= fRemovedPositions;
- List newPositions= new ArrayList(fNOfRemovedPositions);
- for (int i= 0, n= oldPositions.size(); i < n; i ++) {
- Object current= oldPositions.get(i);
- if (current != null)
- newPositions.add(current);
- }
- fRemovedPositions= newPositions;
- }
-
- /**
- * Update the presentation.
- *
- * @param textPresentation the text presentation
- * @param addedPositions the added positions
- * @param removedPositions the removed positions
- */
- private void updatePresentation(TextPresentation textPresentation, List addedPositions, List removedPositions) {
- Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
- if (runnable == null)
- return;
-
- JavaEditor editor= fEditor;
- if (editor == null)
- return;
-
- IWorkbenchPartSite site= editor.getSite();
- if (site == null)
- return;
-
- Shell shell= site.getShell();
- if (shell == null || shell.isDisposed())
- return;
-
- Display display= shell.getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- display.asyncExec(runnable);
- }
-
- /**
- * Stop reconciling positions.
- */
- private void stopReconcilingPositions() {
- fRemovedPositions.clear();
- fNOfRemovedPositions= 0;
- fAddedPositions.clear();
- }
-
- /**
- * Install this reconciler on the given editor, presenter and highlightings.
- * @param editor the editor
- * @param sourceViewer the source viewer
- * @param presenter the semantic highlighting presenter
- * @param semanticHighlightings the semantic highlightings
- * @param highlightings the highlightings
- */
- public void install(JavaEditor editor, ISourceViewer sourceViewer, SemanticHighlightingPresenter presenter, SemanticHighlighting[] semanticHighlightings, Highlighting[] highlightings) {
- fPresenter= presenter;
- fSemanticHighlightings= semanticHighlightings;
- fHighlightings= highlightings;
-
- fEditor= editor;
- fSourceViewer= sourceViewer;
-
- if (fEditor instanceof CompilationUnitEditor) {
- ((CompilationUnitEditor)fEditor).addReconcileListener(this);
- } else if (fEditor == null) {
- fSourceViewer.addTextInputListener(this);
- scheduleJob();
- }
- }
-
- /**
- * Uninstall this reconciler from the editor
- */
- public void uninstall() {
- if (fPresenter != null)
- fPresenter.setCanceled(true);
-
- if (fEditor != null) {
- if (fEditor instanceof CompilationUnitEditor)
- ((CompilationUnitEditor)fEditor).removeReconcileListener(this);
- else
- fSourceViewer.removeTextInputListener(this);
- fEditor= null;
- }
-
- fSourceViewer= null;
- fSemanticHighlightings= null;
- fHighlightings= null;
- fPresenter= null;
- }
-
- /**
- * Schedule a background job for retrieving the AST and reconciling the Semantic Highlighting model.
- */
- private void scheduleJob() {
- final IJavaScriptElement element= fEditor.getInputJavaElement();
-
- synchronized (fJobLock) {
- final Job oldJob= fJob;
- if (fJob != null) {
- fJob.cancel();
- fJob= null;
- }
-
- if (element != null) {
- fJob= new Job(JavaEditorMessages.SemanticHighlighting_job) {
- protected IStatus run(IProgressMonitor monitor) {
- if (oldJob != null) {
- try {
- oldJob.join();
- } catch (InterruptedException e) {
- JavaScriptPlugin.log(e);
- return Status.CANCEL_STATUS;
- }
- }
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- JavaScriptUnit ast= JavaScriptPlugin.getDefault().getASTProvider().getAST(element, ASTProvider.WAIT_YES, monitor);
- reconciled(ast, false, monitor);
- synchronized (fJobLock) {
- // allow the job to be gc'ed
- if (fJob == this)
- fJob= null;
- }
- return Status.OK_STATUS;
- }
- };
- fJob.setSystem(true);
- fJob.setPriority(Job.DECORATE);
- fJob.schedule();
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- synchronized (fJobLock) {
- if (fJob != null) {
- fJob.cancel();
- fJob= null;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null)
- scheduleJob();
- }
-
- /**
- * Refreshes the highlighting.
- *
- *
- */
- public void refresh() {
- scheduleJob();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightings.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightings.java
deleted file mode 100644
index 5e8cdeef..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticHighlightings.java
+++ /dev/null
@@ -1,1666 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.ObjectLiteral;
-import org.eclipse.wst.jsdt.core.dom.ObjectLiteralField;
-import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
-import org.eclipse.wst.jsdt.core.dom.QualifiedName;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.SimpleType;
-import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.StructuralPropertyDescriptor;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-/**
- * Semantic highlightings
- *
- *
- */
-public class SemanticHighlightings {
-
- /**
- * A named preference part that controls the highlighting of static final fields.
- */
- public static final String STATIC_FINAL_FIELD="staticFinalField"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of static fields.
- */
- public static final String STATIC_FIELD="staticField"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of fields.
- */
- public static final String FIELD="field"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of method declarations.
- */
- public static final String METHOD_DECLARATION="methodDeclarationName"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of static method invocations.
- */
- public static final String STATIC_METHOD_INVOCATION="staticMethodInvocation"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of inherited method invocations.
- */
- public static final String INHERITED_METHOD_INVOCATION="inheritedMethodInvocation"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of annotation element references.
- *
- */
- public static final String ANNOTATION_ELEMENT_REFERENCE="annotationElementReference"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of abstract method invocations.
- */
- public static final String ABSTRACT_METHOD_INVOCATION="abstractMethodInvocation"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of local variables.
- */
- public static final String LOCAL_VARIABLE_DECLARATION="localVariableDeclaration"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of local variables.
- */
- public static final String LOCAL_VARIABLE="localVariable"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of parameter variables.
- */
- public static final String PARAMETER_VARIABLE="parameterVariable"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of deprecated members.
- */
- public static final String DEPRECATED_MEMBER="deprecatedMember"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of type parameters.
- *
- */
- public static final String TYPE_VARIABLE="typeParameter"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of type parameters.
- *
- * @author STP
- */
- public static final String OBJECT_INITIALIZER="objectInitializer"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of methods
- * (invocations and declarations).
- *
- *
- */
- public static final String METHOD="method"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of auto(un)boxed
- * expressions.
- *
- *
- */
- public static final String AUTOBOXING="autoboxing"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of classes.
- *
- *
- */
- public static final String CLASS="class"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of enums.
- *
- *
- */
- public static final String ENUM="enum"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of interfaces.
- *
- *
- */
- public static final String INTERFACE="interface"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of annotations.
- *
- *
- */
- public static final String ANNOTATION="annotation"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of type arguments.
- *
- *
- */
- public static final String TYPE_ARGUMENT="typeArgument"; //$NON-NLS-1$
-
- /**
- * Semantic highlightings
- */
- private static SemanticHighlighting[] fgSemanticHighlightings;
-
- /**
- * Semantic highlighting for static final fields.
- */
-/*
- private static final class StaticFinalFieldHighlighting extends SemanticHighlighting {
- @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return STATIC_FINAL_FIELD;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- public RGB getDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_staticFinalField;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
- IBinding binding= token.getBinding();
- return binding != null && binding.getKind() == IBinding.VARIABLE && ((IVariableBinding)binding).isField() && (binding.getModifiers() & (Modifier.FINAL | Modifier.STATIC)) == (Modifier.FINAL | Modifier.STATIC);
- }
-}
-*/
-
- /**
- * Semantic highlighting for static fields.
- */
-/*
- private static final class StaticFieldHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return STATIC_FIELD;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- public RGB getDefaultTextColor() {
- return new RGB(0, 0, 192);
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_staticField;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
- IBinding binding= token.getBinding();
- return binding != null && binding.getKind() == IBinding.VARIABLE && ((IVariableBinding)binding).isField() && (binding.getModifiers() & Modifier.STATIC) == Modifier.STATIC;
- }
- }
-*/
-
- /**
- * Semantic highlighting for fields.
- */
-/*
- private static final class FieldHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return FIELD;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- public RGB getDefaultTextColor() {
- return new RGB(0, 0, 192);
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_field;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
- IBinding binding= token.getBinding();
- return binding != null && binding.getKind() == IBinding.VARIABLE && ((IVariableBinding)binding).isField();
- }
- }
-*/
- /**
- * Semantic highlighting for fields.
- * @author STP
- */
- private static final class ObjectInitializerHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return OBJECT_INITIALIZER;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return true;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_objectInitializer;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- */
-
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- StructuralPropertyDescriptor location= node.getLocationInParent();
- if (location == ObjectLiteralField.FIELD_NAME_PROPERTY ) {
- ASTNode parent= node.getParent();
- return (parent != null && parent instanceof ObjectLiteral);
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for auto(un)boxed expressions.
- */
-/*
- private static final class AutoboxHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return AUTOBOXING;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(171, 48, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_autoboxing;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumesLiteral(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumesLiteral(SemanticToken token) {
- return isAutoUnBoxing(token.getLiteral());
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
- return isAutoUnBoxing(token.getNode());
- }
-
- private boolean isAutoUnBoxing(Expression node) {
- if (isAutoUnBoxingExpression(node))
- return true;
- // special cases: the autoboxing conversions happens at a
- // location that is not mapped directly to a simple name
- // or a literal, but can still be mapped somehow
- // A) expressions
- StructuralPropertyDescriptor desc= node.getLocationInParent();
- if (desc == ArrayAccess.ARRAY_PROPERTY
- || desc == InfixExpression.LEFT_OPERAND_PROPERTY
- || desc == InfixExpression.RIGHT_OPERAND_PROPERTY
- || desc == ConditionalExpression.THEN_EXPRESSION_PROPERTY
- || desc == PrefixExpression.OPERAND_PROPERTY
- || desc == CastExpression.EXPRESSION_PROPERTY
- || desc == ConditionalExpression.ELSE_EXPRESSION_PROPERTY) {
- ASTNode parent= node.getParent();
- if (parent instanceof Expression)
- return isAutoUnBoxingExpression((Expression) parent);
- }
- // B) constructor invocations
- if (desc == SimpleType.NAME_PROPERTY || desc == QualifiedType.NAME_PROPERTY) {
- ASTNode parent= node.getParent();
- if (parent != null && parent.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
- parent= parent.getParent();
- if (parent instanceof Expression)
- return isAutoUnBoxingExpression((Expression) parent);
- }
- }
- return false;
- }
-
- private boolean isAutoUnBoxingExpression(Expression expression) {
- return expression.resolveBoxing() || expression.resolveUnboxing();
- }
- }
-*/
- /**
- * Semantic highlighting for method declarations.
- */
- private static final class MethodDeclarationHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return METHOD_DECLARATION;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return true;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_methodDeclaration;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- */
- public boolean consumes(SemanticToken token) {
- StructuralPropertyDescriptor location= token.getNode().getLocationInParent();
- return location == FunctionDeclaration.NAME_PROPERTY ;
- }
- }
-
- /**
- * Semantic highlighting for static method invocations.
- */
-/*
- private static final class StaticMethodInvocationHighlighting extends SemanticHighlighting {
- public String getPreferenceKey() {
- return STATIC_METHOD_INVOCATION;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_staticMethodInvocation;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- if (node.isDeclaration())
- return false;
-
- IBinding binding= token.getBinding();
- return binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.STATIC) == Modifier.STATIC;
- }
- }
-*/
-
- /**
- * Semantic highlighting for annotation element references.
- *
- */
-/*
- private static final class AnnotationElementReferenceHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return ANNOTATION_ELEMENT_REFERENCE;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_annotationElementReference;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- if (node.getParent() instanceof MemberValuePair) {
- IBinding binding= token.getBinding();
- boolean isAnnotationElement= binding != null && binding.getKind() == IBinding.METHOD;
-
- return isAnnotationElement;
- }
-
- return false;
- }
- }
-*/
-
- /**
- * Semantic highlighting for abstract method invocations.
- */
-/*
- private static final class AbstractMethodInvocationHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return ABSTRACT_METHOD_INVOCATION;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_abstractMethodInvocation;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- if (node.isDeclaration())
- return false;
-
- IBinding binding= token.getBinding();
- boolean isAbstractMethod= binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT;
- if (!isAbstractMethod)
- return false;
-
- // filter out annotation value references
- if (binding != null) {
- ITypeBinding declaringType= ((IFunctionBinding)binding).getDeclaringClass();
- if (declaringType.isAnnotation())
- return false;
- }
-
- return true;
- }
- }
-*/
-
- /**
- * Semantic highlighting for inherited method invocations.
- */
-/*
- private static final class InheritedMethodInvocationHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return INHERITED_METHOD_INVOCATION;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_inheritedMethodInvocation;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- if (node.isDeclaration())
- return false;
-
- IBinding binding= token.getBinding();
- if (binding == null || binding.getKind() != IBinding.METHOD)
- return false;
-
- ITypeBinding currentType= Bindings.getBindingOfParentType(node);
- ITypeBinding declaringType= ((IFunctionBinding) binding).getDeclaringClass();
- if (currentType == declaringType || currentType == null)
- return false;
-
- return Bindings.isSuperType(declaringType, currentType);
- }
- }
-*/
-
- /**
- * Semantic highlighting for inherited method invocations.
- */
- private static final class MethodHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return METHOD;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_method;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.wst.jsdt.core.dom.ASTNode)
- */
- public boolean consumes(SemanticToken token) {
- IBinding binding= getMethodBinding(token);
- return binding != null && binding.getKind() == IBinding.METHOD;
- }
-
- /**
- * Extracts the method binding from the token's simple name. The method
- * binding is either the token's binding (if the parent of token is a
- * method call or declaration) or the constructor binding of a class
- * instance creation if the node is the type name of a class instance
- * creation.
- *
- * @param token the token to extract the method binding from
- * @return the corresponding method binding, or <code>null</code>
- */
- private IBinding getMethodBinding(SemanticToken token) {
- IBinding binding= null;
- // work around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62605
- ASTNode node= token.getNode();
- ASTNode parent= node.getParent();
- while (isTypePath(node, parent)) {
- node= parent;
- parent= parent.getParent();
- }
-
- if (parent != null && node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY)
- binding= ((ClassInstanceCreation) parent).resolveConstructorBinding();
- else
- binding= token.getBinding();
- return binding;
- }
-
- /**
- * Returns <code>true</code> if the given child/parent nodes are valid
- * sub nodes of a <code>Type</code> ASTNode.
- * @param child the child node
- * @param parent the parent node
- * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
- */
- private boolean isTypePath(ASTNode child, ASTNode parent) {
- if (parent instanceof Type) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
- } else if (parent instanceof QualifiedName) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == QualifiedName.NAME_PROPERTY;
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for local variable declarations.
- */
- private static final class LocalVariableDeclarationHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return LOCAL_VARIABLE_DECLARATION;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_localVariableDeclaration;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- */
- public boolean consumes(SemanticToken token) {
- SimpleName node= token.getNode();
- StructuralPropertyDescriptor location= node.getLocationInParent();
- if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) {
- ASTNode parent= node.getParent();
- if (parent instanceof VariableDeclaration) {
- parent= parent.getParent();
- return parent == null || !(parent instanceof FieldDeclaration);
- }
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for local variables.
- */
- private static final class LocalVariableHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return LOCAL_VARIABLE;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_localVariable;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- */
- public boolean consumes(SemanticToken token) {
- IBinding binding= token.getBinding();
- if (binding != null && binding.getKind() == IBinding.VARIABLE && !((IVariableBinding) binding).isField()) {
- ASTNode decl= token.getRoot().findDeclaringNode(binding);
- return decl instanceof VariableDeclaration;
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for parameter variables.
- */
- private static final class ParameterVariableHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return PARAMETER_VARIABLE;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_parameterVariable;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- */
- public boolean consumes(SemanticToken token) {
- IBinding binding= token.getBinding();
- if (binding != null && binding.getKind() == IBinding.VARIABLE && !((IVariableBinding) binding).isField()) {
- ASTNode decl= token.getRoot().findDeclaringNode(binding);
- return decl != null && decl.getLocationInParent() == FunctionDeclaration.PARAMETERS_PROPERTY;
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for deprecated members.
- */
- private static final class DeprecatedMemberHighlighting extends SemanticHighlighting {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- */
- public String getPreferenceKey() {
- return DEPRECATED_MEMBER;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 0, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- */
- public boolean isBoldByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- */
- public boolean isItalicByDefault() {
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isStrikethroughByDefault()
- *
- */
- public boolean isStrikethroughByDefault() {
- return true;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- */
- public boolean isEnabledByDefault() {
- return true;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- */
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_deprecatedMember;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- */
- public boolean consumes(SemanticToken token) {
- IBinding binding= getMethodBinding(token);
- return binding != null ? binding.isDeprecated() : false;
- }
-
- /**
- * Extracts the method binding from the token's simple name. The method
- * binding is either the token's binding (if the parent of token is a
- * method call or declaration) or the constructor binding of a class
- * instance creation if the node is the type name of a class instance
- * creation.
- *
- * @param token the token to extract the method binding from
- * @return the corresponding method binding, or <code>null</code>
- */
- private IBinding getMethodBinding(SemanticToken token) {
- IBinding binding= null;
- // work around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62605
- ASTNode node= token.getNode();
- ASTNode parent= node.getParent();
- while (isTypePath(node, parent)) {
- node= parent;
- parent= parent.getParent();
- }
-
- if (parent != null && node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY)
- binding= ((ClassInstanceCreation) parent).resolveConstructorBinding();
- else
- binding= token.getBinding();
- return binding;
- }
-
- /**
- * Returns <code>true</code> if the given child/parent nodes are valid
- * sub nodes of a <code>Type</code> ASTNode.
- * @param child the child node
- * @param parent the parent node
- * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
- */
- private boolean isTypePath(ASTNode child, ASTNode parent) {
- if (parent instanceof Type) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
- } else if (parent instanceof QualifiedName) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == QualifiedName.NAME_PROPERTY;
- }
- return false;
- }
- }
-
- /**
- * Semantic highlighting for type variables.
- *
- */
-/*
- private static final class TypeVariableHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return TYPE_VARIABLE;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(100, 70, 50);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return true;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_typeVariables;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types in type parameter lists
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- if (node.getNodeType() != ASTNode.SIMPLE_TYPE && node.getNodeType() != ASTNode.TYPE_PARAMETER)
- return false;
-
- // 2: match generic type variable references
- IBinding binding= token.getBinding();
- return binding instanceof ITypeBinding && ((ITypeBinding) binding).isTypeVariable();
- }
- }
-*/
-
- /**
- * Semantic highlighting for classes.
- *
- */
-/*
- private static final class ClassHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return CLASS;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(0, 80, 50);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_classes;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- int nodeType= node.getNodeType();
- if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.THIS_EXPRESSION && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.TYPE_DECLARATION)
- return false;
- while (nodeType == ASTNode.QUALIFIED_NAME) {
- node= node.getParent();
- nodeType= node.getNodeType();
- if (nodeType == ASTNode.IMPORT_DECLARATION)
- return false;
- }
-
- // 2: match classes
- IBinding binding= token.getBinding();
- return binding instanceof ITypeBinding && ((ITypeBinding) binding).isClass();
- }
- }
-*/
-/*
- private static final class EnumHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return ENUM;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(100, 70, 50);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_enums;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- int nodeType= node.getNodeType();
- if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.ENUM_DECLARATION)
- return false;
- while (nodeType == ASTNode.QUALIFIED_NAME) {
- node= node.getParent();
- nodeType= node.getNodeType();
- if (nodeType == ASTNode.IMPORT_DECLARATION)
- return false;
- }
-
- // 2: match enums
- IBinding binding= token.getBinding();
- return binding instanceof ITypeBinding && ((ITypeBinding) binding).isEnum();
- }
- }
-*/
-
- /**
- * Semantic highlighting for interfaces.
- *
- */
-/*
- private static final class InterfaceHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return INTERFACE;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(50, 63, 112);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_interfaces;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- int nodeType= node.getNodeType();
- if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.TYPE_DECLARATION)
- return false;
- while (nodeType == ASTNode.QUALIFIED_NAME) {
- node= node.getParent();
- nodeType= node.getNodeType();
- if (nodeType == ASTNode.IMPORT_DECLARATION)
- return false;
- }
-
- // 2: match interfaces
- IBinding binding= token.getBinding();
- return binding instanceof ITypeBinding && ((ITypeBinding) binding).isInterface();
- }
- }
-*/
-
- /**
- * Semantic highlighting for annotation types.
- *
- */
-/*
- private static final class AnnotationHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return ANNOTATION;
- }
- public RGB getDefaultDefaultTextColor() {
- return new RGB(100, 100, 100);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return true; // as it replaces the syntax based highlighting which is always enabled
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_annotations;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- int nodeType= node.getNodeType();
- if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.ANNOTATION_TYPE_DECLARATION
- && nodeType != ASTNode.MARKER_ANNOTATION && nodeType != ASTNode.NORMAL_ANNOTATION && nodeType != ASTNode.SINGLE_MEMBER_ANNOTATION)
- return false;
- while (nodeType == ASTNode.QUALIFIED_NAME) {
- node= node.getParent();
- nodeType= node.getNodeType();
- if (nodeType == ASTNode.IMPORT_DECLARATION)
- return false;
- }
-
- // 2: match annotations
- IBinding binding= token.getBinding();
- return binding instanceof ITypeBinding && ((ITypeBinding) binding).isAnnotation();
- }
- }
-*/
-
- /**
- * Semantic highlighting for annotation types.
- *
- */
-/*
- private static final class TypeArgumentHighlighting extends SemanticHighlighting {
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#getPreferenceKey()
- public String getPreferenceKey() {
- return TYPE_ARGUMENT;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextColor()
- */
- public RGB getDefaultDefaultTextColor() {
- return new RGB(13, 100, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDefaultTextStyleBold()
- public boolean isBoldByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isItalicByDefault()
- public boolean isItalicByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#isEnabledByDefault()
- public boolean isEnabledByDefault() {
- return false;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.ISemanticHighlighting#getDisplayName()
- public String getDisplayName() {
- return JavaEditorMessages.SemanticHighlighting_typeArguments;
- }
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticToken)
- public boolean consumes(SemanticToken token) {
-
- // 1: match types
- SimpleName name= token.getNode();
- ASTNode node= name.getParent();
- int nodeType= node.getNodeType();
- if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.QUALIFIED_TYPE)
- return false;
-
- // 2: match type arguments
- StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
- if (locationInParent == ParameterizedType.TYPE_ARGUMENTS_PROPERTY)
- return true;
-
- return false;
- }
- }
-*/
-
- /**
- * A named preference that controls the given semantic highlighting's color.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the color preference key
- */
- public static String getColorPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
- }
-
- /**
- * A named preference that controls if the given semantic highlighting has the text attribute bold.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the bold preference key
- */
- public static String getBoldPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
- }
-
- /**
- * A named preference that controls if the given semantic highlighting has the text attribute italic.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the italic preference key
- */
- public static String getItalicPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
- }
-
- /**
- * A named preference that controls if the given semantic highlighting has the text attribute strikethrough.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the strikethrough preference key
- *
- */
- public static String getStrikethroughPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX;
- }
-
- /**
- * A named preference that controls if the given semantic highlighting has the text attribute underline.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the underline preference key
- *
- */
- public static String getUnderlinePreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
- }
-
- /**
- * A named preference that controls if the given semantic highlighting is enabled.
- *
- * @param semanticHighlighting the semantic highlighting
- * @return the enabled preference key
- */
- public static String getEnabledPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
- }
-
- /**
- * @return The semantic highlightings, the order defines the precedence of matches, the first match wins.
- */
- public static SemanticHighlighting[] getSemanticHighlightings() {
- if (fgSemanticHighlightings == null)
- fgSemanticHighlightings= new SemanticHighlighting[] {
-// STP
-new ObjectInitializerHighlighting(),
- new DeprecatedMemberHighlighting(),
-// new AutoboxHighlighting(),
-// new StaticFinalFieldHighlighting(),
-// new StaticFieldHighlighting(),
-// new FieldHighlighting(),
- new MethodDeclarationHighlighting(),
-// new StaticMethodInvocationHighlighting(),
-// new AbstractMethodInvocationHighlighting(),
-// new AnnotationElementReferenceHighlighting(),
-// new InheritedMethodInvocationHighlighting(),
- new ParameterVariableHighlighting(),
- new LocalVariableDeclarationHighlighting(),
- new LocalVariableHighlighting(),
-// new TypeVariableHighlighting(), // before type arguments!
- new MethodHighlighting(), // before types to get ctors
-// new TypeArgumentHighlighting(), // before other types
-// new ClassHighlighting(),
-// new EnumHighlighting(),
-// new AnnotationHighlighting(), // before interfaces
-// new InterfaceHighlighting(),
- };
- return fgSemanticHighlightings;
- }
-
- /**
- * Initialize default preferences in the given preference store.
- * @param store The preference store
- */
- public static void initDefaults(IPreferenceStore store) {
- SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings();
- for (int i= 0, n= semanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= semanticHighlightings[i];
- setDefaultAndFireEvent(store, SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), semanticHighlighting.getDefaultTextColor());
- store.setDefault(SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), semanticHighlighting.isBoldByDefault());
- store.setDefault(SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting), semanticHighlighting.isItalicByDefault());
- store.setDefault(SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting), semanticHighlighting.isStrikethroughByDefault());
- store.setDefault(SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting), semanticHighlighting.isUnderlineByDefault());
- store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), semanticHighlighting.isEnabledByDefault());
- }
-
- convertMethodHighlightingPreferences(store);
- convertAnnotationHighlightingPreferences(store);
- }
-
- /**
- * Tests whether <code>event</code> in <code>store</code> affects the
- * enablement of semantic highlighting.
- *
- * @param store the preference store where <code>event</code> was observed
- * @param event the property change under examination
- * @return <code>true</code> if <code>event</code> changed semantic
- * highlighting enablement, <code>false</code> if it did not
- *
- */
- public static boolean affectsEnablement(IPreferenceStore store, PropertyChangeEvent event) {
- String relevantKey= null;
- SemanticHighlighting[] highlightings= getSemanticHighlightings();
- for (int i= 0; i < highlightings.length; i++) {
- if (event.getProperty().equals(getEnabledPreferenceKey(highlightings[i]))) {
- relevantKey= event.getProperty();
- break;
- }
- }
- if (relevantKey == null)
- return false;
-
- for (int i= 0; i < highlightings.length; i++) {
- String key= getEnabledPreferenceKey(highlightings[i]);
- if (key.equals(relevantKey))
- continue;
- if (store.getBoolean(key))
- return false; // another is still enabled or was enabled before
- }
-
- // all others are disabled, so toggling relevantKey affects the enablement
- return true;
- }
-
- /**
- * Tests whether semantic highlighting is currently enabled.
- *
- * @param store the preference store to consult
- * @return <code>true</code> if semantic highlighting is enabled,
- * <code>false</code> if it is not
- *
- */
- public static boolean isEnabled(IPreferenceStore store) {
- SemanticHighlighting[] highlightings= getSemanticHighlightings();
- boolean enable= false;
- for (int i= 0; i < highlightings.length; i++) {
- String enabledKey= getEnabledPreferenceKey(highlightings[i]);
- if (store.getBoolean(enabledKey)) {
- enable= true;
- break;
- }
- }
-
- return enable;
- }
-
- /**
- * In 3.0, methods were highlighted by a rule-based word matcher that
- * matched any identifier that was followed by possibly white space and a
- * left parenthesis.
- * <p>
- * With generics, this does not work any longer for constructors of generic
- * types, and the highlighting has been moved to be a semantic highlighting.
- * Because different preference key naming schemes are used, we have to
- * migrate the old settings to the new ones, which is done here. Nothing
- * needs to be done if the old settings were set to the default values.
- * </p>
- *
- * @param store the preference store to migrate
- *
- */
- private static void convertMethodHighlightingPreferences(IPreferenceStore store) {
- String colorkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
- String boldkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
- String italickey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
- String enabledkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
-
- String oldColorkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR;
- String oldBoldkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD;
- String oldItalickey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_ITALIC;
-
- if (conditionalReset(store, oldColorkey, colorkey)
- || conditionalReset(store, oldBoldkey, boldkey)
- || conditionalReset(store, oldItalickey, italickey)) {
- store.setValue(enabledkey, true);
- }
-
- }
-
- /**
- * In 3.1, annotations were highlighted by a rule-based word matcher that matched any identifier
- * preceded by an '@' sign and possibly white space.
- * <p>
- * This does not work when there is a comment between the '@' and the annotation, results in
- * stale highlighting if there is a new line between the '@' and the annotation, and does not
- * work for highlighting annotation declarations. Because different preference key naming
- * schemes are used, we have to migrate the old settings to the new ones, which is done here.
- * Nothing needs to be done if the old settings were set to the default values.
- * </p>
- *
- * @param store the preference store to migrate
- *
- */
- private static void convertAnnotationHighlightingPreferences(IPreferenceStore store) {
- String colorkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
- String boldkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
- String italickey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
- String strikethroughKey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX;
- String underlineKey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
- String enabledkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
-
- String oldColorkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_COLOR;
- String oldBoldkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_BOLD;
- String oldItalickey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_ITALIC;
- String oldStrikethroughKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_STRIKETHROUGH;
- String oldUnderlineKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_UNDERLINE;
-
- if (conditionalReset(store, oldColorkey, colorkey)
- || conditionalReset(store, oldBoldkey, boldkey)
- || conditionalReset(store, oldItalickey, italickey)
- || conditionalReset(store, oldStrikethroughKey, strikethroughKey)
- || conditionalReset(store, oldUnderlineKey, underlineKey)) {
- store.setValue(enabledkey, true);
- }
-
- }
-
- /**
- * If the setting pointed to by <code>oldKey</code> is not the default
- * setting, store that setting under <code>newKey</code> and reset
- * <code>oldKey</code> to its default setting.
- * <p>
- * Returns <code>true</code> if any changes were made.
- * </p>
- *
- * @param store the preference store to read from and write to
- * @param oldKey the old preference key
- * @param newKey the new preference key
- * @return <code>true</code> if <code>store</code> was modified,
- * <code>false</code> if not
- *
- */
- private static boolean conditionalReset(IPreferenceStore store, String oldKey, String newKey) {
- if (!store.isDefault(oldKey)) {
- if (store.isDefault(newKey))
- store.setValue(newKey, store.getString(oldKey));
- store.setToDefault(oldKey);
- return true;
- }
- return false;
- }
-
- /**
- * Sets the default value and fires a property
- * change event if necessary.
- *
- * @param store the preference store
- * @param key the preference key
- * @param newValue the new value
- *
- */
- private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) {
- RGB oldValue= null;
- if (store.isDefault(key))
- oldValue= PreferenceConverter.getDefaultColor(store, key);
-
- PreferenceConverter.setDefault(store, key, newValue);
-
- if (oldValue != null && !oldValue.equals(newValue))
- store.firePropertyChangeEvent(key, oldValue, newValue);
- }
-
- /**
- * Do not instantiate
- */
- private SemanticHighlightings() {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticToken.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticToken.java
deleted file mode 100644
index 05c6941d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SemanticToken.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.Expression;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-
-/**
- * Semantic token
- */
-public final class SemanticToken {
-
- /** AST node */
- private SimpleName fNode;
- private Expression fLiteral;
-
- /** Binding */
- private IBinding fBinding;
- /** Is the binding resolved? */
- private boolean fIsBindingResolved= false;
-
- /** AST root */
- private JavaScriptUnit fRoot;
- private boolean fIsRootResolved= false;
-
- /**
- * @return Returns the binding, can be <code>null</code>.
- */
- public IBinding getBinding() {
- if (!fIsBindingResolved) {
- fIsBindingResolved= true;
- if (fNode != null)
- fBinding= fNode.resolveBinding();
- }
-
- return fBinding;
- }
-
- /**
- * @return the AST node (a {@link SimpleName})
- */
- public SimpleName getNode() {
- return fNode;
- }
-
- /**
- * @return the AST node (a <code>Boolean-, Character- or NumberLiteral</code>)
- */
- public Expression getLiteral() {
- return fLiteral;
- }
-
- /**
- * @return the AST root
- */
- public JavaScriptUnit getRoot() {
- if (!fIsRootResolved) {
- fIsRootResolved= true;
- fRoot= (JavaScriptUnit) (fNode != null ? fNode : fLiteral).getRoot();
- }
-
- return fRoot;
- }
-
- /**
- * Update this token with the given AST node.
- * <p>
- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
- * </p>
- *
- * @param node the AST simple name
- */
- void update(SimpleName node) {
- clear();
- fNode= node;
- }
-
- /**
- * Update this token with the given AST node.
- * <p>
- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
- * </p>
- *
- * @param literal the AST literal
- */
- void update(Expression literal) {
- clear();
- fLiteral= literal;
- }
-
- /**
- * Clears this token.
- * <p>
- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
- * </p>
- */
- void clear() {
- fNode= null;
- fLiteral= null;
- fBinding= null;
- fIsBindingResolved= false;
- fRoot= null;
- fIsRootResolved= false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistAction.java
deleted file mode 100644
index f216b315..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistAction.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalCategory;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalComputerRegistry;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-/**
- * Action to run content assist on a specific proposal category.
- *
- *
- */
-final class SpecificContentAssistAction extends Action implements IUpdate {
- /**
- * The category represented by this action.
- */
- private final CompletionProposalCategory fCategory;
- /**
- * The content assist executor.
- */
- private final SpecificContentAssistExecutor fExecutor= new SpecificContentAssistExecutor(CompletionProposalComputerRegistry.getDefault());
- /**
- * The editor.
- */
- private JavaEditor fEditor;
-
- /**
- * Creates a new action for a certain proposal category.
- *
- * @param category
- */
- public SpecificContentAssistAction(CompletionProposalCategory category) {
- fCategory= category;
- setText(category.getName());
- setImageDescriptor(category.getImageDescriptor());
- setActionDefinitionId("org.eclipse.wst.jsdt.ui.specific_content_assist.command"); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- ITextEditor editor= getActiveEditor();
- if (editor == null)
- return;
-
- fExecutor.invokeContentAssist(editor, fCategory.getId());
-
- return;
- }
-
- private ITextEditor getActiveEditor() {
- return fEditor;
- }
-
- /**
- * Sets the active editor part.
- *
- * @param part the editor, possibly <code>null</code>
- */
- public void setActiveEditor(IEditorPart part) {
- JavaEditor editor;
- if (part instanceof JavaEditor)
- editor= (JavaEditor) part;
- else
- editor= null;
- fEditor= editor;
- setEnabled(computeEnablement(fEditor));
- }
-
- private boolean computeEnablement(ITextEditor editor) {
- if (editor == null)
- return false;
- ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
- boolean hasContentAssist= target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- if (!hasContentAssist)
- return false;
-
- ISelection selection= editor.getSelectionProvider().getSelection();
- return isValidSelection(selection);
- }
-
- /**
- * Computes the partition type at the selection start and checks whether the proposal category
- * has any computers for this partition.
- *
- * @param selection the selection
- * @return <code>true</code> if there are any computers for the selection
- */
- private boolean isValidSelection(ISelection selection) {
- if (!(selection instanceof ITextSelection))
- return false;
- int offset= ((ITextSelection) selection).getOffset();
-
- IDocument document= getDocument();
- if (document == null)
- return false;
-
- String contentType;
- try {
- contentType= TextUtilities.getContentType(document, IJavaScriptPartitions.JAVA_PARTITIONING, offset, true);
- } catch (BadLocationException x) {
- return false;
- }
-
- return fCategory.hasComputers(contentType);
- }
-
- private IDocument getDocument() {
- Assert.isTrue(fEditor != null);
- IDocumentProvider provider= fEditor.getDocumentProvider();
- if (provider == null)
- return null;
-
- IDocument document= provider.getDocument(fEditor.getEditorInput());
- return document;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- setEnabled(computeEnablement(fEditor));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java
deleted file mode 100644
index ad669cb0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalCategory;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalComputerRegistry;
-
-/**
- * A content assist executor can invoke content assist for a specific proposal category on an editor.
- *
- *
- */
-public final class SpecificContentAssistExecutor {
-
- private final CompletionProposalComputerRegistry fRegistry;
-
- /**
- * Creates a new executor.
- *
- * @param registry the computer registry to use for the enablement of proposal categories
- */
- public SpecificContentAssistExecutor(CompletionProposalComputerRegistry registry) {
- Assert.isNotNull(registry);
- fRegistry= registry;
- }
-
- /**
- * Invokes content assist on <code>editor</code>, showing only proposals computed by the
- * <code>CompletionProposalCategory</code> with the given <code>categoryId</code>.
- *
- * @param editor the editor to invoke code assist on
- * @param categoryId the id of the proposal category to show proposals for
- */
- public void invokeContentAssist(final ITextEditor editor, String categoryId) {
- Collection categories= fRegistry.getProposalCategories();
- boolean[] inclusionState= new boolean[categories.size()];
- boolean[] separateState= new boolean[categories.size()];
- int i= 0;
- for (Iterator it= categories.iterator(); it.hasNext(); i++) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
- inclusionState[i]= cat.isIncluded();
- cat.setIncluded(cat.getId().equals(categoryId));
- separateState[i]= cat.isSeparateCommand();
- cat.setSeparateCommand(false);
- }
-
- try {
- ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
- if (target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
- target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- } finally {
- i= 0;
- for (Iterator it= categories.iterator(); it.hasNext(); i++) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
- cat.setIncluded(inclusionState[i]);
- cat.setSeparateCommand(separateState[i]);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/StorageMarkerAnnotationModel.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/StorageMarkerAnnotationModel.java
deleted file mode 100644
index 59f4dab2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/StorageMarkerAnnotationModel.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.Position;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-
-
-/**
- * Source editor resource marker annotation model implementation
- */
-public class StorageMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
- public final static String SECONDARY_ID_KEY = "org.eclipse.wst.sse.ui.extensions.breakpoint.path"; //$NON-NLS-1$
- protected IResource fMarkerResource;
- protected String fSecondaryMarkerAttributeValue;
-
- /**
- * Constructor
- *
- * @param resource
- */
- public StorageMarkerAnnotationModel(IResource resource) {
- super(resource);
- fMarkerResource = resource;
- }
-
- public StorageMarkerAnnotationModel(IResource resource, String secondaryID) {
- super(resource);
- fMarkerResource = resource;
- fSecondaryMarkerAttributeValue = secondaryID;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createMarkerAnnotation(org.eclipse.core.resources.IMarker)
- */
-// protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
-// /*
-// * We need to do some special processing if marker is a validation
-// * (aka problem) marker or if marker is a breakpoint marker so create
-// * a special marker annotation for those markers. Otherwise, use
-// * default.
-// */
-// if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
-// return new StructuredMarkerAnnotation(marker);
-// }
-// return super.createMarkerAnnotation(marker);
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#getMarkerPosition(org.eclipse.core.resources.IMarker)
- */
- public Position getMarkerPosition(IMarker marker) {
- Position pos = super.getMarkerPosition(marker);
-
- // if ((pos == null || pos.getLength() == 0) && marker.getType() ==
- // IInternalDebugUIConstants.ANN_INSTR_POINTER_CURRENT) {
- if (pos == null || pos.getLength() == 0) {
- // We probably should create position from marker if marker
- // attributes specify a valid position
- pos = createPositionFromMarker(marker);
- }
-
- return pos;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#isAcceptable(org.eclipse.core.resources.IMarker)
- */
- protected boolean isAcceptable(IMarker marker) {
-// try {
-// Object attr = marker.getAttribute(IBreakpointConstants.ATTR_HIDDEN);
-// if (attr != null && ((Boolean) attr).equals(Boolean.TRUE))
-// return false;
-// }
-// catch (CoreException e) {
-// // ignore
-// }
-
- if (fSecondaryMarkerAttributeValue == null)
- return super.isAcceptable(marker);
- String markerSecondaryMarkerAttributeValue = marker.getAttribute(SECONDARY_ID_KEY, ""); //$NON-NLS-1$
- boolean isSameFile = fSecondaryMarkerAttributeValue.equalsIgnoreCase(markerSecondaryMarkerAttributeValue);
- return super.isAcceptable(marker) && isSameFile;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleCommentAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleCommentAction.java
deleted file mode 100644
index a5fc7545..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleCommentAction.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-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.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-/**
- * An action which toggles comment prefixes on the selected lines.
- *
- *
- */
-public final class ToggleCommentAction extends TextEditorAction {
-
- /** The text operation target */
- private ITextOperationTarget fOperationTarget;
- /** The document partitioning */
- private String fDocumentPartitioning;
- /** The comment prefixes */
- private Map fPrefixesMap;
-
- /**
- * Creates and initializes the action for the given text editor. The action
- * configures its visual representation from the given resource bundle.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
- * <code>null</code> if none
- * @param editor the text editor
- * @see org.eclipse.ui.texteditor.ResourceAction#ResourceAction(ResourceBundle, String, int)
- */
- public ToggleCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /**
- * Implementation of the <code>IAction</code> prototype. Checks if the selected
- * lines are all commented or not and uncomments/comments them respectively.
- */
- public void run() {
- if (fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null)
- return;
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- if (!validateEditorInputState())
- return;
-
- final int operationCode;
- if (isSelectionCommented(editor.getSelectionProvider().getSelection()))
- operationCode= ITextOperationTarget.STRIP_PREFIX;
- else
- operationCode= ITextOperationTarget.PREFIX;
-
- Shell shell= editor.getSite().getShell();
- if (!fOperationTarget.canDoOperation(operationCode)) {
- if (shell != null)
- MessageDialog.openError(shell, JavaEditorMessages.ToggleComment_error_title, JavaEditorMessages.ToggleComment_error_message);
- return;
- }
-
- Display display= null;
- if (shell != null && !shell.isDisposed())
- display= shell.getDisplay();
-
- BusyIndicator.showWhile(display, new Runnable() {
- public void run() {
- fOperationTarget.doOperation(operationCode);
- }
- });
- }
-
- /**
- * Is the given selection single-line commented?
- *
- * @param selection Selection to check
- * @return <code>true</code> iff all selected lines are commented
- */
- private boolean isSelectionCommented(ISelection selection) {
- if (!(selection instanceof ITextSelection))
- return false;
-
- ITextSelection textSelection= (ITextSelection) selection;
- if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
- return false;
-
- IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
-
- try {
-
- IRegion block= getTextBlockFromSelection(textSelection, document);
- ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning, block.getOffset(), block.getLength(), false);
-
- int lineCount= 0;
- int[] lines= new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
- for (int i= 0, j= 0; i < regions.length; i++, j+= 2) {
- // start line of region
- lines[j]= getFirstCompleteLineOfRegion(regions[i], document);
- // end line of region
- int length= regions[i].getLength();
- int offset= regions[i].getOffset() + length;
- if (length > 0)
- offset--;
- lines[j + 1]= (lines[j] == -1 ? -1 : document.getLineOfOffset(offset));
- lineCount += lines[j + 1] - lines[j] + 1;
- }
-
- // Perform the check
- for (int i= 0, j= 0; i < regions.length; i++, j += 2) {
- String[] prefixes= (String[]) fPrefixesMap.get(regions[i].getType());
- if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0)
- if (!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
- return false;
- }
-
- return true;
-
- } catch (BadLocationException x) {
- // should not happen
- JavaScriptPlugin.log(x);
- }
-
- return false;
- }
-
- /**
- * Creates a region describing the text block (something that starts at
- * the beginning of a line) completely containing the current selection.
- *
- * @param selection The selection to use
- * @param document The document
- * @return the region describing the text block comprising the given selection
- */
- private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) {
-
- try {
- IRegion line= document.getLineInformationOfOffset(selection.getOffset());
- int length= selection.getLength() == 0 ? line.getLength() : selection.getLength() + (selection.getOffset() - line.getOffset());
- return new Region(line.getOffset(), length);
-
- } catch (BadLocationException x) {
- // should not happen
- JavaScriptPlugin.log(x);
- }
-
- return null;
- }
-
- /**
- * Returns the index of the first line whose start offset is in the given text range.
- *
- * @param region the text range in characters where to find the line
- * @param document The document
- * @return the first line whose start index is in the given range, -1 if there is no such line
- */
- private int getFirstCompleteLineOfRegion(IRegion region, IDocument document) {
-
- try {
-
- int startLine= document.getLineOfOffset(region.getOffset());
-
- int offset= document.getLineOffset(startLine);
- if (offset >= region.getOffset())
- return startLine;
-
- offset= document.getLineOffset(startLine + 1);
- return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
-
- } catch (BadLocationException x) {
- // should not happen
- JavaScriptPlugin.log(x);
- }
-
- return -1;
- }
-
- /**
- * Determines whether each line is prefixed by one of the prefixes.
- *
- * @param startLine Start line in document
- * @param endLine End line in document
- * @param prefixes Possible comment prefixes
- * @param document The document
- * @return <code>true</code> iff each line from <code>startLine</code>
- * to and including <code>endLine</code> is prepended by one
- * of the <code>prefixes</code>, ignoring whitespace at the
- * begin of line
- */
- private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
-
- try {
-
- // check for occurrences of prefixes in the given lines
- for (int i= startLine; i <= endLine; i++) {
-
- IRegion line= document.getLineInformation(i);
- String text= document.get(line.getOffset(), line.getLength());
-
- int[] found= TextUtilities.indexOf(prefixes, text, 0);
-
- if (found[0] == -1)
- // found a line which is not commented
- return false;
-
- String s= document.get(line.getOffset(), found[0]);
- s= s.trim();
- if (s.length() != 0)
- // found a line which is not commented
- return false;
-
- }
-
- return true;
-
- } catch (BadLocationException x) {
- // should not happen
- JavaScriptPlugin.log(x);
- }
-
- return false;
- }
-
- /**
- * Implementation of the <code>IUpdate</code> prototype method discovers
- * the operation through the current editor's
- * <code>ITextOperationTarget</code> adapter, and sets the enabled state
- * accordingly.
- */
- public void update() {
- super.update();
-
- if (!canModifyEditor()) {
- setEnabled(false);
- return;
- }
-
- ITextEditor editor= getTextEditor();
- if (fOperationTarget == null && editor != null)
- fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
-
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) && fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
- setEnabled(isEnabled);
- }
-
- /*
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- super.setEditor(editor);
- fOperationTarget= null;
- }
-
- public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
- fPrefixesMap= null;
-
- String[] types= configuration.getConfiguredContentTypes(sourceViewer);
- Map prefixesMap= new HashMap(types.length);
- for (int i= 0; i < types.length; i++) {
- String type= types[i];
- String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
- if (prefixes != null && prefixes.length > 0) {
- int emptyPrefixes= 0;
- for (int j= 0; j < prefixes.length; j++)
- if (prefixes[j].length() == 0)
- emptyPrefixes++;
-
- if (emptyPrefixes > 0) {
- String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
- for (int j= 0, k= 0; j < prefixes.length; j++) {
- String prefix= prefixes[j];
- if (prefix.length() != 0) {
- nonemptyPrefixes[k]= prefix;
- k++;
- }
- }
- prefixes= nonemptyPrefixes;
- }
-
- prefixesMap.put(type, prefixes);
- }
- }
- fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
- fPrefixesMap= prefixesMap;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleMarkOccurrencesAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleMarkOccurrencesAction.java
deleted file mode 100644
index cb4bd0a8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleMarkOccurrencesAction.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-/**
- * A toolbar action which toggles the {@linkplain org.eclipse.wst.jsdt.ui.PreferenceConstants#EDITOR_MARK_OCCURRENCES mark occurrences preference}.
- *
- *
- */
-public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPropertyChangeListener {
-
- private IPreferenceStore fStore;
-
- /**
- * Constructs and updates the action.
- */
- public ToggleMarkOccurrencesAction() {
- super(JavaEditorMessages.getBundleForConstructedKeys(), "ToggleMarkOccurrencesAction.", null, IAction.AS_CHECK_BOX); //$NON-NLS-1$
- JavaPluginImages.setToolImageDescriptors(this, "mark_occurrences.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.TOGGLE_MARK_OCCURRENCES_ACTION);
- update();
- }
-
- /*
- * @see IAction#actionPerformed
- */
- public void run() {
- fStore.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, isChecked());
- }
-
- /*
- * @see TextEditorAction#update
- */
- public void update() {
- ITextEditor editor= getTextEditor();
-
- boolean checked= false;
- if (editor instanceof JavaEditor)
- checked= ((JavaEditor)editor).isMarkingOccurrences();
-
- setChecked(checked);
- setEnabled(editor != null);
- }
-
- /*
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
-
- super.setEditor(editor);
-
- if (editor != null) {
-
- if (fStore == null) {
- fStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- fStore.addPropertyChangeListener(this);
- }
-
- } else if (fStore != null) {
- fStore.removePropertyChangeListener(this);
- fStore= null;
- }
-
- update();
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_MARK_OCCURRENCES))
- setChecked(Boolean.valueOf(event.getNewValue().toString()).booleanValue());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/TogglePresentationAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/TogglePresentationAction.java
deleted file mode 100644
index f73cf59b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/TogglePresentationAction.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import org.eclipse.jface.action.IAction;
-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.IEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-/**
- * A tool bar 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(JavaEditorMessages.getBundleForConstructedKeys(), "TogglePresentation.", null, IAction.AS_CHECK_BOX); //$NON-NLS-1$
- JavaPluginImages.setToolImageDescriptors(this, "segment_edit.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.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);
- if (editor instanceof CompilationUnitEditor) {
- IWorkingCopyManager manager= JavaScriptPlugin.getDefault().getWorkingCopyManager();
- setEnabled(manager.getWorkingCopy(editor.getEditorInput()) != null);
- } else if (editor instanceof ClassFileEditor) {
- IEditorInput input= editor.getEditorInput();
- IClassFile cf= null;
- if (input instanceof IClassFileEditorInput) {
- IClassFileEditorInput cfi= (IClassFileEditorInput)input;
- cf= cfi.getClassFile();
- }
- setEnabled(cf != null && cf.exists());
- } else
- setEnabled(editor != null);
- }
-
- /*
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
-
- super.setEditor(editor);
-
- if (editor != null) {
-
- if (fStore == null) {
- fStore= JavaScriptPlugin.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.
- *
- * @param editor the text editor
- */
- 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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleTextHoverAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleTextHoverAction.java
deleted file mode 100644
index ce48c36d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/ToggleTextHoverAction.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-
-
-/**
- * A toolbar action which toggles the enabling state of the
- * editor's text hover.
- */
-public class ToggleTextHoverAction extends TextEditorAction implements IPropertyChangeListener {
-
-
- private IPreferenceStore fStore;
-
- /**
- * Constructs and updates the action.
- */
- public ToggleTextHoverAction() {
- super(JavaEditorMessages.getBundleForConstructedKeys(), "ToggleTextHover.", null); //$NON-NLS-1$
- JavaPluginImages.setToolImageDescriptors(this, "jdoc_hover_edit.gif"); //$NON-NLS-1$
- setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_TEXT_HOVER);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.TOGGLE_TEXTHOVER_ACTION);
- update();
- }
-
- /*
- * @see IAction#actionPerformed
- */
- public void run() {
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- boolean showHover= !fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_HOVER);
- setChecked(showHover);
-
- fStore.removePropertyChangeListener(this);
- fStore.setValue(PreferenceConstants.EDITOR_SHOW_HOVER, showHover);
- fStore.addPropertyChangeListener(this);
- }
-
- /*
- * @see TextEditorAction#update
- */
- public void update() {
- boolean showHover= fStore != null && fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_HOVER);
- setChecked(showHover);
- setEnabled(getTextEditor() != null);
- }
-
- /*
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- super.setEditor(editor);
- if (editor != null) {
- if (fStore == null) {
- fStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- fStore.addPropertyChangeListener(this);
- }
- } else if (fStore != null) {
- fStore.removePropertyChangeListener(this);
- fStore= null;
- }
- update();
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_SHOW_HOVER))
- update();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/WorkingCopyManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/WorkingCopyManager.java
deleted file mode 100644
index 556d47a5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/WorkingCopyManager.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.javaeditor;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManager;
-import org.eclipse.wst.jsdt.ui.IWorkingCopyManagerExtension;
-
-
-/**
- * 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 ICompilationUnitDocumentProvider 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(ICompilationUnitDocumentProvider provider) {
- Assert.isNotNull(provider);
- fDocumentProvider= provider;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.IWorkingCopyManager#connect(org.eclipse.ui.IEditorInput)
- */
- public void connect(IEditorInput input) throws CoreException {
- fDocumentProvider.connect(input);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.ui.IWorkingCopyManager#disconnect(org.eclipse.ui.IEditorInput)
- */
- public void disconnect(IEditorInput input) {
- fDocumentProvider.disconnect(input);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.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.wst.jsdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
- */
- public IJavaScriptUnit getWorkingCopy(IEditorInput input) {
- return getWorkingCopy(input, true);
- }
-
- /**
- * Returns the working copy remembered for the compilation unit encoded in the
- * given editor input.
- * <p>
- * Note: This method must not be part of the public {@link IWorkingCopyManager} API.
- * </p>
- *
- * @param input the editor input
- * @param primaryOnly if <code>true</code> only primary working copies will be returned
- * @return the working copy of the compilation unit, or <code>null</code> if the
- * input does not encode an editor input, or if there is no remembered working
- * copy for this compilation unit
- *
- */
- public IJavaScriptUnit getWorkingCopy(IEditorInput input, boolean primaryOnly) {
- IJavaScriptUnit unit= fMap == null ? null : (IJavaScriptUnit) fMap.get(input);
- if (unit == null)
- unit= fDocumentProvider.getWorkingCopy(input);
- if (unit != null && (!primaryOnly || JavaModelUtil.isPrimary(unit)))
- return unit;
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.wst.jsdt.core.IJavaScriptUnit)
- */
- public void setWorkingCopy(IEditorInput input, IJavaScriptUnit workingCopy) {
- if (fDocumentProvider.getDocument(input) != null) {
- if (fMap == null)
- fMap= new HashMap();
- fMap.put(input, workingCopy);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.IWorkingCopyManagerExtension#removeWorkingCopy(org.eclipse.ui.IEditorInput)
- */
- public void removeWorkingCopy(IEditorInput input) {
- fMap.remove(input);
- if (fMap.isEmpty())
- fMap= null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/AbstractSaveParticipantPreferenceConfiguration.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/AbstractSaveParticipantPreferenceConfiguration.java
deleted file mode 100644
index c847d102..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/AbstractSaveParticipantPreferenceConfiguration.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-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;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public abstract class AbstractSaveParticipantPreferenceConfiguration implements ISaveParticipantPreferenceConfiguration {
-
- /**
- * Preference prefix that is appended to the id of {@link SaveParticipantDescriptor save participants}.
- *
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- *
- * @see SaveParticipantDescriptor
- *
- */
- private static final String EDITOR_SAVE_PARTICIPANT_PREFIX= "editor_save_participant_"; //$NON-NLS-1$
-
- private SelectionButtonDialogField fEnableField;
- private Control fConfigControl;
- private IScopeContext fContext;
- private ControlEnableState fConfigControlEnabledState;
-
- /**
- * The id of the post save listener managed by this configuration block, not null
- */
- protected abstract String getPostSaveListenerId();
-
- /**
- * The name of the post save listener managed by this configuration block, not null
- */
- protected abstract String getPostSaveListenerName();
-
- protected Control createConfigControl(Composite composite, IPreferencePageContainer container) {
- //Default has no specific controls
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Control createControl(Composite parent, IPreferencePageContainer container) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridData gridData= new GridData(SWT.FILL, SWT.TOP, true, false);
- composite.setLayoutData(gridData);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- fEnableField= new SelectionButtonDialogField(SWT.CHECK);
- fEnableField.setLabelText(getPostSaveListenerName());
- fEnableField.doFillIntoGrid(composite, 1);
-
- fConfigControl= createConfigControl(composite, container);
-
- return composite;
- }
-
- /**
- * {@inheritDoc}
- */
- public void initialize(final IScopeContext context, IAdaptable element) {
- boolean enabled= isEnabled(context);
- fEnableField.setSelection(enabled);
-
- if (fConfigControl != null && !enabled) {
- fConfigControlEnabledState= ControlEnableState.disable(fConfigControl);
- }
-
- fEnableField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- enableConfigControl(fEnableField.isSelected());
- }
- });
-
- fContext= context;
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {}
-
- /**
- * {@inheritDoc}
- */
- public void performDefaults() {
- String key= getPreferenceKey();
- boolean defaultEnabled= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN).getBoolean(key, false);
- fContext.getNode(JavaScriptUI.ID_PLUGIN).putBoolean(key, defaultEnabled);
- fEnableField.setSelection(defaultEnabled);
- }
-
- /**
- * {@inheritDoc}
- */
- public void performOk() {}
-
- /**
- * {@inheritDoc}
- */
- public void enableProjectSettings() {
- fContext.getNode(JavaScriptUI.ID_PLUGIN).putBoolean(getPreferenceKey(), fEnableField.isSelected());
- }
-
- /**
- * {@inheritDoc}
- */
- public void disableProjectSettings() {
- fContext.getNode(JavaScriptUI.ID_PLUGIN).remove(getPreferenceKey());
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasSettingsInScope(IScopeContext context) {
- return context.getNode(JavaScriptUI.ID_PLUGIN).get(getPreferenceKey(), null) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isEnabled(IScopeContext context) {
- IEclipsePreferences node;
- if (hasSettingsInScope(context)) {
- node= context.getNode(JavaScriptUI.ID_PLUGIN);
- } else {
- node= new InstanceScope().getNode(JavaScriptUI.ID_PLUGIN);
- }
- IEclipsePreferences defaultNode= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN);
-
- String key= getPreferenceKey();
- return node.getBoolean(key, defaultNode.getBoolean(key, false));
- }
-
- protected void enableConfigControl(boolean isEnabled) {
- fContext.getNode(JavaScriptUI.ID_PLUGIN).putBoolean(getPreferenceKey(), isEnabled);
- if (fConfigControl != null) {
- if (fConfigControlEnabledState != null) {
- fConfigControlEnabledState.restore();
- fConfigControlEnabledState= null;
- } else {
- fConfigControlEnabledState= ControlEnableState.disable(fConfigControl);
- }
- }
- }
-
- private String getPreferenceKey() {
- return EDITOR_SAVE_PARTICIPANT_PREFIX + getPostSaveListenerId();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java
deleted file mode 100644
index e3c6da08..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-
-/**
- * This <code>IPostSaveListener</code> is informed when
- * a compilation unit is saved through the {@link org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider}.
- * <p>
- * In oder to get notified the listener must be registered with the {@link SaveParticipantRegistry}
- * and be enabled on the save participant preference page.</p>
- * <p>
- * The notification order of post save listeners is unspecified.</p>
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see SaveParticipantDescriptor
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
- *
- */
-public interface IPostSaveListener {
-
- /**
- * A human readable name of this listener.
- *
- * @return the name
- */
- String getName();
-
- /**
- * The unique id of this listener.
- *
- * @return a non-empty id
- */
- String getId();
-
- /**
- * Informs this post save listener that the given <code>compilationUnit</code>
- * has been saved by the {@link org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider}. The listener
- * is allowed to modify the given compilation unit and to open a dialog.
- * <p>
- * <em>Every implementor of this method must strictly obey these rules:</em>
- * <ul>
- * <li>not touch any file other than the given <code>compilationUnit</code>
- * which is already locked by a scheduling rule </li>
- * <li>changing the scheduling rule or posting a new job is not allowed</li>
- * <li>it is not allowed to save the given <code>compilationUnit</code></li>
- * <li>it must be able to deal with unsaved resources and with compilation units which are not on the Java build path</li>
- * <li>must not assume to be called in the UI thread</li>
- * <li>should be as fast as possible since this code is executed every time the <code>compilationUnit</code> is saved</li>
- * </ul>
- * The compilation unit document provider can disable a listener that violates any of the above rules.</p>
- *
- * @param compilationUnit the compilation unit which was saved
- * @param monitor the progress monitor for reporting progress
- * @see org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
- */
- void saved(IJavaScriptUnit compilationUnit, IProgressMonitor monitor) throws CoreException;
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java
deleted file mode 100644
index 113fbdce..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Preference UI to configure details of a save participant on the the
- * Java &gt; Editor &gt; Save Participants preference page.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- *
- */
-public interface ISaveParticipantPreferenceConfiguration {
-
- /**
- * Creates a control that will be displayed on the Java &gt; Editor &gt; Save Participants
- * preference page to edit the details of a save participant.
- *
- * @param parent the parent composite to which to add the preferences control
- * @param container the container in which this preference configuration is displayed
- * @return the control that was added to the <code>parent</code>
- */
- Control createControl(Composite parent, IPreferencePageContainer container);
-
- /**
- * Called after creating the control.
- * <p>
- * Implementations should load the preferences values and update the controls accordingly.
- * </p>
- * @param context the context from which to load the preference values from
- * @param element the element to configure, or null if this configures the workspace settings
- */
- void initialize(IScopeContext context, IAdaptable element);
-
- /**
- * Called when the <code>OK</code> button is pressed on the preference
- * page.
- * <p>
- * Implementations should commit the configured preference settings
- * into their form of preference storage.</p>
- */
- void performOk();
-
- /**
- * Called when the <code>Defaults</code> button is pressed on the
- * preference page.
- * <p>
- * Implementation should reset any preference settings to
- * their default values and adjust the controls accordingly.</p>
- */
- void performDefaults();
-
- /**
- * Called when the preference page is being disposed.
- * <p>
- * Implementations should free any resources they are holding on to.</p>
- */
- void dispose();
-
- /**
- * Called when project specific settings have been enabled
- */
- void enableProjectSettings();
-
- /**
- * Called when project specific settings have been disabled
- */
- void disableProjectSettings();
-
- /**
- * Called when a compilation unit is saved.
- * <p>
- * @param context the context in which the compilation unit is saved
- * @return true if the corresponding {@link IPostSaveListener} needs to be informed
- */
- boolean isEnabled(IScopeContext context);
-
- /**
- * Called when the property page is opened to check whether this has enabled settings
- * in the given context.
- *
- * @param context the context to check
- * @return true if this has settings in context
- */
- boolean hasSettingsInScope(IScopeContext context);
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantDescriptor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantDescriptor.java
deleted file mode 100644
index a6d37b4e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantDescriptor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import org.eclipse.core.runtime.Assert;
-
-/**
- * Describes a save participant contribution.
- *
- *
- */
-public class SaveParticipantDescriptor {
-
- /** The listener */
- private final IPostSaveListener fPostSaveListener;
- /** The preference configuration block, if any */
- private ISaveParticipantPreferenceConfiguration fPreferenceConfiguration;
-
- /**
- * Creates a new descriptor which connects a {@link IPostSaveListener}
- * with an {@link ISaveParticipantPreferenceConfiguration}.
- *
- * @param listener the listener
- */
- SaveParticipantDescriptor(IPostSaveListener listener) {
- Assert.isNotNull(listener);
-
- fPostSaveListener= listener;
- }
-
- /**
- * Returns the post save listener of the described
- * save participant
- *
- * @return the listener
- */
- public IPostSaveListener getPostSaveListener() {
- return fPostSaveListener;
- }
-
- /**
- * Creates a new preference configuration of the described
- * save participant.
- *
- * @return the preference configuration
- */
- public ISaveParticipantPreferenceConfiguration createPreferenceConfiguration() {
- return new AbstractSaveParticipantPreferenceConfiguration() {
-
- protected String getPostSaveListenerId() {
- return fPostSaveListener.getId();
- }
-
- protected String getPostSaveListenerName() {
- return fPostSaveListener.getName();
- }
- };
- }
-
- /**
- * Returns the preference configuration of the described
- * save participant.
- *
- * @return the preference configuration
- */
- public ISaveParticipantPreferenceConfiguration getPreferenceConfiguration() {
- if (fPreferenceConfiguration == null)
- fPreferenceConfiguration= createPreferenceConfiguration();
-
- return fPreferenceConfiguration;
- }
-
- /**
- * Returns the identifier of the described save participant.
- *
- * @return the non-empty id of this descriptor
- */
- public String getId() {
- return fPostSaveListener.getId();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.java
deleted file mode 100644
index 3244d71c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- *
- *
- */
-final class SaveParticipantMessages extends NLS {
-
- private static final String BUNDLE_NAME= SaveParticipantMessages.class.getName();
-
- private SaveParticipantMessages() {
- // Do not instantiate
- }
-
- public static String SaveParticipantRegistry_participantNotFound;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, SaveParticipantMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.properties
deleted file mode 100644
index 3dcc0868..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantMessages.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-SaveParticipantRegistry_participantNotFound= The ''{0}'' save participant could not be found and will be disabled.
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantRegistry.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantRegistry.java
deleted file mode 100644
index 3c36260b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/saveparticipant/SaveParticipantRegistry.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpPostSaveListener;
-import org.eclipse.wst.jsdt.internal.ui.fix.CleanUpSaveParticipantPreferenceConfiguration;
-
-/**
- * A registry for save participants. This registry manages
- * {@link SaveParticipantDescriptor}s and keeps track of enabled save
- * participants.
- * <p>
- * Save participants can be enabled and disabled on the Java &gt; Editor &gt;
- * Save Participants preference page. Enabled save participants are notified
- * through a call to
- * {@link IPostSaveListener#saved(org.eclipse.wst.jsdt.core.IJavaScriptUnit, org.eclipse.core.runtime.IProgressMonitor)}
- * whenever the {@link org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider} saves a compilation unit
- * that is in the workspace.</p>
- * <p>
- * An instance of this registry can be received through a call to {@link org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin#getSaveParticipantRegistry()}.</p>
- *
- *
- */
-public final class SaveParticipantRegistry {
-
- private static final IPostSaveListener[] EMPTY_ARRAY= new IPostSaveListener[0];
-
- /** The map of descriptors, indexed by their identifiers. */
- private Map fDescriptors;
-
- /**
- * Creates a new instance.
- */
- public SaveParticipantRegistry() {
- }
-
- /**
- * Returns an array of <code>SaveParticipantDescriptor</code> describing
- * all registered save participants.
- *
- * @return the array of registered save participant descriptors
- */
- public synchronized SaveParticipantDescriptor[] getSaveParticipantDescriptors() {
- ensureRegistered();
- return (SaveParticipantDescriptor[]) fDescriptors.values().toArray(new SaveParticipantDescriptor[fDescriptors.size()]);
- }
-
- /**
- * Returns the save participant descriptor for the given <code>id</code> or
- * <code>null</code> if no such listener is registered.
- *
- * @param id the identifier of the requested save participant
- * @return the corresponding descriptor, or <code>null</code> if none can be found
- */
- public synchronized SaveParticipantDescriptor getSaveParticipantDescriptor(String id) {
- ensureRegistered();
- return (SaveParticipantDescriptor) fDescriptors.get(id);
- }
-
- /**
- * Ensures that all descriptors are created and stored in
- * <code>fDescriptors</code>.
- */
- private void ensureRegistered() {
- if (fDescriptors == null)
- reloadDescriptors();
- }
-
- /**
- * Loads the save participants.
- * <p>
- * This method can be called more than once in
- * order to reload from a changed extension registry.
- * </p>
- */
- private void reloadDescriptors() {
- Map map= new HashMap();
- SaveParticipantDescriptor desc= new SaveParticipantDescriptor(new CleanUpPostSaveListener()) {
- /**
- * {@inheritDoc}
- */
- public ISaveParticipantPreferenceConfiguration createPreferenceConfiguration() {
- return new CleanUpSaveParticipantPreferenceConfiguration();
- }
- };
- map.put(desc.getId(), desc);
-
- fDescriptors= map;
- }
-
- public void dispose() {
- }
-
- /**
- * Checks weather there are enabled or disabled post save listener in the given context.
- *
- * @param context to context to check, not null
- * @return true if there are settings in context
- */
- public synchronized boolean hasSettingsInScope(IScopeContext context) {
- ensureRegistered();
-
- for (Iterator iterator= fDescriptors.values().iterator(); iterator.hasNext();) {
- SaveParticipantDescriptor descriptor= (SaveParticipantDescriptor)iterator.next();
- if (descriptor.getPreferenceConfiguration().hasSettingsInScope(context))
- return true;
- }
-
- return false;
- }
-
- public IPostSaveListener[] getEnabledPostSaveListeners(IProject project) {
- return getEnabledPostSaveListeners(new ProjectScope(project));
- }
-
- /**
- * Returns an array of <code>IPostSaveListener</code> which are
- * enabled in the given context.
- *
- * @param context the context from which to retrive the settings from, not null
- * @return the current enabled post save listeners according to the preferences
- */
- public synchronized IPostSaveListener[] getEnabledPostSaveListeners(IScopeContext context) {
- ensureRegistered();
-
- ArrayList result= null;
- for (Iterator iterator= fDescriptors.values().iterator(); iterator.hasNext();) {
- SaveParticipantDescriptor descriptor= (SaveParticipantDescriptor)iterator.next();
- if (descriptor.getPreferenceConfiguration().isEnabled(context)) {
- if (result == null) {
- result= new ArrayList();
- }
- result.add(descriptor.getPostSaveListener());
- }
- }
-
- if (result == null) {
- return EMPTY_ARRAY;
- } else {
- return (IPostSaveListener[])result.toArray(new IPostSaveListener[result.size()]);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/GoToNextPreviousMemberAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/GoToNextPreviousMemberAction.java
deleted file mode 100644
index 6bd51299..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/GoToNextPreviousMemberAction.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.jsdt.core.IInitializer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.internal.corext.SourceRange;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class GoToNextPreviousMemberAction extends Action implements IUpdate {
-
- public static final String NEXT_MEMBER= "GoToNextMember"; //$NON-NLS-1$
- public static final String PREVIOUS_MEMBER= "GoToPreviousMember"; //$NON-NLS-1$
- private JavaEditor fEditor;
- private boolean fIsGotoNext;
-
- public static GoToNextPreviousMemberAction newGoToNextMemberAction(JavaEditor editor) {
- String text= SelectionActionMessages.GotoNextMember_label;
- return new GoToNextPreviousMemberAction(editor, text, true);
- }
-
- public static GoToNextPreviousMemberAction newGoToPreviousMemberAction(JavaEditor editor) {
- String text= SelectionActionMessages.GotoPreviousMember_label;
- return new GoToNextPreviousMemberAction(editor, text, false);
- }
-
- private GoToNextPreviousMemberAction(JavaEditor editor, String text, boolean isGotoNext) {
- super(text);
- Assert.isNotNull(editor);
- fEditor= editor;
- fIsGotoNext= isGotoNext;
- update();
- if (isGotoNext)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_NEXT_MEMBER_ACTION);
- else
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_MEMBER_ACTION);
- }
-
- /*
- * This constructor is for testing purpose only.
- */
- public GoToNextPreviousMemberAction(boolean isSelectNext) {
- super(""); //$NON-NLS-1$
- fIsGotoNext= isSelectNext;
- }
-
- public void update() {
- boolean enabled= false;
- ISourceReference ref= getSourceReference();
- if (ref != null) {
- ISourceRange range;
- try {
- range= ref.getSourceRange();
- enabled= range != null && range.getLength() > 0;
- } catch (JavaScriptModelException e) {
- // enabled= false;
- }
- }
- setEnabled(enabled);
- }
-
- /* (non-JavaDoc)
- * Method declared in IAction.
- */
- public final void run() {
- ITextSelection selection= getTextSelection();
- ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), null);
- // Check if new selection differs from current selection
- if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength())
- return;
- fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength());
- }
-
- private IType[] getTypes() throws JavaScriptModelException {
- IEditorInput input= fEditor.getEditorInput();
- if (input instanceof IClassFileEditorInput) {
- return new IType[] { ((IClassFileEditorInput)input).getClassFile().getType() };
- } else {
- return JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input).getAllTypes();
- }
- }
-
- private ISourceReference getSourceReference() {
- IEditorInput input= fEditor.getEditorInput();
- if (input instanceof IClassFileEditorInput) {
- return ((IClassFileEditorInput)input).getClassFile();
- } else {
- return JavaScriptPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
- }
- }
-
- private ITextSelection getTextSelection() {
- return (ITextSelection)fEditor.getSelectionProvider().getSelection();
- }
-
- public ISourceRange getNewSelectionRange(ISourceRange oldSourceRange, IType[] types) {
- try{
- if (types == null)
- types= getTypes();
- Integer[] offsetArray= createOffsetArray(types);
- if (offsetArray.length == 0)
- return oldSourceRange;
- Arrays.sort(offsetArray);
- Integer oldOffset= new Integer(oldSourceRange.getOffset());
- int index= Arrays.binarySearch(offsetArray, oldOffset);
-
- if (fIsGotoNext)
- return createNewSourceRange(getNextOffset(index, offsetArray, oldOffset));
- else
- return createNewSourceRange(getPreviousOffset(index, offsetArray, oldOffset));
-
- } catch (JavaScriptModelException e){
- JavaScriptPlugin.log(e); //dialog would be too heavy here
- return oldSourceRange;
- }
- }
-
- private static Integer getPreviousOffset(int index, Integer[] offsetArray, Integer oldOffset) {
- if (index == -1)
- return oldOffset;
- if (index == 0)
- return offsetArray[0];
- if (index > 0)
- return offsetArray[index - 1];
- Assert.isTrue(index < -1);
- int absIndex= Math.abs(index);
- return offsetArray[absIndex - 2];
- }
-
- private static Integer getNextOffset(int index, Integer[] offsetArray, Integer oldOffset) {
- if (index == -1)
- return offsetArray[0];
-
- if (index == 0){
- if (offsetArray.length != 1)
- return offsetArray[1];
- else
- return offsetArray[0];
- }
- if (index > 0){
- if (index == offsetArray.length - 1)
- return oldOffset;
- return offsetArray[index + 1];
- }
- Assert.isTrue(index < -1);
- int absIndex= Math.abs(index);
- if (absIndex > offsetArray.length)
- return oldOffset;
- else
- return offsetArray[absIndex - 1];
- }
-
- private static ISourceRange createNewSourceRange(Integer offset){
- return new SourceRange(offset.intValue(), 0);
- }
-
- private static Integer[] createOffsetArray(IType[] types) throws JavaScriptModelException {
- List result= new ArrayList();
- for (int i= 0; i < types.length; i++) {
- IType iType= types[i];
- addOffset(result, iType.getNameRange().getOffset());
- addOffset(result, iType.getSourceRange().getOffset() + iType.getSourceRange().getLength());
- addMemberOffsetList(result, iType.getFunctions());
- addMemberOffsetList(result, iType.getFields());
- addMemberOffsetList(result, iType.getInitializers());
- }
- return (Integer[]) result.toArray(new Integer[result.size()]);
- }
-
- private static void addMemberOffsetList(List result, IMember[] members) throws JavaScriptModelException {
- for (int i= 0; i < members.length; i++) {
- addOffset(result, getOffset(members[i]));
- }
- }
-
- private static int getOffset(IMember iMember) throws JavaScriptModelException {
- //special case
- if (iMember.getElementType() == IJavaScriptElement.INITIALIZER)
- return firstOpeningBraceOffset((IInitializer)iMember);
-
- if (iMember.getNameRange() != null && iMember.getNameRange().getOffset() >= 0)
- return iMember.getNameRange().getOffset();
- return iMember.getSourceRange().getOffset();
- }
-
- private static int firstOpeningBraceOffset(IInitializer iInitializer) throws JavaScriptModelException {
- try {
- IScanner scanner= ToolFactory.createScanner(false, false, false, false);
- scanner.setSource(iInitializer.getSource().toCharArray());
- int token= scanner.getNextToken();
- while (token != ITerminalSymbols.TokenNameEOF && token != ITerminalSymbols.TokenNameLBRACE)
- token= scanner.getNextToken();
- if (token == ITerminalSymbols.TokenNameLBRACE)
- return iInitializer.getSourceRange().getOffset() + scanner.getCurrentTokenStartPosition() + scanner.getRawTokenSource().length;
- return iInitializer.getSourceRange().getOffset();
- } catch (InvalidInputException e) {
- return iInitializer.getSourceRange().getOffset();
- }
- }
-
- //-- private helper methods
-
- private static ISourceRange createSourceRange(ITextSelection ts) {
- return new SourceRange(ts.getOffset(), ts.getLength());
- }
-
- private static void addOffset(List result, int offset) {
- if (offset >= 0)
- result.add(new Integer(offset));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.java
deleted file mode 100644
index 0eb50fcb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- *
- *
- */
-final class SelectionActionMessages extends NLS {
-
- private static final String BUNDLE_NAME= SelectionActionMessages.class.getName();
-
- private SelectionActionMessages() {
- // Do not instantiate
- }
-
- public static String StructureSelect_error_title;
- public static String StructureSelect_error_message;
- public static String StructureSelectNext_label;
- public static String StructureSelectNext_tooltip;
- public static String StructureSelectNext_description;
- public static String StructureSelectPrevious_label;
- public static String StructureSelectPrevious_tooltip;
- public static String StructureSelectPrevious_description;
- public static String StructureSelectEnclosing_label;
- public static String StructureSelectEnclosing_tooltip;
- public static String StructureSelectEnclosing_description;
- public static String StructureSelectHistory_label;
- public static String StructureSelectHistory_tooltip;
- public static String StructureSelectHistory_description;
-
- public static String GotoNextMember_label;
- public static String GotoPreviousMember_label;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, SelectionActionMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.properties
deleted file mode 100644
index 3d3cce90..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionActionMessages.properties
+++ /dev/null
@@ -1,32 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-StructureSelect_error_title= Expand Selection To
-StructureSelect_error_message= No source code attached to class file. To perform this operation you will need to attach source.
-
-StructureSelectNext_label=&Next Element
-StructureSelectNext_tooltip=Expand Selection to Include Next Sibling
-StructureSelectNext_description=Expand selection to include next sibling
-
-StructureSelectPrevious_label=&Previous Element
-StructureSelectPrevious_tooltip=Expand Selection to Include Previous Sibling
-StructureSelectPrevious_description=Expand selection to include previous sibling
-
-StructureSelectEnclosing_label=&Enclosing Element
-StructureSelectEnclosing_tooltip=Expand Selection to Include Enclosing Element
-StructureSelectEnclosing_description=Expand selection to include enclosing element
-
-StructureSelectHistory_label=&Restore Last Selection
-StructureSelectHistory_tooltip=Restore Last Selection
-StructureSelectHistory_description=Restore last selection
-
-GotoNextMember_label= N&ext Member
-GotoPreviousMember_label= Previ&ous Member
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionHistory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionHistory.java
deleted file mode 100644
index a1a125d2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/SelectionHistory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class SelectionHistory {
-
- private List fHistory;
- private JavaEditor fEditor;
- private ISelectionChangedListener fSelectionListener;
- private int fSelectionChangeListenerCounter;
- private StructureSelectHistoryAction fHistoryAction;
-
- public SelectionHistory(JavaEditor editor) {
- Assert.isNotNull(editor);
- fEditor= editor;
- fHistory= new ArrayList(3);
- fSelectionListener= new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (fSelectionChangeListenerCounter == 0)
- flush();
- }
- };
- fEditor.getSelectionProvider().addSelectionChangedListener(fSelectionListener);
- }
-
- public void setHistoryAction(StructureSelectHistoryAction action) {
- Assert.isNotNull(action);
- fHistoryAction= action;
- }
-
- public boolean isEmpty() {
- return fHistory.isEmpty();
- }
-
- public void remember(ISourceRange range) {
- fHistory.add(range);
- fHistoryAction.update();
- }
-
- public ISourceRange getLast() {
- if (isEmpty())
- return null;
- int size= fHistory.size();
- ISourceRange result= (ISourceRange)fHistory.remove(size - 1);
- fHistoryAction.update();
- return result;
- }
-
- public void flush() {
- if (fHistory.isEmpty())
- return;
- fHistory.clear();
- fHistoryAction.update();
- }
-
- public void ignoreSelectionChanges() {
- fSelectionChangeListenerCounter++;
- }
-
- public void listenToSelectionChanges() {
- fSelectionChangeListenerCounter--;
- }
-
- public void dispose() {
- fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectEnclosingAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectEnclosingAction.java
deleted file mode 100644
index 8a152b8d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectEnclosingAction.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.internal.corext.dom.SelectionAnalyzer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class StructureSelectEnclosingAction extends StructureSelectionAction {
-
- public StructureSelectEnclosingAction(JavaEditor editor, SelectionHistory history) {
- super(SelectionActionMessages.StructureSelectEnclosing_label, editor, history);
- setToolTipText(SelectionActionMessages.StructureSelectEnclosing_tooltip);
- setDescription(SelectionActionMessages.StructureSelectEnclosing_description);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.STRUCTURED_SELECT_ENCLOSING_ACTION);
- }
-
- /*
- * This constructor is for testing purpose only.
- */
- public StructureSelectEnclosingAction() {
- }
-
- /*
- * @see StructureSelectionAction#internalGetNewSelectionRange(ISourceRange, IJavaScriptUnit, SelectionAnalyzer)
- */
- ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaScriptModelException{
- ASTNode first= selAnalyzer.getFirstSelectedNode();
- if (first == null || first.getParent() == null)
- return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
-
- return getSelectedNodeSourceRange(sr, first.getParent());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectHistoryAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectHistoryAction.java
deleted file mode 100644
index 6091e878..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectHistoryAction.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class StructureSelectHistoryAction extends Action implements IUpdate {
- private JavaEditor fEditor;
- private SelectionHistory fHistory;
-
- public StructureSelectHistoryAction(JavaEditor editor, SelectionHistory history) {
- super(SelectionActionMessages.StructureSelectHistory_label);
- setToolTipText(SelectionActionMessages.StructureSelectHistory_tooltip);
- setDescription(SelectionActionMessages.StructureSelectHistory_description);
- Assert.isNotNull(history);
- Assert.isNotNull(editor);
- fHistory= history;
- fEditor= editor;
- update();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.STRUCTURED_SELECTION_HISTORY_ACTION);
- }
-
- public void update() {
- setEnabled(!fHistory.isEmpty());
- }
-
- public void run() {
- ISourceRange old= fHistory.getLast();
- if (old != null) {
- try {
- fHistory.ignoreSelectionChanges();
- fEditor.selectAndReveal(old.getOffset(), old.getLength());
- } finally {
- fHistory.listenToSelectionChanges();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectNextAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectNextAction.java
deleted file mode 100644
index 1d7b551c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectNextAction.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.internal.corext.dom.GenericVisitor;
-import org.eclipse.wst.jsdt.internal.corext.dom.SelectionAnalyzer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class StructureSelectNextAction extends StructureSelectionAction{
-
- private static class NextNodeAnalyzer extends GenericVisitor {
- private final int fOffset;
- private ASTNode fNextNode;
- private NextNodeAnalyzer(int offset) {
- super(true);
- fOffset= offset;
- }
- public static ASTNode perform(int offset, ASTNode lastCoveringNode) {
- NextNodeAnalyzer analyzer= new NextNodeAnalyzer(offset);
- lastCoveringNode.accept(analyzer);
- return analyzer.fNextNode;
- }
- protected boolean visitNode(ASTNode node) {
- int start= node.getStartPosition();
- int end= start + node.getLength();
- if (start == fOffset) {
- fNextNode= node;
- return true;
- } else {
- return (start < fOffset && fOffset < end);
- }
- }
- }
-
- public StructureSelectNextAction(JavaEditor editor, SelectionHistory history) {
- super(SelectionActionMessages.StructureSelectNext_label, editor, history);
- setToolTipText(SelectionActionMessages.StructureSelectNext_tooltip);
- setDescription(SelectionActionMessages.StructureSelectNext_description);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.STRUCTURED_SELECT_NEXT_ACTION);
- }
-
- /*
- * This constructor is for testing purpose only.
- */
- public StructureSelectNextAction() {
- }
-
- /* non java doc
- * @see StructureSelectionAction#internalGetNewSelectionRange(ISourceRange, IJavaScriptUnit, SelectionAnalyzer)
- */
- ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaScriptModelException{
- if (oldSourceRange.getLength() == 0 && selAnalyzer.getLastCoveringNode() != null) {
- ASTNode previousNode= NextNodeAnalyzer.perform(oldSourceRange.getOffset(), selAnalyzer.getLastCoveringNode());
- if (previousNode != null)
- return getSelectedNodeSourceRange(sr, previousNode);
- }
- ASTNode first= selAnalyzer.getFirstSelectedNode();
- if (first == null)
- return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
-
- ASTNode parent= first.getParent();
- if (parent == null)
- return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
-
- ASTNode lastSelectedNode= selAnalyzer.getSelectedNodes()[selAnalyzer.getSelectedNodes().length - 1];
- ASTNode nextNode= getNextNode(parent, lastSelectedNode);
- if (nextNode == parent)
- return getSelectedNodeSourceRange(sr, first.getParent());
- int offset= oldSourceRange.getOffset();
- int end= Math.min(sr.getSourceRange().getLength(), nextNode.getStartPosition() + nextNode.getLength() - 1);
- return StructureSelectionAction.createSourceRange(offset, end);
- }
-
- private static ASTNode getNextNode(ASTNode parent, ASTNode node){
- ASTNode[] siblingNodes= StructureSelectionAction.getSiblingNodes(node);
- if (siblingNodes == null || siblingNodes.length == 0)
- return parent;
- if (node == siblingNodes[siblingNodes.length -1 ])
- return parent;
- else
- return siblingNodes[StructureSelectionAction.findIndex(siblingNodes, node) + 1];
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectPreviousAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectPreviousAction.java
deleted file mode 100644
index 1f7fcfc2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectPreviousAction.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.internal.corext.dom.GenericVisitor;
-import org.eclipse.wst.jsdt.internal.corext.dom.SelectionAnalyzer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public class StructureSelectPreviousAction extends StructureSelectionAction {
-
- private static class PreviousNodeAnalyzer extends GenericVisitor {
- private final int fOffset;
- private ASTNode fPreviousNode;
- private PreviousNodeAnalyzer(int offset) {
- super(true);
- fOffset= offset;
- }
- public static ASTNode perform(int offset, ASTNode lastCoveringNode) {
- PreviousNodeAnalyzer analyzer= new PreviousNodeAnalyzer(offset);
- lastCoveringNode.accept(analyzer);
- return analyzer.fPreviousNode;
- }
- protected boolean visitNode(ASTNode node) {
- int start= node.getStartPosition();
- int end= start + node.getLength();
- if (end == fOffset) {
- fPreviousNode= node;
- return true;
- } else {
- return (start < fOffset && fOffset < end);
- }
- }
- }
-
- public StructureSelectPreviousAction(JavaEditor editor, SelectionHistory history) {
- super(SelectionActionMessages.StructureSelectPrevious_label, editor, history);
- setToolTipText(SelectionActionMessages.StructureSelectPrevious_tooltip);
- setDescription(SelectionActionMessages.StructureSelectPrevious_description);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.STRUCTURED_SELECT_PREVIOUS_ACTION);
- }
-
- /*
- * This constructor is for testing purpose only.
- */
- public StructureSelectPreviousAction() {
- }
-
- /* non java doc
- * @see StructureSelectionAction#internalGetNewSelectionRange(ISourceRange, IJavaScriptUnit, SelectionAnalyzer)
- */
- ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaScriptModelException{
- if (oldSourceRange.getLength() == 0 && selAnalyzer.getLastCoveringNode() != null) {
- ASTNode previousNode= PreviousNodeAnalyzer.perform(oldSourceRange.getOffset(), selAnalyzer.getLastCoveringNode());
- if (previousNode != null)
- return getSelectedNodeSourceRange(sr, previousNode);
- }
- ASTNode first= selAnalyzer.getFirstSelectedNode();
- if (first == null)
- return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
-
- ASTNode parent= first.getParent();
- if (parent == null)
- return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
-
- ASTNode previousNode= getPreviousNode(parent, selAnalyzer.getSelectedNodes()[0]);
- if (previousNode == parent)
- return getSelectedNodeSourceRange(sr, parent);
-
- int offset= previousNode.getStartPosition();
- int end= oldSourceRange.getOffset() + oldSourceRange.getLength() - 1;
- return StructureSelectionAction.createSourceRange(offset, end);
- }
-
- private static ASTNode getPreviousNode(ASTNode parent, ASTNode node){
- ASTNode[] siblingNodes= StructureSelectionAction.getSiblingNodes(node);
- if (siblingNodes == null || siblingNodes.length == 0)
- return parent;
- if (node == siblingNodes[0]) {
- return parent;
- } else {
- int index= StructureSelectionAction.findIndex(siblingNodes, node);
- if (index < 1)
- return parent;
- return siblingNodes[index - 1];
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java
deleted file mode 100644
index 46b76645..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.javaeditor.selectionactions;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.StructuralPropertyDescriptor;
-import org.eclipse.wst.jsdt.internal.corext.SourceRange;
-import org.eclipse.wst.jsdt.internal.corext.dom.Selection;
-import org.eclipse.wst.jsdt.internal.corext.dom.SelectionAnalyzer;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-public abstract class StructureSelectionAction extends Action {
-
- public static final String NEXT= "SelectNextElement"; //$NON-NLS-1$
- public static final String PREVIOUS= "SelectPreviousElement"; //$NON-NLS-1$
- public static final String ENCLOSING= "SelectEnclosingElement"; //$NON-NLS-1$
- public static final String HISTORY= "RestoreLastSelection"; //$NON-NLS-1$
-
- private JavaEditor fEditor;
- private SelectionHistory fSelectionHistory;
-
- protected StructureSelectionAction(String text, JavaEditor editor, SelectionHistory history) {
- super(text);
- Assert.isNotNull(editor);
- Assert.isNotNull(history);
- fEditor= editor;
- fSelectionHistory= history;
- }
-
- /*
- * This constructor is for testing purpose only.
- */
- protected StructureSelectionAction() {
- super(""); //$NON-NLS-1$
- }
-
- /*
- * Method declared in IAction.
- */
- public final void run() {
- IJavaScriptElement inputElement= EditorUtility.getEditorInputJavaElement(fEditor, false);
- if (!(inputElement instanceof ISourceReference && inputElement.exists()))
- return;
-
- ISourceReference source= (ISourceReference)inputElement;
- ISourceRange sourceRange;
- try {
- sourceRange= source.getSourceRange();
- if (sourceRange == null || sourceRange.getLength() == 0) {
- MessageDialog.openInformation(fEditor.getEditorSite().getShell(),
- SelectionActionMessages.StructureSelect_error_title,
- SelectionActionMessages.StructureSelect_error_message);
- return;
- }
- } catch (JavaScriptModelException e) {
- }
- ITextSelection selection= getTextSelection();
- ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), source);
- // Check if new selection differs from current selection
- if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength())
- return;
- fSelectionHistory.remember(new SourceRange(selection.getOffset(), selection.getLength()));
- try {
- fSelectionHistory.ignoreSelectionChanges();
- fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength());
- } finally {
- fSelectionHistory.listenToSelectionChanges();
- }
- }
-
- public final ISourceRange getNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr) {
- try{
- JavaScriptUnit root= getAST(sr);
- if (root == null)
- return oldSourceRange;
- Selection selection= Selection.createFromStartLength(oldSourceRange.getOffset(), oldSourceRange.getLength());
- SelectionAnalyzer selAnalyzer= new SelectionAnalyzer(selection, true);
- root.accept(selAnalyzer);
- return internalGetNewSelectionRange(oldSourceRange, sr, selAnalyzer);
- } catch (JavaScriptModelException e){
- JavaScriptPlugin.log(e); //dialog would be too heavy here
- return new SourceRange(oldSourceRange.getOffset(), oldSourceRange.getLength());
- }
- }
-
- /**
- * Subclasses determine the actual new selection.
- */
- abstract ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaScriptModelException;
-
- protected final ITextSelection getTextSelection() {
- return (ITextSelection)fEditor.getSelectionProvider().getSelection();
- }
-
- // -- helper methods for subclasses to fit a node range into the source range
-
- protected static ISourceRange getLastCoveringNodeRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaScriptModelException {
- if (selAnalyzer.getLastCoveringNode() == null)
- return oldSourceRange;
- else
- return getSelectedNodeSourceRange(sr, selAnalyzer.getLastCoveringNode());
- }
-
- protected static ISourceRange getSelectedNodeSourceRange(ISourceReference sr, ASTNode nodeToSelect) throws JavaScriptModelException {
- int offset= nodeToSelect.getStartPosition();
- int end= Math.min(sr.getSourceRange().getLength(), nodeToSelect.getStartPosition() + nodeToSelect.getLength() - 1);
- return createSourceRange(offset, end);
- }
-
- //-- private helper methods
-
- private static ISourceRange createSourceRange(ITextSelection ts){
- return new SourceRange(ts.getOffset(), ts.getLength());
- }
-
- private static JavaScriptUnit getAST(ISourceReference sr) {
- return ASTProvider.getASTProvider().getAST((IJavaScriptElement) sr, ASTProvider.WAIT_YES, null);
- }
-
- //-- helper methods for this class and subclasses
-
- static ISourceRange createSourceRange(int offset, int end){
- int length= end - offset + 1;
- if (length == 0) //to allow 0-length selection
- length= 1;
- return new SourceRange(Math.max(0, offset), length);
- }
-
- static ASTNode[] getSiblingNodes(ASTNode node) {
- ASTNode parent= node.getParent();
- StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
- if (locationInParent.isChildListProperty()) {
- List siblings= (List) parent.getStructuralProperty(locationInParent);
- return (ASTNode[]) siblings.toArray(new ASTNode[siblings.size()]);
- }
- return null;
- }
-
- static int findIndex(Object[] array, Object o){
- for (int i= 0; i < array.length; i++) {
- Object object= array[i];
- if (object == o)
- return i;
- }
- return -1;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelAdapterFactory.java
deleted file mode 100644
index 0ab5850e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelAdapterFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.team.core.mapping.IResourceMappingMerger;
-import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
-
-/**
- * Adaptor factory for model support.
- *
- *
- */
-public final class JavaModelAdapterFactory implements IAdapterFactory {
-
- /**
- * {@inheritDoc}
- */
- public Object getAdapter(final Object adaptable, final Class adapter) {
- if (adaptable instanceof JavaModelProvider) {
- if (adapter == IResourceMappingMerger.class)
- return new JavaModelMerger((ModelProvider) adaptable);
- else if (adapter == ISynchronizationCompareAdapter.class)
- return new JavaSynchronizationCompareAdapter();
- } else if (adaptable instanceof RefactoringHistory) {
- if (adapter == ResourceMapping.class)
- return new JavaRefactoringHistoryResourceMapping((RefactoringHistory) adaptable);
- else if (adapter == IResource.class)
- return new JavaRefactoringHistoryResourceMapping((RefactoringHistory) adaptable).getResource();
- } else if (adaptable instanceof RefactoringDescriptorProxy) {
- if (adapter == ResourceMapping.class)
- return new JavaRefactoringDescriptorResourceMapping((RefactoringDescriptorProxy) adaptable);
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Class[] getAdapterList() {
- return new Class[] { ResourceMapping.class, ISynchronizationCompareAdapter.class, IResource.class};
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelContentProvider.java
deleted file mode 100644
index 7fd72d91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelContentProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-/**
- * Content provider for Java models.
- *
- *
- */
-public final class JavaModelContentProvider extends StandardJavaScriptElementContentProvider {
-
- /** The name of the settings folder */
- private static final String NAME_SETTINGS_FOLDER= ".settings"; //$NON-NLS-1$
-
- /**
- * Creates a new java model content provider.
- */
- public JavaModelContentProvider() {
- super(true);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object[] getChildren(final Object element) {
- if (element instanceof IJavaScriptUnit)
- return NO_CHILDREN;
- else if (element instanceof RefactoringHistory)
- return ((RefactoringHistory) element).getDescriptors();
- else if (element instanceof IJavaScriptProject) {
- final List elements= new ArrayList();
- elements.add(((IJavaScriptProject) element).getProject().getFolder(NAME_SETTINGS_FOLDER));
- final Object[] children= super.getChildren(element);
- for (int index= 0; index < children.length; index++) {
- if (!elements.contains(children[index]))
- elements.add(children[index]);
- }
- return elements.toArray();
- } else if (element instanceof IFolder) {
- final IFolder folder= (IFolder) element;
- try {
- return folder.members();
- } catch (CoreException exception) {
- // Do nothing
- }
- }
- return super.getChildren(element);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasChildren(final Object element) {
- if (element instanceof IJavaScriptUnit)
- return false;
- else if (element instanceof RefactoringHistory)
- return true;
- else if (element instanceof RefactoringDescriptorProxy)
- return false;
- else if (element instanceof IFolder)
- return true;
- return super.hasChildren(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelLabelProvider.java
deleted file mode 100644
index 93cf515c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelLabelProvider.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryControlConfiguration;
-import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Label provider for Java models.
- *
- *
- */
-public final class JavaModelLabelProvider extends AppearanceAwareLabelProvider {
-
- /** The name of the settings folder */
- private static final String NAME_SETTINGS_FOLDER= ".settings"; //$NON-NLS-1$
-
- /** The refactoring history label provider */
- private final RefactoringHistoryLabelProvider fHistoryLabelProvider= new RefactoringHistoryLabelProvider(new RefactoringHistoryControlConfiguration(null, false, false));
-
- /** The project preferences label */
- private final String fPreferencesLabel;
-
- /** The pending refactorings label */
- private final String fRefactoringsLabel;
-
- /** The project settings image, or <code>null</code> */
- private Image fSettingsImage= null;
-
- /**
- * Creates a new java model label provider.
- */
- public JavaModelLabelProvider() {
- this(ModelMessages.JavaModelLabelProvider_project_preferences_label, ModelMessages.JavaModelLabelProvider_refactorings_label);
- }
-
- /**
- * Creates a new java model label provider.
- *
- * @param preferences
- * the preferences label
- * @param refactorings
- * the refactorings label
- */
- public JavaModelLabelProvider(final String preferences, final String refactorings) {
- super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS);
- Assert.isNotNull(preferences);
- Assert.isNotNull(refactorings);
- fPreferencesLabel= preferences;
- fRefactoringsLabel= refactorings;
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- super.dispose();
- fHistoryLabelProvider.dispose();
- if (fSettingsImage != null && !fSettingsImage.isDisposed()) {
- fSettingsImage.dispose();
- fSettingsImage= null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Image getImage(final Object element) {
- if (element instanceof IFolder) {
- final IFolder folder= (IFolder) element;
- if (folder.getName().equals(NAME_SETTINGS_FOLDER)) {
- if (fSettingsImage == null || fSettingsImage.isDisposed())
- fSettingsImage= JavaPluginImages.DESC_OBJS_PROJECT_SETTINGS.createImage();
- return decorateImage(fSettingsImage, element);
- }
- }
- Image image= super.getImage(element);
- if (image == null) {
- if (element instanceof RefactoringHistory)
- image= fHistoryLabelProvider.getImage(element);
- else if (element instanceof RefactoringDescriptorProxy)
- image= fHistoryLabelProvider.getImage(element);
- return decorateImage(image, element);
- }
- return image;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getText(final Object element) {
- if (element instanceof IFolder) {
- final IFolder folder= (IFolder) element;
- if (folder.getName().equals(NAME_SETTINGS_FOLDER))
- return decorateText(fPreferencesLabel, element);
- }
- String text= super.getText(element);
- if (text == null || "".equals(text)) { //$NON-NLS-1$
- if (element instanceof RefactoringHistory)
- text= fRefactoringsLabel;
- else if (element instanceof RefactoringDescriptorProxy)
- text= fHistoryLabelProvider.getText(element);
- return decorateText(text, element);
- }
- return text;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelMerger.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelMerger.java
deleted file mode 100644
index 6a0b57e2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelMerger.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ltk.ui.refactoring.model.AbstractResourceMappingMerger;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Java-aware refactoring model merger.
- *
- *
- */
-public final class JavaModelMerger extends AbstractResourceMappingMerger {
-
- /**
- * Creates a new java model merger.
- *
- * @param provider
- * the model provider
- */
- public JavaModelMerger(final ModelProvider provider) {
- super(provider);
- }
-
- /**
- * {@inheritDoc}
- */
- protected IProject[] getDependencies(final IProject[] projects) {
- Assert.isNotNull(projects);
- final Set set= new HashSet();
- for (int index= 0; index < projects.length; index++)
- getDependentProjects(set, projects[index]);
- final IProject[] result= new IProject[set.size()];
- set.toArray(result);
- return result;
- }
-
- /**
- * Returns the dependent projects of the specified project.
- *
- * @param set
- * the project set
- * @param project
- * the project to get its dependent projects
- */
- private void getDependentProjects(final Set set, final IProject project) {
- Assert.isNotNull(set);
- Assert.isNotNull(project);
- final IJavaScriptModel model= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- if (model != null) {
- try {
- final String name= project.getName();
- final IJavaScriptProject[] projects= model.getJavaScriptProjects();
- for (int index= 0; index < projects.length; index++) {
- final String[] names= projects[index].getRequiredProjectNames();
- for (int offset= 0; offset < names.length; offset++) {
- if (name.equals(names[offset]))
- set.add(projects[index].getProject());
- }
- }
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelProvider.java
deleted file mode 100644
index 8e1ca22b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaModelProvider.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaElementResourceMapping;
-
-/**
- * Java-aware model provider.
- *
- *
- */
-public final class JavaModelProvider extends ModelProvider {
-
- /** The model provider id */
- public static final String JAVA_MODEL_PROVIDER_ID= "org.eclipse.wst.jsdt.ui.modelProvider"; //$NON-NLS-1$
-
- /**
- * Returns the resource associated with the corresponding model element.
- *
- * @param element
- * the model element
- * @return the associated resource, or <code>null</code>
- */
- public static IResource getResource(final Object element) {
- IResource resource= null;
- if (element instanceof IJavaScriptElement) {
- resource= ((IJavaScriptElement) element).getResource();
- } else if (element instanceof IResource) {
- resource= (IResource) element;
- } else if (element instanceof IAdaptable) {
- final IAdaptable adaptable= (IAdaptable) element;
- final Object adapted= adaptable.getAdapter(IResource.class);
- if (adapted instanceof IResource)
- resource= (IResource) adapted;
- } else {
- final Object adapted= Platform.getAdapterManager().getAdapter(element, IResource.class);
- if (adapted instanceof IResource)
- resource= (IResource) adapted;
- }
- return resource;
- }
-
- /**
- * Creates a new java model provider.
- */
- public JavaModelProvider() {
- // Used by the runtime
- }
-
- /**
- * {@inheritDoc}
- */
- public ResourceMapping[] getMappings(final IResource resource, final ResourceMappingContext context, final IProgressMonitor monitor) throws CoreException {
- final IJavaScriptElement element= JavaScriptCore.create(resource);
- if (element != null)
- return new ResourceMapping[] { JavaElementResourceMapping.create(element)};
- final Object adapted= resource.getAdapter(ResourceMapping.class);
- if (adapted instanceof ResourceMapping)
- return new ResourceMapping[] { ((ResourceMapping) adapted)};
- return new ResourceMapping[] { new JavaResourceMapping(resource)};
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringDescriptorResourceMapping.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringDescriptorResourceMapping.java
deleted file mode 100644
index 18f878ad..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringDescriptorResourceMapping.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.model.AbstractRefactoringDescriptorResourceMapping;
-
-/**
- * Refactoring descriptor resource mapping for the Java model provider.
- *
- *
- */
-public final class JavaRefactoringDescriptorResourceMapping extends AbstractRefactoringDescriptorResourceMapping {
-
- /**
- * Creates a new java refactoring descriptor resource mapping.
- *
- * @param descriptor
- * the refactoring descriptor
- */
- public JavaRefactoringDescriptorResourceMapping(final RefactoringDescriptorProxy descriptor) {
- super(descriptor);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getModelProviderId() {
- return JavaModelProvider.JAVA_MODEL_PROVIDER_ID;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringHistoryResourceMapping.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringHistoryResourceMapping.java
deleted file mode 100644
index 2afeb2e9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaRefactoringHistoryResourceMapping.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.ltk.core.refactoring.model.AbstractRefactoringHistoryResourceMapping;
-
-/**
- * Refactoring history resource mapping for the Java model provider.
- *
- *
- */
-public final class JavaRefactoringHistoryResourceMapping extends AbstractRefactoringHistoryResourceMapping {
-
- /**
- * Creates a new refactoring history resource mapping.
- *
- * @param history
- * the refactoring history
- */
- public JavaRefactoringHistoryResourceMapping(final RefactoringHistory history) {
- super(history);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getModelProviderId() {
- return JavaModelProvider.JAVA_MODEL_PROVIDER_ID;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaResourceMapping.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaResourceMapping.java
deleted file mode 100644
index 1b4f06b2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaResourceMapping.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Resource mapping for the java model provider.
- *
- *
- */
-public final class JavaResourceMapping extends ResourceMapping {
-
- /** The resource to map */
- private final IResource fResource;
-
- /**
- * Creates a new java resource mapping.
- *
- * @param resource
- * the resource to map
- */
- public JavaResourceMapping(final IResource resource) {
- Assert.isNotNull(resource);
- fResource= resource;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getModelObject() {
- return fResource;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getModelProviderId() {
- return JavaModelProvider.JAVA_MODEL_PROVIDER_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- public IProject[] getProjects() {
- return new IProject[] { fResource.getProject() };
- }
-
- /**
- * {@inheritDoc}
- */
- public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) {
- return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { fResource }, IResource.DEPTH_INFINITE, IResource.NONE) };
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationCompareAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationCompareAdapter.java
deleted file mode 100644
index 18043245..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationCompareAdapter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.ui.refactoring.model.AbstractSynchronizationCompareAdapter;
-import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Java-aware synchronization compare adapter.
- *
- *
- */
-public final class JavaSynchronizationCompareAdapter extends AbstractSynchronizationCompareAdapter {
-
- /** The modelProviderId name */
- private static final String MODEL_PROVIDER_ID= "modelProviderId"; //$NON-NLS-1$
-
- /** The modelProviders name */
- private static final String MODEL_PROVIDERS= "modelProviders"; //$NON-NLS-1$
-
- /** The resourcePath name */
- private static final String RESOURCE_PATH= "resourcePath"; //$NON-NLS-1$
-
- /** The resourceType name */
- private static final String RESOURCE_TYPE= "resourceType"; //$NON-NLS-1$
-
- /** The resources name */
- private static final String RESOURCES= "resources"; //$NON-NLS-1$
-
- /** The workingSetName name */
- private static final String WORKING_SET_NAME= "workingSetName"; //$NON-NLS-1$
-
- /** The workingSets name */
- private static final String WORKING_SETS= "workingSets"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- */
- public ICompareInput asCompareInput(final ISynchronizationContext context, final Object element) {
- if (element instanceof RefactoringDescriptorProxy)
- return super.asCompareInput(context, element);
- final IResource resource= JavaModelProvider.getResource(element);
- if (resource != null)
- return super.asCompareInput(context, resource);
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ResourceMapping[] restore(final IMemento memento) {
- IMemento[] children= memento.getChildren(RESOURCES);
- final List result= new ArrayList();
- for (int index= 0; index < children.length; index++) {
- final Integer typeInt= children[index].getInteger(RESOURCE_TYPE);
- if (typeInt == null)
- continue;
- final String pathString= children[index].getString(RESOURCE_PATH);
- if (pathString == null)
- continue;
- IResource resource= null;
- final IPath path= new Path(pathString);
- final IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- switch (typeInt.intValue()) {
- case IResource.ROOT:
- resource= root;
- break;
- case IResource.PROJECT:
- resource= root.getProject(path.lastSegment());
- break;
- case IResource.FILE:
- resource= root.getFile(path);
- break;
- case IResource.FOLDER:
- resource= root.getFolder(path);
- break;
- }
- if (resource != null) {
- final ResourceMapping mapping= JavaSynchronizationContentProvider.getResourceMapping(resource);
- if (mapping != null)
- result.add(mapping);
- }
- }
- children= memento.getChildren(WORKING_SETS);
- for (int index= 0; index < children.length; index++) {
- final String name= children[index].getString(WORKING_SET_NAME);
- if (name == null)
- continue;
- final IWorkingSet set= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
- if (set != null) {
- final ResourceMapping mapping= JavaSynchronizationContentProvider.getResourceMapping(set);
- if (mapping != null)
- result.add(mapping);
- }
- }
- children= memento.getChildren(MODEL_PROVIDERS);
- for (int index= 0; index < children.length; index++) {
- final String id= children[index].getString(MODEL_PROVIDER_ID);
- if (id == null)
- continue;
- final IModelProviderDescriptor descriptor= ModelProvider.getModelProviderDescriptor(id);
- if (descriptor == null)
- continue;
- try {
- final ModelProvider provider= descriptor.getModelProvider();
- if (provider != null) {
- final ResourceMapping mapping= JavaSynchronizationContentProvider.getResourceMapping(provider);
- if (mapping != null)
- result.add(mapping);
- }
- } catch (CoreException event) {
- JavaScriptPlugin.log(event);
- }
- }
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- public void save(final ResourceMapping[] mappings, final IMemento memento) {
- for (int index= 0; index < mappings.length; index++) {
- final Object object= mappings[index].getModelObject();
- if (object instanceof IJavaScriptElement) {
- final IJavaScriptElement element= (IJavaScriptElement) object;
- final IResource resource= (IResource) element.getAdapter(IResource.class);
- if (resource != null) {
- final IMemento child= memento.createChild(RESOURCES);
- child.putInteger(RESOURCE_TYPE, resource.getType());
- child.putString(RESOURCE_PATH, resource.getFullPath().toString());
- }
- }
- if (object instanceof IResource) {
- final IResource resource= (IResource) object;
- final IMemento child= memento.createChild(RESOURCES);
- child.putInteger(RESOURCE_TYPE, resource.getType());
- child.putString(RESOURCE_PATH, resource.getFullPath().toString());
- } else if (object instanceof IWorkingSet)
- memento.createChild(WORKING_SETS).putString(WORKING_SET_NAME, ((IWorkingSet) object).getName());
- else if (object instanceof ModelProvider)
- memento.createChild(MODEL_PROVIDERS).putString(MODEL_PROVIDER_ID, ((ModelProvider) object).getId());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationContentProvider.java
deleted file mode 100644
index f767ddb7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationContentProvider.java
+++ /dev/null
@@ -1,808 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-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.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-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.NullProgressMonitor;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.ltk.ui.refactoring.model.AbstractSynchronizationContentProvider;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.team.core.diff.FastDiffFilter;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IDiffChangeEvent;
-import org.eclipse.team.core.diff.IDiffTree;
-import org.eclipse.team.core.diff.IDiffVisitor;
-import org.eclipse.team.core.mapping.IResourceDiffTree;
-import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.team.core.mapping.ISynchronizationScope;
-import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
-import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
-import org.eclipse.ui.navigator.PipelinedShapeModification;
-import org.eclipse.ui.navigator.PipelinedViewerUpdate;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaElementResourceMapping;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Java-aware synchronization content provider.
- *
- *
- */
-public final class JavaSynchronizationContentProvider extends AbstractSynchronizationContentProvider implements IPipelinedTreeContentProvider {
-
- /** The refactorings folder */
-// private static final String NAME_REFACTORING_FOLDER= ".refactorings"; //$NON-NLS-1$
-
- /**
- * Returns the diffs associated with the element.
- *
- * @param context
- * the synchronization context
- * @param element
- * the element
- * @return an array of diffs
- */
- static IDiff[] getDiffs(final ISynchronizationContext context, final Object element) {
- return context.getDiffTree().getDiffs(getResourceTraversals(element));
- }
-
- /**
- * Returns the resource mapping for the element.
- *
- * @param element
- * the element to get the resource mapping
- * @return the resource mapping
- */
- static ResourceMapping getResourceMapping(final Object element) {
- if (element instanceof IJavaScriptElement)
- return JavaElementResourceMapping.create((IJavaScriptElement) element);
- if (element instanceof IAdaptable) {
- final IAdaptable adaptable= (IAdaptable) element;
- final Object adapted= adaptable.getAdapter(ResourceMapping.class);
- if (adapted instanceof ResourceMapping)
- return (ResourceMapping) adapted;
- }
- return null;
- }
-
- /**
- * Returns the resource traversals for the element.
- *
- * @param element
- * the element to get the resource traversals
- * @return the resource traversals
- */
- static ResourceTraversal[] getResourceTraversals(final Object element) {
- final ResourceMapping mapping= getResourceMapping(element);
- if (mapping != null)
- try {
- return mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, new NullProgressMonitor());
- } catch (final CoreException exception) {
- JavaScriptPlugin.log(exception);
- }
- return new ResourceTraversal[0];
- }
-
- /** The content provider, or <code>null</code> */
- private ITreeContentProvider fContentProvider= null;
-
- /** The model root, or <code>null</code> */
- private Object fModelRoot= null;
-
- /**
- * Returns the java element associated with the project.
- *
- * @param project
- * the project
- * @return the associated java element, or <code>null</code> if the
- * project is not a java project
- */
- private IJavaScriptProject asJavaProject(final IProject project) {
- try {
- if (project.getDescription().hasNature(JavaScriptCore.NATURE_ID))
- return JavaScriptCore.create(project);
- } catch (final CoreException exception) {
- // Only log the error for projects that are accessible (i.e. exist and are open)
- if (project.isAccessible())
- JavaScriptPlugin.log(exception);
- }
- return null;
- }
-
- /**
- * Converts the shape modification to use java elements.
- *
- * @param modification
- * the shape modification to convert
- */
- private void convertToJavaElements(final PipelinedShapeModification modification) {
- final Object parent= modification.getParent();
- if (parent instanceof IResource) {
- final IJavaScriptElement project= asJavaProject(((IResource) parent).getProject());
- if (project != null) {
- modification.getChildren().clear();
- return;
- }
- }
- if (parent instanceof ISynchronizationContext) {
- final Set result= new HashSet();
- for (final Iterator iterator= modification.getChildren().iterator(); iterator.hasNext();) {
- final Object element= iterator.next();
- if (element instanceof IProject) {
- final IJavaScriptElement project= asJavaProject((IProject) element);
- if (project != null) {
- iterator.remove();
- result.add(project);
- }
- }
- }
- modification.getChildren().addAll(result);
- }
- }
-
- /**
- * Converts the viewer update to use java elements.
- *
- * @param update
- * the viewer update to convert
- * @return <code>true</code> if any elements have been converted,
- * <code>false</code> otherwise
- */
- private boolean convertToJavaElements(final PipelinedViewerUpdate update) {
- final Set result= new HashSet();
- for (final Iterator iterator= update.getRefreshTargets().iterator(); iterator.hasNext();) {
- final Object element= iterator.next();
- if (element instanceof IProject) {
- final IJavaScriptElement project= asJavaProject((IProject) element);
- if (project != null) {
- iterator.remove();
- result.add(project);
- }
- }
- }
- update.getRefreshTargets().addAll(result);
- return !result.isEmpty();
- }
-
- /**
- * {@inheritDoc}
- */
- public void diffsChanged(final IDiffChangeEvent event, final IProgressMonitor monitor) {
- syncExec(new Runnable() {
-
- public void run() {
- handleChange(event);
- }
- }, getViewer().getControl());
- }
-
- /**
- * Returns all the existing projects that contain additions,
- * removals or deletions.
- *
- * @param event
- * the event
- * @return the projects that contain changes
- */
- private IJavaScriptProject[] getChangedProjects(final IDiffChangeEvent event) {
- final Set result= new HashSet();
- final IDiff[] changes= event.getChanges();
- for (int index= 0; index < changes.length; index++) {
- final IResource resource= ResourceDiffTree.getResourceFor(changes[index]);
- if (resource != null) {
- final IJavaScriptProject project= asJavaProject(resource.getProject());
- if (project != null)
- result.add(project);
- }
- }
- final IDiff[] additions= event.getAdditions();
- for (int index= 0; index < additions.length; index++) {
- final IResource resource= ResourceDiffTree.getResourceFor(additions[index]);
- if (resource != null) {
- final IJavaScriptProject project= asJavaProject(resource.getProject());
- if (project != null)
- result.add(project);
- }
- }
- final IPath[] removals = event.getRemovals();
- for (int i = 0; i < removals.length; i++) {
- IPath path = removals[i];
- if (path.segmentCount() > 0) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
- // Only consider projects that still exist
- if (project.exists()) {
- final IJavaScriptProject javaProject= asJavaProject(project.getProject());
- if (javaProject != null)
- result.add(javaProject);
- }
- }
- }
- return (IJavaScriptProject[]) result.toArray(new IJavaScriptProject[result.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Object[] getChildrenInContext(final ISynchronizationContext context, final Object parent, final Object[] children) {
- final Object[] elements= super.getChildrenInContext(context, parent, children);
- if (parent instanceof IPackageFragment)
- return getPackageFragmentChildren(context, parent, elements);
- else if (parent instanceof IPackageFragmentRoot)
- return getPackageFragmentRootChildren(context, parent, elements);
- else if (parent instanceof IJavaScriptProject)
- return getJavaProjectChildren(context, parent, elements);
- else if (parent instanceof RefactoringHistory)
- return ((RefactoringHistory) parent).getDescriptors();
- // It may be the case that the elements are folders that have a corresponding
- // source folder in which case they should be filtered out
- return getFilteredElements(parent, elements);
- }
-
- /**
- * Returns the filtered elements.
- *
- * @param parent
- * the parent element
- * @param children
- * the child elements
- * @return the filtered elements
- */
- private Object[] getFilteredElements(final Object parent, final Object[] children) {
- final List result= new ArrayList(children.length);
- for (int index= 0; index < children.length; index++) {
- if (children[index] instanceof IFolder) {
- if (!(JavaScriptCore.create((IFolder) children[index]) instanceof IPackageFragmentRoot))
- result.add(children[index]);
- } else
- result.add(children[index]);
- }
- return result.toArray();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ITreeContentProvider getDelegateContentProvider() {
- if (fContentProvider == null)
- fContentProvider= new JavaModelContentProvider();
- return fContentProvider;
- }
-
- /**
- * Returns the projects that used to have changes in the diff tree
- * but have been deleted from the workspace.
- *
- * @param event
- * the event
- * @return the deleted projects
- */
- private Set getDeletedProjects(final IDiffChangeEvent event) {
- final Set result= new HashSet();
- final IPath[] deletions= event.getRemovals();
- for (int index= 0; index < deletions.length; index++) {
- final IPath path= deletions[index];
- if (path.segmentCount() > 0) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
- if (!project.isAccessible())
- result.add(project);
- }
- }
- return result;
- }
-
- /**
- * Since the this content provider overrides the resource content provider,
- * this method is only invoked when the resource content provider is
- * disabled. In this case, we still want the Java projects to appear at the
- * root of the view.
- *
- * {@inheritDoc}
- */
- public Object[] getElements(Object parent) {
- if (parent instanceof ISynchronizationContext)
- // Put the resource projects directly under the context
- parent= getModelRoot();
- return super.getElements(parent);
- }
-
- /**
- * Returns the java project children in the current scope.
- *
- * @param context
- * the synchronization context
- * @param parent
- * the parent element
- * @param children
- * the child elements
- * @return the java project children
- */
- private Object[] getJavaProjectChildren(final ISynchronizationContext context, final Object parent, final Object[] children) {
- final LinkedList list= new LinkedList();
- for (int index= 0; index < children.length; index++) {
- if (children[index] instanceof IPackageFragment) {
- final IPackageFragment fragment= (IPackageFragment) children[index];
- if (getChildren(fragment).length == 0)
- continue;
- }
- // We need to check whether a folder has non-fragment children (bug 138767)
- if (children[index] instanceof IFolder) {
- IFolder folder = (IFolder) children[index];
- if (getChildren(folder).length == 0)
- continue;
- }
- list.add(children[index]);
- }
-
- final IResource resource= JavaModelProvider.getResource(parent);
- if (resource != null) {
- final IResourceDiffTree tree= context.getDiffTree();
- final IResource[] members= tree.members(resource);
- for (int index= 0; index < members.length; index++) {
- IResource child = members[index];
- if (isVisible(context, child)) {
- if (hasPhantomFolder(tree, child)) {
- // Add any phantom resources that are visible
- list.add(child);
- }
-
-
-// if (members[index] instanceof IFolder) {
-// final IFolder folder= (IFolder) members[index];
-// if (folder.getName().equals(NAME_REFACTORING_FOLDER)) {
-// final RefactoringHistory history= getRefactorings(context, (IProject) resource, null);
-// if (!history.isEmpty()) {
-// list.remove(folder);
-// list.addFirst(history);
-// }
-// }
-// }
- }
- }
-
- }
- return list.toArray(new Object[list.size()]);
- }
-
- private boolean hasPhantomFolder(IResourceDiffTree tree, IResource child) {
- if (!child.exists())
- return true;
- final boolean[] found = new boolean[] { false };
- tree.accept(child.getFullPath(), new IDiffVisitor() {
- public boolean visit(IDiff delta){
- IResource treeResource = ResourceDiffTree.getResourceFor(delta);
- if (treeResource.getType()==IResource.FILE && !treeResource.getParent().exists()){
- found[0] = true;
- return false;
- }
-
- return true;
- }}, IResource.DEPTH_INFINITE);
- return found[0];
- }
-
-
- /**
- * {@inheritDoc}
- */
- protected String getModelProviderId() {
- return JavaModelProvider.JAVA_MODEL_PROVIDER_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Object getModelRoot() {
- if (fModelRoot == null)
- fModelRoot= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- return fModelRoot;
- }
-
- /**
- * Returns the package fragment children in the current scope.
- *
- * @param context
- * the synchronization context
- * @param parent
- * the parent element
- * @param children
- * the child elements
- * @return the package fragment children
- */
- private Object[] getPackageFragmentChildren(final ISynchronizationContext context, final Object parent, final Object[] children) {
- final Set set= new HashSet();
- for (int index= 0; index < children.length; index++)
- set.add(children[index]);
- final IResource resource= ((IPackageFragment) parent).getResource();
- if (resource != null) {
- final IResourceDiffTree tree= context.getDiffTree();
- final IResource[] members= tree.members(resource);
- for (int index= 0; index < members.length; index++) {
- final int type= members[index].getType();
- if (type == IResource.FILE) {
- final IDiff diff= tree.getDiff(members[index]);
- if (diff != null && isVisible(diff))
- if (isInScope(context.getScope(), parent, members[index])) {
- final IJavaScriptElement element= JavaScriptCore.create(members[index]);
- if (element == null) {
- set.add(members[index]);
- } else {
- set.add(element);
- }
- }
- }
- }
- }
- return set.toArray(new Object[set.size()]);
- }
-
- /**
- * Returns the package fragment root children in the current scope.
- *
- * @param context
- * the synchronization context
- * @param parent
- * the parent element
- * @param children
- * the child elements
- * @return the package fragment root children
- */
- private Object[] getPackageFragmentRootChildren(final ISynchronizationContext context, final Object parent, final Object[] children) {
- final Set set= new HashSet();
- for (int index= 0; index < children.length; index++) {
- if (children[index] instanceof IPackageFragment) {
- IPackageFragment fragment = (IPackageFragment) children[index];
- if (fragment.isOpen() && getChildren(fragment).length == 0)
- // Don't add the default package unless it has children
- continue;
- }
- set.add(children[index]);
- }
- final IResource resource= JavaModelProvider.getResource(parent);
- if (resource != null) {
- final IResourceDiffTree tree= context.getDiffTree();
- final IResource[] members= tree.members(resource);
- for (int index= 0; index < members.length; index++) {
- final int type= members[index].getType();
- final boolean contained= isInScope(context.getScope(), parent, members[index]);
- final boolean visible= isVisible(context, members[index]);
- if (type == IResource.FILE && contained && visible) {
- // If the file is not a compilation unit add it.
- // (compilation units are always children of packages so they
- // don't need to be added here)
- final IJavaScriptElement element= JavaScriptCore.create((IFile) members[index]);
- if (element == null)
- set.add(members[index]);
- } else if (type == IResource.FOLDER && contained && visible && tree.getDiff(members[index]) != null) {
- // If the folder is out-of-sync, add it
- final IJavaScriptElement element= JavaScriptCore.create(members[index]);
- if (element != null)
- set.add(element);
- }
- if (type == IResource.FOLDER) {
- // If the folder contains java elements, add it
- final IFolder folder= (IFolder) members[index];
- tree.accept(folder.getFullPath(), new IDiffVisitor() {
-
- public final boolean visit(final IDiff diff) {
- if (isVisible(diff)) {
- final IResource current= tree.getResource(diff);
- if (current != null) {
- final int kind= current.getType();
- if (kind == IResource.FILE) {
- final IJavaScriptElement element= JavaScriptCore.create(current.getParent());
- if (element != null)
- set.add(element);
- } else {
- final IJavaScriptElement element= JavaScriptCore.create(current);
- if (element != null)
- set.add(element);
- }
- }
- }
- return true;
- }
- }, IResource.DEPTH_INFINITE);
- }
- }
- return set.toArray(new Object[set.size()]);
- }
- return children;
- }
-
- /**
- * {@inheritDoc}
- */
- public void getPipelinedChildren(final Object parent, final Set children) {
- if (parent instanceof ISynchronizationContext) {
- // When a context is the root, the resource content provider returns
- // projects as direct children. We should replace any projects that
- // are Java projects with an IJavaScriptProject
- final Set result= new HashSet(children.size());
- for (final Iterator iterator= children.iterator(); iterator.hasNext();) {
- final Object element= iterator.next();
- if (element instanceof IProject) {
- final IJavaScriptElement java= asJavaProject((IProject) element);
- if (java != null) {
- iterator.remove();
- result.add(java);
- }
- }
- if (element instanceof IFolder) {
- IFolder folder = (IFolder) element;
- IJavaScriptElement javaElement = JavaScriptCore.create(folder);
- // If the folder is also a package, don't show it
- // as a folder since it will be shown as a package
- if (javaElement instanceof IPackageFragmentRoot) {
- iterator.remove();
- }
- }
- }
- children.addAll(result);
- } else if (parent instanceof ISynchronizationScope) {
- // When the root is a scope, we should return the
- // Java model provider so all model providers appear
- // at the root of the viewer.
- children.add(getModelProvider());
- } else if (parent instanceof IFolder) {
- // Remove any children that are also source folders so they
- // don't appear twice
- for (final Iterator iterator= children.iterator(); iterator.hasNext();) {
- final Object element= iterator.next();
- if (element instanceof IFolder) {
- IFolder folder = (IFolder) element;
- IJavaScriptElement javaElement = JavaScriptCore.create(folder);
- if (javaElement instanceof IPackageFragmentRoot) {
- iterator.remove();
- }
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void getPipelinedElements(final Object element, final Set elements) {
- getPipelinedChildren(element, elements);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getPipelinedParent(final Object element, final Object parent) {
- if (element instanceof IJavaScriptElement)
- return getParent(element);
- return parent;
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResourceTraversal[] getTraversals(final ISynchronizationContext context, final Object object) {
- return getResourceTraversals(object);
- }
-
- /**
- * Returns the visible projects.
- *
- * @return the visible projects
- */
- private Set getVisibleProjects() {
- final TreeItem[] children= ((TreeViewer) getViewer()).getTree().getItems();
- final Set result= new HashSet();
- for (int index= 0; index < children.length; index++) {
- final Object data= children[index].getData();
- if (data instanceof IJavaScriptProject)
- result.add(data);
- }
- return result;
- }
-
- /**
- * Handles a diff change event.
- *
- * @param event
- * the event
- */
- private void handleChange(final IDiffChangeEvent event) {
- final Set existing= getVisibleProjects();
- // Get all existing and open projects that contain changes
- // and determine what needs to be done to the project
- // (i.e. add, remove or refresh)
- final IJavaScriptProject[] changed= getChangedProjects(event);
- final List refreshes= new ArrayList(changed.length);
- final List additions= new ArrayList(changed.length);
- final List removals= new ArrayList(changed.length);
- for (int index= 0; index < changed.length; index++) {
- final IJavaScriptProject project= changed[index];
- if (hasVisibleChanges(event.getTree(), project)) {
- if (existing.contains(project))
- refreshes.add(project);
- else
- additions.add(project);
- } else
- removals.add(project);
- }
- // Remove any java projects that correspond to deleted or closed projects
- final Set removed= getDeletedProjects(event);
- for (final Iterator iterator= existing.iterator(); iterator.hasNext();) {
- final IJavaScriptProject element= (IJavaScriptProject) iterator.next();
- if (removed.contains(element.getResource()))
- removals.add(element);
- }
-
- if (!removals.isEmpty() || !additions.isEmpty() || !refreshes.isEmpty()) {
- final TreeViewer viewer= (TreeViewer) getViewer();
- final Tree tree= viewer.getTree();
- try {
- tree.setRedraw(false);
- if (!additions.isEmpty())
- viewer.add(viewer.getInput(), additions.toArray());
- if (!removals.isEmpty())
- viewer.remove(viewer.getInput(), removals.toArray());
- if (!refreshes.isEmpty()) {
- for (final Iterator iter= refreshes.iterator(); iter.hasNext();)
- viewer.refresh(iter.next());
- }
- } finally {
- tree.setRedraw(true);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasChildren(final Object element) {
- if (element instanceof IJavaScriptUnit || element instanceof IFile || element instanceof RefactoringDescriptorProxy || element instanceof RefactoringDescriptor)
- return false;
- return super.hasChildren(element);
- }
-
- /**
- * Returns whether the element has some children in the current scope.
- *
- * @param scope
- * the synchronization scope
- * @param element
- * the element
- * @param resource
- * the resource
- * @return <code>true</code> if it has some children, <code>false</code>
- * otherwise
- */
- private boolean hasChildrenInScope(final ISynchronizationScope scope, final Object element, final IResource resource) {
- final IResource[] roots= scope.getRoots();
- final IPath path= resource.getFullPath();
- if (element instanceof IPackageFragment) {
- for (int index= 0; index < roots.length; index++)
- if (path.equals(roots[index].getFullPath().removeLastSegments(1)))
- return true;
- return false;
- }
- for (int index= 0; index < roots.length; index++)
- if (path.isPrefixOf(roots[index].getFullPath()))
- return true;
- return false;
- }
-
- /**
- * Has the java project visible changes?
- *
- * @param tree
- * the diff tree
- * @param project
- * the java project
- * @return <code>true</code> if it has visible changes, <code>false</code>
- * otherwise
- */
- private boolean hasVisibleChanges(final IDiffTree tree, final IJavaScriptProject project) {
- return tree.hasMatchingDiffs(project.getResource().getFullPath(), new FastDiffFilter() {
-
- public boolean select(final IDiff diff) {
- return isVisible(diff);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public PipelinedShapeModification interceptAdd(final PipelinedShapeModification modification) {
- convertToJavaElements(modification);
- return modification;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean interceptRefresh(final PipelinedViewerUpdate update) {
- return convertToJavaElements(update);
- }
-
- /**
- * {@inheritDoc}
- */
- public PipelinedShapeModification interceptRemove(final PipelinedShapeModification modification) {
- convertToJavaElements(modification);
- return modification;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean interceptUpdate(final PipelinedViewerUpdate anUpdateSynchronization) {
- return convertToJavaElements(anUpdateSynchronization);
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean isInScope(final ISynchronizationScope scope, final Object parent, final Object element) {
- final IResource resource= JavaModelProvider.getResource(element);
- if (resource == null)
- return false;
- if (scope.contains(resource))
- return true;
- if (hasChildrenInScope(scope, element, resource))
- return true;
- return false;
- }
-
- /**
- * Executes the given runnable.
- *
- * @param runnable
- * the runnable
- * @param control
- * the control
- */
- private void syncExec(final Runnable runnable, final Control control) {
- if (control != null && !control.isDisposed())
- control.getDisplay().syncExec(new Runnable() {
-
- public void run() {
- if (!control.isDisposed())
- BusyIndicator.showWhile(control.getDisplay(), runnable);
- }
- });
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationLabelProvider.java
deleted file mode 100644
index d9c84bd0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/JavaSynchronizationLabelProvider.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreePathLabelProvider;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.ltk.ui.refactoring.model.AbstractSynchronizationLabelProvider;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IDiffTree;
-import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator;
-
-/**
- * Java-aware synchronization label provider.
- *
- *
- */
-public final class JavaSynchronizationLabelProvider extends AbstractSynchronizationLabelProvider implements ITreePathLabelProvider{
-
- /** The delegate label provider, or <code>null</code> */
- private ILabelProvider fLabelProvider= null;
-
- /** The model root, or <code>null</code> */
- private Object fModelRoot= null;
-
- /** The package image, or <code>null</code> */
- private Image fPackageImage= null;
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- if (fPackageImage != null && !fPackageImage.isDisposed())
- fPackageImage.dispose();
- if (fLabelProvider != null)
- fLabelProvider.dispose();
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- */
- public Image getDelegateImage(final Object element) {
- if (element instanceof IPackageFragment) {
- final IPackageFragment fragment= (IPackageFragment) element;
- final IResource resource= fragment.getResource();
- if (resource == null || !resource.exists()) {
- if (fPackageImage == null)
- fPackageImage= JavaPluginImages.DESC_OBJS_PACKAGE.createImage();
- return fPackageImage;
- }
- }
- return super.getDelegateImage(element);
- }
-
- /**
- * {@inheritDoc}
- */
- protected ILabelProvider getDelegateLabelProvider() {
- if (fLabelProvider == null)
- fLabelProvider= new DecoratingLabelProvider(new JavaModelLabelProvider(ModelMessages.JavaModelLabelProvider_project_preferences_label, ModelMessages.JavaModelLabelProvider_refactorings_label), new ProblemsLabelDecorator(null));
- return fLabelProvider;
- }
-
- /**
- * {@inheritDoc}
- */
- protected IDiff getDiff(final Object element) {
- final ISynchronizationContext context= getContext();
- final IResource resource= JavaModelProvider.getResource(element);
- if (context != null && resource != null) {
- final IDiff[] diff= JavaSynchronizationContentProvider.getDiffs(context, element);
- for (int index= 0; index < diff.length; index++) {
- if (context.getDiffTree().getResource(diff[index]).equals(resource))
- return diff[index];
- }
- }
- return super.getDiff(element);
- }
-
- /**
- * {@inheritDoc}
- */
- protected int getMarkerSeverity(final Object element) {
- // Decoration label provider is handling this
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Object getModelRoot() {
- if (fModelRoot == null)
- fModelRoot= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- return fModelRoot;
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean hasDecendantConflicts(final Object element) {
- final ISynchronizationContext context= getContext();
- final IResource resource= JavaModelProvider.getResource(element);
- if (context != null && resource != null)
- return context.getDiffTree().getProperty(resource.getFullPath(), IDiffTree.P_HAS_DESCENDANT_CONFLICTS);
- return super.hasDecendantConflicts(element);
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean isBusy(final Object element) {
- final ISynchronizationContext context= getContext();
- final IResource resource= JavaModelProvider.getResource(element);
- if (context != null && resource != null)
- return context.getDiffTree().getProperty(resource.getFullPath(), IDiffTree.P_BUSY_HINT);
- return super.isBusy(element);
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean isIncludeOverlays() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreePathLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel, org.eclipse.jface.viewers.TreePath)
- */
- public void updateLabel(ViewerLabel label, TreePath elementPath) {
- Object firstSegment = elementPath.getFirstSegment();
- if (firstSegment instanceof IProject && elementPath.getSegmentCount() == 2) {
- IProject project = (IProject) firstSegment;
- Object lastSegment = elementPath.getLastSegment();
- if (lastSegment instanceof IFolder) {
- IFolder folder = (IFolder) lastSegment;
- if (!folder.getParent().equals(project)) {
- // This means that a folder that is not a direct child of the project
- // is a child in the tree. Therefore, the resource content provider
- // must be active and in compress folder mode so we will leave
- // it to the resource provider to provide the proper label.
- // We need to do this because of bug 153912
- return;
- }
- }
- }
- label.setImage(getImage(elementPath.getLastSegment()));
- label.setText(getText(elementPath.getLastSegment()));
- Font f = getFont(elementPath.getLastSegment());
- if (f != null)
- label.setFont(f);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.java
deleted file mode 100644
index 5577a35d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.model;
-
-import org.eclipse.osgi.util.NLS;
-
-public class ModelMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.model.ModelMessages"; //$NON-NLS-1$
-
- public static String JavaModelLabelProvider_project_preferences_label;
-
- public static String JavaModelLabelProvider_refactorings_label;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, ModelMessages.class);
- }
-
- private ModelMessages() {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.properties
deleted file mode 100644
index 620d4136..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/model/ModelMessages.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-JavaModelLabelProvider_project_preferences_label=Settings
-JavaModelLabelProvider_refactorings_label=Refactorings
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/CommonLayoutActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/CommonLayoutActionGroup.java
deleted file mode 100644
index cd874359..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/CommonLayoutActionGroup.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.navigator.IExtensionStateModel;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.actions.MultiActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.navigator.IExtensionStateConstants.Values;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackagesMessages;
-
-/**
- * Adds view menus to switch between flat and hierarchical layout.
- *
- *
- */
-public class CommonLayoutActionGroup extends MultiActionGroup {
-
- public static final String LAYOUT_GROUP_NAME = "layout"; //$NON-NLS-1$
-
- private IExtensionStateModel fStateModel;
- private StructuredViewer fStructuredViewer;
-
- private boolean fHasContributedToViewMenu = false;
- private IAction fHierarchicalLayout = null;
- private IAction fFlatLayoutAction = null;
- private IAction[] fActions;
-
- private IMenuManager fLayoutSubMenu;
-
- private class CommonLayoutAction extends Action implements IAction {
-
- private final boolean fIsFlatLayout;
-
- public CommonLayoutAction(boolean flat) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fIsFlatLayout = flat;
- if (fIsFlatLayout) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION);
- }
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- if (fStateModel.getBooleanProperty(Values.IS_LAYOUT_FLAT) != fIsFlatLayout) {
- fStateModel.setBooleanProperty(Values.IS_LAYOUT_FLAT, fIsFlatLayout);
-
- fStructuredViewer.getControl().setRedraw(false);
- try {
- fStructuredViewer.refresh();
- } finally {
- fStructuredViewer.getControl().setRedraw(true);
- }
- }
- }
- }
-
- public CommonLayoutActionGroup(StructuredViewer structuredViewer,
- IExtensionStateModel stateModel) {
- super();
- fStateModel = stateModel;
- fStructuredViewer = structuredViewer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ActionGroup#fillActionBars(IActionBars)
- */
- public void fillActionBars(IActionBars actionBars) {
- if (!fHasContributedToViewMenu) {
-
- IMenuManager viewMenu = actionBars.getMenuManager();
- // Create layout sub menu
- if (fLayoutSubMenu == null) {
- fLayoutSubMenu = new MenuManager(PackagesMessages.LayoutActionGroup_label);
- addActions(fLayoutSubMenu);
-
- viewMenu.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(LAYOUT_GROUP_NAME));
- }
-
- viewMenu.appendToGroup(LAYOUT_GROUP_NAME, fLayoutSubMenu);
-
- fHasContributedToViewMenu = true;
- }
- }
-
- public void unfillActionBars(IActionBars actionBars) {
- if (fHasContributedToViewMenu) {
- // Create layout sub menu
- if (fLayoutSubMenu != null) {
- actionBars.getMenuManager().remove(fLayoutSubMenu);
- fLayoutSubMenu.dispose();
- fLayoutSubMenu= null;
- }
-
- fHasContributedToViewMenu = false;
- }
- }
-
- private IAction[] createActions() {
-
- fFlatLayoutAction = new CommonLayoutAction(true);
- fFlatLayoutAction.setText(PackagesMessages.LayoutActionGroup_flatLayoutAction_label);
- JavaPluginImages.setLocalImageDescriptors(fFlatLayoutAction, "flatLayout.gif"); //$NON-NLS-1$
-
- fHierarchicalLayout = new CommonLayoutAction(false);
- fHierarchicalLayout.setText(PackagesMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
- JavaPluginImages.setLocalImageDescriptors(fHierarchicalLayout, "hierarchicalLayout.gif"); //$NON-NLS-1$
-
- return new IAction[] { fFlatLayoutAction, fHierarchicalLayout };
- }
-
- public void setFlatLayout(boolean flatLayout) {
- if (fActions == null) {
- fActions = createActions();
-
- // indicates check the flat action
- setActions(fActions, flatLayout ? 0 : 1);
- }
- fHierarchicalLayout.setChecked(!flatLayout);
- fFlatLayoutAction.setChecked(flatLayout);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/ContainerFolder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/ContainerFolder.java
deleted file mode 100644
index 07b659ce..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/ContainerFolder.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-
-/**
- * @author childsb
- *
- */
-public class ContainerFolder {
-
-
-
-
- Object parent;
- String name;
- public ContainerFolder(String fullPath, Object parent){
-
- this.parent = parent;
- name = fullPath;
- }
-
- public Object getParentObject() {
- return parent;
- }
-
- public String getName() {
- return name;
-
- }
- public String toString() { return name;}
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/IExtensionStateConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/IExtensionStateConstants.java
deleted file mode 100644
index 4b5908cd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/IExtensionStateConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-
-public interface IExtensionStateConstants {
-
- String ROOT_MODE= "rootMode"; //$NON-NLS-1$
-
- interface Values {
-
- String IS_LAYOUT_FLAT= "isLayoutFlat"; //$NON-NLS-1$
-
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaDropAdapterAssistant.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaDropAdapterAssistant.java
deleted file mode 100644
index 6f5773bf..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaDropAdapterAssistant.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-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.ui.actions.CopyFilesAndFoldersOperation;
-import org.eclipse.ui.navigator.CommonDropAdapter;
-import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackagesMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.ReorgCopyStarter;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.ReorgMoveStarter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-public class JavaDropAdapterAssistant extends CommonDropAdapterAssistant {
-
- private List fElements;
- private JavaMoveProcessor fMoveProcessor;
- private int fCanMoveElements;
- private JavaCopyProcessor fCopyProcessor;
- private int fCanCopyElements;
-
- public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent dropTargetEvent, Object target) {
- if (LocalSelectionTransfer.getInstance().isSupportedType(dropAdapter.getCurrentTransfer())) {
- try {
-
- switch (dropAdapter.getCurrentOperation()) {
- case DND.DROP_MOVE :
- handleDropMove(target);
- break;
- case DND.DROP_COPY :
- handleDropCopy(target);
- break;
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- } catch (InterruptedException e) {
- //ok
- } finally {
- // The drag source listener must not perform any operation
- // since this drop adapter did the remove of the source even
- // if we moved something.
- //event.detail= DND.DROP_NONE;
- }
- clear();
- return Status.OK_STATUS;
- } else if (FileTransfer.getInstance().isSupportedType(dropAdapter.getCurrentTransfer())) {
- try {
-
- final Object data = FileTransfer.getInstance().nativeToJava(dropAdapter.getCurrentTransfer());
- if (!(data instanceof String[]))
- return Status.CANCEL_STATUS;
-
- final IContainer targetContainer = getActualTarget(target);
- if (targetContainer == null)
- return Status.CANCEL_STATUS;
-
-
- getShell().forceActive();
- new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, targetContainer);
- } catch (JavaScriptModelException e) {
- String title = PackagesMessages.DropAdapter_errorTitle;
- String message = PackagesMessages.DropAdapter_errorMessage;
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- return Status.OK_STATUS;
- }
- return Status.CANCEL_STATUS;
- }
-
- public IStatus validateDrop(Object target, int operation, TransferData transferType) {
- IStatus result = Status.OK_STATUS;
- if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) {
- initializeSelection();
- try {
- switch (operation) {
- case DND.DROP_DEFAULT :
- if (handleValidateDefault(target) != DND.DROP_NONE) {
- result = Status.OK_STATUS;
- } else {
- result = Status.CANCEL_STATUS;
- }
- break;
- case DND.DROP_COPY :
- if (handleValidateCopy(target) != DND.DROP_NONE) {
- result = Status.OK_STATUS;
- } else {
- result = Status.CANCEL_STATUS;
- }
- break;
- case DND.DROP_MOVE :
- if (handleValidateMove(target) != DND.DROP_NONE) {
- result = Status.OK_STATUS;
- } else {
- result = Status.CANCEL_STATUS;
- }
- break;
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message);
- //event.detail= DND.DROP_NONE;
- result = Status.CANCEL_STATUS;
- }
- }
- return result;
- }
-
- public boolean isSupportedType(TransferData transferType) {
- return super.isSupportedType(transferType) || FileTransfer.getInstance().isSupportedType(transferType);
- }
-
- private IContainer getActualTarget(Object dropTarget) throws JavaScriptModelException {
- if (dropTarget instanceof IContainer)
- return (IContainer) dropTarget;
- else if (dropTarget instanceof IJavaScriptElement)
- return getActualTarget(((IJavaScriptElement) dropTarget).getCorrespondingResource());
- return null;
- }
-
- protected void initializeSelection() {
- if (fElements != null)
- return;
- ISelection s = LocalSelectionTransfer.getInstance().getSelection();
- if (!(s instanceof IStructuredSelection))
- return;
- fElements = ((IStructuredSelection) s).toList();
- }
-
- private void handleDropMove(final Object target) throws JavaScriptModelException, InvocationTargetException, InterruptedException {
- IJavaScriptElement[] javaElements = ReorgUtils.getJavaElements(fElements);
- IResource[] resources = ReorgUtils.getResources(fElements);
- ReorgMoveStarter starter = null;
- if (target instanceof IResource)
- starter = ReorgMoveStarter.create(javaElements, resources, (IResource) target);
- else if (target instanceof IJavaScriptElement)
- starter = ReorgMoveStarter.create(javaElements, resources, (IJavaScriptElement) target);
- if (starter != null)
- starter.run(getShell());
- }
-
- private void handleDropCopy(final Object target) throws JavaScriptModelException, InvocationTargetException, InterruptedException {
- IJavaScriptElement[] javaElements = ReorgUtils.getJavaElements(fElements);
- IResource[] resources = ReorgUtils.getResources(fElements);
- ReorgCopyStarter starter = null;
- if (target instanceof IResource)
- starter = ReorgCopyStarter.create(javaElements, resources, (IResource) target);
- else if (target instanceof IJavaScriptElement)
- starter = ReorgCopyStarter.create(javaElements, resources, (IJavaScriptElement) target);
- if (starter != null)
- starter.run(getShell());
- }
-
- private int handleValidateCopy(Object target) throws JavaScriptModelException {
-
- final ICopyPolicy policy= ReorgPolicyFactory.createCopyPolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements));
- fCopyProcessor= policy.canEnable() ? new JavaCopyProcessor(policy) : null;
-
- if (!canCopyElements())
- return DND.DROP_NONE;
-
- if (target instanceof IResource && fCopyProcessor != null && fCopyProcessor.setDestination((IResource)target).isOK())
- return DND.DROP_COPY;
- else if (target instanceof IJavaScriptElement && fCopyProcessor != null && fCopyProcessor.setDestination((IJavaScriptElement)target).isOK())
- return DND.DROP_COPY;
- else
- return DND.DROP_NONE;
- }
-
- private int handleValidateDefault(Object target) throws JavaScriptModelException {
- if (target == null)
- return DND.DROP_NONE;
-
- return handleValidateMove(target);
- }
-
- private int handleValidateMove(Object target) throws JavaScriptModelException {
- if (target == null)
- return DND.DROP_NONE;
-
- IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements));
- fMoveProcessor= (policy.canEnable()) ? new JavaMoveProcessor(policy) : null;
-
- if (!canMoveElements())
- return DND.DROP_NONE;
-
- if (target instanceof IResource && fMoveProcessor != null && fMoveProcessor.setDestination((IResource)target).isOK())
- return DND.DROP_MOVE;
- else if (target instanceof IJavaScriptElement && fMoveProcessor != null && fMoveProcessor.setDestination((IJavaScriptElement)target).isOK())
- return DND.DROP_MOVE;
- else
- return DND.DROP_NONE;
- }
-
-
- private boolean canMoveElements() {
- if (fCanMoveElements == 0) {
- fCanMoveElements = 2;
- if (fMoveProcessor == null)
- fCanMoveElements = 1;
- }
- return fCanMoveElements == 2;
- }
-
-
- private boolean canCopyElements() {
- if (fCanCopyElements == 0) {
- fCanCopyElements = 2;
- if (fCopyProcessor == null)
- fCanCopyElements = 1;
- }
- return fCanCopyElements == 2;
- }
-
- private void clear() {
- fElements = null;
- fMoveProcessor = null;
- fCanMoveElements = 0;
- fCopyProcessor = null;
- fCanCopyElements = 0;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaFileLinkHelper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaFileLinkHelper.java
deleted file mode 100644
index abc26b6c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaFileLinkHelper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.ResourceUtil;
-import org.eclipse.ui.navigator.ILinkHelper;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavaFileLinkHelper implements ILinkHelper {
-
- public void activateEditor(IWorkbenchPage page, IStructuredSelection selection) {
- if (selection == null || selection.isEmpty())
- return;
- Object element= selection.getFirstElement();
- IEditorPart part= EditorUtility.isOpenInEditor(element);
- if (part != null) {
- page.bringToTop(part);
- if (element instanceof IJavaScriptElement)
- EditorUtility.revealInEditor(part, (IJavaScriptElement) element);
- }
-
- }
-
- public IStructuredSelection findSelection(IEditorInput input) {
- IJavaScriptElement element= JavaScriptUI.getEditorInputJavaElement(input);
- if (element == null) {
- IFile file = ResourceUtil.getFile(input);
- if (file != null) {
- element= JavaScriptCore.create(file);
- }
- }
- return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorActionProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorActionProvider.java
deleted file mode 100644
index 42025f00..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorActionProvider.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.wst.jsdt.ui.actions.CCPActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-
-/**
- * Contributes the following actions to the menu on behalf of the JDT content
- * extension.
- *
- * <ul>
- * <li>{@link OpenViewActionGroup}. Contributes the Open View actions (type
- * hierarchy, call hierarchy, etc).</li>
- * <li>{@link CCPActionGroup}. Contributes the Cut/Copy/Paste/Delete.</li>
- * <li>{@link JavaSearchActionGroup}. Contributes the search functionality (find in workspace, project, etc).</li>
- * <li>{@link GenerateActionGroup}. Contributes the "Source>" and "Generate>" submenu .</li>
- * </ul>
- */
-public class JavaNavigatorActionProvider extends CommonActionProvider {
-
- private OpenViewActionGroup fOpenViewGroup;
-
- private CCPActionGroup fCCPGroup;
-
- private JavaSearchActionGroup fSearchGroup;
-
- //private GenerateBuildPathActionGroup fBuildPathGroup;
-
- private GenerateActionGroup fGenerateGroup;
-
- private boolean fInViewPart= false;
-
- public void fillActionBars(IActionBars actionBars) {
- if (fInViewPart) {
- fOpenViewGroup.fillActionBars(actionBars);
- fCCPGroup.fillActionBars(actionBars);
- // fBuildPathGroup.fillActionBars(actionBars);
- fGenerateGroup.fillActionBars(actionBars);
- fSearchGroup.fillActionBars(actionBars);
- }
- }
-
- public void fillContextMenu(IMenuManager menu) {
- if (fInViewPart) {
- ISelection selection = (this.getContext()!=null) ? this.getContext().getSelection() : null;
- boolean isEmpty = (selection!=null)? selection.isEmpty() : false;
- fOpenViewGroup.containsShowInMenu(!isEmpty);
- fOpenViewGroup.fillContextMenu(menu);
- fCCPGroup.setShowLimited(isEmpty);
- fCCPGroup.fillContextMenu(menu);
- // fBuildPathGroup.fillContextMenu(menu);
- fGenerateGroup.fillContextMenu(menu);
- fSearchGroup.fillContextMenu(menu);
- }
- }
-
- public void init(ICommonActionExtensionSite site) {
-
- ICommonViewerWorkbenchSite workbenchSite= null;
- if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
- workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
-
- if (workbenchSite != null) {
- if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart= (IViewPart) workbenchSite.getPart();
-
- fOpenViewGroup= new OpenViewActionGroup(viewPart, site.getStructuredViewer());
- fOpenViewGroup.containsOpenPropertiesAction(false);
- fCCPGroup= new CCPActionGroup(viewPart);
- fGenerateGroup= new GenerateActionGroup(viewPart);
- fSearchGroup= new JavaSearchActionGroup(viewPart);
- //fBuildPathGroup= new GenerateBuildPathActionGroup(viewPart);
-
- fInViewPart= true;
- }
- }
- }
-
- public void setContext(ActionContext context) {
- super.setContext(context);
- if (fInViewPart) {
- fOpenViewGroup.setContext(context);
- fCCPGroup.setContext(context);
- fGenerateGroup.setContext(context);
- fSearchGroup.setContext(context);
- //fBuildPathGroup.setContext(context);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorContentProvider.java
deleted file mode 100644
index be1dbf8f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorContentProvider.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-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.IWorkspaceRoot;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.IExtensionStateModel;
-import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
-import org.eclipse.ui.navigator.PipelinedShapeModification;
-import org.eclipse.ui.navigator.PipelinedViewerUpdate;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.navigator.IExtensionStateConstants.Values;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerContentProvider;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class JavaNavigatorContentProvider extends
- PackageExplorerContentProvider implements IPipelinedTreeContentProvider {
-
- public JavaNavigatorContentProvider() {
- super(false);
- }
-
- public JavaNavigatorContentProvider(boolean provideMembers) {
- super(provideMembers);
- }
-
- public static final String JDT_EXTENSION_ID = "org.eclipse.wst.jsdt.ui.javaContent"; //$NON-NLS-1$
-
- private IExtensionStateModel fStateModel;
-
- private Object fRealInput;
-
- private IPropertyChangeListener fLayoutPropertyListener;
-
- public void init(ICommonContentExtensionSite commonContentExtensionSite) {
- IExtensionStateModel stateModel = commonContentExtensionSite
- .getExtensionStateModel();
- IMemento memento = commonContentExtensionSite.getMemento();
-
- fStateModel = stateModel;
- restoreState(memento);
- fLayoutPropertyListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (Values.IS_LAYOUT_FLAT.equals(event.getProperty())) {
- if (event.getNewValue() != null) {
- boolean newValue = ((Boolean) event.getNewValue())
- .booleanValue() ? true : false;
- setIsFlatLayout(newValue);
- }
- }
-
- }
- };
- fStateModel.addPropertyChangeListener(fLayoutPropertyListener);
-
- IPreferenceStore store = PreferenceConstants.getPreferenceStore();
- boolean showCUChildren = store
- .getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
- setProvideMembers(showCUChildren);
- }
-
- public void dispose() {
- super.dispose();
- fStateModel.removePropertyChangeListener(fLayoutPropertyListener);
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fRealInput = newInput;
- super.inputChanged(viewer, oldInput, findInputElement(newInput));
- }
-
- public Object getParent(Object element) {
- Object parent= super.getParent(element);
- if (parent instanceof IJavaScriptModel) {
- return getViewerInput() != null ? fRealInput : parent;
- }
- if (parent instanceof IJavaScriptProject) {
- return ((IJavaScriptProject)parent).getProject();
- }
- return parent;
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof IWorkspaceRoot) {
- IWorkspaceRoot root = (IWorkspaceRoot) inputElement;
- return root.getProjects();
- } else if (inputElement instanceof IJavaScriptModel) {
- return ((IJavaScriptModel)inputElement).getWorkspace().getRoot().getProjects();
- }
- if (inputElement instanceof IProject) {
- return super.getElements(JavaScriptCore.create((IProject)inputElement));
- }
- return super.getElements(inputElement);
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof IProject) {
- return ((IProject) element).isAccessible();
- }
- return super.hasChildren(element);
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IWorkspaceRoot) {
- IWorkspaceRoot root = (IWorkspaceRoot) parentElement;
- return root.getProjects();
- }
- if (parentElement instanceof IProject) {
- return super.getChildren(JavaScriptCore.create((IProject)parentElement));
- }
- return super.getChildren(parentElement);
- }
-
- private Object findInputElement(Object newInput) {
- if (newInput instanceof IWorkspaceRoot) {
- return JavaScriptCore.create((IWorkspaceRoot) newInput);
- }
- return newInput;
- }
-
- public void restoreState(IMemento memento) {
-
- }
-
- public void saveState(IMemento memento) {
-
- }
-
- public void getPipelinedChildren(Object parent, Set currentChildren) {
- customize(getChildren(parent), currentChildren);
- }
-
- public void getPipelinedElements(Object input, Set currentElements) {
- customize(getElements(input), currentElements);
- }
-
- public Object getPipelinedParent(Object object, Object suggestedParent) {
- return getParent(object);
- }
-
- public PipelinedShapeModification interceptAdd(PipelinedShapeModification addModification) {
-
- Object parent= addModification.getParent();
-
- if (parent instanceof IJavaScriptProject) {
- addModification.setParent(((IJavaScriptProject)parent).getProject());
- }
-
- if (parent instanceof IWorkspaceRoot) {
- deconvertJavaProjects(addModification);
- }
-
- convertToJavaElements(addModification);
- return addModification;
- }
-
- public PipelinedShapeModification interceptRemove(
- PipelinedShapeModification removeModification) {
- deconvertJavaProjects(removeModification);
- convertToJavaElements(removeModification.getChildren());
- return removeModification;
- }
-
- private void deconvertJavaProjects(PipelinedShapeModification modification) {
- Set convertedChildren = new LinkedHashSet();
- for (Iterator iterator = modification.getChildren().iterator(); iterator.hasNext();) {
- Object added = iterator.next();
- if(added instanceof IJavaScriptProject) {
- iterator.remove();
- convertedChildren.add(((IJavaScriptProject)added).getProject());
- }
- }
- modification.getChildren().addAll(convertedChildren);
- }
-
- /**
- * Converts the shape modification to use Java elements.
- *
- *
- * @param modification
- * the shape modification to convert
- * @return returns true if the conversion took place
- */
- private boolean convertToJavaElements(PipelinedShapeModification modification) {
- Object parent = modification.getParent();
- // As of 3.3, we no longer re-parent additions to IProject.
- if (parent instanceof IContainer) {
- IJavaScriptElement element = JavaScriptCore.create((IContainer) parent);
- if (element != null && element.exists()) {
- // we don't convert the root
- if( !(element instanceof IJavaScriptModel) && !(element instanceof IJavaScriptProject))
- modification.setParent(element);
- return convertToJavaElements(modification.getChildren());
-
- }
- }
- return false;
- }
-
- /**
- * Converts the shape modification to use Java elements.
- *
- *
- * @param currentChildren
- * The set of current children that would be contributed or refreshed in the viewer.
- * @return returns true if the conversion took place
- */
- private boolean convertToJavaElements(Set currentChildren) {
-
- LinkedHashSet convertedChildren = new LinkedHashSet();
- IJavaScriptElement newChild;
- for (Iterator childrenItr = currentChildren.iterator(); childrenItr
- .hasNext();) {
- Object child = childrenItr.next();
- // only convert IFolders and IFiles
- if (child instanceof IFolder || child instanceof IFile) {
- if ((newChild = JavaScriptCore.create((IResource) child)) != null
- && newChild.exists()) {
- childrenItr.remove();
- convertedChildren.add(newChild);
- }
- } else if (child instanceof IJavaScriptProject) {
- childrenItr.remove();
- convertedChildren.add( ((IJavaScriptProject)child).getProject());
- }
- }
- if (!convertedChildren.isEmpty()) {
- currentChildren.addAll(convertedChildren);
- return true;
- }
- return false;
-
- }
-
- /**
- * Adapted from the C Navigator Content Provider
- * @param javaElements
- * @param proposedChildren
- */
- private void customize(Object[] javaElements, Set proposedChildren) {
- List elementList= Arrays.asList(javaElements);
- for (Iterator iter= proposedChildren.iterator(); iter.hasNext();) {
- Object element= iter.next();
- IResource resource= null;
- if (element instanceof IResource) {
- resource= (IResource)element;
- } else if (element instanceof IAdaptable) {
- resource= (IResource)((IAdaptable)element).getAdapter(IResource.class);
- }
- if (resource != null) {
- int i= elementList.indexOf(resource);
- if (i >= 0) {
- javaElements[i]= null;
- }
- }
- }
- for (int i= 0; i < javaElements.length; i++) {
- Object element= javaElements[i];
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement cElement= (IJavaScriptElement)element;
- IResource resource= cElement.getResource();
- if (resource != null) {
- proposedChildren.remove(resource);
- }
- proposedChildren.add(element);
- } else if (element != null) {
- proposedChildren.add(element);
- }
- }
- }
-
-
-
- public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) {
- return convertToJavaElements(refreshSynchronization.getRefreshTargets());
-
- }
-
- public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) {
- return convertToJavaElements(updateSynchronization.getRefreshTargets());
- }
-
- protected void postAdd(final Object parent, final Object element, Collection runnables) {
- if (parent instanceof IJavaScriptModel)
- super.postAdd(((IJavaScriptModel) parent).getWorkspace(), element, runnables);
- else if (parent instanceof IJavaScriptProject)
- super.postAdd( ((IJavaScriptProject)parent).getProject(), element, runnables);
- else
- super.postAdd(parent, element, runnables);
- }
-
-
- protected void postRefresh(final List toRefresh, final boolean updateLabels, Collection runnables) {
- for (Iterator iter = toRefresh.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if(element instanceof IJavaScriptModel) {
- iter.remove();
- toRefresh.add(fRealInput);
- super.postRefresh(toRefresh, updateLabels, runnables);
- return;
- }
- }
- super.postRefresh(toRefresh, updateLabels, runnables);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorLabelProvider.java
deleted file mode 100644
index d8e85596..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorLabelProvider.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonLabelProvider;
-import org.eclipse.ui.navigator.IExtensionStateModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.navigator.IExtensionStateConstants.Values;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerContentProvider;
-import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Provides the labels for the Project Explorer.
- * <p>
- * It provides labels for the packages in hierarchical layout and in all other
- * cases delegates it to its super class.
- * </p>
- *
- *
- */
-public class JavaNavigatorLabelProvider implements ICommonLabelProvider {
-
- private final long LABEL_FLAGS = JavaScriptElementLabels.DEFAULT_QUALIFIED
- | JavaScriptElementLabels.ROOT_POST_QUALIFIED
- | JavaScriptElementLabels.APPEND_ROOT_PATH
- | JavaScriptElementLabels.M_PARAMETER_TYPES
- | JavaScriptElementLabels.M_PARAMETER_NAMES
- | JavaScriptElementLabels.M_APP_RETURNTYPE
- | JavaScriptElementLabels.M_EXCEPTIONS
- | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE
- | JavaScriptElementLabels.T_TYPE_PARAMETERS;
-
- private PackageExplorerLabelProvider delegeteLabelProvider;
-
- private PackageExplorerContentProvider fContentProvider;
-
- private IExtensionStateModel fStateModel;
-
- private IPropertyChangeListener fLayoutPropertyListener;
-
- public JavaNavigatorLabelProvider() {
-
- }
- public void init(ICommonContentExtensionSite commonContentExtensionSite) {
- fStateModel = commonContentExtensionSite.getExtensionStateModel();
- fContentProvider = (PackageExplorerContentProvider) commonContentExtensionSite.getExtension().getContentProvider();
- delegeteLabelProvider = createLabelProvider();
-
- delegeteLabelProvider.setIsFlatLayout(fStateModel
- .getBooleanProperty(Values.IS_LAYOUT_FLAT));
- fLayoutPropertyListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (Values.IS_LAYOUT_FLAT.equals(event.getProperty())) {
- if (event.getNewValue() != null) {
- boolean newValue = ((Boolean) event.getNewValue())
- .booleanValue() ? true : false;
- delegeteLabelProvider.setIsFlatLayout(newValue);
- }
- }
-
- }
- };
- fStateModel.addPropertyChangeListener(fLayoutPropertyListener);
- }
-
- public String getDescription(Object element) {
- return formatMessage(element);
- }
-
- private PackageExplorerLabelProvider createLabelProvider() {
- return new PackageExplorerLabelProvider(fContentProvider);
- }
-
- public void dispose() {
- delegeteLabelProvider.dispose();
- fStateModel.removePropertyChangeListener(fLayoutPropertyListener);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- delegeteLabelProvider.propertyChange(event);
- }
-
- public void addLabelDecorator(ILabelDecorator decorator) {
- delegeteLabelProvider.addLabelDecorator(decorator);
- }
-
- public void addListener(ILabelProviderListener listener) {
- delegeteLabelProvider.addListener(listener);
- }
-
- public Color getBackground(Object element) {
- return delegeteLabelProvider.getBackground(element);
- }
-
- public Color getForeground(Object element) {
- return delegeteLabelProvider.getForeground(element);
- }
-
- public Image getImage(Object element) {
- return delegeteLabelProvider.getImage(element);
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return delegeteLabelProvider.isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- delegeteLabelProvider.removeListener(listener);
- }
-
- public boolean equals(Object obj) {
- return delegeteLabelProvider.equals(obj);
- }
-
- public int hashCode() {
- return delegeteLabelProvider.hashCode();
- }
-
- public String toString() {
- return delegeteLabelProvider.toString();
- }
-
- public String getText(Object element) {
- return delegeteLabelProvider.getText(element);
- }
-
- public void setIsFlatLayout(boolean state) {
- delegeteLabelProvider.setIsFlatLayout(state);
- }
-
- // Taken from StatusBarUpdater
-
- private String formatMessage(Object element) {
- if (element instanceof IJavaScriptElement) {
- return formatJavaElementMessage((IJavaScriptElement) element);
- } else if (element instanceof IResource) {
- return formatResourceMessage((IResource) element);
- }
- return ""; //$NON-NLS-1$
- }
-
- private String formatJavaElementMessage(IJavaScriptElement element) {
- return JavaScriptElementLabels.getElementLabel(element, LABEL_FLAGS);
- }
-
- private String formatResourceMessage(IResource element) {
- IContainer parent = element.getParent();
- if (parent != null && parent.getType() != IResource.ROOT)
- return element.getName() + JavaScriptElementLabels.CONCAT_STRING
- + parent.getFullPath().makeRelative().toString();
- else
- return element.getName();
- }
-
- public void restoreState(IMemento memento) {
-
- }
-
- public void saveState(IMemento memento) {
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorRefactorActionProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorRefactorActionProvider.java
deleted file mode 100644
index 32a86b6d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorRefactorActionProvider.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-/**
- * Contributes the following actions to the menu on behalf of the JDT content
- * extension.
- *
- * <ul>
- * <li>{@link RefactorActionGroup}. Contributes the "Refactor>" and "Source>" submenus to the context menu.</li>
- * </ul>
- */
-public class JavaNavigatorRefactorActionProvider extends CommonActionProvider {
-
- private RefactorActionGroup fRefactorGroup;
-
- public void fillActionBars(IActionBars actionBars) {
- if (fRefactorGroup != null) {
- fRefactorGroup.fillActionBars(actionBars);
- fRefactorGroup.retargetFileMenuActions(actionBars);
- }
- }
-
- public void fillContextMenu(IMenuManager menu) {
- if (fRefactorGroup != null) {
- fRefactorGroup.fillContextMenu(menu);
- }
- }
-
- public void init(ICommonActionExtensionSite site) {
- ICommonViewerWorkbenchSite workbenchSite= null;
- if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
- workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
-
- // we only initialize the refactor group when in a view part
- // (required for the constructor)
- if (workbenchSite != null) {
- if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart= (IViewPart) workbenchSite.getPart();
-
- fRefactorGroup= new RefactorActionGroup(viewPart);
- }
- }
- }
-
- public void setContext(ActionContext context) {
- if (fRefactorGroup != null) {
- fRefactorGroup.setContext(context);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorViewActionProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorViewActionProvider.java
deleted file mode 100644
index b1df68d2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/JavaNavigatorViewActionProvider.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.IExtensionActivationListener;
-import org.eclipse.ui.navigator.IExtensionStateModel;
-import org.eclipse.ui.navigator.INavigatorActivationService;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.navigator.IExtensionStateConstants.Values;
-
-/**
- * Contributes the following actions to the menu on behalf of the JDT content
- * extension.
- *
- * <ul>
- * <li>{@link CommonLayoutActionGroup}. Contributes the "Package Presentation>" submenu in the View's drop down menu (not right-click).</li>
- * </ul>
- */
-public class JavaNavigatorViewActionProvider extends CommonActionProvider {
-
- private static final int HIERARCHICAL_LAYOUT= 0x1;
-
- private static final int FLAT_LAYOUT= 0x2;
-
- private static final String TAG_LAYOUT= "org.eclipse.wst.jsdt.internal.ui.navigator.layout"; //$NON-NLS-1$
-
- private IExtensionStateModel fStateModel;
-
- private CommonLayoutActionGroup fLayoutActionGroup;
-
- private ICommonActionExtensionSite fExtensionSite;
-
- private String fExtensionId;
-
- private IActionBars fActionBars;
-
- private boolean fEnabled= false;
-
- private IExtensionActivationListener fMenuUpdater= new IExtensionActivationListener() {
-
- public void onExtensionActivation(String viewerId, String[] theNavigatorExtensionIds, boolean isCurrentlyActive) {
-
- if (fExtensionSite != null && fActionBars != null) {
-
- int search= Arrays.binarySearch(theNavigatorExtensionIds, fExtensionId);
- if (search > -1) {
- if (isMyViewer(viewerId)) {
- if (wasEnabled(isCurrentlyActive))
- fLayoutActionGroup.fillActionBars(fActionBars);
-
- else
- if (wasDisabled(isCurrentlyActive))
- fLayoutActionGroup.unfillActionBars(fActionBars);
- // else no change
- }
- fEnabled= isCurrentlyActive;
- }
- }
-
- }
-
- private boolean isMyViewer(String viewerId) {
- String myViewerId= fExtensionSite.getViewSite().getId();
- return myViewerId != null && myViewerId.equals(viewerId);
- }
-
- private boolean wasDisabled(boolean isActive) {
- return fEnabled && !isActive;
- }
-
- private boolean wasEnabled(boolean isActive) {
- return !fEnabled && isActive;
- }
- };
-
-
- public void fillActionBars(IActionBars actionBars) {
- fActionBars= actionBars;
- fLayoutActionGroup.fillActionBars(actionBars);
- }
-
- public void init(ICommonActionExtensionSite site) {
-
- fExtensionSite= site;
-
- fStateModel= fExtensionSite.getExtensionStateModel();
- fLayoutActionGroup= new CommonLayoutActionGroup(fExtensionSite.getStructuredViewer(), fStateModel);
-
- INavigatorActivationService activationService= fExtensionSite.getContentService().getActivationService();
- activationService.addExtensionActivationListener(fMenuUpdater);
-
- fExtensionId= fExtensionSite.getExtensionId();
-
- fEnabled= true;
-
- }
-
- public void dispose() {
- super.dispose();
- fExtensionSite.getContentService().getActivationService().removeExtensionActivationListener(fMenuUpdater);
- }
-
- public void setContext(ActionContext context) {
- super.setContext(context);
- }
-
- public void restoreState(IMemento memento) {
- boolean isCurrentLayoutFlat= false;
- Integer state= null;
- if (memento != null)
- state= memento.getInteger(TAG_LAYOUT);
-
- // If no memento try an restore from preference store
- if (state == null) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- state= new Integer(store.getInt(TAG_LAYOUT));
- }
-
- if (state.intValue() == FLAT_LAYOUT)
- isCurrentLayoutFlat= true;
- else
- if (state.intValue() == HIERARCHICAL_LAYOUT)
- isCurrentLayoutFlat= false;
-
- fStateModel.setBooleanProperty(Values.IS_LAYOUT_FLAT, isCurrentLayoutFlat);
- fLayoutActionGroup.setFlatLayout(isCurrentLayoutFlat);
- }
-
- public void saveState(IMemento aMemento) {
- super.saveState(aMemento);
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- if (fStateModel.getBooleanProperty(Values.IS_LAYOUT_FLAT))
- store.setValue(TAG_LAYOUT, FLAT_LAYOUT);
- else
- store.setValue(TAG_LAYOUT, HIERARCHICAL_LAYOUT);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialElementsFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialElementsFilter.java
deleted file mode 100644
index 21aa6067..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialElementsFilter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.IExtensionStateModel;
-import org.eclipse.ui.navigator.INavigatorContentService;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-/**
- *
- * This filter is only applicable to instances of the Common Navigator.
- *
- * This filter will not allow essential elements to be blocked.
- */
-public abstract class NonEssentialElementsFilter extends ViewerFilter {
-
- private static final String JAVA_EXTENSION_ID = "org.eclipse.wst.jsdt.java.ui.javaContent"; //$NON-NLS-1$
-
- private boolean isStateModelInitialized = false;
- private IExtensionStateModel fStateModel = null;
-
- private INavigatorContentService fContentService;
-
- private ViewerFilter fDelegateFilter;
-
- protected NonEssentialElementsFilter(ViewerFilter delegateFilter) {
- fDelegateFilter = delegateFilter;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (!isStateModelInitialized) {
- initStateModel(viewer);
- }
- if (fContentService == null || fStateModel == null) {
- return true;
- } else if (element instanceof IPackageFragment) {
- if (isApplicable() && viewer instanceof StructuredViewer) {
- boolean isHierarchicalLayout= !fStateModel.getBooleanProperty(IExtensionStateConstants.Values.IS_LAYOUT_FLAT);
- try {
- IPackageFragment fragment = (IPackageFragment) element;
- if (isHierarchicalLayout && !fragment.isDefaultPackage() && fragment.hasSubpackages()) {
- return hasFilteredChildren((StructuredViewer) viewer, fragment);
- }
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
- }
- return doSelect(viewer, parent, element);
- }
-
- private boolean hasFilteredChildren(StructuredViewer viewer, IPackageFragment fragment) {
- Object[] children= getRawChildren(viewer, fragment);
- ViewerFilter[] filters= viewer.getFilters();
- for (int i= 0; i < filters.length; i++) {
- children= filters[i].filter(viewer, fragment, children);
- if (children.length == 0)
- return false;
- }
- return true;
- }
-
- private Object[] getRawChildren(StructuredViewer viewer, IPackageFragment fragment) {
- IStructuredContentProvider provider = (IStructuredContentProvider) viewer.getContentProvider();
- if (provider instanceof ITreeContentProvider) {
- return ((ITreeContentProvider)provider).getChildren(fragment);
- }
- return provider.getElements(fragment);
- }
-
- protected boolean doSelect(Viewer viewer, Object parent, Object element) {
- return fDelegateFilter.select(viewer, parent, element);
- }
-
- private boolean isApplicable() {
- return fContentService != null && fContentService.isVisible(JAVA_EXTENSION_ID) && fContentService.isActive(JAVA_EXTENSION_ID);
- }
-
- private synchronized void initStateModel(Viewer viewer) {
- if (!isStateModelInitialized) {
- if (viewer instanceof CommonViewer) {
-
- CommonViewer commonViewer = (CommonViewer) viewer;
- fContentService = commonViewer.getNavigatorContentService();
- fStateModel = fContentService.findStateModel(JAVA_EXTENSION_ID);
-
- isStateModelInitialized = true;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyInnerPackageFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyInnerPackageFilter.java
deleted file mode 100644
index 8df5b0dd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyInnerPackageFilter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.wst.jsdt.internal.ui.filters.EmptyInnerPackageFilter;
-
-
-public class NonEssentialEmptyInnerPackageFilter extends NonEssentialElementsFilter {
-
-
- public NonEssentialEmptyInnerPackageFilter() {
- super(new EmptyInnerPackageFilter());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyPackageFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyPackageFilter.java
deleted file mode 100644
index 2ff84c6f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/NonEssentialEmptyPackageFilter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.wst.jsdt.internal.ui.filters.EmptyPackageFilter;
-
-
-
-
-/**
- * Filters out all empty package fragments unless the mode of the viewer is set to hierarchical
- * layout.
- *
- * This filter is only applicable to instances of the Common Navigator.
- */
-public class NonEssentialEmptyPackageFilter extends NonEssentialElementsFilter {
-
- public NonEssentialEmptyPackageFilter() {
- super(new EmptyPackageFilter());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/OpenAndExpand.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/OpenAndExpand.java
deleted file mode 100644
index f5b2e7fd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/OpenAndExpand.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.ui.actions.OpenAction;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class OpenAndExpand extends SelectionDispatchAction implements IAction {
-
- private OpenAction fOpenAction;
- private TreeViewer fViewer;
-
- public OpenAndExpand(IWorkbenchSite site, OpenAction openAction, TreeViewer viewer) {
- super(site);
- fOpenAction = openAction;
- fViewer = viewer;
- }
-
- public void run() {
- fOpenAction.run();
- if(getSelection() != null && getSelection() instanceof IStructuredSelection)
- expand(((IStructuredSelection)getSelection()).getFirstElement());
-
- }
-
- public void run(ISelection selection) {
- fOpenAction.run(selection);
- if(selection != null && selection instanceof IStructuredSelection)
- expand(((IStructuredSelection)selection).getFirstElement());
- }
-
- public void run(IStructuredSelection selection) {
- fOpenAction.run(selection);
- if(selection != null)
- expand(selection.getFirstElement());
- }
-
- public void run(ITextSelection selection) {
- fOpenAction.run(selection);
- }
-
- public void run(JavaTextSelection selection) {
- fOpenAction.run(selection);
- }
-
- public void run(Object[] elements) {
- fOpenAction.run(elements);
- }
-
- public void runWithEvent(Event event) {
- fOpenAction.runWithEvent(event);
- }
-
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- fOpenAction.addPropertyChangeListener(listener);
- }
-
- public boolean equals(Object obj) {
- return fOpenAction.equals(obj);
- }
-
- public int getAccelerator() {
- return fOpenAction.getAccelerator();
- }
-
- public String getActionDefinitionId() {
- return fOpenAction.getActionDefinitionId();
- }
-
- public String getDescription() {
- return fOpenAction.getDescription();
- }
-
- public ImageDescriptor getDisabledImageDescriptor() {
- return fOpenAction.getDisabledImageDescriptor();
- }
-
- public Object getElementToOpen(Object object) throws JavaScriptModelException {
- return fOpenAction.getElementToOpen(object);
- }
-
- public HelpListener getHelpListener() {
- return fOpenAction.getHelpListener();
- }
-
- public ImageDescriptor getHoverImageDescriptor() {
- return fOpenAction.getHoverImageDescriptor();
- }
-
- public String getId() {
- return fOpenAction.getId();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return fOpenAction.getImageDescriptor();
- }
-
- public IMenuCreator getMenuCreator() {
- return fOpenAction.getMenuCreator();
- }
-
- public ISelection getSelection() {
- return fOpenAction.getSelection();
- }
-
- public ISelectionProvider getSelectionProvider() {
- return fOpenAction.getSelectionProvider();
- }
-
- public Shell getShell() {
- return fOpenAction.getShell();
- }
-
- public IWorkbenchSite getSite() {
- return fOpenAction.getSite();
- }
-
- public int getStyle() {
- return fOpenAction.getStyle();
- }
-
- public String getText() {
- return fOpenAction.getText();
- }
-
- public String getToolTipText() {
- return fOpenAction.getToolTipText();
- }
-
- public int hashCode() {
- return fOpenAction.hashCode();
- }
-
- public boolean isChecked() {
- return fOpenAction.isChecked();
- }
-
- public boolean isEnabled() {
- return fOpenAction.isEnabled();
- }
-
- public boolean isHandled() {
- return fOpenAction.isHandled();
- }
-
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fOpenAction.removePropertyChangeListener(listener);
- }
-
- public void selectionChanged(ISelection selection) {
- fOpenAction.selectionChanged(selection);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- fOpenAction.selectionChanged(selection);
- }
-
- public void selectionChanged(ITextSelection selection) {
- fOpenAction.selectionChanged(selection);
- }
-
- public void selectionChanged(JavaTextSelection selection) {
- fOpenAction.selectionChanged(selection);
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- fOpenAction.selectionChanged(event);
- }
-
- public void setAccelerator(int keycode) {
- fOpenAction.setAccelerator(keycode);
- }
-
- public void setActionDefinitionId(String id) {
- fOpenAction.setActionDefinitionId(id);
- }
-
- public void setChecked(boolean checked) {
- fOpenAction.setChecked(checked);
- }
-
- public void setDescription(String text) {
- fOpenAction.setDescription(text);
- }
-
- public void setDisabledImageDescriptor(ImageDescriptor newImage) {
- fOpenAction.setDisabledImageDescriptor(newImage);
- }
-
- public void setEnabled(boolean enabled) {
- fOpenAction.setEnabled(enabled);
- }
-
- public void setHelpListener(HelpListener listener) {
- fOpenAction.setHelpListener(listener);
- }
-
- public void setHoverImageDescriptor(ImageDescriptor newImage) {
- fOpenAction.setHoverImageDescriptor(newImage);
- }
-
- public void setId(String id) {
- fOpenAction.setId(id);
- }
-
- public void setImageDescriptor(ImageDescriptor newImage) {
- fOpenAction.setImageDescriptor(newImage);
- }
-
- public void setMenuCreator(IMenuCreator creator) {
- fOpenAction.setMenuCreator(creator);
- }
-
- public void setSpecialSelectionProvider(ISelectionProvider provider) {
- fOpenAction.setSpecialSelectionProvider(provider);
- }
-
- public void setText(String text) {
- fOpenAction.setText(text);
- }
-
- public void setToolTipText(String toolTipText) {
- fOpenAction.setToolTipText(toolTipText);
- }
-
- public String toString() {
- return fOpenAction.toString();
- }
-
- public void update(ISelection selection) {
- fOpenAction.update(selection);
- }
-
- private void expand(Object target) {
- if (! fOpenAction.isEnabled())
- fViewer.setExpandedState(target, !fViewer.getExpandedState(target));
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java
deleted file mode 100644
index 1129ff12..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.navigator;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionConstants;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.wst.jsdt.ui.actions.OpenAction;
-import org.eclipse.wst.jsdt.ui.actions.OpenEditorActionGroup;
-
-public class PackageExplorerOpenActionProvider extends CommonActionProvider {
-
-
- private IAction fOpenAndExpand;
- private OpenEditorActionGroup fOpenGroup;
-
- private boolean fInViewPart = false;
-
- public void fillActionBars(IActionBars actionBars) {
- if (fInViewPart) {
- fOpenGroup.fillActionBars(actionBars);
-
- if (fOpenAndExpand == null && fOpenGroup.getOpenAction().isEnabled()) // TODO: is not updated!
- actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenGroup.getOpenAction());
- else if (fOpenAndExpand != null && fOpenAndExpand.isEnabled())
- actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenAndExpand);
- }
-
- }
-
- public void fillContextMenu(IMenuManager menu) {
-
- if (fInViewPart) {
- if (fOpenGroup.getOpenAction().isEnabled()) {
- fOpenGroup.fillContextMenu(menu);
- }
- }
- }
-
- public void init(ICommonActionExtensionSite site) {
-
- ICommonViewerWorkbenchSite workbenchSite = null;
- if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
- workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
-
- if (workbenchSite != null) {
- if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart = (IViewPart) workbenchSite.getPart();
-
- fOpenGroup = new OpenEditorActionGroup(viewPart);
-
- if (site.getStructuredViewer() instanceof TreeViewer)
- fOpenAndExpand = new OpenAndExpand(workbenchSite.getSite(), (OpenAction) fOpenGroup.getOpenAction(), (TreeViewer) site.getStructuredViewer());
- fInViewPart = true;
- }
- }
- }
-
- public void setContext(ActionContext context) {
- super.setContext(context);
- if (fInViewPart) {
- fOpenGroup.setContext(context);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CollapseAllAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CollapseAllAction.java
deleted file mode 100644
index 45db3c7c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CollapseAllAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Collapse all nodes.
- */
-class CollapseAllAction extends Action {
-
- private PackageExplorerPart fPackageExplorer;
-
- CollapseAllAction(PackageExplorerPart part) {
- super(PackagesMessages.CollapseAllAction_label);
- setDescription(PackagesMessages.CollapseAllAction_description);
- setToolTipText(PackagesMessages.CollapseAllAction_tooltip);
- JavaPluginImages.setLocalImageDescriptors(this, "collapseall.gif"); //$NON-NLS-1$
-
- fPackageExplorer= part;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.COLLAPSE_ALL_ACTION);
- }
-
- public void run() {
- fPackageExplorer.collapseAll();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CustomHashtable.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CustomHashtable.java
deleted file mode 100644
index 87eda51a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/CustomHashtable.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Peter Shipton - original hashtable implementation
- * Nick Edgar - added element comparer support
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jface.viewers.IElementComparer;
-
-/**
- * CustomHashtable associates keys with values. Keys and values cannot be null.
- * The size of the Hashtable is the number of key/value pairs it contains.
- * The capacity is the number of key/value pairs the Hashtable can hold.
- * The load factor is a float value which determines how full the Hashtable
- * gets before expanding the capacity. If the load factor of the Hashtable
- * is exceeded, the capacity is doubled.
- * <p>
- * CustomHashtable allows a custom comparator and hash code provider.
- */
-/* package */final class CustomHashtable {
-
- /**
- * HashMapEntry is an internal class which is used to hold the entries of a Hashtable.
- */
- private static class HashMapEntry {
- Object key, value;
-
- HashMapEntry next;
-
- HashMapEntry(Object theKey, Object theValue) {
- key = theKey;
- value = theValue;
- }
- }
-
- private static final class EmptyEnumerator implements Enumeration {
- public boolean hasMoreElements() {
- return false;
- }
-
- public Object nextElement() {
- throw new NoSuchElementException();
- }
- }
-
- private class HashEnumerator implements Enumeration {
- boolean key;
-
- int start;
-
- HashMapEntry entry;
-
- HashEnumerator(boolean isKey) {
- key = isKey;
- start = firstSlot;
- }
-
- public boolean hasMoreElements() {
- if (entry != null)
- return true;
- while (start <= lastSlot)
- if (elementData[start++] != null) {
- entry = elementData[start - 1];
- return true;
- }
- return false;
- }
-
- public Object nextElement() {
- if (hasMoreElements()) {
- Object result = key ? entry.key : entry.value;
- entry = entry.next;
- return result;
- } else
- throw new NoSuchElementException();
- }
- }
-
- transient int elementCount;
-
- transient HashMapEntry[] elementData;
-
- private float loadFactor;
-
- private int threshold;
-
- transient int firstSlot = 0;
-
- transient int lastSlot = -1;
-
- transient private IElementComparer comparer;
-
- private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
-
- /**
- * The default capacity used when not specified in the constructor.
- */
- public static final int DEFAULT_CAPACITY = 13;
-
- /**
- * Constructs a new Hashtable using the default capacity
- * and load factor.
- */
- public CustomHashtable() {
- this(13);
- }
-
- /**
- * Constructs a new Hashtable using the specified capacity
- * and the default load factor.
- *
- * @param capacity the initial capacity
- */
- public CustomHashtable(int capacity) {
- this(capacity, null);
- }
-
- /**
- * Constructs a new hash table with the default capacity and the given
- * element comparer.
- *
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(IElementComparer comparer) {
- this(DEFAULT_CAPACITY, comparer);
- }
-
- /**
- * Constructs a new hash table with the given capacity and the given
- * element comparer.
- *
- * @param capacity the maximum number of elements that can be added without
- * rehashing
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(int capacity, IElementComparer comparer) {
- if (capacity >= 0) {
- elementCount = 0;
- elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
- firstSlot = elementData.length;
- loadFactor = 0.75f;
- computeMaxSize();
- } else
- throw new IllegalArgumentException();
- this.comparer = comparer;
- }
-
- /**
- * Constructs a new hash table with enough capacity to hold all keys in the
- * given hash table, then adds all key/value pairs in the given hash table
- * to the new one, using the given element comparer.
- *
- * @param table the hash table to add from
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
- this(table.size() * 2, comparer);
- for (int i = table.elementData.length; --i >= 0;) {
- HashMapEntry entry = table.elementData[i];
- while (entry != null) {
- put(entry.key, entry.value);
- entry = entry.next;
- }
- }
- }
-
- private void computeMaxSize() {
- threshold = (int) (elementData.length * loadFactor);
- }
-
- /**
- * Answers if this Hashtable contains the specified object as a key
- * of one of the key/value pairs.
- *
- * @param key the object to look for as a key in this Hashtable
- * @return true if object is a key in this Hashtable, false otherwise
- */
- public boolean containsKey(Object key) {
- return getEntry(key) != null;
- }
-
- /**
- * Answers an Enumeration on the values of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the values of this Hashtable
- */
- public Enumeration elements() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(false);
- }
-
- /**
- * Answers the value associated with the specified key in
- * this Hashtable.
- *
- * @param key the key of the value returned
- * @return the value associated with the specified key, null if the specified key
- * does not exist
- */
- public Object get(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry.value;
- entry = entry.next;
- }
- return null;
- }
-
- private HashMapEntry getEntry(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry;
- entry = entry.next;
- }
- return null;
- }
-
- /**
- * Answers the hash code for the given key.
- */
- private int hashCode(Object key) {
- if (comparer == null)
- return key.hashCode();
- else
- return comparer.hashCode(key);
- }
-
- /**
- * Compares two keys for equality.
- */
- private boolean keyEquals(Object a, Object b) {
- if (comparer == null)
- return a.equals(b);
- else
- return comparer.equals(a, b);
- }
-
- /**
- * Answers an Enumeration on the keys of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the keys of this Hashtable
- */
- public Enumeration keys() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(true);
- }
-
- /**
- * Associate the specified value with the specified key in this Hashtable.
- * If the key already exists, the old value is replaced. The key and value
- * cannot be null.
- *
- * @param key the key to add
- * @param value the value to add
- * @return the old value associated with the specified key, null if the key did
- * not exist
- */
- public Object put(Object key, Object value) {
- if (key != null && value != null) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key))
- entry = entry.next;
- if (entry == null) {
- if (++elementCount > threshold) {
- rehash();
- index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- }
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- entry = new HashMapEntry(key, value);
- entry.next = elementData[index];
- elementData[index] = entry;
- return null;
- }
- Object result = entry.value;
- entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607
- entry.value = value;
- return result;
- } else
- throw new NullPointerException();
- }
-
- /**
- * Increases the capacity of this Hashtable. This method is sent when
- * the size of this Hashtable exceeds the load factor.
- */
- private void rehash() {
- int length = elementData.length << 1;
- if (length == 0)
- length = 1;
- firstSlot = length;
- lastSlot = -1;
- HashMapEntry[] newData = new HashMapEntry[length];
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- HashMapEntry next = entry.next;
- entry.next = newData[index];
- newData[index] = entry;
- entry = next;
- }
- }
- elementData = newData;
- computeMaxSize();
- }
-
- /**
- * Remove the key/value pair with the specified key from this Hashtable.
- *
- * @param key the key to remove
- * @return the value associated with the specified key, null if the specified key
- * did not exist
- */
- public Object remove(Object key) {
- HashMapEntry last = null;
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key)) {
- last = entry;
- entry = entry.next;
- }
- if (entry != null) {
- if (last == null)
- elementData[index] = entry.next;
- else
- last.next = entry.next;
- elementCount--;
- return entry.value;
- }
- return null;
- }
-
- /**
- * Answers the number of key/value pairs in this Hashtable.
- *
- * @return the number of key/value pairs in this Hashtable
- */
- public int size() {
- return elementCount;
- }
-
- /**
- * Answers the string representation of this Hashtable.
- *
- * @return the string representation of this Hashtable
- */
- public String toString() {
- if (size() == 0)
- return "{}"; //$NON-NLS-1$
-
- StringBuffer buffer = new StringBuffer();
- buffer.append('{');
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- buffer.append(entry.key);
- buffer.append('=');
- buffer.append(entry.value);
- buffer.append(", "); //$NON-NLS-1$
- entry = entry.next;
- }
- }
- // Remove the last ", "
- if (elementCount > 0)
- buffer.setLength(buffer.length() - 2);
- buffer.append('}');
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/DefaultElementComparer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/DefaultElementComparer.java
deleted file mode 100644
index 04b01e4a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/DefaultElementComparer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.viewers.IElementComparer;
-
-public class DefaultElementComparer implements IElementComparer {
-
- public static final DefaultElementComparer INSTANCE= new DefaultElementComparer();
-
- public boolean equals(Object a, Object b) {
- return a.equals(b);
- }
- public int hashCode(Object element) {
- return element.hashCode();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDragAdapter.java
deleted file mode 100644
index 07f93e6b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDragAdapter.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-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.TransferDragSourceListener;
-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.DragSourceAdapter;
-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.actions.WorkspaceModifyOperation;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.internal.corext.util.Resources;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-/**
- * Drag support class to allow dragging of files and folder from
- * the packages view to another application.
- */
-class FileTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
-
- private ISelectionProvider fProvider;
-
- FileTransferDragAdapter(ISelectionProvider provider) {
- fProvider= provider;
- Assert.isNotNull(fProvider);
- }
-
- public Transfer getTransfer() {
- return FileTransfer.getInstance();
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit= isDragable(fProvider.getSelection());
- }
-
- private boolean isDragable(ISelection s) {
- if (!(s instanceof IStructuredSelection))
- return false;
- IStructuredSelection selection= (IStructuredSelection)s;
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement jElement= (IJavaScriptElement)element;
- int type= jElement.getElementType();
- // valid elements are: roots, units and types. Don't allow dragging
- // projects outside of eclipse
- if (type != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT &&
- type != IJavaScriptElement.JAVASCRIPT_UNIT && type != IJavaScriptElement.TYPE)
- return false;
- IPackageFragmentRoot root= (IPackageFragmentRoot)jElement.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (root != null && root.isArchive())
- return false;
- }
- }
- List resources= convertIntoResources(selection);
- return resources.size() == selection.size();
- }
-
- public void dragSetData(DragSourceEvent event){
- List elements= getResources();
- if (elements == null || elements.size() == 0) {
- event.data= null;
- return;
- }
-
- event.data= getResourceLocations(elements);
- }
-
- private static String[] getResourceLocations(List resources) {
- return Resources.getLocationOSStrings((IResource[]) resources.toArray(new IResource[resources.size()]));
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (!event.doit)
- return;
-
- if (event.detail == DND.DROP_MOVE) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=30543
- // handleDropMove(event);
- } else if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_TARGET_MOVE) {
- handleRefresh(event);
- }
- }
-
- /* package */ void handleDropMove(DragSourceEvent event) {
- final List elements= getResources();
- if (elements == null || elements.size() == 0)
- return;
-
- WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(PackagesMessages.DragAdapter_deleting, elements.size());
- MultiStatus status= createMultiStatus();
- Iterator iter= elements.iterator();
- while(iter.hasNext()) {
- IResource resource= (IResource)iter.next();
- try {
- monitor.subTask(resource.getFullPath().toOSString());
- resource.delete(true, null);
-
- } catch (CoreException e) {
- status.add(e.getStatus());
- } finally {
- monitor.worked(1);
- }
- }
- if (!status.isOK()) {
- throw new CoreException(status);
- }
- } finally {
- monitor.done();
- }
- }
- };
- runOperation(op, true, false);
- }
-
- private void handleRefresh(DragSourceEvent event) {
- final Set roots= collectRoots(getResources());
-
- WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(PackagesMessages.DragAdapter_refreshing, roots.size());
- MultiStatus status= createMultiStatus();
- Iterator iter= roots.iterator();
- while (iter.hasNext()) {
- IResource r= (IResource)iter.next();
- try {
- r.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();
- }
- }
- };
-
- runOperation(op, true, false);
- }
-
- protected Set collectRoots(final List elements) {
- final Set roots= new HashSet(10);
-
- Iterator iter= elements.iterator();
- while (iter.hasNext()) {
- IResource resource= (IResource)iter.next();
- IResource parent= resource.getParent();
- if (parent == null) {
- roots.add(resource);
- } else {
- roots.add(parent);
- }
- }
- return roots;
- }
-
- private List getResources() {
- ISelection s= fProvider.getSelection();
- if (!(s instanceof IStructuredSelection))
- return null;
-
- return convertIntoResources((IStructuredSelection)s);
- }
-
- private List convertIntoResources(IStructuredSelection selection) {
- List result= new ArrayList(selection.size());
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- Object o= iter.next();
- IResource r= null;
- if (o instanceof IResource) {
- r= (IResource)o;
- } else if (o instanceof IAdaptable) {
- r= (IResource)((IAdaptable)o).getAdapter(IResource.class);
- }
- // Only add resource for which we have a location
- // in the local file system.
- if (r != null && r.getLocation() != null) {
- result.add(r);
- }
- }
- return result;
- }
-
- private MultiStatus createMultiStatus() {
- return new MultiStatus(JavaScriptPlugin.getPluginId(),
- IStatus.OK, PackagesMessages.DragAdapter_problem, null);
- }
-
- private void runOperation(IRunnableWithProgress op, boolean fork, boolean cancelable) {
- try {
- Shell parent= JavaScriptPlugin.getActiveWorkbenchShell();
- new ProgressMonitorDialog(parent).run(fork, cancelable, op);
- } catch (InvocationTargetException e) {
- String message= PackagesMessages.DragAdapter_problem;
- String title= PackagesMessages.DragAdapter_problemTitle;
- ExceptionHandler.handle(e, title, message);
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled by user.
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDropAdapter.java
deleted file mode 100644
index c289e058..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/FileTransferDropAdapter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Resources;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-/**
- * Adapter to handle file drop from other applications.
- */
-class FileTransferDropAdapter extends JdtViewerDropAdapter implements TransferDropTargetListener {
-
- FileTransferDropAdapter(AbstractTreeViewer viewer) {
- super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
- }
-
- //---- TransferDropTargetListener interface ---------------------------------------
-
- public Transfer getTransfer() {
- return FileTransfer.getInstance();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
- if (target == null)
- return false;
- return target instanceof IJavaScriptElement || target instanceof IResource;
- }
-
- //---- Actual DND -----------------------------------------------------------------
-
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
-
- boolean isPackageFragment= target instanceof IPackageFragment;
- boolean isJavaProject= target instanceof IJavaScriptProject;
- boolean isPackageFragmentRoot= target instanceof IPackageFragmentRoot;
- boolean isContainer= target instanceof IContainer;
-
- if (!(isPackageFragment || isJavaProject || isPackageFragmentRoot || isContainer))
- return;
-
- if (isContainer) {
- IContainer container= (IContainer)target;
- if (container.isAccessible() && !Resources.isReadOnly(container))
- event.detail= DND.DROP_COPY;
- } else {
- IJavaScriptElement element= (IJavaScriptElement)target;
- if (!element.isReadOnly())
- event.detail= DND.DROP_COPY;
- }
-
- return;
- }
-
- public void drop(Object dropTarget, final DropTargetEvent event) {
- try {
- int operation= event.detail;
-
- event.detail= DND.DROP_NONE;
- final Object data= event.data;
- if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
- return;
-
- final IContainer target= getActualTarget(dropTarget);
- if (target == null)
- return;
-
- // Run the import operation asynchronously.
- // Otherwise the drag source (e.g., Windows Explorer) will be blocked
- // while the operation executes. Fixes bug 35796.
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- getShell().forceActive();
- new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target);
- // Import always performs a copy.
- event.detail= DND.DROP_COPY;
- }
- });
- } catch (JavaScriptModelException e) {
- String title= PackagesMessages.DropAdapter_errorTitle;
- String message= PackagesMessages.DropAdapter_errorMessage;
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- }
-
- private IContainer getActualTarget(Object dropTarget) throws JavaScriptModelException{
- if (dropTarget instanceof IContainer)
- return (IContainer)dropTarget;
- else if (dropTarget instanceof IJavaScriptElement)
- return getActualTarget(((IJavaScriptElement)dropTarget).getCorrespondingResource());
- return null;
- }
-
- private Shell getShell() {
- return getViewer().getControl().getShell();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoPackageAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoPackageAction.java
deleted file mode 100644
index 9fa726b3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoPackageAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.PackageSelectionDialog;
-
-class GotoPackageAction extends Action {
-
- private PackageExplorerPart fPackageExplorer;
-
- GotoPackageAction(PackageExplorerPart part) {
- super(PackagesMessages.GotoPackage_action_label);
- setDescription(PackagesMessages.GotoPackage_action_description);
- fPackageExplorer= part;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PACKAGE_ACTION);
- }
-
- public void run() {
- try {
- Shell shell= JavaScriptPlugin.getActiveWorkbenchShell();
- SelectionDialog dialog= createAllPackagesDialog(shell);
- dialog.setTitle(getDialogTitle());
- dialog.setMessage(PackagesMessages.GotoPackage_dialog_message);
- dialog.open();
- Object[] res= dialog.getResult();
- if (res != null && res.length == 1)
- gotoPackage((IPackageFragment)res[0]);
- } catch (JavaScriptModelException e) {
- }
- }
-
- private SelectionDialog createAllPackagesDialog(Shell shell) throws JavaScriptModelException{
- IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- int flag= PackageSelectionDialog.F_HIDE_EMPTY_INNER;
- PackageSelectionDialog dialog= new PackageSelectionDialog(shell, progressService, flag, scope);
- dialog.setFilter(""); //$NON-NLS-1$
- dialog.setIgnoreCase(false);
- dialog.setMultipleSelection(false);
- return dialog;
- }
-
- private void gotoPackage(IPackageFragment p) {
- fPackageExplorer.selectReveal(new StructuredSelection(p));
- if (!p.equals(getSelectedElement())) {
- MessageDialog.openInformation(fPackageExplorer.getSite().getShell(),
- getDialogTitle(),
- Messages.format(PackagesMessages.PackageExplorer_element_not_present, p.getElementName()));
- }
- }
-
- private Object getSelectedElement() {
- return ((IStructuredSelection)fPackageExplorer.getSite().getSelectionProvider().getSelection()).getFirstElement();
- }
-
- private String getDialogTitle() {
- return PackagesMessages.GotoPackage_dialog_title;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoRequiredProjectAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoRequiredProjectAction.java
deleted file mode 100644
index 0bdf843a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoRequiredProjectAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-/**
- * Goto to the referenced required project
- */
-class GotoRequiredProjectAction extends Action {
-
- private PackageExplorerPart fPackageExplorer;
-
- GotoRequiredProjectAction(PackageExplorerPart part) {
- super(PackagesMessages.GotoRequiredProjectAction_label);
- setDescription(PackagesMessages.GotoRequiredProjectAction_description);
- setToolTipText(PackagesMessages.GotoRequiredProjectAction_tooltip);
- fPackageExplorer= part;
- }
-
- public void run() {
- IStructuredSelection selection= (IStructuredSelection)fPackageExplorer.getSite().getSelectionProvider().getSelection();
- Object element= selection.getFirstElement();
- if (element instanceof JsGlobalScopeContainer.RequiredProjectWrapper) {
- JsGlobalScopeContainer.RequiredProjectWrapper wrapper= (JsGlobalScopeContainer.RequiredProjectWrapper) element;
- fPackageExplorer.tryToReveal(wrapper.getProject());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoResourceAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoResourceAction.java
deleted file mode 100644
index a7e2edb9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoResourceAction.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public class GotoResourceAction extends Action {
-
- private PackageExplorerPart fPackageExplorer;
-
- private static class GotoResourceDialog extends FilteredResourcesSelectionDialog {
- private IJavaScriptModel fJavaModel;
- public GotoResourceDialog(Shell parentShell, IContainer container, StructuredViewer viewer) {
- super(parentShell, false, container, IResource.FILE | IResource.FOLDER | IResource.PROJECT);
- fJavaModel= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- setTitle(PackagesMessages.GotoResource_dialog_title);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, IJavaHelpContextIds.GOTO_RESOURCE_DIALOG);
- }
-
- protected ItemsFilter createFilter() {
- return new GotoResourceFilter();
- }
-
- private class GotoResourceFilter extends ResourceFilter {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog.ResourceFilter#matchItem(java.lang.Object)
- */
- public boolean matchItem(Object item) {
- IResource resource = (IResource) item;
- return super.matchItem(item) && select(resource);
- }
-
- /**
- * This is the orignal <code>select</code> method. Since
- * <code>GotoResourceDialog</code> needs to extend
- * <code>FilteredResourcesSelectionDialog</code> result of this
- * method must be combined with the <code>matchItem</code> method
- * from super class (<code>ResourceFilter</code>).
- *
- * @param resource
- * A resource
- * @return <code>true</code> if item matches against given
- * conditions <code>false</code> otherwise
- */
- private boolean select(IResource resource) {
- IProject project= resource.getProject();
- try {
- if (project.getNature(JavaScriptCore.NATURE_ID) != null)
- return fJavaModel.contains(resource);
- } catch (CoreException e) {
- // do nothing. Consider resource;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog.ResourceFilter#equalsFilter(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter)
- */
- public boolean equalsFilter(ItemsFilter filter) {
- if (!super.equalsFilter(filter)) {
- return false;
- }
- if (!(filter instanceof GotoResourceFilter)) {
- return false;
- }
- return true;
- }
- }
-
- }
-
- public GotoResourceAction(PackageExplorerPart explorer) {
- setText(PackagesMessages.GotoResource_action_label);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_RESOURCE_ACTION);
- fPackageExplorer= explorer;
- }
-
- public void run() {
- TreeViewer viewer= fPackageExplorer.getTreeViewer();
- GotoResourceDialog dialog= new GotoResourceDialog(fPackageExplorer.getSite().getShell(),
- ResourcesPlugin.getWorkspace().getRoot(), viewer);
- dialog.open();
- Object[] result = dialog.getResult();
- if (result == null || result.length == 0 || !(result[0] instanceof IResource))
- return;
- StructuredSelection selection= null;
- IJavaScriptElement element = JavaScriptCore.create((IResource)result[0]);
- if (element != null && element.exists())
- selection= new StructuredSelection(element);
- else
- selection= new StructuredSelection(result[0]);
- viewer.setSelection(selection, true);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoTypeAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoTypeAction.java
deleted file mode 100644
index 11651377..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/GotoTypeAction.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.IJavaScriptElementSearchConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-class GotoTypeAction extends Action {
-
- private PackageExplorerPart fPackageExplorer;
-
- GotoTypeAction(PackageExplorerPart part) {
- super();
- setText(PackagesMessages.GotoType_action_label);
- setDescription(PackagesMessages.GotoType_action_description);
- fPackageExplorer= part;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION);
- }
-
- public void run() {
- Shell shell= JavaScriptPlugin.getActiveWorkbenchShell();
- SelectionDialog dialog= null;
- try {
- dialog= JavaScriptUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
- SearchEngine.createWorkspaceScope(), IJavaScriptElementSearchConstants.CONSIDER_ALL_TYPES, false);
- } catch (JavaScriptModelException e) {
- String title= getDialogTitle();
- String message= PackagesMessages.GotoType_error_message;
- ExceptionHandler.handle(e, title, message);
- return;
- }
-
- dialog.setTitle(getDialogTitle());
- dialog.setMessage(PackagesMessages.GotoType_dialog_message);
- if (dialog.open() == IDialogConstants.CANCEL_ID) {
- return;
- }
-
- Object[] types= dialog.getResult();
- if (types != null && types.length > 0) {
- gotoType((IType) types[0]);
- }
- }
-
- private void gotoType(IType type) {
- IJavaScriptUnit cu= (IJavaScriptUnit) type.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- IJavaScriptElement element= null;
- if (cu != null) {
- element= cu.getPrimary();
- }
- else {
- element= type.getAncestor(IJavaScriptElement.CLASS_FILE);
- }
- if (element != null) {
- PackageExplorerPart view= PackageExplorerPart.openInActivePerspective();
- if (view != null) {
- view.selectReveal(new StructuredSelection(element));
- if (!element.equals(getSelectedElement(view))) {
- MessageDialog.openInformation(fPackageExplorer.getSite().getShell(),
- getDialogTitle(),
- Messages.format(PackagesMessages.PackageExplorer_element_not_present, element.getElementName()));
- }
- }
- }
- }
-
- private Object getSelectedElement(PackageExplorerPart view) {
- return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement();
- }
-
- private String getDialogTitle() {
- return PackagesMessages.GotoType_dialog_title;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/HierarchicalDecorationContext.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/HierarchicalDecorationContext.java
deleted file mode 100644
index 70390b8d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/HierarchicalDecorationContext.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.IDecorationContext;
-import org.eclipse.team.ui.mapping.SynchronizationStateTester;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaElementResourceMapping;
-
-public class HierarchicalDecorationContext implements IDecorationContext {
-
- private HierarchicalSynchronizationStateTester fStateTester;
- public static final HierarchicalDecorationContext CONTEXT= new HierarchicalDecorationContext();
-
- private HierarchicalDecorationContext() {
- fStateTester= new HierarchicalSynchronizationStateTester();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IDecorationContext#getProperties()
- */
- public String[] getProperties() {
- return new String[] { SynchronizationStateTester.PROP_TESTER };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IDecorationContext#getProperty(java.lang.String)
- */
- public Object getProperty(String property) {
- if (property == SynchronizationStateTester.PROP_TESTER) {
- return fStateTester;
- }
- return null;
- }
-
- private static final class HierarchicalSynchronizationStateTester extends SynchronizationStateTester {
-
- public HierarchicalSynchronizationStateTester() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.mapping.SynchronizationStateTester#getState(java.lang.Object, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public int getState(Object element, int stateMask, IProgressMonitor monitor) throws CoreException {
- if (element instanceof JavaElementResourceMapping) {
- JavaElementResourceMapping mapping= (JavaElementResourceMapping) element;
- IJavaScriptElement javaElement= mapping.getJavaElement();
- if (javaElement instanceof IPackageFragment) {
- IPackageFragment packageFragment= (IPackageFragment) javaElement;
- if (!packageFragment.isDefaultPackage()) {
- element= new HierarchicalPackageFragementResourceMapping(packageFragment);
- }
- }
- }
- return super.getState(element, stateMask, monitor);
- }
- }
-
- private static final class HierarchicalPackageFragementResourceMapping extends JavaElementResourceMapping {
- private final IPackageFragment fPack;
- private HierarchicalPackageFragementResourceMapping(IPackageFragment fragment) {
- Assert.isNotNull(fragment);
- fPack= fragment;
- }
- public Object getModelObject() {
- return fPack;
- }
- public IProject[] getProjects() {
- return new IProject[] {fPack.getJavaScriptProject().getProject() };
- }
- public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
- return new ResourceTraversal[] {
- new ResourceTraversal(new IResource[] {fPack.getResource()}, IResource.DEPTH_INFINITE, 0)
- };
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/IMultiElementTreeContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/IMultiElementTreeContentProvider.java
deleted file mode 100644
index f768d158..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/IMultiElementTreeContentProvider.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreePath;
-
-public interface IMultiElementTreeContentProvider extends ITreeContentProvider {
- public TreePath[] getTreePaths(Object element);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/JsGlobalScopeContainer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/JsGlobalScopeContainer.java
deleted file mode 100644
index 881d4643..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/JsGlobalScopeContainer.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
-import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJsGlobalScopeContainerInitializerExtension;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.util.JSDScopeUiUtil;
-
-/**
- * Representation of class path containers in Java UI.
- */
-public class JsGlobalScopeContainer extends PackageFragmentRootContainer {
-
- private IIncludePathEntry fClassPathEntry;
- private IJsGlobalScopeContainer fContainer;
-
- public static class RequiredProjectWrapper implements IAdaptable, IWorkbenchAdapter {
-
- private final JsGlobalScopeContainer fParent;
- private final IJavaScriptProject fProject;
-
- public RequiredProjectWrapper(JsGlobalScopeContainer parent, IJavaScriptProject project) {
- fParent= parent;
- fProject= project;
- }
-
- public IJavaScriptProject getProject() {
- return fProject;
- }
-
- public JsGlobalScopeContainer getParentJsGlobalScopeContainer() {
- return fParent;
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class)
- return this;
- return null;
- }
-
- public Object[] getChildren(Object o) {
- return new Object[0];
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
- }
-
- public String getLabel(Object o) {
- return fProject.getElementName();
- }
-
- public Object getParent(Object o) {
- return fParent;
- }
- }
-
- public JsGlobalScopeContainer(IJavaScriptProject parent, IIncludePathEntry entry) {
- super(parent);
- fClassPathEntry= entry;
- try {
- fContainer= JavaScriptCore.getJsGlobalScopeContainer(entry.getPath(), parent);
- } catch (JavaScriptModelException e) {
- fContainer= null;
- }
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof JsGlobalScopeContainer) {
- JsGlobalScopeContainer other = (JsGlobalScopeContainer)obj;
- if (getJavaProject().equals(other.getJavaProject()) &&
- fClassPathEntry.equals(other.fClassPathEntry)) {
- return true;
- }
-
- }
- return false;
- }
-
- public int hashCode() {
- return getJavaProject().hashCode()*17+fClassPathEntry.hashCode();
- }
-
- public IPackageFragmentRoot[] getPackageFragmentRoots() {
- return getJavaProject().findPackageFragmentRoots(fClassPathEntry);
- }
-
- public IAdaptable[] getChildren() {
- List list= new ArrayList();
- IPackageFragmentRoot[] roots= getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- list.add(roots[i]);
- }
- if (fContainer != null) {
- IIncludePathEntry[] classpathEntries= fContainer.getIncludepathEntries();
- if (classpathEntries == null) {
- // invalid implementation of a classpath container
- JavaScriptPlugin.log(new IllegalArgumentException("Invalid classpath container implementation: getClasspathEntries() returns null. " + fContainer.getPath())); //$NON-NLS-1$
- } else {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- for (int i= 0; i < classpathEntries.length; i++) {
- IIncludePathEntry entry= classpathEntries[i];
- if (entry.getEntryKind() == IIncludePathEntry.CPE_PROJECT) {
- IResource resource= root.findMember(entry.getPath());
- if (resource instanceof IProject)
- list.add(new RequiredProjectWrapper(this, JavaScriptCore.create((IProject) resource)));
- }
- }
- }
- }
- return (IAdaptable[]) list.toArray(new IAdaptable[list.size()]);
- }
-
- public ImageDescriptor getImageDescriptor() {
- IJsGlobalScopeContainerInitializerExtension init = JSDScopeUiUtil.getContainerUiInitializer(fClassPathEntry.getPath());
- if(init!=null ) {
- IPath entPath = fClassPathEntry.getPath();
- ImageDescriptor image = init.getImage(entPath, fClassPathEntry.toString(), super.getJavaProject());
- if(image!=null) return image;
- }
- return JavaPluginImages.DESC_OBJS_LIBRARY;
- }
-
- public String getLabel() {
- if (fContainer != null)
- return fContainer.getDescription();
-
- IPath path= fClassPathEntry.getPath();
- String containerId= path.segment(0);
- JsGlobalScopeContainerInitializer initializer= JavaScriptCore.getJsGlobalScopeContainerInitializer(containerId);
- if (initializer != null) {
- String description= initializer.getDescription(path, getJavaProject());
- return Messages.format(PackagesMessages.JsGlobalScopeContainer_unbound_label, description);
- }
- return Messages.format(PackagesMessages.JsGlobalScopeContainer_unknown_label, path.toString());
- }
-
- public IIncludePathEntry getClasspathEntry() {
- return fClassPathEntry;
- }
-
- static boolean contains(IJavaScriptProject project, IIncludePathEntry entry, IPackageFragmentRoot root) {
- IPackageFragmentRoot[] roots= project.findPackageFragmentRoots(entry);
- for (int i= 0; i < roots.length; i++) {
- if (roots[i].equals(root))
- return true;
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LayoutActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LayoutActionGroup.java
deleted file mode 100644
index e66818e8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LayoutActionGroup.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Adds view menus to switch between flat and hierarchical layout.
- *
- *
- */
-class LayoutActionGroup extends ActionGroup {
-
- public static final String VIEWMENU_LAYOUT_GROUP= "layout"; //$NON-NLS-1$
-
- private IAction fFlatLayoutAction;
- private IAction fHierarchicalLayoutAction;
- private IAction fShowLibrariesNode;
-
- LayoutActionGroup(PackageExplorerPart packageExplorer) {
- fFlatLayoutAction= new LayoutAction(packageExplorer, true);
- fHierarchicalLayoutAction= new LayoutAction(packageExplorer, false);
- fShowLibrariesNode= new ShowLibrariesNodeAction(packageExplorer);
- }
-
- /* (non-Javadoc)
- * @see ActionGroup#fillActionBars(IActionBars)
- */
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- contributeToViewMenu(actionBars.getMenuManager());
- }
-
- private void contributeToViewMenu(IMenuManager viewMenu) {
- viewMenu.add(new Separator(VIEWMENU_LAYOUT_GROUP));
-
- // Create layout sub menu
-
- IMenuManager layoutSubMenu= new MenuManager(PackagesMessages.LayoutActionGroup_label);
- layoutSubMenu.add(fFlatLayoutAction);
- layoutSubMenu.add(fHierarchicalLayoutAction);
-
- viewMenu.add(layoutSubMenu);
- viewMenu.add(fShowLibrariesNode);
- }
-}
-
-class LayoutAction extends Action implements IAction {
-
- private boolean fIsFlatLayout;
- private PackageExplorerPart fPackageExplorer;
-
- public LayoutAction(PackageExplorerPart packageExplorer, boolean flat) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
-
- fIsFlatLayout= flat;
- fPackageExplorer= packageExplorer;
- if (fIsFlatLayout) {
- setText(PackagesMessages.LayoutActionGroup_flatLayoutAction_label);
- JavaPluginImages.setLocalImageDescriptors(this, "flatLayout.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION);
- } else {
- setText(PackagesMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
- JavaPluginImages.setLocalImageDescriptors(this, "hierarchicalLayout.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION);
- }
- setChecked(packageExplorer.isFlatLayout() == fIsFlatLayout);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- if (fPackageExplorer.isFlatLayout() != fIsFlatLayout)
- fPackageExplorer.setFlatLayout(fIsFlatLayout);
- }
-}
-
-class ShowLibrariesNodeAction extends Action implements IAction {
-
- private PackageExplorerPart fPackageExplorer;
-
- public ShowLibrariesNodeAction(PackageExplorerPart packageExplorer) {
- super(PackagesMessages.LayoutActionGroup_show_libraries_in_group, AS_CHECK_BOX);
- fPackageExplorer= packageExplorer;
- setChecked(packageExplorer.isLibrariesNodeShown());
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- fPackageExplorer.setShowLibrariesNode(isChecked());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LibraryContainer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LibraryContainer.java
deleted file mode 100644
index 59548f7e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/LibraryContainer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-public class LibraryContainer extends PackageFragmentRootContainer {
-
- public LibraryContainer(IJavaScriptProject project) {
- super(project);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof LibraryContainer) {
- LibraryContainer other = (LibraryContainer)obj;
- return getJavaProject().equals(other.getJavaProject());
- }
- return false;
- }
-
- public int hashCode() {
- return getJavaProject().hashCode();
- }
-
- public IAdaptable[] getChildren() {
- return getPackageFragmentRoots();
- }
-
-
- public ImageDescriptor getImageDescriptor() {
- return JavaPluginImages.DESC_OBJS_LIBRARY;
- }
-
- public String getLabel() {
- return PackagesMessages.LibraryContainer_name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.packageview.PackageFragmentRootContainer#getPackageFragmentRoots()
- */
- public IPackageFragmentRoot[] getPackageFragmentRoots() {
- List list= new ArrayList();
- try {
- IPackageFragmentRoot[] roots= getJavaProject().getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- int classpathEntryKind= root.getRawIncludepathEntry().getEntryKind();
- if (classpathEntryKind == IIncludePathEntry.CPE_LIBRARY || classpathEntryKind == IIncludePathEntry.CPE_VARIABLE) {
- list.add(root);
- }
- }
- } catch (JavaScriptModelException e) {
- // fall through
- }
- return (IPackageFragmentRoot[]) list.toArray(new IPackageFragmentRoot[list.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerActionGroup.java
deleted file mode 100644
index eb27f5ac..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerActionGroup.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.OpenInNewWindowAction;
-import org.eclipse.ui.views.framelist.BackAction;
-import org.eclipse.ui.views.framelist.ForwardAction;
-import org.eclipse.ui.views.framelist.Frame;
-import org.eclipse.ui.views.framelist.FrameAction;
-import org.eclipse.ui.views.framelist.FrameList;
-import org.eclipse.ui.views.framelist.GoIntoAction;
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.framelist.UpAction;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.NewWizardsActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectAllAction;
-//import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.ViewActionGroup;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.BuildActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.CCPActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.ImportActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants;
-import org.eclipse.wst.jsdt.ui.actions.NavigateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenProjectAction;
-import org.eclipse.wst.jsdt.ui.actions.ProjectActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-class PackageExplorerActionGroup extends CompositeActionGroup {
-
- private PackageExplorerPart fPart;
-
- private FrameList fFrameList;
- private GoIntoAction fZoomInAction;
- private BackAction fBackAction;
- private ForwardAction fForwardAction;
- private UpAction fUpAction;
- private GotoTypeAction fGotoTypeAction;
- private GotoPackageAction fGotoPackageAction;
- private GotoResourceAction fGotoResourceAction;
- private CollapseAllAction fCollapseAllAction;
- private SelectAllAction fSelectAllAction;
-
-
- private ToggleLinkingAction fToggleLinkingAction;
-
- private RefactorActionGroup fRefactorActionGroup;
- private NavigateActionGroup fNavigateActionGroup;
- private ViewActionGroup fViewActionGroup;
-
- private CustomFiltersActionGroup fCustomFiltersActionGroup;
-
- private IAction fGotoRequiredProjectAction;
-
- private ProjectActionGroup fProjectActionGroup;
-
- public PackageExplorerActionGroup(PackageExplorerPart part) {
- super();
- fPart= part;
- TreeViewer viewer= part.getTreeViewer();
-
- IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doWorkingSetChanged(event);
- }
- };
-
- IWorkbenchPartSite site = fPart.getSite();
- setGroups(new ActionGroup[] {
- new NewWizardsActionGroup(site),
- fNavigateActionGroup= new NavigateActionGroup(fPart),
- new CCPActionGroup(fPart),
- /*new GenerateBuildPathActionGroup(fPart),*/
- new GenerateActionGroup(fPart),
- fRefactorActionGroup= new RefactorActionGroup(fPart),
- new ImportActionGroup(fPart),
- new BuildActionGroup(fPart),
- new JavaSearchActionGroup(fPart),
- fProjectActionGroup= new ProjectActionGroup(fPart),
- fViewActionGroup= new ViewActionGroup(fPart.getRootMode(), workingSetListener, site),
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(fPart, viewer),
- new LayoutActionGroup(fPart)
- });
-
-
- fViewActionGroup.fillFilters(viewer);
-
- PackagesFrameSource frameSource= new PackagesFrameSource(fPart);
- fFrameList= new FrameList(frameSource);
- frameSource.connectTo(fFrameList);
-
- fZoomInAction= new GoIntoAction(fFrameList);
- fBackAction= new BackAction(fFrameList);
- fForwardAction= new ForwardAction(fFrameList);
- fUpAction= new UpAction(fFrameList);
-
- fGotoTypeAction= new GotoTypeAction(fPart);
- fGotoPackageAction= new GotoPackageAction(fPart);
- fGotoResourceAction= new GotoResourceAction(fPart);
- fCollapseAllAction= new CollapseAllAction(fPart);
- fToggleLinkingAction = new ToggleLinkingAction(fPart);
- fGotoRequiredProjectAction= new GotoRequiredProjectAction(fPart);
- fSelectAllAction= new SelectAllAction(fPart.getTreeViewer());
- }
-
- public void dispose() {
- super.dispose();
- }
-
-
- //---- Persistent state -----------------------------------------------------------------------
-
- /* package */ void restoreFilterAndSorterState(IMemento memento) {
- fViewActionGroup.restoreState(memento);
- fCustomFiltersActionGroup.restoreState(memento);
- }
-
- /* package */ void saveFilterAndSorterState(IMemento memento) {
- fViewActionGroup.saveState(memento);
- fCustomFiltersActionGroup.saveState(memento);
- }
-
- //---- Action Bars ----------------------------------------------------------------------------
-
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- setGlobalActionHandlers(actionBars);
- fillToolBar(actionBars.getToolBarManager());
- fillViewMenu(actionBars.getMenuManager());
- }
-
- /* package */ void updateActionBars(IActionBars actionBars) {
- actionBars.getToolBarManager().removeAll();
- actionBars.getMenuManager().removeAll();
- fillActionBars(actionBars);
- actionBars.updateActionBars();
- fZoomInAction.setEnabled(true);
- }
-
- private void setGlobalActionHandlers(IActionBars actionBars) {
- // Navigate Go Into and Go To actions.
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
- actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
- actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
- actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
- actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
-
- fRefactorActionGroup.retargetFileMenuActions(actionBars);
- }
-
- /* package */ void fillToolBar(IToolBarManager toolBar) {
- toolBar.add(fBackAction);
- toolBar.add(fForwardAction);
- toolBar.add(fUpAction);
-
- toolBar.add(new Separator());
- toolBar.add(fCollapseAllAction);
- toolBar.add(fToggleLinkingAction);
-
- }
-
- /* package */ void fillViewMenu(IMenuManager menu) {
- menu.add(new Separator());
- menu.add(fToggleLinkingAction);
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
- }
-
- //---- Context menu -------------------------------------------------------------------------
-
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection= (IStructuredSelection)getContext().getSelection();
- int size= selection.size();
- Object element= selection.getFirstElement();
-
- if (element instanceof JsGlobalScopeContainer.RequiredProjectWrapper)
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fGotoRequiredProjectAction);
-
- addGotoMenu(menu, element, size);
-
- addOpenNewWindowAction(menu, element);
-
- super.fillContextMenu(menu);
- }
-
- private void addGotoMenu(IMenuManager menu, Object element, int size) {
- boolean enabled= size == 1 && fPart.getTreeViewer().isExpandable(element) && (isGoIntoTarget(element) || element instanceof IContainer);
- fZoomInAction.setEnabled(enabled);
- if (enabled)
- menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction);
- }
-
- private boolean isGoIntoTarget(Object element) {
- if (element == null)
- return false;
- if (element instanceof IJavaScriptElement) {
- int type= ((IJavaScriptElement)element).getElementType();
- return type == IJavaScriptElement.JAVASCRIPT_PROJECT ||
- type == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT ||
- type == IJavaScriptElement.PACKAGE_FRAGMENT;
- }
- if (element instanceof IWorkingSet) {
- return true;
- }
- return false;
- }
-
- private void addOpenNewWindowAction(IMenuManager menu, Object element) {
- if (element instanceof IJavaScriptElement) {
- element= ((IJavaScriptElement)element).getResource();
-
- }
- // fix for 64890 Package explorer out of sync when open/closing projects [package explorer] 64890
- if (element instanceof IProject && !((IProject)element).isOpen())
- return;
-
- if (!(element instanceof IContainer))
- return;
- menu.appendToGroup(
- IContextMenuConstants.GROUP_OPEN,
- new OpenInNewWindowAction(fPart.getSite().getWorkbenchWindow(), (IContainer)element));
- }
-
- //---- Key board and mouse handling ------------------------------------------------------------
-
- /* package*/ void handleDoubleClick(DoubleClickEvent event) {
- TreeViewer viewer= fPart.getTreeViewer();
- IStructuredSelection selection= (IStructuredSelection)event.getSelection();
- Object element= selection.getFirstElement();
- if (viewer.isExpandable(element)) {
- if (doubleClickGoesInto()) {
- // don't zoom into compilation units and class files
- if (element instanceof IJavaScriptUnit || element instanceof IClassFile)
- return;
- if (element instanceof IOpenable || element instanceof IContainer || element instanceof IWorkingSet) {
- fZoomInAction.run();
- }
- } else {
- IAction openAction= fNavigateActionGroup.getOpenAction();
- if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
- return;
- if (selection instanceof ITreeSelection) {
- TreePath[] paths= ((ITreeSelection)selection).getPathsFor(element);
- for (int i= 0; i < paths.length; i++) {
- viewer.setExpandedState(paths[i], !viewer.getExpandedState(paths[i]));
- }
- } else {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- }
- } else if (element instanceof IProject && !((IProject) element).isOpen()) {
- OpenProjectAction openProjectAction= fProjectActionGroup.getOpenProjectAction();
- if (openProjectAction.isEnabled()) {
- openProjectAction.run();
- }
- }
- }
-
- /* package */ void handleOpen(OpenEvent event) {
- IAction openAction= fNavigateActionGroup.getOpenAction();
- if (openAction != null && openAction.isEnabled()) {
- openAction.run();
- return;
- }
- }
-
- /* package */ void handleKeyEvent(KeyEvent event) {
- if (event.stateMask != 0)
- return;
-
- if (event.keyCode == SWT.BS) {
- if (fUpAction != null && fUpAction.isEnabled()) {
- fUpAction.run();
- event.doit= false;
- }
- }
- }
-
- private void doWorkingSetChanged(PropertyChangeEvent event) {
- if (ViewActionGroup.MODE_CHANGED.equals(event.getProperty())) {
- fPart.rootModeChanged(((Integer)event.getNewValue()).intValue());
- Object oldInput= null;
- Object newInput= null;
- if (fPart.showProjects()) {
- oldInput= fPart.getWorkingSetModel();
- newInput= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- } else if (fPart.showWorkingSets()) {
- oldInput= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- newInput= fPart.getWorkingSetModel();
- }
- if (oldInput != null && newInput != null) {
- Frame frame;
- for (int i= 0; (frame= fFrameList.getFrame(i)) != null; i++) {
- if (frame instanceof TreeFrame) {
- TreeFrame treeFrame= (TreeFrame)frame;
- if (oldInput.equals(treeFrame.getInput()))
- treeFrame.setInput(newInput);
- }
- }
- }
- } else {
- IWorkingSet workingSet= (IWorkingSet) event.getNewValue();
-
- String workingSetLabel= null;
- if (workingSet != null)
- workingSetLabel= workingSet.getLabel();
- fPart.setWorkingSetLabel(workingSetLabel);
- fPart.updateTitle();
-
- String property= event.getProperty();
- if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- TreeViewer viewer= fPart.getTreeViewer();
- viewer.getControl().setRedraw(false);
- viewer.refresh();
- viewer.getControl().setRedraw(true);
- }
- }
- }
-
- private boolean doubleClickGoesInto() {
- return PreferenceConstants.DOUBLE_CLICK_GOES_INTO.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.DOUBLE_CLICK));
- }
-
- public FrameAction getUpAction() {
- return fUpAction;
- }
-
- public FrameAction getBackAction() {
- return fBackAction;
- }
- public FrameAction getForwardAction() {
- return fForwardAction;
- }
-
- public ViewActionGroup getWorkingSetActionGroup() {
- return fViewActionGroup;
- }
-
- public CustomFiltersActionGroup getCustomFilterActionGroup() {
- return fCustomFiltersActionGroup;
- }
-
- public FrameList getFrameList() {
- return fFrameList;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerContentProvider.java
deleted file mode 100644
index 28b6ffa5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerContentProvider.java
+++ /dev/null
@@ -1,1191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-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.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.navigator.ContainerFolder;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetModel;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.ProjectLibraryRoot;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-/**
- * Content provider for the PackageExplorer.
- *
- * <p>
- * Since 2.1 this content provider can provide the children for flat or hierarchical
- * layout.
- * </p>
- *
- * @see org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider
- */
-public class PackageExplorerContentProvider extends StandardJavaScriptElementContentProvider implements ITreeContentProvider, IElementChangedListener, IPropertyChangeListener {
-
- protected static final int ORIGINAL= 0;
- protected static final int PARENT= 1 << 0;
- protected static final int GRANT_PARENT= 1 << 1;
- protected static final int PROJECT= 1 << 2;
-
- private TreeViewer fViewer;
- private Object fInput;
- private boolean fIsFlatLayout;
- private boolean fShowLibrariesNode;
- private boolean fFoldPackages;
-
- private Collection fPendingUpdates;
-
- private UIJob fUpdateJob;
-
- /**
- * Creates a new content provider for Java elements.
- * @param provideMembers if set, members of compilation units and class files are shown
- */
- public PackageExplorerContentProvider(boolean provideMembers) {
- super(provideMembers);
- fShowLibrariesNode= false;
- fIsFlatLayout= false;
- fFoldPackages= arePackagesFoldedInHierarchicalLayout();
- fPendingUpdates= null;
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-
- fUpdateJob= null;
- }
-
- private boolean arePackagesFoldedInHierarchicalLayout(){
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER);
- }
-
- protected Object getViewerInput() {
- return fInput;
- }
-
- /* (non-Javadoc)
- * Method declared on IElementChangedListener.
- */
- public void elementChanged(final ElementChangedEvent event) {
- final ArrayList runnables= new ArrayList();
- try {
- // 58952 delete project does not update Package Explorer [package explorer]
- // if the input to the viewer is deleted then refresh to avoid the display of stale elements
- if (inputDeleted(runnables))
- return;
-
- processDelta(event.getDelta(), runnables);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- } finally {
- executeRunnables(runnables);
- }
- }
-
- protected final void executeRunnables(final Collection runnables) {
-
- // now post all collected runnables
- final Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- //Are we in the UIThread? If so spin it until we are done
- if ((ctrl.getDisplay().getThread() == Thread.currentThread()) && !fViewer.isBusy()) {
- runUpdates(runnables);
- } else {
- synchronized (this) {
- if (fPendingUpdates == null) {
- fPendingUpdates= runnables;
- } else {
- fPendingUpdates.addAll(runnables);
- }
- }
- postAsyncUpdate(ctrl.getDisplay());
- }
- }
- }
-
- private void postAsyncUpdate(final Display display) {
- if (fUpdateJob == null) {
- fUpdateJob= new UIJob(display, PackagesMessages.PackageExplorerContentProvider_update_job_description) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- TreeViewer viewer= fViewer;
- if (viewer != null && viewer.isBusy()) {
- schedule(100); // reschedule when viewer is busy: bug 184991
- } else {
- runPendingUpdates();
- }
- return Status.OK_STATUS;
- }
- };
- fUpdateJob.setSystem(true);
- }
- fUpdateJob.schedule();
- }
-
- /**
- * Run all of the runnables that are the widget updates. Must be called in the display thread.
- */
- public void runPendingUpdates() {
- Collection pendingUpdates;
- synchronized (this) {
- pendingUpdates= fPendingUpdates;
- fPendingUpdates= null;
- }
- if (pendingUpdates != null && fViewer != null) {
- Control control = fViewer.getControl();
- if (control != null && !control.isDisposed()) {
- runUpdates(pendingUpdates);
- }
- }
- }
-
- private void runUpdates(Collection runnables) {
- Iterator runnableIterator = runnables.iterator();
- while (runnableIterator.hasNext()){
- ((Runnable) runnableIterator.next()).run();
- }
- }
-
-
- private boolean inputDeleted(Collection runnables) {
- if (fInput == null)
- return false;
- if ((fInput instanceof IJavaScriptElement) && ((IJavaScriptElement) fInput).exists())
- return false;
- if ((fInput instanceof IResource) && ((IResource) fInput).exists())
- return false;
- if (fInput instanceof WorkingSetModel)
- return false;
- if (fInput instanceof IWorkingSet) // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=156239
- return false;
- postRefresh(fInput, ORIGINAL, fInput, runnables);
- return true;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- super.dispose();
- JavaScriptCore.removeElementChangedListener(this);
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider#getPackageFragmentRootContent(org.eclipse.wst.jsdt.core.IPackageFragmentRoot)
- */
- protected Object[] getPackageFragmentRootContent(IPackageFragmentRoot root) throws JavaScriptModelException {
- if (fIsFlatLayout) {
- return super.getPackageFragmentRootContent(root);
- }
-
- // hierarchical package mode
- ArrayList result= new ArrayList();
- getHierarchicalPackageChildren(root, null, result);
- if (!isProjectPackageFragmentRoot(root)) {
- Object[] nonJavaResources= root.getNonJavaScriptResources();
- for (int i= 0; i < nonJavaResources.length; i++) {
- result.add(nonJavaResources[i]);
- }
- }
- return result.toArray();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider#getPackageContent(org.eclipse.wst.jsdt.core.IPackageFragment)
- */
- protected Object[] getPackageContent(IPackageFragment fragment) throws JavaScriptModelException {
- if (fIsFlatLayout) {
- return super.getPackageContent(fragment);
- }
-
- // hierarchical package mode
- ArrayList result= new ArrayList();
-
- getHierarchicalPackageChildren((IPackageFragmentRoot) fragment.getParent(), fragment, result);
- Object[] nonPackages= super.getPackageContent(fragment);
- if (result.isEmpty())
- return nonPackages;
- for (int i= 0; i < nonPackages.length; i++) {
- result.add(nonPackages[i]);
- }
- return result.toArray();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider#getFolderContent(org.eclipse.core.resources.IFolder)
- */
- protected Object[] getFolderContent(IFolder folder) throws CoreException {
- if (fIsFlatLayout) {
- return super.getFolderContent(folder);
- }
-
- // hierarchical package mode
- ArrayList result= new ArrayList();
-
- getHierarchicalPackagesInFolder(folder, result);
- Object[] others= super.getFolderContent(folder);
- if (result.isEmpty())
- return others;
- for (int i= 0; i < others.length; i++) {
- result.add(others[i]);
- }
- return result.toArray();
- }
-
-
- public Object[] getChildren(Object parentElement) {
- try {
- if (parentElement instanceof IJavaScriptModel)
- return concatenate(getJavaProjects((IJavaScriptModel)parentElement), getNonJavaProjects((IJavaScriptModel)parentElement));
-
- if(parentElement instanceof ContainerFolder) {
- return getContainerPackageFragmentRoots((PackageFragmentRootContainer)((ContainerFolder)parentElement).getParentObject());
- }
- if (parentElement instanceof PackageFragmentRootContainer)
- return getContainerPackageFragmentRoots((PackageFragmentRootContainer)parentElement, true);
-
- if(parentElement instanceof ProjectLibraryRoot) {
- return ((ProjectLibraryRoot)parentElement).getChildren();
- }
-
- if (parentElement instanceof IProject) {
- IProject project= (IProject) parentElement;
- if (project.isAccessible())
- return project.members();
- return NO_CHILDREN;
- }
- if(parentElement instanceof IPackageFragmentRoot && ((IPackageFragmentRoot)parentElement).isVirtual()) {
- return getLibraryChildren((IPackageFragmentRoot)parentElement);
- }
-
- return super.getChildren(parentElement);
- } catch (CoreException e) {
- return NO_CHILDREN;
- }
- }
-
-
-private Object[] getLibraryChildren(IPackageFragmentRoot container) {
-
-
- Object[] children=null;
- try {
- children = container.getChildren();
- } catch (JavaScriptModelException ex1) {
- // TODO Auto-generated catch block
- ex1.printStackTrace();
- }
- if(children==null) return null;
- ArrayList allChildren = new ArrayList();
-
- boolean unique = false;
- try {
- while(!unique && children!=null && children.length>0) {
- for(int i = 0;i<children.length;i++) {
- String display1 = ((IJavaScriptElement)children[0]).getDisplayName();
- String display2 = ((IJavaScriptElement)children[i]).getDisplayName();
- if(!( (display1==display2) || (display1!=null && display1.compareTo(display2)==0))){
- allChildren.addAll(Arrays.asList(children));
- unique=true;
- break;
- }
- }
- ArrayList more = new ArrayList();
- for(int i = 0;!unique && i<children.length;i++) {
- if(children[i] instanceof IPackageFragment) {
- more.addAll(Arrays.asList(((IPackageFragment)children[i]).getChildren()));
- }else if(children[i] instanceof IPackageFragmentRoot) {
- more.addAll(Arrays.asList(((IPackageFragmentRoot)children[i]).getChildren()));
- }else if(children[i] instanceof IClassFile) {
- more.addAll(Arrays.asList( filter(((IClassFile)children[i]).getChildren())) );
- }else if(children[i] instanceof IJavaScriptUnit) {
- more.addAll(Arrays.asList( filter(((IJavaScriptUnit)children[i]).getChildren())) );
- }else {
- /* bottomed out, now at javaElement level */
- unique=true;
- break;
- }
-
- }
- if(!unique) children = more.toArray();
- }
- } catch (JavaScriptModelException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
-
-
- return allChildren.toArray();
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider#getPackageFragmentRoots(org.eclipse.wst.jsdt.core.IJavaScriptProject)
- */
- protected Object[] getPackageFragmentRoots(IJavaScriptProject project) throws JavaScriptModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- List result= new ArrayList();
-
- boolean addJARContainer= false;
- ArrayList projectPackageFragmentRoots = new ArrayList();
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- for (int i= 0; i < roots.length; i++) {
- IPackageFragmentRoot root= roots[i];
- IIncludePathEntry classpathEntry= root.getRawIncludepathEntry();
-
- IIncludePathAttribute[] attribs = classpathEntry.getExtraAttributes();
- boolean shouldHide = false;
- for(int p = 0;p<attribs.length;p++){
- if(attribs[p]==IIncludePathAttribute.HIDE) shouldHide = true;
- }
-
- int entryKind= classpathEntry.getEntryKind();
- if (entryKind == IIncludePathEntry.CPE_CONTAINER) {
- // all JsGlobalScopeContainers are added later
- } else if (fShowLibrariesNode && (entryKind != IIncludePathEntry.CPE_SOURCE) && entryKind!=IIncludePathEntry.CPE_CONTAINER) {
- addJARContainer= true;
- projectPackageFragmentRoots.add(root);
- } else {
- if (isProjectPackageFragmentRoot(root)) {
- // filter out package fragments that correspond to projects and
- // replace them with the package fragments directly
- Object[] fragments= getPackageFragmentRootContent(root);
- for (int j= 0; j < fragments.length; j++) {
- result.add(fragments[j]);
- }
- } else if(!shouldHide){
- result.add(root);
- }
- }
- }
-
- if (addJARContainer) {
- projectPackageFragmentRoots.add(new LibraryContainer(project));
- }
-
- // separate loop to make sure all containers are on the classpath
- IIncludePathEntry[] rawClasspath= project.getRawIncludepath();
- for (int i= 0; i < rawClasspath.length; i++) {
- IIncludePathEntry classpathEntry= rawClasspath[i];
- if (classpathEntry.getEntryKind() == IIncludePathEntry.CPE_CONTAINER) {
- projectPackageFragmentRoots.add(new JsGlobalScopeContainer(project, classpathEntry));
- }
- }
- Object[] resources= project.getNonJavaScriptResources();
- for (int i= 0; i < resources.length; i++) {
- result.add(resources[i]);
- }
- ProjectLibraryRoot projectLibs = new ProjectLibraryRoot(project);
- result.add(0,projectLibs);
- return result.toArray();
- }
-// private Object[] getContainerPackageFragmentRoots3(PackageFragmentRootContainer container) {
-// Object[] children = container.getChildren();
-// if(children==null) return null;
-// ArrayList allChildren = new ArrayList();
-// for(int i=0;i<children.length;i++) {
-// try {
-// allChildren.addAll(Arrays.asList(((IPackageFragmentRoot)children[i]).getChildren()));
-// } catch (JavaScriptModelException ex) {
-//
-// }
-// }
-// return allChildren.toArray();
-// }
-//
- private Object[] getContainerPackageFragmentRoots(PackageFragmentRootContainer container) {
- return getContainerPackageFragmentRoots(container, false);
- }
- private Object[] getContainerPackageFragmentRoots(PackageFragmentRootContainer container, boolean createFolder) {
-
- Object[] children = container.getChildren();
- if(children==null) return new Object[0];
-
- ArrayList allChildren = new ArrayList();
- ArrayList expanded = new ArrayList();
- expanded.addAll(Arrays.asList(children));
-
-
- if(expanded==null || expanded.size() < 1) return new Object[0];
-
- Object next = expanded.remove(0);
-
- while(next!=null) {
- try {
- if(next instanceof IPackageFragment) {
- expanded.addAll(Arrays.asList(((IPackageFragment)next).getChildren()));
- }else if(next instanceof IPackageFragmentRoot) {
- expanded.addAll(Arrays.asList(((IPackageFragmentRoot)next).getChildren()));
- }else if(next instanceof IClassFile) {
- List newChildren = Arrays.asList( filter(((IClassFile)next).getChildren() ));
- allChildren.removeAll(newChildren);
- allChildren.addAll(newChildren);
- }else if(next instanceof IJavaScriptUnit) {
- List newChildren = Arrays.asList( filter(((IJavaScriptUnit)next).getChildren()));
- allChildren.removeAll(newChildren);
- allChildren.addAll(newChildren);
-
- }
- } catch (JavaScriptModelException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
-
- if(expanded.size()>0)
- next = expanded.remove(0);
- else
- next = null;
-
- }
-
- return allChildren.toArray();
-
-
-
- }
- private Object[] getContainerPackageFragmentRootsDeprc(PackageFragmentRootContainer container, boolean createFolder) {
-
-
- if(container!=null) {
-
- Object[] children = container.getChildren();
- if(children==null) return null;
- ArrayList allChildren = new ArrayList();
-
- boolean unique = false;
-
- while(!unique && children!=null && children.length>0) {
- String display1=null;
- for(int i = 0;i<children.length;i++) {
- display1 = ((IJavaScriptElement)children[0]).getDisplayName();
- String display2 = ((IJavaScriptElement)children[i]).getDisplayName();
- if(!( (display1==display2) || (display1!=null && display1.compareTo(display2)==0))){
- allChildren.addAll(Arrays.asList(children));
- unique=true;
- break;
- }
- }
- if(!unique && createFolder) {
- ContainerFolder folder = new ContainerFolder(display1, container);
- return new Object[] {folder};
- }
- ArrayList more = new ArrayList();
- for(int i = 0;!unique && i<children.length;i++) {
-
- try {
- if(children[i] instanceof IPackageFragment) {
- more.addAll(Arrays.asList(((IPackageFragment)children[i]).getChildren()));
- }else if(children[i] instanceof IPackageFragmentRoot) {
- more.addAll(Arrays.asList(((IPackageFragmentRoot)children[i]).getChildren()));
- }else if(children[i] instanceof IClassFile) {
- more.addAll(Arrays.asList( filter(((IClassFile)children[i]).getChildren())) );
- }else if(children[i] instanceof IJavaScriptUnit) {
- more.addAll(Arrays.asList( filter(((IJavaScriptUnit)children[i]).getChildren())) );
- }else {
- /* bottomed out, now at javaElement level */
- unique=true;
- break;
- }
- } catch (JavaScriptModelException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
-
- }
- if(!unique) children = more.toArray();
- }
-
-
-
- return allChildren.toArray();
- }else {
-
-
- Object[] children = container.getChildren();
- if(children==null) return null;
- ArrayList allChildren = new ArrayList();
- for(int i=0;i<children.length;i++) {
- try {
- allChildren.addAll(Arrays.asList(((IPackageFragmentRoot)children[i]).getChildren()));
- } catch (JavaScriptModelException ex) {
-
- }
- }
- return allChildren.toArray();
- }
- }
-
- private Object[] getNonJavaProjects(IJavaScriptModel model) throws JavaScriptModelException {
- return model.getNonJavaScriptResources();
- }
-
- protected Object internalGetParent(Object element) {
- if (!fIsFlatLayout && element instanceof IPackageFragment) {
- return getHierarchicalPackageParent((IPackageFragment) element);
- } else if (element instanceof IPackageFragmentRoot) {
- // since we insert logical package containers we have to fix
- // up the parent for package fragment roots so that they refer
- // to the container and containers refer to the project
- IPackageFragmentRoot root= (IPackageFragmentRoot)element;
-
- try {
- IIncludePathEntry entry= root.getRawIncludepathEntry();
- int entryKind= entry.getEntryKind();
- if (entryKind == IIncludePathEntry.CPE_CONTAINER) {
- return new JsGlobalScopeContainer(root.getJavaScriptProject(), entry);
- } else if (fShowLibrariesNode && (entryKind == IIncludePathEntry.CPE_LIBRARY || entryKind == IIncludePathEntry.CPE_VARIABLE)) {
- return new LibraryContainer(root.getJavaScriptProject());
- }
- } catch (JavaScriptModelException e) {
- // fall through
- }
- } else if (element instanceof PackageFragmentRootContainer) {
- return ((PackageFragmentRootContainer)element).getJavaProject();
- }
- return super.internalGetParent(element);
- }
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
- fViewer= (TreeViewer)viewer;
- if (oldInput == null && newInput != null) {
- JavaScriptCore.addElementChangedListener(this);
- } else if (oldInput != null && newInput == null) {
- JavaScriptCore.removeElementChangedListener(this);
- }
- fInput= newInput;
- }
-
- // hierarchical packages
- /**
- * Returns the hierarchical packages inside a given fragment or root.
- * @param parent The parent package fragment root
- * @param fragment The package to get the children for or 'null' to get the children of the root.
- * @param result Collection where the resulting elements are added
- * @throws JavaScriptModelException
- */
- private void getHierarchicalPackageChildren(IPackageFragmentRoot parent, IPackageFragment fragment, Collection result) throws JavaScriptModelException {
- IJavaScriptElement[] children= parent.getChildren();
- String prefix= fragment != null ? fragment.getElementName() + '/' : ""; //$NON-NLS-1$
- if (prefix.length()==1)
- prefix=""; //$NON-NLS-1$
- int prefixLen= prefix.length();
- for (int i= 0; i < children.length; i++) {
- IPackageFragment curr= (IPackageFragment) children[i];
- if (fragment==null)
- {
- if (curr.isDefaultPackage())
- result.add(curr);
- }
- else
- {
- String name= curr.getElementName();
- if (name.startsWith(prefix) && name.length() > prefixLen && name.indexOf('/', prefixLen) == -1) {
- if (fFoldPackages) {
- curr= getFolded(children, curr);
- }
- result.add(curr);
- }
- }
-
- }
- }
-
- /**
- * Returns the hierarchical packages inside a given folder.
- * @param folder The parent folder
- * @param result Collection where the resulting elements are added
- * @throws CoreException thrown when elements could not be accessed
- */
- private void getHierarchicalPackagesInFolder(IFolder folder, Collection result) throws CoreException {
- IResource[] resources= folder.members();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (resource instanceof IFolder) {
- IFolder curr= (IFolder) resource;
- IJavaScriptElement element= JavaScriptCore.create(curr);
- if (element instanceof IPackageFragment) {
- if (element.exists()) {
- if (fFoldPackages) {
- IPackageFragment fragment= (IPackageFragment) element;
- IPackageFragmentRoot root= (IPackageFragmentRoot) fragment.getParent();
- element= getFolded(root.getChildren(), fragment);
- }
- result.add(element);
- }
- }
- }
- }
- }
-
- public Object getHierarchicalPackageParent(IPackageFragment child) {
- String name= child.getElementName();
- IPackageFragmentRoot parent= (IPackageFragmentRoot) child.getParent();
- int index= name.lastIndexOf('/');
- if (index != -1) {
- String realParentName= name.substring(0, index);
- IPackageFragment element= parent.getPackageFragment(realParentName);
- if (element.exists()) {
- try {
- if (fFoldPackages && isEmpty(element) && findSinglePackageChild(element, parent.getChildren()) != null) {
- return getHierarchicalPackageParent(element);
- }
- } catch (JavaScriptModelException e) {
- // ignore
- }
- return element;
- } else { // bug 65240
- IResource resource= element.getResource();
- if (resource != null) {
- return resource;
- }
- }
- }
- if (parent.getResource() instanceof IProject) {
- return parent.getJavaScriptProject();
- }
- return parent;
- }
-
- private static IPackageFragment getFolded(IJavaScriptElement[] children, IPackageFragment pack) throws JavaScriptModelException {
- while (isEmpty(pack)) {
- IPackageFragment collapsed= findSinglePackageChild(pack, children);
- if (collapsed == null) {
- return pack;
- }
- pack= collapsed;
- }
- return pack;
- }
-
- private static boolean isEmpty(IPackageFragment fragment) throws JavaScriptModelException {
- return !fragment.containsJavaResources() && fragment.getNonJavaScriptResources().length == 0;
- }
-
- private static IPackageFragment findSinglePackageChild(IPackageFragment fragment, IJavaScriptElement[] children) {
- String prefix= fragment.getElementName() + '/';
- int prefixLen= prefix.length();
- IPackageFragment found= null;
- for (int i= 0; i < children.length; i++) {
- IJavaScriptElement element= children[i];
- String name= element.getElementName();
- if (name.startsWith(prefix) && name.length() > prefixLen && name.indexOf('/', prefixLen) == -1) {
- if (found == null) {
- found= (IPackageFragment) element;
- } else {
- return null;
- }
- }
- }
- return found;
- }
-
- // ------ delta processing ------
-
- /**
- * Processes a delta recursively. When more than two children are affected the
- * tree is fully refreshed starting at this node.
- *
- * @param delta the delta to process
- * @param runnables the resulting view changes as runnables (type {@link Runnable})
- * @return true is returned if the conclusion is to refresh a parent of an element. In that case no siblings need
- * to be processed
- * @throws JavaScriptModelException thrown when the access to an element failed
- */
- private boolean processDelta(IJavaScriptElementDelta delta, Collection runnables) throws JavaScriptModelException {
-
- int kind= delta.getKind();
- int flags= delta.getFlags();
- IJavaScriptElement element= delta.getElement();
- int elementType= element.getElementType();
-
-
- if (elementType != IJavaScriptElement.JAVASCRIPT_MODEL && elementType != IJavaScriptElement.JAVASCRIPT_PROJECT) {
- IJavaScriptProject proj= element.getJavaScriptProject();
- if (proj == null || !proj.getProject().isOpen()) // TODO: Not needed if parent already did the 'open' check!
- return false;
- }
-
- if (!fIsFlatLayout && elementType == IJavaScriptElement.PACKAGE_FRAGMENT) {
- if (kind == IJavaScriptElementDelta.REMOVED) {
- final Object parent = getHierarchicalPackageParent((IPackageFragment) element);
- if (parent instanceof IPackageFragmentRoot) {
- postRemove(element, runnables);
- return false;
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT, element, runnables);
- return true;
- }
- } else if (kind == IJavaScriptElementDelta.ADDED) {
- final Object parent = getHierarchicalPackageParent((IPackageFragment) element);
- if (parent instanceof IPackageFragmentRoot) {
- postAdd(parent, element, runnables);
- return false;
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT, element, runnables);
- return true;
- }
- }
- handleAffectedChildren(delta, element, runnables);
- return false;
- }
-
- if (elementType == IJavaScriptElement.JAVASCRIPT_UNIT) {
- IJavaScriptUnit cu= (IJavaScriptUnit) element;
- if (!JavaModelUtil.isPrimary(cu)) {
- return false;
- }
-
- if (!getProvideMembers() && cu.isWorkingCopy() && kind == IJavaScriptElementDelta.CHANGED) {
- return false;
- }
-
- if ((kind == IJavaScriptElementDelta.CHANGED) && !isStructuralCUChange(flags)) {
- return false; // test moved ahead
- }
-
- if (!isOnClassPath(cu)) { // TODO: isOnClassPath expensive! Should be put after all cheap tests
- return false;
- }
-
- }
-
- if (elementType == IJavaScriptElement.JAVASCRIPT_PROJECT) {
- // handle open and closing of a project
- if ((flags & (IJavaScriptElementDelta.F_CLOSED | IJavaScriptElementDelta.F_OPENED)) != 0) {
- postRefresh(element, ORIGINAL, element, runnables);
- return false;
- }
- // if the raw class path has changed we refresh the entire project
- if ((flags & IJavaScriptElementDelta.F_INCLUDEPATH_CHANGED) != 0) {
- postRefresh(element, ORIGINAL, element, runnables);
- return false;
- }
- // if added it could be that the corresponding IProject is already shown. Remove it first.
- // bug 184296
- if (kind == IJavaScriptElementDelta.ADDED) {
- postRemove(element.getResource(), runnables);
- postAdd(element.getParent(), element, runnables);
- return false;
- }
- }
-
- if (kind == IJavaScriptElementDelta.REMOVED) {
- Object parent= internalGetParent(element);
- if (element instanceof IPackageFragment) {
- // refresh package fragment root to allow filtering empty (parent) packages: bug 72923
- if (fViewer.testFindItem(parent) != null)
- postRefresh(parent, PARENT, element, runnables);
- return true;
- }
-
- postRemove(element, runnables);
- if (parent instanceof IPackageFragment)
- postUpdateIcon((IPackageFragment)parent, runnables);
- // we are filtering out empty subpackages, so we
- // a package becomes empty we remove it from the viewer.
- if (isPackageFragmentEmpty(element.getParent())) {
- if (fViewer.testFindItem(parent) != null)
- postRefresh(internalGetParent(parent), GRANT_PARENT, element, runnables);
- return true;
- }
- return false;
- }
-
- if (kind == IJavaScriptElementDelta.ADDED) {
- Object parent= internalGetParent(element);
- // we are filtering out empty subpackages, so we
- // have to handle additions to them specially.
- if (parent instanceof IPackageFragment) {
- Object grandparent= internalGetParent(parent);
- // 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View
- // avoid posting a refresh to an invisible parent
- if (parent.equals(fInput)) {
- postRefresh(parent, PARENT, element, runnables);
- } else {
- // refresh from grandparent if parent isn't visible yet
- if (fViewer.testFindItem(parent) == null)
- postRefresh(grandparent, GRANT_PARENT, element, runnables);
- else {
- postRefresh(parent, PARENT, element, runnables);
- }
- }
- return true;
- } else {
- postAdd(parent, element, runnables);
- }
- }
-
- if (elementType == IJavaScriptElement.JAVASCRIPT_UNIT) {
- if (kind == IJavaScriptElementDelta.CHANGED) {
- // isStructuralCUChange already performed above
- postRefresh(element, ORIGINAL, element, runnables);
- updateSelection(delta, runnables);
- }
- return false;
- }
- // no changes possible in class files
- if (elementType == IJavaScriptElement.CLASS_FILE)
- return false;
-
-
- if (elementType == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT) {
- // the contents of an external JAR has changed
- if ((flags & IJavaScriptElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) {
- postRefresh(element, ORIGINAL, element, runnables);
- return false;
- }
- // the source attachment of a JAR has changed
- if ((flags & (IJavaScriptElementDelta.F_SOURCEATTACHED | IJavaScriptElementDelta.F_SOURCEDETACHED)) != 0)
- postUpdateIcon(element, runnables);
-
- if (isClassPathChange(delta)) {
- // throw the towel and do a full refresh of the affected java project.
- postRefresh(element.getJavaScriptProject(), PROJECT, element, runnables);
- return true;
- }
- }
- handleAffectedChildren(delta, element, runnables);
- return false;
- }
-
- private static boolean isStructuralCUChange(int flags) {
- // No refresh on working copy creation (F_PRIMARY_WORKING_COPY)
- return ((flags & IJavaScriptElementDelta.F_CHILDREN) != 0) || ((flags & (IJavaScriptElementDelta.F_CONTENT | IJavaScriptElementDelta.F_FINE_GRAINED)) == IJavaScriptElementDelta.F_CONTENT);
- }
-
- /* package */ void handleAffectedChildren(IJavaScriptElementDelta delta, IJavaScriptElement element, Collection runnables) throws JavaScriptModelException {
- int count= 0;
-
- IResourceDelta[] resourceDeltas= delta.getResourceDeltas();
- if (resourceDeltas != null) {
- for (int i= 0; i < resourceDeltas.length; i++) {
- int kind= resourceDeltas[i].getKind();
- if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
- count++;
- }
- }
- }
- IJavaScriptElementDelta[] affectedChildren= delta.getAffectedChildren();
- for (int i= 0; i < affectedChildren.length; i++) {
- int kind= affectedChildren[i].getKind();
- if (kind == IJavaScriptElementDelta.ADDED || kind == IJavaScriptElementDelta.REMOVED) {
- count++;
- }
- }
-
- if (count > 1) {
- // more than one child changed, refresh from here downwards
- if (element instanceof IPackageFragment) {
- // a package fragment might become non empty refresh from the parent
- IJavaScriptElement parent= (IJavaScriptElement) internalGetParent(element);
- // 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View
- // avoid posting a refresh to an invisible parent
- if (element.equals(fInput)) {
- postRefresh(element, ORIGINAL, element, runnables);
- } else {
- postRefresh(parent, PARENT, element, runnables);
- }
- } else if (element instanceof IPackageFragmentRoot) {
- Object toRefresh= internalGetParent(element);
- postRefresh(toRefresh, ORIGINAL, toRefresh, runnables);
- } else {
- postRefresh(element, ORIGINAL, element, runnables);
- }
- return;
- }
- if (resourceDeltas != null) {
- for (int i= 0; i < resourceDeltas.length; i++) {
- if (processResourceDelta(resourceDeltas[i], element, runnables)) {
- return; // early return, element got refreshed
- }
- }
- }
- for (int i= 0; i < affectedChildren.length; i++) {
- if (processDelta(affectedChildren[i], runnables)) {
- return; // early return, element got refreshed
- }
- }
- }
-
- protected void processAffectedChildren(IJavaScriptElementDelta[] affectedChildren, Collection runnables) throws JavaScriptModelException {
- for (int i= 0; i < affectedChildren.length; i++) {
- processDelta(affectedChildren[i], runnables);
- }
- }
-
- private boolean isOnClassPath(IJavaScriptUnit element) {
- IJavaScriptProject project= element.getJavaScriptProject();
- if (project == null || !project.exists())
- return false;
- return project.isOnIncludepath(element);
- }
-
- /**
- * Updates the selection. It finds newly added elements
- * and selects them.
- * @param delta the delta to process
- * @param runnables the resulting view changes as runnables (type {@link Runnable})
- */
- private void updateSelection(IJavaScriptElementDelta delta, Collection runnables) {
- final IJavaScriptElement addedElement= findAddedElement(delta);
- if (addedElement != null) {
- final StructuredSelection selection= new StructuredSelection(addedElement);
- runnables.add(new Runnable() {
- public void run() {
- // 19431
- // if the item is already visible then select it
- if (fViewer.testFindItem(addedElement) != null)
- fViewer.setSelection(selection);
- }
- });
- }
- }
-
- private IJavaScriptElement findAddedElement(IJavaScriptElementDelta delta) {
- if (delta.getKind() == IJavaScriptElementDelta.ADDED)
- return delta.getElement();
-
- IJavaScriptElementDelta[] affectedChildren= delta.getAffectedChildren();
- for (int i= 0; i < affectedChildren.length; i++)
- return findAddedElement(affectedChildren[i]);
-
- return null;
- }
-
- /**
- * Updates the package icon
- * @param element the element to update
- * @param runnables the resulting view changes as runnables (type {@link Runnable})
- */
- private void postUpdateIcon(final IJavaScriptElement element, Collection runnables) {
- runnables.add(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE});
- }
- });
- }
-
- /**
- * Process a resource delta.
- *
- * @param delta the delta to process
- * @param parent the parent
- * @param runnables the resulting view changes as runnables (type {@link Runnable})
- * @return true if the parent got refreshed
- */
- private boolean processResourceDelta(IResourceDelta delta, Object parent, Collection runnables) {
- int status= delta.getKind();
- int flags= delta.getFlags();
-
- IResource resource= delta.getResource();
- // filter out changes affecting the output folder
- if (resource == null)
- return false;
-
- // this could be optimized by handling all the added children in the parent
- if ((status & IResourceDelta.REMOVED) != 0) {
- if (parent instanceof IPackageFragment) {
- // refresh one level above to deal with empty package filtering properly
- postRefresh(internalGetParent(parent), PARENT, parent, runnables);
- return true;
- } else {
- postRemove(resource, runnables);
- return false;
- }
- }
- if ((status & IResourceDelta.ADDED) != 0) {
- if (parent instanceof IPackageFragment) {
- // refresh one level above to deal with empty package filtering properly
- postRefresh(internalGetParent(parent), PARENT, parent, runnables);
- return true;
- } else
- {
- postAdd(parent, resource, runnables);
- return false;
- }
- }
- if ((status & IResourceDelta.CHANGED) != 0) {
- if ((flags & IResourceDelta.TYPE) != 0) {
- postRefresh(parent, PARENT, resource, runnables);
- return true;
- }
- }
- // open/close state change of a project
- if ((flags & IResourceDelta.OPEN) != 0) {
- postProjectStateChanged(internalGetParent(parent), runnables);
- return true;
- }
- IResourceDelta[] resourceDeltas= delta.getAffectedChildren();
-
- int count= 0;
- for (int i= 0; i < resourceDeltas.length; i++) {
- int kind= resourceDeltas[i].getKind();
- if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
- count++;
- if (count > 1) {
- postRefresh(parent, PARENT, resource, runnables);
- return true;
- }
- }
- }
- for (int i= 0; i < resourceDeltas.length; i++) {
- if (processResourceDelta(resourceDeltas[i], resource, runnables)) {
- return false; // early return, element got refreshed
- }
- }
- return false;
- }
-
- public void setIsFlatLayout(boolean state) {
- fIsFlatLayout= state;
- }
-
- public void setShowLibrariesNode(boolean state) {
- fShowLibrariesNode= state;
- }
-
- private void postRefresh(Object root, int relation, Object affectedElement, Collection runnables) {
- // JFace doesn't refresh when object isn't part of the viewer
- // Therefore move the refresh start down to the viewer's input
- if (isParent(root, fInput))
- root= fInput;
- List toRefresh= new ArrayList(1);
- toRefresh.add(root);
- augmentElementToRefresh(toRefresh, relation, affectedElement);
- postRefresh(toRefresh, true, runnables);
- }
-
- /**
- * Can be implemented by subclasses to add additional elements to refresh
- *
- * @param toRefresh the elements to refresh
- * @param relation the relation to the affected element ({@link #GRANT_PARENT}, {@link #PARENT}, {@link #ORIGINAL}, {@link #PROJECT})
- * @param affectedElement the affected element
- */
- protected void augmentElementToRefresh(List toRefresh, int relation, Object affectedElement) {
- }
-
- private boolean isParent(Object root, Object child) {
- Object parent= getParent(child);
- if (parent == null)
- return false;
- if (parent.equals(root))
- return true;
- return isParent(root, parent);
- }
-
- protected void postRefresh(final List toRefresh, final boolean updateLabels, Collection runnables) {
- runnables.add(new Runnable() {
- public void run() {
- for (Iterator iter= toRefresh.iterator(); iter.hasNext();) {
- fViewer.refresh(iter.next(), updateLabels);
- }
- }
- });
- }
-
- protected void postAdd(final Object parent, final Object element, Collection runnables) {
- runnables.add(new Runnable() {
- public void run() {
- Widget[] items= fViewer.testFindItems(element);
- for (int i= 0; i < items.length; i++) {
- Widget item= items[i];
- if (item instanceof TreeItem && !item.isDisposed()) {
- TreeItem parentItem= ((TreeItem) item).getParentItem();
- if (parentItem != null && !parentItem.isDisposed() && parent.equals(parentItem.getData())) {
- return; // no add, element already added (most likely by a refresh)
- }
- }
- }
- fViewer.add(parent, element);
- }
- });
- }
-
- protected void postRemove(final Object element, Collection runnables) {
- runnables.add(new Runnable() {
- public void run() {
- fViewer.remove(element);
- }
- });
- }
-
- protected void postProjectStateChanged(final Object root, Collection runnables) {
- runnables.add(new Runnable() {
- public void run() {
- fViewer.refresh(root, true);
- // trigger a synthetic selection change so that action refresh their
- // enable state.
- fViewer.setSelection(fViewer.getSelection());
- }
- });
- }
-
-
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (arePackagesFoldedInHierarchicalLayout() != fFoldPackages){
- fFoldPackages= arePackagesFoldedInHierarchicalLayout();
- if (fViewer != null && !fViewer.getControl().isDisposed()) {
- fViewer.getControl().setRedraw(false);
- Object[] expandedObjects= fViewer.getExpandedElements();
- fViewer.refresh();
- fViewer.setExpandedElements(expandedObjects);
- fViewer.getControl().setRedraw(true);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerLabelProvider.java
deleted file mode 100644
index 7bb4195d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerLabelProvider.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.internal.ui.navigator.ContainerFolder;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Provides the labels for the Package Explorer.
- * <p>
- * It provides labels for the packages in hierarchical layout and in all
- * other cases delegates it to its super class.
- * </p>
- *
- */
-public class PackageExplorerLabelProvider extends AppearanceAwareLabelProvider {
-
- private PackageExplorerContentProvider fContentProvider;
- private Map fWorkingSetImages;
-
- private boolean fIsFlatLayout;
- private PackageExplorerProblemsDecorator fProblemDecorator;
-
- public PackageExplorerLabelProvider(PackageExplorerContentProvider cp) {
- super(DEFAULT_TEXTFLAGS | JavaScriptElementLabels.P_COMPRESSED | JavaScriptElementLabels.ALL_CATEGORY, DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS);
-
- fProblemDecorator= new PackageExplorerProblemsDecorator();
- addLabelDecorator(fProblemDecorator);
- Assert.isNotNull(cp);
- fContentProvider= cp;
- fWorkingSetImages= null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider#getRichTextLabel(java.lang.Object)
- */
- public ColoredString getRichTextLabel(Object element) {
- String text= getSpecificText(element);
- if (text != null) {
- return new ColoredString(decorateText(text, element));
- }
- return super.getRichTextLabel(element);
- }
-
- private String getSpecificText(Object element) {
- if (!fIsFlatLayout && element instanceof IPackageFragment) {
- IPackageFragment fragment = (IPackageFragment) element;
- Object parent= fContentProvider.getHierarchicalPackageParent(fragment);
- if (parent instanceof IPackageFragment) {
- return getNameDelta((IPackageFragment) parent, fragment);
- } else if (parent instanceof IFolder) { // bug 152735
- return getNameDelta((IFolder) parent, fragment);
- }
- } else if (element instanceof IWorkingSet) {
- return ((IWorkingSet) element).getLabel();
- }
- return null;
- }
-
- public String getText(Object element) {
- if(element instanceof ContainerFolder) {
- return ((ContainerFolder)element).toString();
- }
- String text= getSpecificText(element);
- if (text != null) {
- return decorateText(text, element);
- }
- text = super.getText(element);
- if(element instanceof IClassFile) {
- text = ((IClassFile)element).getPath().lastSegment();
- }else if (element instanceof IJavaScriptUnit) {
- text = ((IJavaScriptUnit)element).getPath().lastSegment();
- }
-
- return text;
-
- }
-
- private String getNameDelta(IPackageFragment parent, IPackageFragment fragment) {
- String prefix= parent.getElementName() + '/';
- String fullName= fragment.getElementName();
- if (fullName.startsWith(prefix)) {
- return fullName.substring(prefix.length());
- }
- return fullName;
- }
-
- private String getNameDelta(IFolder parent, IPackageFragment fragment) {
- IPath prefix= parent.getFullPath();
- IPath fullPath= fragment.getPath();
- if (prefix.isPrefixOf(fullPath)) {
- StringBuffer buf= new StringBuffer();
- for (int i= prefix.segmentCount(); i < fullPath.segmentCount(); i++) {
- if (buf.length() > 0)
- buf.append('.');
- buf.append(fullPath.segment(i));
- }
- return buf.toString();
- }
- return fragment.getElementName();
- }
-
- public Image getImage(Object element) {
-
- if(element instanceof ContainerFolder) {
- return super.getImage(((ContainerFolder)element).getParentObject());
- }
-
- if (element instanceof IWorkingSet) {
- ImageDescriptor image= ((IWorkingSet)element).getImageDescriptor();
- if (fWorkingSetImages == null) {
- fWorkingSetImages= new HashMap();
- }
-
- Image result= (Image) fWorkingSetImages.get(image);
- if (result == null) {
- result= image.createImage();
- fWorkingSetImages.put(image, result);
- }
- return decorateImage(result, element);
- }
- return super.getImage(element);
- }
-
- public void setIsFlatLayout(boolean state) {
- fIsFlatLayout= state;
- fProblemDecorator.setIsFlatLayout(state);
- }
-
- public void dispose() {
- if (fWorkingSetImages != null) {
- for (Iterator iter= fWorkingSetImages.values().iterator(); iter.hasNext();) {
- ((Image)iter.next()).dispose();
- }
- }
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java
deleted file mode 100644
index fc4bae90..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java
+++ /dev/null
@@ -1,1607 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-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.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.PerformanceStats;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.help.IContextProvider;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.IOpenListener;
-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.ITreeSelection;
-import org.eclipse.jface.viewers.ITreeViewerListener;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeExpansionEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-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.Item;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTarget;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.framelist.Frame;
-import org.eclipse.ui.views.framelist.FrameAction;
-import org.eclipse.ui.views.framelist.FrameList;
-import org.eclipse.ui.views.framelist.IFrameSource;
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dnd.DelegatingDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.ResourceTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.filters.OutputFolderFilter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.preferences.MembersOrderPreferenceCache;
-import org.eclipse.wst.jsdt.internal.ui.util.JavaUIHelp;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.FilterUpdater;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.ConfigureWorkingSetAction;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.ViewActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetModel;
-import org.eclipse.wst.jsdt.ui.IPackagesViewPart;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-import org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup;
-
-/**
- * The ViewPart for the ProjectExplorer. It listens to part activation events.
- * When selection linking with the editor is enabled the view selection tracks
- * the active editor page. Similarly when a resource is selected in the packages
- * view the corresponding editor is activated.
- */
-
-public class PackageExplorerPart extends ViewPart
- implements ISetSelectionTarget, IMenuListener,
- IShowInTarget,
- IPackagesViewPart, IPropertyChangeListener,
- IViewPartInputProvider {
-
- private static final String PERF_CREATE_PART_CONTROL= "org.eclipse.wst.jsdt.ui/perf/explorer/createPartControl"; //$NON-NLS-1$
- private static final String PERF_MAKE_ACTIONS= "org.eclipse.wst.jsdt.ui/perf/explorer/makeActions"; //$NON-NLS-1$
-
- private static final int HIERARCHICAL_LAYOUT= 0x1;
- private static final int FLAT_LAYOUT= 0x2;
-
- private final static String VIEW_ID= JavaScriptUI.ID_PACKAGES;
-
- // Persistence tags.
- private static final String TAG_LAYOUT= "layout"; //$NON-NLS-1$
- private static final String TAG_GROUP_LIBRARIES= "group_libraries"; //$NON-NLS-1$
- private static final String TAG_ROOT_MODE= "rootMode"; //$NON-NLS-1$
- private static final String TAG_LINK_EDITOR= "linkWithEditor"; //$NON-NLS-1$
- private static final String TAG_MEMENTO= "memento"; //$NON-NLS-1$
-
- private boolean fIsCurrentLayoutFlat = false; // true means flat, false means hierarchical
- private boolean fShowLibrariesNode;
- private boolean fLinkingEnabled;
-
- private int fRootMode;
- private WorkingSetModel fWorkingSetModel;
-
- private PackageExplorerLabelProvider fLabelProvider;
- private DecoratingJavaLabelProvider fDecoratingLabelProvider;
- private PackageExplorerContentProvider fContentProvider;
- private FilterUpdater fFilterUpdater;
-
- private PackageExplorerActionGroup fActionSet;
- private ProblemTreeViewer fViewer;
- private Menu fContextMenu;
-
- private IMemento fMemento;
-
- private ISelection fLastOpenSelection;
- private final ISelectionChangedListener fPostSelectionListener;
-
- private String fWorkingSetLabel;
- private IDialogSettings fDialogSettings;
-
-
- private IPartListener2 fLinkWithEditorListener= new IPartListener2() {
- public void partVisible(IWorkbenchPartReference partRef) {}
- public void partBroughtToTop(IWorkbenchPartReference partRef) {}
- public void partClosed(IWorkbenchPartReference partRef) {}
- public void partDeactivated(IWorkbenchPartReference partRef) {}
- public void partHidden(IWorkbenchPartReference partRef) {}
- public void partOpened(IWorkbenchPartReference partRef) {}
- public void partInputChanged(IWorkbenchPartReference partRef) {
- if (partRef instanceof IEditorReference) {
- editorActivated(((IEditorReference) partRef).getEditor(true));
- }
- }
-
- public void partActivated(IWorkbenchPartReference partRef) {
- if (partRef instanceof IEditorReference) {
- editorActivated(((IEditorReference) partRef).getEditor(true));
- }
- }
-
- };
-
- private ITreeViewerListener fExpansionListener= new ITreeViewerListener() {
- public void treeCollapsed(TreeExpansionEvent event) {
- }
-
- public void treeExpanded(TreeExpansionEvent event) {
- Object element= event.getElement();
- if (element instanceof IJavaScriptUnit ||
- element instanceof IClassFile)
- expandMainType(element);
- }
- };
-
- private class PackageExplorerProblemTreeViewer extends ProblemTreeViewer {
- // fix for 64372 Projects showing up in Package Explorer twice [package explorer]
- private List fPendingRefreshes;
-
- public PackageExplorerProblemTreeViewer(Composite parent, int style) {
- super(parent, style);
- fPendingRefreshes= Collections.synchronizedList(new ArrayList());
- ColoredViewersManager.install(this);
- }
- public void add(Object parentElement, Object[] childElements) {
- if (fPendingRefreshes.contains(parentElement)) {
- return;
- }
- super.add(parentElement, childElements);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalRefresh(java.lang.Object, boolean)
- */
- protected void internalRefresh(Object element, boolean updateLabels) {
- try {
- fPendingRefreshes.add(element);
- super.internalRefresh(element, updateLabels);
- } finally {
- fPendingRefreshes.remove(element);
- }
- }
-
- protected boolean evaluateExpandableWithFilters(Object parent) {
- if (parent instanceof IJavaScriptProject
- || parent instanceof IJavaScriptUnit || parent instanceof IClassFile
- || parent instanceof JsGlobalScopeContainer) {
- return false;
- }
- if (parent instanceof IPackageFragmentRoot && ((IPackageFragmentRoot) parent).isArchive()) {
- return false;
- }
- return true;
- }
-
- protected boolean isFiltered(Object object, Object parent, ViewerFilter[] filters) {
- if (object instanceof PackageFragmentRootContainer) {
- return !hasFilteredChildren(object);
- }
-
- boolean res= super.isFiltered(object, parent, filters);
- if (res && isEssential(object)) {
- return false;
- }
- return res;
- }
-
- /* Checks if a filtered object in essential (i.e. is a parent that
- * should not be removed).
- */
- private boolean isEssential(Object object) {
- try {
- if (!isFlatLayout() && object instanceof IPackageFragment) {
- IPackageFragment fragment = (IPackageFragment) object;
- if (!fragment.isDefaultPackage() && fragment.hasSubpackages()) {
- return hasFilteredChildren(fragment);
- }
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return false;
- }
-
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- IStructuredSelection is= (IStructuredSelection)invalidSelection;
- List ns= null;
- if (newSelection instanceof IStructuredSelection) {
- ns= new ArrayList(((IStructuredSelection)newSelection).toList());
- } else {
- ns= new ArrayList();
- }
- boolean changed= false;
- for (Iterator iter= is.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof IJavaScriptProject) {
- IProject project= ((IJavaScriptProject)element).getProject();
- if (!project.isOpen() && project.exists()) {
- ns.add(project);
- changed= true;
- }
- } else if (element instanceof IProject) {
- IProject project= (IProject)element;
- if (project.isOpen()) {
- IJavaScriptProject jProject= JavaScriptCore.create(project);
- if (jProject != null && jProject.exists())
- ns.add(jProject);
- changed= true;
- }
- }
- }
- if (changed) {
- newSelection= new StructuredSelection(ns);
- setSelection(newSelection);
- }
- super.handleInvalidSelection(invalidSelection, newSelection);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Object[] addAditionalProblemParents(Object[] elements) {
- if (showWorkingSets() && elements != null) {
- return fWorkingSetModel.addWorkingSets(elements);
- }
- return elements;
- }
-
- //---- special handling to preserve the selection correctly
- private boolean fInPreserveSelection;
- protected void preservingSelection(Runnable updateCode) {
- try {
- fInPreserveSelection= true;
- super.preservingSelection(updateCode);
- } finally {
- fInPreserveSelection= false;
- }
- }
- protected void setSelectionToWidget(ISelection selection, boolean reveal) {
- if (true) {
- super.setSelectionToWidget(selection, reveal);
- return;
- }
- if (!fInPreserveSelection || !(selection instanceof ITreeSelection)) {
- super.setSelectionToWidget(selection, reveal);
- return;
- }
- IContentProvider cp= getContentProvider();
- if (!(cp instanceof IMultiElementTreeContentProvider)) {
- super.setSelectionToWidget(selection, reveal);
- return;
- }
- IMultiElementTreeContentProvider contentProvider= (IMultiElementTreeContentProvider)cp;
- ITreeSelection toRestore= (ITreeSelection)selection;
- List pathsToSelect= new ArrayList();
- for (Iterator iter= toRestore.iterator(); iter.hasNext();) {
- Object element= iter.next();
- TreePath[] pathsToRestore= toRestore.getPathsFor(element);
- CustomHashtable currentParents= createRootAccessedMap(contentProvider.getTreePaths(element));
- for (int i= 0; i < pathsToRestore.length; i++) {
- TreePath path= pathsToRestore[i];
- Object root= path.getFirstSegment();
- if (root != null && path.equals((TreePath)currentParents.get(root), getComparer())) {
- pathsToSelect.add(path);
- }
- }
- }
- List toSelect= new ArrayList();
- for (Iterator iter= pathsToSelect.iterator(); iter.hasNext();) {
- TreePath path= (TreePath)iter.next();
- int size= path.getSegmentCount();
- if (size == 0)
- continue;
- Widget current= getTree();
- int last= size - 1;
- Object segment;
- for (int i= 0; i < size && current != null && (segment= path.getSegment(i)) != null; i++) {
- internalExpandToLevel(current, 1);
- current= internalFindChild(current, segment);
- if (i == last && current != null)
- toSelect.add(current);
- }
- }
- getTree().setSelection((TreeItem[])toSelect.toArray(new TreeItem[toSelect.size()]));
- }
- private Widget internalFindChild(Widget parent, Object element) {
- Item[] items = getChildren(parent);
- for (int i = 0; i < items.length; i++) {
- Item item = items[i];
- Object data = item.getData();
- if (data != null && equals(data, element))
- return item;
- }
- return null;
- }
- private CustomHashtable createRootAccessedMap(TreePath[] paths) {
- CustomHashtable result= new CustomHashtable(getComparer());
- for (int i= 0; i < paths.length; i++) {
- TreePath path= paths[i];
- Object root= path.getFirstSegment();
- if (root != null) {
- result.put(root, path);
- }
- }
- return result;
- }
- }
-
- public PackageExplorerPart() {
- fPostSelectionListener= new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handlePostSelectionChanged(event);
- }
- };
-
- // exception: initialize from preference
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettingsSection(getClass().getName());
-
- // on by default
- fShowLibrariesNode= fDialogSettings.get(TAG_GROUP_LIBRARIES) == null || fDialogSettings.getBoolean(TAG_GROUP_LIBRARIES);
-
- fLinkingEnabled= fDialogSettings.getBoolean(TAG_LINK_EDITOR);
-
- try {
- fIsCurrentLayoutFlat= fDialogSettings.getInt(TAG_LAYOUT) == FLAT_LAYOUT;
- } catch (NumberFormatException e) {
- fIsCurrentLayoutFlat= false;
- }
-
- try {
- fRootMode= fDialogSettings.getInt(TAG_ROOT_MODE);
- } catch (NumberFormatException e) {
- fRootMode= ViewActionGroup.SHOW_PROJECTS;
- }
-
- }
-
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- if (memento == null) {
- String persistedMemento= fDialogSettings.get(TAG_MEMENTO);
- if (persistedMemento != null) {
- try {
- memento= XMLMemento.createReadRoot(new StringReader(persistedMemento));
- } catch (WorkbenchException e) {
- // don't do anything. Simply don't restore the settings
- }
- }
- }
- fMemento= memento;
- if (memento != null) {
- restoreLayoutState(memento);
- restoreLinkingEnabled(memento);
- restoreRootMode(memento);
- }
- if (showWorkingSets()) {
- createWorkingSetModel();
- }
- }
-
- private void restoreRootMode(IMemento memento) {
- Integer value= memento.getInteger(TAG_ROOT_MODE);
- fRootMode= value == null ? ViewActionGroup.SHOW_PROJECTS : value.intValue();
- if (fRootMode != ViewActionGroup.SHOW_PROJECTS && fRootMode != ViewActionGroup.SHOW_WORKING_SETS)
- fRootMode= ViewActionGroup.SHOW_PROJECTS;
- }
-
- private void restoreLayoutState(IMemento memento) {
- Integer layoutState= memento.getInteger(TAG_LAYOUT);
- fIsCurrentLayoutFlat= layoutState == null || layoutState.intValue() == FLAT_LAYOUT;
-
- // on by default
- Integer groupLibraries= memento.getInteger(TAG_GROUP_LIBRARIES);
- fShowLibrariesNode= groupLibraries == null || groupLibraries.intValue() != 0;
- }
-
- /**
- * Returns the package explorer part of the active perspective. If
- * there isn't any package explorer part <code>null</code> is returned.
- * @return the package explorer from the active perspective
- */
- public static PackageExplorerPart getFromActivePerspective() {
- IWorkbenchPage activePage= JavaScriptPlugin.getActivePage();
- if (activePage == null)
- return null;
- IViewPart view= activePage.findView(VIEW_ID);
- if (view instanceof PackageExplorerPart)
- return (PackageExplorerPart)view;
- return null;
- }
-
- /**
- * Makes the package explorer part visible in the active perspective. If there
- * isn't a package explorer part registered <code>null</code> is returned.
- * Otherwise the opened view part is returned.
- * @return the opened package explorer
- */
- public static PackageExplorerPart openInActivePerspective() {
- try {
- return (PackageExplorerPart)JavaScriptPlugin.getActivePage().showView(VIEW_ID);
- } catch(PartInitException pe) {
- return null;
- }
- }
-
- public void dispose() {
- XMLMemento memento= XMLMemento.createWriteRoot("packageExplorer"); //$NON-NLS-1$
- saveState(memento);
- StringWriter writer= new StringWriter();
- try {
- memento.save(writer);
- fDialogSettings.put(TAG_MEMENTO, writer.getBuffer().toString());
- } catch (IOException e) {
- // don't do anything. Simply don't store the settings
- }
-
- if (fContextMenu != null && !fContextMenu.isDisposed())
- fContextMenu.dispose();
-
- getSite().getPage().removePartListener(fLinkWithEditorListener); // always remove even if we didn't register
-
- JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- if (fViewer != null) {
- fViewer.removeTreeListener(fExpansionListener);
- }
-
- if (fActionSet != null)
- fActionSet.dispose();
- if (fFilterUpdater != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
- if (fWorkingSetModel != null)
- fWorkingSetModel.dispose();
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl(Composite parent) {
-
- final PerformanceStats stats= PerformanceStats.getStats(PERF_CREATE_PART_CONTROL, this);
- stats.startRun();
-
- fViewer= createViewer(parent);
- fViewer.setUseHashlookup(true);
-
- initDragAndDrop();
-
- setProviders();
-
- JavaScriptPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-
-
- MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
- fContextMenu= menuMgr.createContextMenu(fViewer.getTree());
- fViewer.getTree().setMenu(fContextMenu);
-
- // Register viewer with site. This must be done before making the actions.
- IWorkbenchPartSite site= getSite();
- site.registerContextMenu(menuMgr, fViewer);
- site.setSelectionProvider(fViewer);
-
- makeActions(); // call before registering for selection changes
-
- // Set input after filter and sorter has been set. This avoids resorting and refiltering.
- restoreFilterAndSorter();
- fViewer.setInput(findInputElement());
- initFrameActions();
- initKeyListener();
-
-
- fViewer.addPostSelectionChangedListener(fPostSelectionListener);
-
- fViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- fActionSet.handleDoubleClick(event);
- }
- });
-
- fViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- fActionSet.handleOpen(event);
- fLastOpenSelection= event.getSelection();
- }
- });
-
- IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
- fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager));
- fViewer.addTreeListener(fExpansionListener);
-
- // Set help for the view
- JavaUIHelp.setHelp(fViewer, IJavaHelpContextIds.PACKAGES_VIEW);
-
- fillActionBars();
-
- updateTitle();
-
- fFilterUpdater= new FilterUpdater(fViewer);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
-
- // Sync'ing the package explorer has to be done here. It can't be done
- // when restoring the link state since the package explorers input isn't
- // set yet.
- setLinkingEnabled(isLinkingEnabled());
-
- stats.endRun();
- }
-
- private void initFrameActions() {
- fActionSet.getUpAction().update();
- fActionSet.getBackAction().update();
- fActionSet.getForwardAction().update();
- }
-
- private ProblemTreeViewer createViewer(Composite composite) {
- return new PackageExplorerProblemTreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- }
-
- /**
- * Answers whether this part shows the packages flat or hierarchical.
- * @return <true> if flat layout is selected
- *
- *
- */
- public boolean isFlatLayout() {
- return fIsCurrentLayoutFlat;
- }
-
- private void setProviders() {
- //content provider must be set before the label provider
- fContentProvider= createContentProvider();
- fContentProvider.setIsFlatLayout(fIsCurrentLayoutFlat);
- fContentProvider.setShowLibrariesNode(fShowLibrariesNode);
- fViewer.setContentProvider(fContentProvider);
-
- fViewer.setComparer(createElementComparer());
-
- fLabelProvider= createLabelProvider();
- fLabelProvider.setIsFlatLayout(fIsCurrentLayoutFlat);
- fDecoratingLabelProvider= new DecoratingJavaLabelProvider(fLabelProvider, false, fIsCurrentLayoutFlat);
- fViewer.setLabelProvider(fDecoratingLabelProvider);
- // problem decoration provided by PackageLabelProvider
- }
-
- public void setShowLibrariesNode(boolean enabled) {
- fShowLibrariesNode= enabled;
- saveDialogSettings();
-
- fContentProvider.setShowLibrariesNode(enabled);
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
-
- boolean isLibrariesNodeShown() {
- return fShowLibrariesNode;
- }
-
-
- public void setFlatLayout(boolean enable) {
- // Update current state and inform content and label providers
- fIsCurrentLayoutFlat= enable;
- saveDialogSettings();
-
- if (fViewer != null) {
- fContentProvider.setIsFlatLayout(isFlatLayout());
- fLabelProvider.setIsFlatLayout(isFlatLayout());
- fDecoratingLabelProvider.setFlatPackageMode(isFlatLayout());
-
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
- }
-
- /**
- * This method should only be called inside this class
- * and from test cases.
- * @return the created content provider
- */
- public PackageExplorerContentProvider createContentProvider() {
- IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- boolean showCUChildren= store.getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
- if (showProjects())
- return new PackageExplorerContentProvider(showCUChildren);
- else
- return new WorkingSetAwareContentProvider(showCUChildren, fWorkingSetModel);
- }
-
- private PackageExplorerLabelProvider createLabelProvider() {
- return new PackageExplorerLabelProvider(fContentProvider);
- }
-
- private IElementComparer createElementComparer() {
- if (showProjects())
- return null;
- else
- return WorkingSetModel.COMPARER;
- }
-
- private void fillActionBars() {
- IActionBars actionBars= getViewSite().getActionBars();
- fActionSet.fillActionBars(actionBars);
- }
-
- private Object findInputElement() {
- if (showWorkingSets()) {
- return fWorkingSetModel;
- } else {
- Object input= getSite().getPage().getInput();
- if (input instanceof IWorkspace) {
- return JavaScriptCore.create(((IWorkspace)input).getRoot());
- } else if (input instanceof IContainer) {
- IJavaScriptElement element= JavaScriptCore.create((IContainer)input);
- if (element != null && element.exists())
- return element;
- return input;
- }
- //1GERPRT: ITPJUI:ALL - Packages View is empty when shown in Type Hierarchy Perspective
- // we can't handle the input
- // fall back to show the workspace
- return JavaScriptCore.create(JavaScriptPlugin.getWorkspace().getRoot());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- if (key.equals(ISelectionProvider.class))
- return fViewer;
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- if (key == IContextProvider.class) {
- return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.PACKAGES_VIEW);
- }
- return super.getAdapter(key);
- }
-
- /**
- * Returns the tool tip text for the given element.
- * @param element the element
- * @return the tooltip
- */
- String getToolTipText(Object element) {
- String result;
- if (!(element instanceof IResource)) {
- if (element instanceof IJavaScriptModel) {
- result= PackagesMessages.PackageExplorerPart_workspace;
- } else if (element instanceof IJavaScriptElement){
- result= JavaScriptElementLabels.getTextLabel(element, JavaScriptElementLabels.ALL_FULLY_QUALIFIED);
- } else if (element instanceof IWorkingSet) {
- result= ((IWorkingSet)element).getLabel();
- } else if (element instanceof WorkingSetModel) {
- result= PackagesMessages.PackageExplorerPart_workingSetModel;
- } else {
- result= fLabelProvider.getText(element);
- }
- } else {
- IPath path= ((IResource) element).getFullPath();
- if (path.isRoot()) {
- result= PackagesMessages.PackageExplorer_title;
- } else {
- result= path.makeRelative().toString();
- }
- }
-
- if (fRootMode == ViewActionGroup.SHOW_PROJECTS) {
- if (fWorkingSetLabel == null)
- return result;
- if (result.length() == 0)
- return Messages.format(PackagesMessages.PackageExplorer_toolTip, new String[] { fWorkingSetLabel });
- return Messages.format(PackagesMessages.PackageExplorer_toolTip2, new String[] { result, fWorkingSetLabel });
- } else { // Working set mode. During initialization element and action set can be null.
- if (element != null && !(element instanceof IWorkingSet) && !(element instanceof WorkingSetModel) && fActionSet != null) {
- FrameList frameList= fActionSet.getFrameList();
- int index= frameList.getCurrentIndex();
- IWorkingSet ws= null;
- while(index >= 0) {
- Frame frame= frameList.getFrame(index);
- if (frame instanceof TreeFrame) {
- Object input= ((TreeFrame)frame).getInput();
- if (input instanceof IWorkingSet) {
- ws= (IWorkingSet) input;
- break;
- }
- }
- index--;
- }
- if (ws != null) {
- return Messages.format(PackagesMessages.PackageExplorer_toolTip3, new String[] {ws.getLabel() , result});
- } else {
- return result;
- }
- } else {
- return result;
- }
- }
- }
-
- public String getTitleToolTip() {
- if (fViewer == null)
- return super.getTitleToolTip();
- return getToolTipText(fViewer.getInput());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- public void setFocus() {
- fViewer.getTree().setFocus();
- }
-
- private ISelection getSelection() {
- return fViewer.getSelection();
- }
-
- //---- Action handling ----------------------------------------------------------
-
- /* (non-Javadoc)
- * @see IMenuListener#menuAboutToShow(IMenuManager)
- */
- public void menuAboutToShow(IMenuManager menu) {
- JavaScriptPlugin.createStandardGroups(menu);
-
- fActionSet.setContext(new ActionContext(getSelection()));
- fActionSet.fillContextMenu(menu);
- fActionSet.setContext(null);
- }
-
- private void makeActions() {
-
- final PerformanceStats stats= PerformanceStats.getStats(PERF_MAKE_ACTIONS, this);
- stats.startRun();
-
- fActionSet= new PackageExplorerActionGroup(this);
- if (fWorkingSetModel != null)
- fActionSet.getWorkingSetActionGroup().setWorkingSetModel(fWorkingSetModel);
-
- stats.endRun();
- }
-
- // ---- Event handling ----------------------------------------------------------
-
- private void initDragAndDrop() {
- initDrag();
- initDrop();
- }
-
- private void initDrag() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getInstance(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance()};
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fViewer),
- new ResourceTransferDragAdapter(fViewer),
- new FileTransferDragAdapter(fViewer)
- };
- fViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fViewer, dragListeners));
- }
-
- private void initDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getInstance(),
- FileTransfer.getInstance()};
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fViewer),
- new FileTransferDropAdapter(fViewer),
- new WorkingSetDropAdapter(this)
- };
- fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
- }
-
- /**
- * Handles post selection changed in viewer.
- *
- * Links to editor (if option enabled).
- * @param event the selection eveny
- */
- private void handlePostSelectionChanged(SelectionChangedEvent event) {
- ISelection selection= event.getSelection();
- // If the selection is the same as the one that triggered the last
- // open event then do nothing. The editor already got revealed.
- if (isLinkingEnabled() && !selection.equals(fLastOpenSelection)) {
- linkToEditor((IStructuredSelection)selection);
- }
- fLastOpenSelection= null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.ISetSelectionTarget#selectReveal(org.eclipse.jface.viewers.ISelection)
- */
- public void selectReveal(final ISelection selection) {
- Control ctrl= getTreeViewer().getControl();
- if (ctrl == null || ctrl.isDisposed())
- return;
-
- fContentProvider.runPendingUpdates();
- fViewer.setSelection(convertSelection(selection), true);
- }
-
- public ISelection convertSelection(ISelection s) {
- if (!(s instanceof IStructuredSelection))
- return s;
-
- Object[] elements= ((IStructuredSelection)s).toArray();
-
- boolean changed= false;
- for (int i= 0; i < elements.length; i++) {
- Object convertedElement= convertElement(elements[i]);
- changed= changed || convertedElement != elements[i];
- elements[i]= convertedElement;
- }
- if (changed)
- return new StructuredSelection(elements);
- else
- return s;
- }
-
- private Object convertElement(Object original) {
- if (original instanceof IJavaScriptElement) {
- if (original instanceof IJavaScriptUnit) {
- IJavaScriptUnit cu= (IJavaScriptUnit) original;
- IJavaScriptProject javaProject= cu.getJavaScriptProject();
- if (javaProject != null && javaProject.exists() && ! javaProject.isOnIncludepath(cu)) {
- // could be a working copy of a .java file that is not on classpath
- IResource resource= cu.getResource();
- if (resource != null)
- return resource;
- }
-
- }
- return original;
-
- } else if (original instanceof IResource) {
- IJavaScriptElement je= JavaScriptCore.create((IResource)original);
- if (je != null && je.exists()) {
- IJavaScriptProject javaProject= je.getJavaScriptProject();
- if (javaProject != null && javaProject.exists()) {
- return je;
- }
- }
- } else if (original instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable)original;
- IJavaScriptElement je= (IJavaScriptElement) adaptable.getAdapter(IJavaScriptElement.class);
- if (je != null && je.exists())
- return je;
-
- IResource r= (IResource) adaptable.getAdapter(IResource.class);
- if (r != null) {
- je= JavaScriptCore.create(r);
- if (je != null && je.exists())
- return je;
- else
- return r;
- }
- }
- return original;
- }
-
- public void selectAndReveal(Object element) {
- selectReveal(new StructuredSelection(element));
- }
-
- public boolean isLinkingEnabled() {
- return fLinkingEnabled;
- }
-
- /**
- * Links to editor (if option enabled)
- * @param selection the selection
- */
- private void linkToEditor(IStructuredSelection selection) {
- // 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) {
- IEditorPart part= EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page= getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof IJavaScriptElement)
- EditorUtility.revealInEditor(part, (IJavaScriptElement)obj);
- }
- }
- }
-
- private boolean isActivePart() {
- return this == getSite().getPage().getActivePart();
- }
-
- public void saveState(IMemento memento) {
- if (fViewer == null && fMemento != null) {
- // part has not been created -> keep the old state
- memento.putMemento(fMemento);
- return;
- }
-
- memento.putInteger(TAG_ROOT_MODE, fRootMode);
- if (fWorkingSetModel != null)
- fWorkingSetModel.saveState(memento);
-
- saveLayoutState(memento);
- saveLinkingEnabled(memento);
-
- if (fActionSet != null) {
- fActionSet.saveFilterAndSorterState(memento);
- }
- }
-
- private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(TAG_LINK_EDITOR, fLinkingEnabled ? 1 : 0);
- }
-
- private void saveLayoutState(IMemento memento) {
- if (memento != null) {
- memento.putInteger(TAG_LAYOUT, getLayoutAsInt());
- memento.putInteger(TAG_GROUP_LIBRARIES, fShowLibrariesNode ? 1 : 0);
- }
- }
-
- private void saveDialogSettings() {
- fDialogSettings.put(TAG_GROUP_LIBRARIES, fShowLibrariesNode);
- fDialogSettings.put(TAG_LAYOUT, getLayoutAsInt());
- fDialogSettings.put(TAG_ROOT_MODE, fRootMode);
- fDialogSettings.put(TAG_LINK_EDITOR, fLinkingEnabled);
- }
-
- private int getLayoutAsInt() {
- if (fIsCurrentLayoutFlat)
- return FLAT_LAYOUT;
- else
- return HIERARCHICAL_LAYOUT;
- }
-
- private void restoreFilterAndSorter() {
- fViewer.addFilter(new OutputFolderFilter());
- setComparator();
- if (fMemento != null)
- fActionSet.restoreFilterAndSorterState(fMemento);
- }
-
- private void restoreLinkingEnabled(IMemento memento) {
- Integer val= memento.getInteger(TAG_LINK_EDITOR);
- fLinkingEnabled= val != null && val.intValue() != 0;
- }
-
- /**
- * Create the KeyListener for doing the refresh on the viewer.
- */
- private void initKeyListener() {
- fViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- fActionSet.handleKeyEvent(event);
- }
- });
- }
-
- /**
- * An editor has been activated. Set the selection in this Packages Viewer
- * to be the editor's input, if linking is enabled.
- * @param editor the activated editor
- */
- void editorActivated(IEditorPart editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput == null)
- return;
- Object input= getInputFromEditor(editorInput);
- if (input == null)
- return;
- if (!inputIsSelected(editorInput))
- showInput(input);
- else
- getTreeViewer().getTree().showSelection();
- }
-
- private Object getInputFromEditor(IEditorInput editorInput) {
- Object input= JavaScriptUI.getEditorInputJavaElement(editorInput);
- if (input == null) {
- input= editorInput.getAdapter(IFile.class);
- }
- if (input == null && editorInput instanceof IStorageEditorInput) {
- try {
- input= ((IStorageEditorInput) editorInput).getStorage();
- } catch (CoreException e) {
- // ignore
- }
- }
- return input;
- }
-
-
- private boolean inputIsSelected(IEditorInput input) {
- IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
- if (selection.size() != 1)
- return false;
- IEditorInput selectionAsInput= null;
- try {
- selectionAsInput= EditorUtility.getEditorInput(selection.getFirstElement());
- } catch (JavaScriptModelException e1) {
- return false;
- }
- return input.equals(selectionAsInput);
- }
-
- boolean showInput(Object input) {
- Object element= null;
-
- if (input instanceof IFile && isOnClassPath((IFile)input)) {
- element= JavaScriptCore.create((IFile)input);
- }
-
- if (element == null) // try a non Java resource
- element= input;
-
- if (element != null) {
- ISelection newSelection= new StructuredSelection(element);
- if (fViewer.getSelection().equals(newSelection)) {
- fViewer.reveal(element);
- } else {
- try {
- fViewer.removePostSelectionChangedListener(fPostSelectionListener);
- fViewer.setSelection(newSelection, true);
-
- while (element != null && fViewer.getSelection().isEmpty()) {
- // Try to select parent in case element is filtered
- element= getParent(element);
- if (element != null) {
- newSelection= new StructuredSelection(element);
- fViewer.setSelection(newSelection, true);
- }
- }
- } finally {
- fViewer.addPostSelectionChangedListener(fPostSelectionListener);
- }
- }
- return true;
- }
- return false;
- }
-
- private boolean isOnClassPath(IFile file) {
- IJavaScriptProject jproject= JavaScriptCore.create(file.getProject());
- return jproject.isOnIncludepath(file);
- }
-
- /**
- * Returns the element's parent.
- * @param element the element
- *
- * @return the parent or <code>null</code> if there's no parent
- */
- private Object getParent(Object element) {
- if (element instanceof IJavaScriptElement)
- return ((IJavaScriptElement)element).getParent();
- else if (element instanceof IResource)
- return ((IResource)element).getParent();
- else if (element instanceof IJarEntryResource) {
- return ((IJarEntryResource)element).getParent();
- }
- return null;
- }
-
- /**
- * A compilation unit or class was expanded, expand
- * the main type.
- * @param element the element
- */
- void expandMainType(Object element) {
- try {
- IType type= null;
- if (element instanceof IJavaScriptUnit) {
- IJavaScriptUnit cu= (IJavaScriptUnit)element;
- IType[] types= cu.getTypes();
- if (types.length > 0)
- type= types[0];
- }
- else if (element instanceof IClassFile) {
- IClassFile cf= (IClassFile)element;
- type= cf.getType();
- }
- if (type != null) {
- final IType type2= type;
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.getDisplay().asyncExec(new Runnable() {
- public void run() {
- Control ctrl2= fViewer.getControl();
- if (ctrl2 != null && !ctrl2.isDisposed())
- fViewer.expandToLevel(type2, 1);
- }
- });
- }
- }
- } catch(JavaScriptModelException e) {
- // no reveal
- }
- }
-
- /**
- * Returns the TreeViewer.
- * @return the tree viewer
- */
- public TreeViewer getTreeViewer() {
- return fViewer;
- }
-
- boolean isExpandable(Object element) {
- if (fViewer == null)
- return false;
- return fViewer.isExpandable(element);
- }
-
- void setWorkingSetLabel(String workingSetName) {
- fWorkingSetLabel= workingSetName;
- setTitleToolTip(getTitleToolTip());
- }
-
- /**
- * Updates the title text and title tool tip.
- * Called whenever the input of the viewer changes.
- */
- void updateTitle() {
- Object input= fViewer.getInput();
- if (input == null
- || (input instanceof IJavaScriptModel)) {
- setContentDescription(""); //$NON-NLS-1$
- setTitleToolTip(""); //$NON-NLS-1$
- } else {
- String inputText= JavaScriptElementLabels.getTextLabel(input, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
- setContentDescription(inputText);
- setTitleToolTip(getToolTipText(input));
- }
- }
-
- /**
- * Sets the decorator for the package explorer.
- *
- * @param decorator a label decorator or <code>null</code> for no decorations.
- * @deprecated To be removed
- */
- public void setLabelDecorator(ILabelDecorator decorator) {
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (fViewer == null)
- return;
-
- boolean refreshViewer= false;
-
- if (PreferenceConstants.SHOW_CU_CHILDREN.equals(event.getProperty())) {
- fActionSet.updateActionBars(getViewSite().getActionBars());
-
- boolean showCUChildren= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
- ((StandardJavaScriptElementContentProvider)fViewer.getContentProvider()).setProvideMembers(showCUChildren);
-
- refreshViewer= true;
- } else if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
- refreshViewer= true;
- }
-
- if (refreshViewer)
- fViewer.refresh();
- }
-
- /* (non-Javadoc)
- * @see IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (fViewer != null) {
- return fViewer.getInput();
- }
- return null;
- }
-
- public void collapseAll() {
- try {
- fViewer.getControl().setRedraw(false);
- fViewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
- } finally {
- fViewer.getControl().setRedraw(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
- */
- public boolean show(ShowInContext context) {
- ISelection selection= context.getSelection();
- if (selection instanceof IStructuredSelection) {
- // fix for 64634 Navigate/Show in/Package Explorer doesn't work
- IStructuredSelection structuredSelection= ((IStructuredSelection) selection);
- if (structuredSelection.size() == 1) {
- int res= tryToReveal(structuredSelection.getFirstElement());
- if (res == IStatus.OK)
- return true;
- if (res == IStatus.CANCEL)
- return false;
- } else if (structuredSelection.size() > 1) {
- selectReveal(structuredSelection);
- return true;
- }
- }
-
- Object input= context.getInput();
- if (input instanceof IEditorInput) {
- Object elementOfInput= getInputFromEditor((IEditorInput) input);
- return elementOfInput != null && (tryToReveal(elementOfInput) == IStatus.OK);
- }
-
- return false;
- }
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- * @return the <code>IShowInSource</code>
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- getTreeViewer().getInput(),
- getTreeViewer().getSelection());
- }
- };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.IPackagesViewPart#setLinkingEnabled(boolean)
- */
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- saveDialogSettings();
-
- IWorkbenchPage page= getSite().getPage();
- if (enabled) {
- page.addPartListener(fLinkWithEditorListener);
-
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- editorActivated(editor);
- }
- } else {
- page.removePartListener(fLinkWithEditorListener);
- }
- }
-
- /**
- * Returns the name for the given element.
- * Used as the name for the current frame.
- * @param element the elemeny
- * @return the name of the frame
- */
- String getFrameName(Object element) {
- if (element instanceof IJavaScriptElement) {
- return ((IJavaScriptElement) element).getElementName();
- } else if (element instanceof WorkingSetModel) {
- return ""; //$NON-NLS-1$
- } else {
- return fLabelProvider.getText(element);
- }
- }
-
- public int tryToReveal(Object element) {
- if (revealElementOrParent(element))
- return IStatus.OK;
-
- WorkingSetFilterActionGroup workingSetGroup= fActionSet.getWorkingSetActionGroup().getFilterGroup();
- if (workingSetGroup != null) {
- IWorkingSet workingSet= workingSetGroup.getWorkingSet();
- if (workingSetGroup.isFiltered(getVisibleParent(element), element)) {
- String message;
- if (element instanceof IJavaScriptElement) {
- String elementLabel= JavaScriptElementLabels.getElementLabel((IJavaScriptElement)element, JavaScriptElementLabels.ALL_DEFAULT);
- message= Messages.format(PackagesMessages.PackageExplorerPart_notFoundSepcific, new String[] {elementLabel, workingSet.getLabel()});
- } else {
- message= Messages.format(PackagesMessages.PackageExplorer_notFound, workingSet.getLabel());
- }
- if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) {
- workingSetGroup.setWorkingSet(null, true);
- if (revealElementOrParent(element))
- return IStatus.OK;
- } else {
- return IStatus.CANCEL;
- }
- }
- }
- // try to remove filters
- CustomFiltersActionGroup filterGroup= fActionSet.getCustomFilterActionGroup();
- String[] currentFilters= filterGroup.internalGetEnabledFilterIds();
- String[] newFilters= filterGroup.removeFiltersFor(getVisibleParent(element), element, getTreeViewer().getContentProvider());
- if (currentFilters.length > newFilters.length) {
- String message;
- if (element instanceof IJavaScriptElement) {
- String elementLabel= JavaScriptElementLabels.getElementLabel((IJavaScriptElement)element, JavaScriptElementLabels.ALL_DEFAULT);
- message= Messages.format(PackagesMessages.PackageExplorerPart_removeFiltersSpecific, elementLabel);
- } else {
- message= PackagesMessages.PackageExplorer_removeFilters;
- }
- if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) {
- filterGroup.setFilters(newFilters);
- if (revealElementOrParent(element))
- return IStatus.OK;
- } else {
- return IStatus.CANCEL;
- }
- }
- FrameAction action= fActionSet.getUpAction();
- while (action.getFrameList().getCurrentIndex() > 0) {
- // only try to go up if there is a parent frame
- // fix for bug# 63769 Endless loop after Show in Package Explorer
- if (action.getFrameList().getSource().getFrame(IFrameSource.PARENT_FRAME, 0) == null)
- break;
- action.run();
- if (revealElementOrParent(element))
- return IStatus.OK;
- }
- return IStatus.ERROR;
- }
-
- private boolean revealElementOrParent(Object element) {
- if (revealAndVerify(element))
- return true;
- element= getVisibleParent(element);
- if (element != null) {
- if (revealAndVerify(element))
- return true;
- if (element instanceof IJavaScriptElement) {
- IResource resource= ((IJavaScriptElement)element).getResource();
- if (resource != null) {
- if (revealAndVerify(resource))
- return true;
- }
- }
- }
- return false;
- }
-
- private Object getVisibleParent(Object object) {
- // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
- if (object == null)
- return null;
- if (!(object instanceof IJavaScriptElement))
- return object;
- IJavaScriptElement element2= (IJavaScriptElement) object;
- switch (element2.getElementType()) {
- case IJavaScriptElement.IMPORT_DECLARATION:
- case IJavaScriptElement.PACKAGE_DECLARATION:
- case IJavaScriptElement.IMPORT_CONTAINER:
- case IJavaScriptElement.TYPE:
- case IJavaScriptElement.METHOD:
- case IJavaScriptElement.FIELD:
- case IJavaScriptElement.INITIALIZER:
- // select parent cu/classfile
- element2= (IJavaScriptElement)element2.getOpenable();
- break;
- case IJavaScriptElement.JAVASCRIPT_MODEL:
- element2= null;
- break;
- }
- return element2;
- }
-
- private boolean revealAndVerify(Object element) {
- if (element == null)
- return false;
- selectReveal(new StructuredSelection(element));
- return ! getSite().getSelectionProvider().getSelection().isEmpty();
- }
-
- public void rootModeChanged(int newMode) {
- fRootMode= newMode;
- saveDialogSettings();
-
- if (showWorkingSets() && fWorkingSetModel == null) {
- createWorkingSetModel();
- if (fActionSet != null) {
- fActionSet.getWorkingSetActionGroup().setWorkingSetModel(fWorkingSetModel);
- }
- }
- IStructuredSelection selection= new StructuredSelection(((IStructuredSelection) fViewer.getSelection()).toArray());
- Object input= fViewer.getInput();
- boolean isRootInputChange= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()).equals(input)
- || (fWorkingSetModel != null && fWorkingSetModel.equals(input))
- || input instanceof IWorkingSet;
- try {
- fViewer.getControl().setRedraw(false);
- if (isRootInputChange) {
- fViewer.setInput(null);
- }
- setProviders();
- setComparator();
- fActionSet.getWorkingSetActionGroup().fillFilters(fViewer);
- if (isRootInputChange) {
- fViewer.setInput(findInputElement());
- }
- fViewer.setSelection(selection, true);
- } finally {
- fViewer.getControl().setRedraw(true);
- }
- if (isRootInputChange && showWorkingSets() && fWorkingSetModel.needsConfiguration()) {
- ConfigureWorkingSetAction action= new ConfigureWorkingSetAction(getSite());
- action.setWorkingSetModel(fWorkingSetModel);
- action.run();
- fWorkingSetModel.configured();
- }
- setTitleToolTip(getTitleToolTip());
- }
-
- private void createWorkingSetModel() {
- SafeRunner.run(new ISafeRunnable() {
- public void run() throws Exception {
- fWorkingSetModel= new WorkingSetModel(fMemento);
- }
- public void handleException(Throwable exception) {
- fWorkingSetModel= new WorkingSetModel(null);
- }
- });
- }
-
-
- /**
- * @return the selected working set to filter if in root mode {@link ViewActionGroup#SHOW_PROJECTS}
- */
- public IWorkingSet getFilterWorkingSet() {
- if (!showProjects())
- return null;
-
- if (fActionSet == null)
- return null;
-
- return fActionSet.getWorkingSetActionGroup().getFilterGroup().getWorkingSet();
- }
-
- public WorkingSetModel getWorkingSetModel() {
- return fWorkingSetModel;
- }
-
- public int getRootMode() {
- return fRootMode;
- }
-
- /* package */ boolean showProjects() {
- return fRootMode == ViewActionGroup.SHOW_PROJECTS;
- }
-
- /* package */ boolean showWorkingSets() {
- return fRootMode == ViewActionGroup.SHOW_WORKING_SETS;
- }
-
- private void setComparator() {
- if (showWorkingSets()) {
- fViewer.setComparator(new WorkingSetAwareJavaElementSorter());
- } else {
- fViewer.setComparator(new JavaScriptElementComparator());
- }
- }
-
- //---- test methods for working set mode -------------------------------
-
- public void internalTestShowWorkingSets(IWorkingSet[] workingSets) {
- if (fWorkingSetModel == null)
- createWorkingSetModel();
- fWorkingSetModel.setActiveWorkingSets(workingSets);
- fWorkingSetModel.configured();
- rootModeChanged(ViewActionGroup.SHOW_WORKING_SETS);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerProblemsDecorator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerProblemsDecorator.java
deleted file mode 100644
index 5a2d8866..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerProblemsDecorator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.TreeHierarchyLayoutProblemsDecorator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-
-
-public class PackageExplorerProblemsDecorator extends TreeHierarchyLayoutProblemsDecorator {
-
- public PackageExplorerProblemsDecorator() {
- super();
- }
-
- public PackageExplorerProblemsDecorator(boolean isFlatLayout) {
- super(isFlatLayout);
- }
-
- protected int computeAdornmentFlags(Object obj) {
- if (!(obj instanceof IWorkingSet))
- return super.computeAdornmentFlags(obj);
-
- IWorkingSet workingSet= (IWorkingSet)obj;
- IAdaptable[] elements= workingSet.getElements();
- int result= 0;
- for (int i= 0; i < elements.length; i++) {
- IAdaptable element= elements[i];
- int flags= super.computeAdornmentFlags(element);
- if ((flags & JavaScriptElementImageDescriptor.ERROR) != 0)
- return JavaScriptElementImageDescriptor.ERROR;
- if ((flags & JavaScriptElementImageDescriptor.WARNING) != 0)
- result= JavaScriptElementImageDescriptor.WARNING;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageFragmentRootContainer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageFragmentRootContainer.java
deleted file mode 100644
index 6b4c723c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageFragmentRootContainer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-
-public abstract class PackageFragmentRootContainer implements IAdaptable {
-
- private static WorkbenchAdapterImpl fgAdapterInstance= new WorkbenchAdapterImpl();
-
- private static class WorkbenchAdapterImpl implements IWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object o) {
- if (o instanceof PackageFragmentRootContainer)
- return ((PackageFragmentRootContainer) o).getChildren();
- return new Object[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- public ImageDescriptor getImageDescriptor(Object o) {
- if (o instanceof PackageFragmentRootContainer)
- return ((PackageFragmentRootContainer) o).getImageDescriptor();
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- public String getLabel(Object o) {
- if (o instanceof PackageFragmentRootContainer)
- return ((PackageFragmentRootContainer) o).getLabel();
- return new String();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object o) {
- if (o instanceof PackageFragmentRootContainer)
- return ((PackageFragmentRootContainer) o).getJavaProject();
- return null;
- }
- }
-
- private IJavaScriptProject fProject;
-
- public PackageFragmentRootContainer(IJavaScriptProject project) {
- Assert.isNotNull(project);
- fProject= project;
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class)
- return fgAdapterInstance;
- return null;
- }
-
- public abstract IAdaptable[] getChildren();
-
- public abstract IPackageFragmentRoot[] getPackageFragmentRoots();
-
- public abstract String getLabel();
-
- public abstract ImageDescriptor getImageDescriptor();
-
- public IJavaScriptProject getJavaProject() {
- return fProject;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesFrameSource.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesFrameSource.java
deleted file mode 100644
index e726f0d1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesFrameSource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
-
-class PackagesFrameSource extends TreeViewerFrameSource {
- private PackageExplorerPart fPackagesExplorer;
-
- PackagesFrameSource(PackageExplorerPart explorer) {
- super(explorer.getTreeViewer());
- fPackagesExplorer= explorer;
- }
-
- protected TreeFrame createFrame(Object input) {
- TreeFrame frame = super.createFrame(input);
- frame.setName(fPackagesExplorer.getFrameName(input));
- frame.setToolTipText(fPackagesExplorer.getToolTipText(input));
- return frame;
- }
-
- /**
- * Also updates the title of the packages explorer
- * @param frame the frame that changed
- */
- protected void frameChanged(TreeFrame frame) {
- super.frameChanged(frame);
- fPackagesExplorer.updateTitle();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.java
deleted file mode 100644
index 7212f2b9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class PackagesMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.packageview.PackagesMessages";//$NON-NLS-1$
-
- private PackagesMessages() {
- // Do not instantiate
- }
-
- public static String DragAdapter_deleting;
- public static String DragAdapter_problem;
- public static String DragAdapter_problemTitle;
- public static String DragAdapter_refreshing;
- public static String DropAdapter_errorTitle;
- public static String DropAdapter_errorMessage;
- public static String GotoPackage_action_label;
- public static String GotoPackage_dialog_message;
- public static String GotoPackage_dialog_title;
- public static String GotoPackage_action_description;
- public static String GotoRequiredProjectAction_label;
- public static String GotoRequiredProjectAction_description;
- public static String GotoRequiredProjectAction_tooltip;
- public static String GotoType_action_label;
- public static String GotoType_action_description;
- public static String GotoType_dialog_message;
- public static String GotoType_dialog_title;
- public static String GotoType_error_message;
- public static String GotoResource_action_label;
- public static String GotoResource_dialog_title;
- public static String LayoutActionGroup_show_libraries_in_group;
- public static String LibraryContainer_name;
- public static String PackageExplorerPart_notFoundSepcific;
- public static String PackageExplorerPart_removeFiltersSpecific;
- public static String PackageExplorer_title;
- public static String PackageExplorer_toolTip;
- public static String PackageExplorer_toolTip2;
- public static String PackageExplorer_toolTip3;
- public static String PackageExplorer_element_not_present;
- public static String PackageExplorer_filteredDialog_title;
- public static String PackageExplorer_notFound;
- public static String PackageExplorer_removeFilters;
- public static String SelectionTransferDropAdapter_error_title;
- public static String SelectionTransferDropAdapter_error_message;
- public static String CollapseAllAction_label;
- public static String CollapseAllAction_tooltip;
- public static String CollapseAllAction_description;
- public static String LayoutActionGroup_label;
- public static String LayoutActionGroup_flatLayoutAction_label;
- public static String LayoutActionGroup_hierarchicalLayoutAction_label;
- public static String JsGlobalScopeContainer_unbound_label;
- public static String JsGlobalScopeContainer_unknown_label;
- public static String PackageExplorerPart_workspace;
- public static String PackageExplorerPart_workingSetModel;
- public static String PackageExplorerContentProvider_update_job_description;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, PackagesMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.properties
deleted file mode 100644
index e5d11bb9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackagesMessages.properties
+++ /dev/null
@@ -1,71 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-
-DragAdapter_deleting=Deleting ...
-DragAdapter_problem=Problem while moving or copying files.
-DragAdapter_problemTitle=Drag & Drop
-DragAdapter_refreshing=Refreshing...
-
-DropAdapter_errorTitle=Drag & Drop
-DropAdapter_errorMessage=Error while moving or copying files.
-
-
-GotoPackage_action_label=&Package...
-GotoPackage_dialog_message=&Choose a package (? = any character, * = any string):
-GotoPackage_dialog_title=Go to Package
-GotoPackage_action_description=Searches for and selects the package entered.
-
-GotoRequiredProjectAction_label=Go to Project
-GotoRequiredProjectAction_description=Go to Project
-GotoRequiredProjectAction_tooltip=Go to Project
-
-GotoType_action_label=&Type...
-GotoType_action_description=Searches for and selects the type entered.
-GotoType_dialog_message=&Choose a type (? = any character, * = any string):
-GotoType_dialog_title=Go to Type
-GotoType_error_message=An exception occurred while searching for types
-
-GotoResource_action_label=&Resource...
-GotoResource_dialog_title= Go to Resource
-
-PackageExplorer_title=JavaScript Explorer
-PackageExplorer_toolTip= Working Set: {0}
-PackageExplorer_toolTip2= {0} - Working Set: {1}
-PackageExplorer_toolTip3= {0}/{1}
-
-PackageExplorer_element_not_present=Cannot reveal {0} in Script Explorer. The element may be hidden by a filter or an active working set.
-
-PackageExplorer_filteredDialog_title=Show In JavaScript Explorer
-PackageExplorer_notFound=Cannot reveal the selected element. Do you want to deselect the current working set ''{0}''?
-PackageExplorer_removeFilters=Cannot reveal the selected element. Do you want to remove some filters to reveal the element?
-PackageExplorerContentProvider_update_job_description=Update script explorer
-
-PackageExplorerPart_workspace=Workspace
-PackageExplorerPart_workingSetModel=Working Sets
-PackageExplorerPart_notFoundSepcific=Cannot reveal ''{0}''. Do you want to deselect the current working set ''{1}''?
-PackageExplorerPart_removeFiltersSpecific=Cannot reveal ''{0}''. Do you want to remove some filters to reveal the element?
-
-SelectionTransferDropAdapter_error_title=Drag and drop
-SelectionTransferDropAdapter_error_message=Unexpected exception. See log for details
-
-CollapseAllAction_label=Collapse All
-CollapseAllAction_tooltip=Collapse All
-CollapseAllAction_description=Collapse All
-
-LayoutActionGroup_label= Folder &Presentation
-LayoutActionGroup_flatLayoutAction_label= &Flat
-LayoutActionGroup_show_libraries_in_group=Show 'Referenced Libraries' Node
-LayoutActionGroup_hierarchicalLayoutAction_label= &Hierarchical
-
-JsGlobalScopeContainer_unbound_label={0} (unbound)
-JsGlobalScopeContainer_unknown_label={0} (unknown)
-LibraryContainer_name=Referenced Libraries
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDragAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDragAdapter.java
deleted file mode 100644
index 5ad5ebca..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDragAdapter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.wst.jsdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
-
-public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
-
- public SelectionTransferDragAdapter(ISelectionProvider provider) {
- super(provider);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDropAdapter.java
deleted file mode 100644
index bd421314..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/SelectionTransferDropAdapter.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.util.TransferDropTargetListener;
-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.Transfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.ReorgCopyStarter;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.ReorgMoveStarter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-public class SelectionTransferDropAdapter extends JdtViewerDropAdapter implements TransferDropTargetListener {
-
- private List fElements;
- private JavaMoveProcessor fMoveProcessor;
- private int fCanMoveElements;
- private JavaCopyProcessor fCopyProcessor;
- private int fCanCopyElements;
- private ISelection fSelection;
-
- private static final long DROP_TIME_DIFF_TRESHOLD= 150;
-
- public SelectionTransferDropAdapter(StructuredViewer viewer) {
- super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
- }
-
- //---- TransferDropTargetListener interface ---------------------------------------
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getInstance();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
- if (target == null)
- return false;
- return target instanceof IJavaScriptElement || target instanceof IResource;
- }
-
- //---- Actual DND -----------------------------------------------------------------
-
- public void dragEnter(DropTargetEvent event) {
- clear();
- super.dragEnter(event);
- }
-
- public void dragLeave(DropTargetEvent event) {
- clear();
- super.dragLeave(event);
- }
-
- private void clear() {
- fElements= null;
- fSelection= null;
- fMoveProcessor= null;
- fCanMoveElements= 0;
- fCopyProcessor= null;
- fCanCopyElements= 0;
- }
-
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
-
- if (tooFast(event))
- return;
-
- initializeSelection();
-
- try {
- switch(operation) {
- case DND.DROP_DEFAULT: event.detail= handleValidateDefault(target, event); break;
- case DND.DROP_COPY: event.detail= handleValidateCopy(target, event); break;
- case DND.DROP_MOVE: event.detail= handleValidateMove(target, event); break;
- }
- } catch (JavaScriptModelException e){
- ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message);
- event.detail= DND.DROP_NONE;
- }
- }
-
- protected void initializeSelection(){
- if (fElements != null)
- return;
- ISelection s= LocalSelectionTransfer.getInstance().getSelection();
- if (!(s instanceof IStructuredSelection))
- return;
- fSelection= s;
- fElements= ((IStructuredSelection)s).toList();
- }
-
- protected ISelection getSelection(){
- return fSelection;
- }
-
- private boolean tooFast(DropTargetEvent event) {
- return Math.abs(LocalSelectionTransfer.getInstance().getSelectionSetTime() - (event.time & 0xFFFFFFFFL)) < DROP_TIME_DIFF_TRESHOLD;
- }
-
- public void drop(Object target, DropTargetEvent event) {
- try{
- switch(event.detail) {
- case DND.DROP_MOVE: handleDropMove(target, event); break;
- case DND.DROP_COPY: handleDropCopy(target, event); break;
- }
- } catch (JavaScriptModelException e){
- ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message);
- } catch(InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- } catch (InterruptedException e) {
- //ok
- } finally {
- // The drag source listener must not perform any operation
- // since this drop adapter did the remove of the source even
- // if we moved something.
- event.detail= DND.DROP_NONE;
- }
- }
-
- private int handleValidateDefault(Object target, DropTargetEvent event) throws JavaScriptModelException{
- if (target == null)
- return DND.DROP_NONE;
-
- if ((event.operations & DND.DROP_MOVE) != 0) {
- return handleValidateMove(target, event);
- }
- if ((event.operations & DND.DROP_COPY) != 0) {
- return handleValidateCopy(target, event);
- }
- return DND.DROP_NONE;
- }
-
- private int handleValidateMove(Object target, DropTargetEvent event) throws JavaScriptModelException{
- if (target == null)
- return DND.DROP_NONE;
-
- if (fMoveProcessor == null) {
- IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements));
- if (policy.canEnable())
- fMoveProcessor= new JavaMoveProcessor(policy);
- }
-
- if (!canMoveElements())
- return DND.DROP_NONE;
-
- if (target instanceof IResource && fMoveProcessor != null && fMoveProcessor.setDestination((IResource)target).isOK())
- return DND.DROP_MOVE;
- else if (target instanceof IJavaScriptElement && fMoveProcessor != null && fMoveProcessor.setDestination((IJavaScriptElement)target).isOK())
- return DND.DROP_MOVE;
- else
- return DND.DROP_NONE;
- }
-
- private boolean canMoveElements() {
- if (fCanMoveElements == 0) {
- fCanMoveElements= 2;
- if (fMoveProcessor == null)
- fCanMoveElements= 1;
- }
- return fCanMoveElements == 2;
- }
-
- private void handleDropMove(final Object target, DropTargetEvent event) throws JavaScriptModelException, InvocationTargetException, InterruptedException{
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(fElements);
- IResource[] resources= ReorgUtils.getResources(fElements);
- ReorgMoveStarter starter= null;
- if (target instanceof IResource)
- starter= ReorgMoveStarter.create(javaElements, resources, (IResource)target);
- else if (target instanceof IJavaScriptElement)
- starter= ReorgMoveStarter.create(javaElements, resources, (IJavaScriptElement)target);
- if (starter != null)
- starter.run(getShell());
- }
-
- private int handleValidateCopy(Object target, DropTargetEvent event) throws JavaScriptModelException{
-
- if (fCopyProcessor == null) {
- final ICopyPolicy policy= ReorgPolicyFactory.createCopyPolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements));
- fCopyProcessor= policy.canEnable() ? new JavaCopyProcessor(policy) : null;
- }
-
- if (!canCopyElements())
- return DND.DROP_NONE;
-
- if (target instanceof IResource && fCopyProcessor != null && fCopyProcessor.setDestination((IResource)target).isOK())
- return DND.DROP_COPY;
- else if (target instanceof IJavaScriptElement && fCopyProcessor != null && fCopyProcessor.setDestination((IJavaScriptElement)target).isOK())
- return DND.DROP_COPY;
- else
- return DND.DROP_NONE;
- }
-
- private boolean canCopyElements() {
- if (fCanCopyElements == 0) {
- fCanCopyElements= 2;
- if (fCopyProcessor == null)
- fCanCopyElements= 1;
- }
- return fCanCopyElements == 2;
- }
-
- private void handleDropCopy(final Object target, DropTargetEvent event) throws JavaScriptModelException, InvocationTargetException, InterruptedException{
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(fElements);
- IResource[] resources= ReorgUtils.getResources(fElements);
- ReorgCopyStarter starter= null;
- if (target instanceof IResource)
- starter= ReorgCopyStarter.create(javaElements, resources, (IResource)target);
- else if (target instanceof IJavaScriptElement)
- starter= ReorgCopyStarter.create(javaElements, resources, (IJavaScriptElement)target);
- if (starter != null)
- starter.run(getShell());
- }
-
- private Shell getShell() {
- return getViewer().getControl().getShell();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/ToggleLinkingAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/ToggleLinkingAction.java
deleted file mode 100644
index fd7b20bb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/ToggleLinkingAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.wst.jsdt.internal.ui.actions.AbstractToggleLinkingAction;
-import org.eclipse.wst.jsdt.ui.IPackagesViewPart;
-
-
-/**
- * This action toggles whether this package explorer links its selection to the active
- * editor.
- *
- *
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- private IPackagesViewPart fPackageExplorerPart;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(IPackagesViewPart explorer) {
- setChecked(explorer.isLinkingEnabled());
- fPackageExplorerPart= explorer;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- fPackageExplorerPart.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
deleted file mode 100644
index 8d44d7ca..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetModel;
-
-public class WorkingSetAwareContentProvider extends PackageExplorerContentProvider implements IMultiElementTreeContentProvider {
-
- private WorkingSetModel fWorkingSetModel;
- private IPropertyChangeListener fListener;
-
- public WorkingSetAwareContentProvider(boolean provideMembers, WorkingSetModel model) {
- super(provideMembers);
- fWorkingSetModel= model;
- fListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- workingSetModelChanged(event);
- }
- };
- fWorkingSetModel.addPropertyChangeListener(fListener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- fWorkingSetModel.removePropertyChangeListener(fListener);
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasChildren(Object element) {
- if (element instanceof IWorkingSet)
- return true;
- return super.hasChildren(element);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object[] getChildren(Object element) {
- Object[] children;
- if (element instanceof WorkingSetModel) {
- Assert.isTrue(fWorkingSetModel == element);
- return fWorkingSetModel.getActiveWorkingSets();
- } else if (element instanceof IWorkingSet) {
- children= getWorkingSetChildren((IWorkingSet)element);
- } else {
- children= super.getChildren(element);
- }
- return children;
- }
-
- private Object[] getWorkingSetChildren(IWorkingSet set) {
- IAdaptable[] elements= fWorkingSetModel.getChildren(set);
- Set result= new HashSet(elements.length);
- for (int i= 0; i < elements.length; i++) {
- IAdaptable element= elements[i];
- if (element instanceof IProject) {
- processResource((IProject) element, result); // also add closed projects
- } else if (element instanceof IResource) {
- IProject project= ((IResource) element).getProject();
- if (project.isOpen()) {
- processResource((IResource) element, result);
- }
- } else if (element instanceof IJavaScriptProject) {
- result.add(element); // also add closed projects
- } else if (element instanceof IJavaScriptElement) {
- IJavaScriptElement elem= (IJavaScriptElement) element;
- IProject project= getProject(elem);
- if (project != null && project.isOpen()) {
- result.add(elem);
- }
- } else {
- IProject project= (IProject) element.getAdapter(IProject.class);
- if (project != null) {
- processResource(project, result);
- }
- }
- }
- return result.toArray();
- }
-
- private void processResource(IResource resource, Collection result) {
- IJavaScriptElement elem= JavaScriptCore.create(resource);
- if (elem != null && elem.exists()) {
- result.add(elem);
- } else {
- result.add(resource);
- }
- }
-
- private IProject getProject(IJavaScriptElement element) {
- IJavaScriptProject project= element.getJavaScriptProject();
- if (project == null)
- return null;
- return project.getProject();
- }
-
- /**
- * {@inheritDoc}
- */
- public TreePath[] getTreePaths(Object element) {
- if (element instanceof IWorkingSet) {
- TreePath path= new TreePath(new Object[] {element});
- return new TreePath[] {path};
- }
- List modelParents= getModelPath(element);
- List result= new ArrayList();
- for (int i= 0; i < modelParents.size(); i++) {
- result.addAll(getTreePaths(modelParents, i));
- }
- return (TreePath[])result.toArray(new TreePath[result.size()]);
- }
-
- private List getModelPath(Object element) {
- List result= new ArrayList();
- result.add(element);
- Object parent= super.getParent(element);
- Object input= getViewerInput();
- // stop at input or on JavaModel. We never visualize it anyway.
- while (parent != null && !parent.equals(input) && !(parent instanceof IJavaScriptModel)) {
- result.add(parent);
- parent= super.getParent(parent);
- }
- Collections.reverse(result);
- return result;
- }
-
- private List/*<TreePath>*/ getTreePaths(List modelParents, int index) {
- List result= new ArrayList();
- Object input= getViewerInput();
- Object element= modelParents.get(index);
- Object[] parents= fWorkingSetModel.getAllParents(element);
- for (int i= 0; i < parents.length; i++) {
- List chain= new ArrayList();
- if (!parents[i].equals(input))
- chain.add(parents[i]);
- for (int m= index; m < modelParents.size(); m++) {
- chain.add(modelParents.get(m));
- }
- result.add(new TreePath(chain.toArray()));
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getParent(Object child) {
- Object[] parents= fWorkingSetModel.getAllParents(child);
- if(parents.length == 0)
- return super.getParent(child);
- Object first= parents[0];
- return first;
- }
-
- protected void augmentElementToRefresh(List toRefresh, int relation, Object affectedElement) {
- // we are refreshing the JavaModel and are in working set mode.
- if (JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()).equals(affectedElement)) {
- toRefresh.remove(affectedElement);
- toRefresh.add(fWorkingSetModel);
- } else if (relation == GRANT_PARENT) {
- Object parent= internalGetParent(affectedElement);
- if (parent != null) {
- toRefresh.addAll(Arrays.asList(fWorkingSetModel.getAllParents(parent)));
- }
- }
- List nonProjetTopLevelElemens= fWorkingSetModel.getNonProjectTopLevelElements();
- if (nonProjetTopLevelElemens.isEmpty())
- return;
- List toAdd= new ArrayList();
- for (Iterator iter= nonProjetTopLevelElemens.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (isChildOf(element, toRefresh))
- toAdd.add(element);
- }
- toRefresh.addAll(toAdd);
- }
-
- private void workingSetModelChanged(PropertyChangeEvent event) {
- String property= event.getProperty();
- Object newValue= event.getNewValue();
- List toRefresh= new ArrayList(1);
- if (WorkingSetModel.CHANGE_WORKING_SET_MODEL_CONTENT.equals(property)) {
- toRefresh.add(fWorkingSetModel);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- toRefresh.add(newValue);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property)) {
- toRefresh.add(newValue);
- }
- ArrayList runnables= new ArrayList();
- postRefresh(toRefresh, true, runnables);
- executeRunnables(runnables);
- }
-
- private boolean isChildOf(Object element, List potentialParents) {
- // Calling super get parent to bypass working set mapping
- Object parent= super.getParent(element);
- if (parent == null)
- return false;
- for (Iterator iter= potentialParents.iterator(); iter.hasNext();) {
- Object potentialParent= iter.next();
- while(parent != null) {
- if (parent.equals(potentialParent))
- return true;
- parent= super.getParent(parent);
- }
-
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareJavaElementSorter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareJavaElementSorter.java
deleted file mode 100644
index 150dd494..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetAwareJavaElementSorter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-
-public class WorkingSetAwareJavaElementSorter extends JavaScriptElementComparator {
-
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (e1 instanceof IWorkingSet || e2 instanceof IWorkingSet)
- return 0;
-
- return super.compare(viewer, e1, e2);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetDropAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetDropAdapter.java
deleted file mode 100644
index 1f730816..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/WorkingSetDropAdapter.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.packageview;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDropAdapter;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.OthersWorkingSetUpdater;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.WorkingSetModel;
-
-public class WorkingSetDropAdapter extends JdtViewerDropAdapter implements TransferDropTargetListener {
-
- private PackageExplorerPart fPackageExplorer;
-
- private IStructuredSelection fSelection;
- private Object[] fElementsToAdds;
- private Set fCurrentElements;
- private IWorkingSet fWorkingSet;
-
- public WorkingSetDropAdapter(PackageExplorerPart part) {
- super(part.getTreeViewer(), DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
- fPackageExplorer= part;
- }
-
- //---- TransferDropTargetListener interface ---------------------------------------
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getInstance();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
- if (target == null)
- return false;
- ISelection selection= LocalSelectionTransfer.getInstance().getSelection();
- if (!isValidSelection(selection)) {
- return false;
- }
- if (!isValidTarget(target))
- return false;
-
- initializeState(target, selection);
- return true;
- }
-
- //---- Actual DND -----------------------------------------------------------------
-
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
- switch(operation) {
- case DND.DROP_DEFAULT:
- case DND.DROP_COPY:
- case DND.DROP_MOVE:
- event.detail= validateTarget(target, operation);
- break;
- case DND.DROP_LINK:
- event.detail= DND.DROP_NONE;
- break;
- }
- }
-
- private int validateTarget(Object target, int operation) {
- showInsertionFeedback(false);
- setDefaultFeedback(DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
- if (!isValidTarget(target))
- return DND.DROP_NONE;
- ISelection s= LocalSelectionTransfer.getInstance().getSelection();
- if (!isValidSelection(s)) {
- return DND.DROP_NONE;
- }
-
- initializeState(target, s);
-
- if (isWorkingSetSelection()) {
- setDefaultFeedback(DND.FEEDBACK_SCROLL);
- if (fLocation == LOCATION_BEFORE || fLocation == LOCATION_AFTER) {
- showInsertionFeedback(true);
- return DND.DROP_MOVE;
- }
- return DND.DROP_NONE;
- } else {
- if (isOthersWorkingSet(fWorkingSet) && operation == DND.DROP_COPY)
- return DND.DROP_NONE;
-
- List realJavaElements= new ArrayList();
- List realResource= new ArrayList();
- ReorgUtils.splitIntoJavaElementsAndResources(fElementsToAdds, realJavaElements, realResource);
- if (fElementsToAdds.length != realJavaElements.size() + realResource.size())
- return DND.DROP_NONE;
- for (Iterator iter= realJavaElements.iterator(); iter.hasNext();) {
- IJavaScriptElement element= (IJavaScriptElement)iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
- return DND.DROP_NONE;
- }
- for (Iterator iter= realResource.iterator(); iter.hasNext();) {
- IResource element= (IResource)iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
- return DND.DROP_NONE;
- }
- if (!(fSelection instanceof ITreeSelection)) {
- return DND.DROP_COPY;
- }
- ITreeSelection treeSelection= (ITreeSelection)fSelection;
- TreePath[] paths= treeSelection.getPaths();
- for (int i= 0; i < paths.length; i++) {
- TreePath path= paths[i];
- if (path.getSegmentCount() != 2)
- return DND.DROP_COPY;
- if (!(path.getSegment(0) instanceof IWorkingSet))
- return DND.DROP_COPY;
- if (paths.length == 1) {
- IWorkingSet ws= (IWorkingSet)path.getSegment(0);
- if (OthersWorkingSetUpdater.ID.equals(ws.getId()))
- return DND.DROP_MOVE;
- }
- }
- }
- if (operation == DND.DROP_DEFAULT)
- return DND.DROP_MOVE;
- return operation;
- }
-
- private boolean isValidTarget(Object target) {
- return target instanceof IWorkingSet;
- }
-
- private boolean isValidSelection(ISelection selection) {
- return selection instanceof IStructuredSelection;
- }
-
- private boolean isOthersWorkingSet(IWorkingSet ws) {
- return OthersWorkingSetUpdater.ID.equals(ws.getId());
- }
-
- private void initializeState(Object target, ISelection s) {
- fWorkingSet= (IWorkingSet)target;
- fSelection= (IStructuredSelection)s;
- fElementsToAdds= fSelection.toArray();
- fCurrentElements= new HashSet(Arrays.asList(fWorkingSet.getElements()));
- }
-
- private boolean isWorkingSetSelection() {
- for (int i= 0; i < fElementsToAdds.length; i++) {
- if (!(fElementsToAdds[i] instanceof IWorkingSet))
- return false;
- }
- return true;
- }
-
- public void drop(Object target, final DropTargetEvent event) {
- if (isWorkingSetSelection()) {
- performWorkingSetReordering();
- } else {
- performElementRearrange(event.detail);
- }
- // drag adapter has nothing to do, even on move.
- event.detail= DND.DROP_NONE;
- }
-
- private void performWorkingSetReordering() {
- WorkingSetModel model= fPackageExplorer.getWorkingSetModel();
- List activeWorkingSets= new ArrayList(Arrays.asList(model.getActiveWorkingSets()));
- int index= activeWorkingSets.indexOf(fWorkingSet);
- if (index != -1) {
- if (fLocation == LOCATION_AFTER)
- index++;
- List result= new ArrayList(activeWorkingSets.size());
- List selected= new ArrayList(Arrays.asList(fElementsToAdds));
- for (int i= 0; i < activeWorkingSets.size(); i++) {
- if (i == index) {
- result.addAll(selected);
- }
- Object element= activeWorkingSets.get(i);
- if (!selected.contains(element)) {
- result.add(element);
- }
- }
- if (index == activeWorkingSets.size())
- result.addAll(selected);
- model.setActiveWorkingSets((IWorkingSet[])result.toArray(new IWorkingSet[result.size()]));
- }
- }
-
- private void performElementRearrange(int eventDetail) {
- // only move if target isn't the other working set. If this is the case
- // the move will happenn automatically by refreshing the other working set
- if (!isOthersWorkingSet(fWorkingSet)) {
- List elements= new ArrayList(Arrays.asList(fWorkingSet.getElements()));
- elements.addAll(Arrays.asList(fElementsToAdds));
- fWorkingSet.setElements((IAdaptable[])elements.toArray(new IAdaptable[elements.size()]));
- }
- if (eventDetail == DND.DROP_MOVE) {
- ITreeSelection treeSelection= (ITreeSelection)fSelection;
- Map workingSets= groupByWorkingSets(treeSelection.getPaths());
- for (Iterator iter= workingSets.keySet().iterator(); iter.hasNext();) {
- IWorkingSet ws= (IWorkingSet)iter.next();
- List toRemove= (List)workingSets.get(ws);
- List currentElements= new ArrayList(Arrays.asList(ws.getElements()));
- currentElements.removeAll(toRemove);
- ws.setElements((IAdaptable[])currentElements.toArray(new IAdaptable[currentElements.size()]));
- }
- }
- }
-
- private Map/*<List<IWorkingSet>>*/ groupByWorkingSets(TreePath[] paths) {
- Map result= new HashMap();
- for (int i= 0; i < paths.length; i++) {
- TreePath path= paths[i];
- IWorkingSet ws= (IWorkingSet)path.getSegment(0);
- List l= (List)result.get(ws);
- if (l == null) {
- l= new ArrayList();
- result.put(ws, l);
- }
- l.add(path.getSegment(1));
- }
- return result;
- }
-
- //---- test methods for JUnit test since DnD is hard to simulate
-
- public int internalTestValidateTarget(Object target, int operation) {
- return validateTarget(target, operation);
- }
-
- public void internalTestDrop(Object target, int eventDetail) {
- if (isWorkingSetSelection()) {
- performWorkingSetReordering();
- } else {
- performElementRearrange(eventDetail);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlock.java
deleted file mode 100644
index ce0a9253..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlock.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-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.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.swt.widgets.Text;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-
-/**
- * Configures Java Editor typing preferences.
- *
- *
- */
-abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock {
-
- /**
- * Use as follows:
- *
- * <pre>
- * SectionManager manager= new SectionManager();
- * Composite composite= manager.createSectionComposite(parent);
- *
- * Composite xSection= manager.createSection("section X"));
- * xSection.setLayout(new FillLayout());
- * new Button(xSection, SWT.PUSH); // add controls to section..
- *
- * [...]
- *
- * return composite; // return main composite
- * </pre>
- */
- protected final class SectionManager {
- /** The preference setting for keeping no section open. */
- private static final String __NONE= "__none"; //$NON-NLS-1$
- private Set fSections= new HashSet();
- private boolean fIsBeingManaged= false;
- private ExpansionAdapter fListener= new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- ExpandableComposite source= (ExpandableComposite) e.getSource();
- updateSectionStyle(source);
- if (fIsBeingManaged)
- return;
- if (e.getState()) {
- try {
- fIsBeingManaged= true;
- for (Iterator iter= fSections.iterator(); iter.hasNext();) {
- ExpandableComposite composite= (ExpandableComposite) iter.next();
- if (composite != source)
- composite.setExpanded(false);
- }
- } finally {
- fIsBeingManaged= false;
- }
- if (fLastOpenKey != null && fDialogSettingsStore != null)
- fDialogSettingsStore.setValue(fLastOpenKey, source.getText());
- } else {
- if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null)
- fDialogSettingsStore.setValue(fLastOpenKey, __NONE);
- }
- ExpandableComposite exComp= getParentExpandableComposite(source);
- if (exComp != null)
- exComp.layout(true, true);
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.reflow(true);
- }
- }
- };
- private Composite fBody;
- private final String fLastOpenKey;
- private final IPreferenceStore fDialogSettingsStore;
- private ExpandableComposite fFirstChild= null;
- /**
- * Creates a new section manager.
- */
- public SectionManager() {
- this(null, null);
- }
- /**
- * Creates a new section manager.
- */
- public SectionManager(IPreferenceStore dialogSettingsStore, String lastOpenKey) {
- fDialogSettingsStore= dialogSettingsStore;
- fLastOpenKey= lastOpenKey;
- }
- private void manage(ExpandableComposite section) {
- if (section == null)
- throw new NullPointerException();
- if (fSections.add(section))
- section.addExpansionListener(fListener);
- makeScrollableCompositeAware(section);
- }
-
- /**
- * Creates a new composite that can contain a set of expandable
- * sections. A <code>ScrolledPageComposite</code> is created and a new
- * composite within that, to ensure that expanding the sections will
- * always have enough space, unless there already is a
- * <code>ScrolledComposite</code> along the parent chain of
- * <code>parent</code>, in which case a normal <code>Composite</code>
- * is created.
- * <p>
- * The receiver keeps a reference to the inner body composite, so that
- * new sections can be added via <code>createSection</code>.
- * </p>
- *
- * @param parent the parent composite
- * @return the newly created composite
- */
- public Composite createSectionComposite(Composite parent) {
- Assert.isTrue(fBody == null);
- boolean isNested= isNestedInScrolledComposite(parent);
- Composite composite;
- if (isNested) {
- composite= new Composite(parent, SWT.NONE);
- fBody= composite;
- } else {
- composite= new ScrolledPageContent(parent);
- fBody= ((ScrolledPageContent) composite).getBody();
- }
-
- fBody.setLayout(new GridLayout());
-
- return composite;
- }
-
- /**
- * Creates an expandable section within the parent created previously by
- * calling <code>createSectionComposite</code>. Controls can be added
- * directly to the returned composite, which has no layout initially.
- *
- * @param label the display name of the section
- * @return a composite within the expandable section
- */
- public Composite createSection(String label) {
- Assert.isNotNull(fBody);
- final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
- if (fFirstChild == null)
- fFirstChild= excomposite;
- excomposite.setText(label);
- String last= null;
- if (fLastOpenKey != null && fDialogSettingsStore != null)
- last= fDialogSettingsStore.getString(fLastOpenKey);
-
- if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
- excomposite.setExpanded(true);
- if (fFirstChild != excomposite)
- fFirstChild.setExpanded(false);
- } else {
- excomposite.setExpanded(false);
- }
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
-
- updateSectionStyle(excomposite);
- manage(excomposite);
-
- Composite contents= new Composite(excomposite, SWT.NONE);
- excomposite.setClient(contents);
-
- return contents;
- }
- }
-
- protected static final int INDENT= 20;
- private OverlayPreferenceStore fStore;
-
- private Map fCheckBoxes= new HashMap();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
-
- private Map fTextFields= new HashMap();
- private ModifyListener fTextFieldListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text= (Text) e.widget;
- fStore.setValue((String) fTextFields.get(text), text.getText());
- }
- };
-
- private ArrayList fNumberFields= new ArrayList();
- private ModifyListener fNumberFieldListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- numberFieldChanged((Text) e.widget);
- }
- };
-
- /**
- * List of master/slave listeners when there's a dependency.
- *
- * @see #createDependency(Button, Control)
- *
- */
- private ArrayList fMasterSlaveListeners= new ArrayList();
-
- private StatusInfo fStatus;
- private final PreferencePage fMainPage;
-
- public AbstractConfigurationBlock(OverlayPreferenceStore store) {
- Assert.isNotNull(store);
- fStore= store;
- fMainPage= null;
- }
-
- public AbstractConfigurationBlock(OverlayPreferenceStore store, PreferencePage mainPreferencePage) {
- Assert.isNotNull(store);
- Assert.isNotNull(mainPreferencePage);
- fStore= store;
- fMainPage= mainPreferencePage;
- }
-
- protected final ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ScrolledPageContent) {
- return (ScrolledPageContent) parent;
- }
- return null;
- }
-
- private final ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ExpandableComposite) {
- return (ExpandableComposite) parent;
- }
- return null;
- }
-
- protected void updateSectionStyle(ExpandableComposite excomposite) {
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
- }
-
- private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.adaptChild(control);
- }
- }
-
- private boolean isNestedInScrolledComposite(Composite parent) {
- return getParentScrolledComposite(parent) != null;
- }
-
- protected 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.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
- makeScrollableCompositeAware(checkBox);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- /**
- * Returns an array of size 2:
- * - first element is of type <code>Label</code>
- * - second element is of type <code>Text</code>
- * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
- *
- * @param composite the parent composite
- * @param label the text field's label
- * @param key the preference key
- * @param textLimit the text limit
- * @param indentation the field's indentation
- * @param isNumber <code>true</code> iff this text field is used to e4dit a number
- * @return the controls added
- */
- protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
-
- PixelConverter pixelConverter= new PixelConverter(composite);
-
- 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= pixelConverter.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 new Control[]{labelControl, textControl};
- }
-
- protected void createDependency(final Button master, final Control slave) {
- createDependency(master, new Control[] {slave});
- }
-
- protected void createDependency(final Button master, final Control[] slaves) {
- Assert.isTrue(slaves.length > 0);
- indent(slaves[0]);
- SelectionListener listener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean state= master.getSelection();
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(state);
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
- master.addSelectionListener(listener);
- fMasterSlaveListeners.add(listener);
- }
-
- protected static void indent(Control control) {
- ((GridData) control.getLayoutData()).horizontalIndent+= INDENT;
- }
-
- public void initialize() {
- initializeFields();
- }
-
- private void initializeFields() {
-
- Iterator iter= fCheckBoxes.keySet().iterator();
- while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= (String) fCheckBoxes.get(b);
- b.setSelection(fStore.getBoolean(key));
- }
-
- iter= fTextFields.keySet().iterator();
- while (iter.hasNext()) {
- Text t= (Text) iter.next();
- String key= (String) fTextFields.get(t);
- t.setText(fStore.getString(key));
- }
-
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
-
- updateStatus(new StatusInfo());
- }
-
- public void performOk() {
- }
-
- public void performDefaults() {
- initializeFields();
- }
-
- IStatus getStatus() {
- if (fStatus == null)
- fStatus= new StatusInfo();
- return fStatus;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
- *
- */
- public void dispose() {
- }
-
- private void numberFieldChanged(Text textControl) {
- String number= textControl.getText();
- IStatus status= validatePositiveNumber(number);
- if (!status.matches(IStatus.ERROR))
- fStore.setValue((String) fTextFields.get(textControl), number);
- updateStatus(status);
- }
-
- private IStatus validatePositiveNumber(String number) {
- StatusInfo status= new StatusInfo();
- if (number.length() == 0) {
- status.setError(PreferencesMessages.JavaEditorPreferencePage_empty_input);
- } else {
- try {
- int value= Integer.parseInt(number);
- if (value < 0)
- status.setError(Messages.format(PreferencesMessages.JavaEditorPreferencePage_invalid_input, number));
- } catch (NumberFormatException e) {
- status.setError(Messages.format(PreferencesMessages.JavaEditorPreferencePage_invalid_input, number));
- }
- }
- return status;
- }
-
- protected void updateStatus(IStatus status) {
- if (fMainPage == null)
- return;
- fMainPage.setValid(status.isOK());
- StatusUtil.applyToStatusLine(fMainPage, status);
- }
-
- protected final OverlayPreferenceStore getPreferenceStore() {
- return fStore;
- }
-
- protected Composite createSubsection(Composite parent, SectionManager manager, String label) {
- if (manager != null) {
- return manager.createSection(label);
- } else {
- Group group= new Group(parent, SWT.SHADOW_NONE);
- group.setText(label);
- GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
- group.setLayoutData(data);
- return group;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferenceAndPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferenceAndPropertyPage.java
deleted file mode 100644
index 503f7c5c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferenceAndPropertyPage.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.ui.preferences.IWorkingCopyManager;
-import org.eclipse.ui.preferences.WorkingCopyManager;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Abstract preference and property page which is used to wrap a
- * {@link org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceAndPropertyConfigurationBlock}.
- *
- *
- */
-public abstract class AbstractConfigurationBlockPreferenceAndPropertyPage extends PropertyAndPreferencePage {
-
- private IPreferenceAndPropertyConfigurationBlock fConfigurationBlock;
- private PreferencesAccess fAccess;
-
- public AbstractConfigurationBlockPreferenceAndPropertyPage() {
- }
-
- /**
- * Create a configuration block which does modify settings in <code>context</code>.
- *
- * @param context the context to modify
- * @return the preference block, not null
- */
- protected abstract IPreferenceAndPropertyConfigurationBlock createConfigurationBlock(IScopeContext context);
-
- protected abstract String getHelpId();
-
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
- }
-
- /**
- * {@inheritDoc}
- */
- protected Control createPreferenceContent(Composite parent) {
-
- IPreferencePageContainer container= getContainer();
- IWorkingCopyManager manager;
- if (container instanceof IWorkbenchPreferenceContainer) {
- manager= ((IWorkbenchPreferenceContainer)container).getWorkingCopyManager();
- } else {
- manager= new WorkingCopyManager(); // non shared
- }
- fAccess= PreferencesAccess.getWorkingCopyPreferences(manager);
- IProject project= getProject();
- IScopeContext context;
- if (project != null) {
- context= fAccess.getProjectScope(project);
- } else {
- context= fAccess.getInstanceScope();
- }
-
- fConfigurationBlock= createConfigurationBlock(context);
-
- Control content= fConfigurationBlock.createControl(parent);
-
- fConfigurationBlock.initialize();
-
- Dialog.applyDialogFont(content);
- return content;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean performOk() {
- fConfigurationBlock.performOk();
-
- try {
- fAccess.applyChanges();
- } catch (BackingStoreException e) {
- JavaScriptPlugin.log(e);
- }
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void performDefaults() {
- fConfigurationBlock.performDefaults();
- super.performDefaults();
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- fConfigurationBlock.dispose();
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (useProjectSpecificSettings) {
- fConfigurationBlock.enableProjectSettings();
- } else {
- fConfigurationBlock.disableProjectSettings();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
deleted file mode 100644
index 2657ec0f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Abstract preference page which is used to wrap a
- * {@link org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
- *
- *
- */
-public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
-
- private IPreferenceConfigurationBlock fConfigurationBlock;
- private OverlayPreferenceStore fOverlayStore;
-
-
- /**
- * Creates a new preference page.
- */
- public AbstractConfigurationBlockPreferencePage() {
- setDescription();
- setPreferenceStore();
- fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
- fConfigurationBlock= createConfigurationBlock(fOverlayStore);
- }
-
- protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
- protected abstract String getHelpId();
- protected abstract void setDescription();
- protected abstract void setPreferenceStore();
-
- /*
- * @see IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
-
- fOverlayStore.load();
- fOverlayStore.start();
-
- Control content= fConfigurationBlock.createControl(parent);
-
- initialize();
-
- Dialog.applyDialogFont(content);
- return content;
- }
-
- private void initialize() {
- fConfigurationBlock.initialize();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
-
- fConfigurationBlock.performOk();
-
- fOverlayStore.propagate();
-
- JavaScriptPlugin.getDefault().savePluginPreferences();
-
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- public void performDefaults() {
-
- fOverlayStore.loadDefaults();
- fConfigurationBlock.performDefaults();
-
- super.performDefaults();
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
-
- fConfigurationBlock.dispose();
-
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- fOverlayStore= null;
- }
-
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AppearancePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AppearancePreferencePage.java
deleted file mode 100644
index e8f24133..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/AppearancePreferencePage.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-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.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class AppearancePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private static final String SHOW_CU_CHILDREN= PreferenceConstants.SHOW_CU_CHILDREN;
- private static final String PREF_METHOD_RETURNTYPE= PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE;
-// private static final String PREF_METHOD_TYPEPARAMETERS= PreferenceConstants.APPEARANCE_METHOD_TYPEPARAMETERS;
-// private static final String PREF_COMPRESS_PACKAGE_NAMES= PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES;
-// private static final String PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW= PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW;
-// private static final String STACK_BROWSING_VIEWS_VERTICALLY= PreferenceConstants.BROWSING_STACK_VERTICALLY;
- private static final String PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER= PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER;
- private static final String PREF_CATEGORY= PreferenceConstants.APPEARANCE_CATEGORY;
-
- public static final String PREF_COLORED_LABELS= "colored_labels_in_views"; //$NON-NLS-1$
-
- private SelectionButtonDialogField fShowMethodReturnType;
- private SelectionButtonDialogField fShowCategory;
-// private SelectionButtonDialogField fCompressPackageNames;
-// private SelectionButtonDialogField fStackBrowsingViewsVertically;
- private SelectionButtonDialogField fShowMembersInPackageView;
-// private StringDialogField fPackageNamePattern;
- private SelectionButtonDialogField fFoldPackagesInPackageExplorer;
-// private SelectionButtonDialogField fShowMethodTypeParameters;
- private SelectionButtonDialogField fShowColoredLabels;
-
- public AppearancePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.AppearancePreferencePage_description);
-
- IDialogFieldListener listener= new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
- };
-
- fShowMethodReturnType= new SelectionButtonDialogField(SWT.CHECK);
- fShowMethodReturnType.setDialogFieldListener(listener);
-// fShowMethodReturnType.setLabelText(PreferencesMessages.AppearancePreferencePage_methodreturntype_label);
- fShowMethodReturnType.setLabelText(PreferencesMessages.AppearancePreferencePage_inferredmethodreturntype_label);
-
-// fShowMethodTypeParameters= new SelectionButtonDialogField(SWT.CHECK);
-// fShowMethodTypeParameters.setDialogFieldListener(listener);
-// fShowMethodTypeParameters.setLabelText(PreferencesMessages.AppearancePreferencePage_methodtypeparams_label);
-
- fShowCategory= new SelectionButtonDialogField(SWT.CHECK);
- fShowCategory.setDialogFieldListener(listener);
- fShowCategory.setLabelText(PreferencesMessages.AppearancePreferencePage_showCategory_label);
-
- fShowMembersInPackageView= new SelectionButtonDialogField(SWT.CHECK);
- fShowMembersInPackageView.setDialogFieldListener(listener);
- fShowMembersInPackageView.setLabelText(PreferencesMessages.AppearancePreferencePage_showMembersInPackagesView);
-
-// fStackBrowsingViewsVertically= new SelectionButtonDialogField(SWT.CHECK);
-// fStackBrowsingViewsVertically.setDialogFieldListener(listener);
-// fStackBrowsingViewsVertically.setLabelText(PreferencesMessages.AppearancePreferencePage_stackViewsVerticallyInTheJavaBrowsingPerspective);
-
- fFoldPackagesInPackageExplorer= new SelectionButtonDialogField(SWT.CHECK);
- fFoldPackagesInPackageExplorer.setDialogFieldListener(listener);
-// fFoldPackagesInPackageExplorer.setLabelText(PreferencesMessages.AppearancePreferencePage_foldEmptyPackages);
- fFoldPackagesInPackageExplorer.setLabelText(PreferencesMessages.AppearancePreferencePage_foldEmptySourceFolders);
-
-// fCompressPackageNames= new SelectionButtonDialogField(SWT.CHECK);
-// fCompressPackageNames.setDialogFieldListener(listener);
-// fCompressPackageNames.setLabelText(PreferencesMessages.AppearancePreferencePage_pkgNamePatternEnable_label);
-
-// fPackageNamePattern= new StringDialogField();
-// fPackageNamePattern.setDialogFieldListener(listener);
-// fPackageNamePattern.setLabelText(PreferencesMessages.AppearancePreferencePage_pkgNamePattern_label);
-
- fShowColoredLabels= new SelectionButtonDialogField(SWT.CHECK);
- fShowColoredLabels.setDialogFieldListener(listener);
- fShowColoredLabels.setLabelText(PreferencesMessages.AppearancePreferencePage_coloredlabels_label);
- }
-
- private void initFields() {
- IPreferenceStore prefs= getPreferenceStore();
- fShowMethodReturnType.setSelection(prefs.getBoolean(PREF_METHOD_RETURNTYPE));
-// fShowMethodTypeParameters.setSelection(prefs.getBoolean(PREF_METHOD_TYPEPARAMETERS));
- fShowMembersInPackageView.setSelection(prefs.getBoolean(SHOW_CU_CHILDREN));
- fShowCategory.setSelection(prefs.getBoolean(PREF_CATEGORY));
-// fStackBrowsingViewsVertically.setSelection(prefs.getBoolean(STACK_BROWSING_VIEWS_VERTICALLY));
-// fPackageNamePattern.setText(prefs.getString(PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW));
-// fCompressPackageNames.setSelection(prefs.getBoolean(PREF_COMPRESS_PACKAGE_NAMES));
-// fPackageNamePattern.setEnabled(fCompressPackageNames.isSelected());
- fFoldPackagesInPackageExplorer.setSelection(prefs.getBoolean(PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER));
-
- fShowColoredLabels.setSelection(prefs.getBoolean(PREF_COLORED_LABELS));
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.APPEARANCE_PREFERENCE_PAGE);
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
- int nColumns= 1;
-
- Composite result= new Composite(parent, SWT.NONE);
- result.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.numColumns= nColumns;
- result.setLayout(layout);
-
- fShowMethodReturnType.doFillIntoGrid(result, nColumns);
-// fShowMethodTypeParameters.doFillIntoGrid(result, nColumns);
- fShowCategory.doFillIntoGrid(result, nColumns);
- fShowMembersInPackageView.doFillIntoGrid(result, nColumns);
- fShowColoredLabels.doFillIntoGrid(result, nColumns);
- fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns);
-
-// new Separator().doFillIntoGrid(result, nColumns);
-
-// fCompressPackageNames.doFillIntoGrid(result, nColumns);
-// fPackageNamePattern.doFillIntoGrid(result, 2);
-// LayoutUtil.setHorizontalGrabbing(fPackageNamePattern.getTextControl(null));
-// LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null), convertWidthInCharsToPixels(65));
-
-// new Separator().doFillIntoGrid(result, nColumns);
-// fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns);
-
-// String noteTitle= PreferencesMessages.AppearancePreferencePage_note;
-// String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives;
-// Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
-// GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-// gd.horizontalSpan= 2;
-// noteControl.setLayoutData(gd);
-
- initFields();
-
- Dialog.applyDialogFont(result);
- return result;
- }
-
- private void doDialogFieldChanged(DialogField field) {
-// if (field == fCompressPackageNames)
-// fPackageNamePattern.setEnabled(fCompressPackageNames.isSelected());
-
- updateStatus(getValidationStatus());
- }
-
- private IStatus getValidationStatus(){
-// if (fCompressPackageNames.isSelected() && fPackageNamePattern.getText().equals("")) //$NON-NLS-1$
-// return new StatusInfo(IStatus.ERROR, PreferencesMessages.AppearancePreferencePage_packageNameCompressionPattern_error_isEmpty);
-// else
- return new StatusInfo();
- }
-
- private void updateStatus(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore prefs= getPreferenceStore();
- prefs.setValue(PREF_METHOD_RETURNTYPE, fShowMethodReturnType.isSelected());
-// prefs.setValue(PREF_METHOD_TYPEPARAMETERS, fShowMethodTypeParameters.isSelected());
- prefs.setValue(PREF_CATEGORY, fShowCategory.isSelected());
- prefs.setValue(SHOW_CU_CHILDREN, fShowMembersInPackageView.isSelected());
-// prefs.setValue(STACK_BROWSING_VIEWS_VERTICALLY, fStackBrowsingViewsVertically.isSelected());
-// prefs.setValue(PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW, fPackageNamePattern.getText());
-// prefs.setValue(PREF_COMPRESS_PACKAGE_NAMES, fCompressPackageNames.isSelected());
- prefs.setValue(PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, fFoldPackagesInPackageExplorer.isSelected());
- prefs.setValue(PREF_COLORED_LABELS, fShowColoredLabels.isSelected());
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return super.performOk();
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore prefs= getPreferenceStore();
- fShowMethodReturnType.setSelection(prefs.getDefaultBoolean(PREF_METHOD_RETURNTYPE));
-// fShowMethodTypeParameters.setSelection(prefs.getDefaultBoolean(PREF_METHOD_TYPEPARAMETERS));
- fShowCategory.setSelection(prefs.getDefaultBoolean(PREF_CATEGORY));
- fShowMembersInPackageView.setSelection(prefs.getDefaultBoolean(SHOW_CU_CHILDREN));
-// fStackBrowsingViewsVertically.setSelection(prefs.getDefaultBoolean(STACK_BROWSING_VIEWS_VERTICALLY));
-// fPackageNamePattern.setText(prefs.getDefaultString(PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW));
-// fCompressPackageNames.setSelection(prefs.getDefaultBoolean(PREF_COMPRESS_PACKAGE_NAMES));
- fFoldPackagesInPackageExplorer.setSelection(prefs.getDefaultBoolean(PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER));
- fShowColoredLabels.setSelection(false);
- super.performDefaults();
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BuildPathsPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BuildPathsPropertyPage.java
deleted file mode 100644
index 8d92e0cd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BuildPathsPropertyPage.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-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.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
-
-/**
- * Property page for configuring the Java build path
- */
-public class BuildPathsPropertyPage extends PropertyPage implements IStatusChangeListener {
-
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.BuildPathsPropertyPage"; //$NON-NLS-1$
-
- private static final String PAGE_SETTINGS= "BuildPathsPropertyPage"; //$NON-NLS-1$
- private static final String INDEX= "pageIndex"; //$NON-NLS-1$
-
- public static final Object DATA_ADD_ENTRY= "add_classpath_entry"; //$NON-NLS-1$
-
- public static final Object DATA_REVEAL_ENTRY= "select_classpath_entry"; //$NON-NLS-1$
- public static final Object DATA_REVEAL_ATTRIBUTE_KEY= "select_classpath_attribute_key"; //$NON-NLS-1$
- public static final String DATA_PAGE_INDEX= "pageIndex"; //$NON-NLS-1$
-
- public static final Object DATA_BLOCK= "block_until_buildpath_applied"; //$NON-NLS-1$
-
- private BuildPathsBlock fBuildPathsBlock;
- private boolean fBlockOnApply= false;
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- protected Control createContents(Composite parent) {
- // ensure the page has no special buttons
- noDefaultAndApplyButton();
-
- IProject project= getProject();
- Control result;
- if (project == null || !isJavaProject(project)) {
- result= createWithoutJava(parent);
- } else if (!project.isOpen()) {
- result= createForClosedProject(parent);
- } else {
- result= createWithJava(parent, project);
- }
- Dialog.applyDialogFont(result);
- return result;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.BUILD_PATH_PROPERTY_PAGE);
- }
-
- private IDialogSettings getSettings() {
- IDialogSettings javaSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- IDialogSettings pageSettings= javaSettings.getSection(PAGE_SETTINGS);
- if (pageSettings == null) {
- pageSettings= javaSettings.addNewSection(PAGE_SETTINGS);
- pageSettings.put(INDEX, 0);
- }
- return pageSettings;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- if (fBuildPathsBlock != null) {
- if (!visible) {
- fBuildPathsBlock.aboutToDispose();
- if (fBuildPathsBlock.hasChangesInDialog()) {
- String title= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title;
- String message= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message;
- String[] buttonLabels= new String[] {
- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save,
- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard,
- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore
- };
- MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
- int res= dialog.open();
- if (res == 0) {
- performOk();
- } else if (res == 1) {
- fBuildPathsBlock.init(JavaScriptCore.create(getProject()), null);
- } else {
- // keep unsaved
- }
- }
- } else {
- fBuildPathsBlock.aboutToShow();
- if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInClasspathFile()) {
- fBuildPathsBlock.init(JavaScriptCore.create(getProject()), null);
- }
- }
- }
- super.setVisible(visible);
- }
-
-
- /*
- * Content for valid projects.
- */
- private Control createWithJava(Composite parent, IProject project) {
- IWorkbenchPreferenceContainer pageContainer= null;
- IPreferencePageContainer container= getContainer();
- if (container instanceof IWorkbenchPreferenceContainer) {
- pageContainer= (IWorkbenchPreferenceContainer) container;
- }
-
- fBuildPathsBlock= new BuildPathsBlock(new BusyIndicatorRunnableContext(), this, getSettings().getInt(INDEX), false, pageContainer);
- fBuildPathsBlock.init(JavaScriptCore.create(project), null);
- return fBuildPathsBlock.createControl(parent);
- }
-
- /*
- * Content for non-Java projects.
- */
- private Control createWithoutJava(Composite parent) {
- Label label= new Label(parent, SWT.LEFT);
- label.setText(PreferencesMessages.BuildPathsPropertyPage_no_java_project_message);
-
- fBuildPathsBlock= null;
- setValid(true);
- return label;
- }
-
- /*
- * Content for closed projects.
- */
- private Control createForClosedProject(Composite parent) {
- Label label= new Label(parent, SWT.LEFT);
- label.setText(PreferencesMessages.BuildPathsPropertyPage_closed_project_message);
-
- fBuildPathsBlock= null;
- setValid(true);
- return label;
- }
-
- private IProject getProject() {
- IAdaptable adaptable= getElement();
- if (adaptable != null) {
- IProject elem= (IProject) adaptable.getAdapter(IProject.class);
- if(elem!=null) return elem;
- }
- return null;
- }
-
- private boolean isJavaProject(IProject proj) {
- try {
- return proj.hasNature(JavaScriptCore.NATURE_ID);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- return false;
- }
-
- /*
- * @see IPreferencePage#performOk
- */
- public boolean performOk() {
- if (fBuildPathsBlock != null) {
- fBuildPathsBlock.aboutToDispose();
- getSettings().put(INDEX, fBuildPathsBlock.getPageIndex());
- if (fBuildPathsBlock.hasChangesInDialog() || fBuildPathsBlock.isClassfileMissing() || fBuildPathsBlock.hasChangesInSuper()) {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- fBuildPathsBlock.configureJavaProject(monitor);
- }
- };
- WorkbenchRunnableAdapter op= new WorkbenchRunnableAdapter(runnable);
- if (fBlockOnApply) {
- try {
- new ProgressMonitorDialog(getShell()).run(true, true, op);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), PreferencesMessages.BuildPathsPropertyPage_error_title, PreferencesMessages.BuildPathsPropertyPage_error_message);
- return false;
- } catch (InterruptedException e) {
- return false;
- }
- } else {
- op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null);
- }
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see IStatusChangeListener#statusChanged
- */
- public void statusChanged(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- if (data instanceof Map) {
- Map map= (Map) data;
- Object selectedLibrary= map.get(DATA_REVEAL_ENTRY);
- if (selectedLibrary instanceof IIncludePathEntry) {
- IIncludePathEntry entry= (IIncludePathEntry) selectedLibrary;
- Object attr= map.get(DATA_REVEAL_ATTRIBUTE_KEY);
- String attributeKey= attr instanceof String ? (String) attr : null;
- if (fBuildPathsBlock != null) {
- fBuildPathsBlock.setElementToReveal(entry, attributeKey);
- }
- }
- Object entryToAdd= map.get(DATA_ADD_ENTRY);
- if (entryToAdd instanceof IIncludePathEntry) {
- if (fBuildPathsBlock != null) {
- fBuildPathsBlock.addElement((IIncludePathEntry) entryToAdd);
- }
- }
-
- Object pageIndex = map.get(DATA_PAGE_INDEX);
-
- if(pageIndex instanceof Integer) {
- fBuildPathsBlock.showPage(((Integer)pageIndex).intValue());
- }
-
- fBlockOnApply= Boolean.TRUE.equals(map.get(DATA_BLOCK));
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BulletListBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BulletListBlock.java
deleted file mode 100644
index b868c1a4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/BulletListBlock.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.Bullet;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GlyphMetrics;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Each line of the given text is preceded by a bullet.
- */
-public class BulletListBlock {
-
- private StyledText fStyledText;
- private boolean fEnabled;
- private String fText;
-
- public BulletListBlock() {
- fEnabled= true;
- fText= ""; //$NON-NLS-1$
- }
-
- public Control createControl(Composite parent) {
- fStyledText= new StyledText(parent, SWT.FLAT | SWT.BORDER | SWT.READ_ONLY);
-
- final GridData data= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- fStyledText.setLayoutData(data);
- configureStyledText(fText, fEnabled);
-
- return fStyledText;
- }
-
- public void setText(String text) {
- fText= text;
- configureStyledText(fText, fEnabled);
- }
-
- public void setEnabled(boolean enabled) {
- fEnabled= enabled;
- configureStyledText(fText, fEnabled);
- }
-
- private void configureStyledText(String text, boolean enabled) {
- if (fStyledText == null)
- return;
-
- fStyledText.setText(text);
- int count= fStyledText.getCharCount();
- if (count == 0)
- return;
-
- Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
-
- fStyledText.setStyleRange(new StyleRange(0, count, foreground, null));
-
- StyleRange styleRange= new StyleRange(0, count, foreground, null);
- styleRange.metrics= new GlyphMetrics(0, 0, 20);
- fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange));
-
- fStyledText.setEnabled(enabled);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ClasspathVariablesPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ClasspathVariablesPreferencePage.java
deleted file mode 100644
index 1313775b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ClasspathVariablesPreferencePage.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.VariableBlock;
-
-public class ClasspathVariablesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String ID= "org.eclipse.wst.jsdt.ui.preferences.ClasspathVariablesPreferencePage"; //$NON-NLS-1$
-
- public static final String DATA_SELECT_VARIABLE= "ClasspathVariablesPreferencePage.select_var"; //$NON-NLS-1$
-
- private VariableBlock fVariableBlock;
- private String fStoredSettings;
-
- /**
- * Constructor for ClasspathVariablesPreferencePage
- */
- public ClasspathVariablesPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- fVariableBlock= new VariableBlock(true, null);
- fStoredSettings= null;
-
- // title only used when page is shown programatically
- setTitle(PreferencesMessages.ClasspathVariablesPreferencePage_title);
- setDescription(PreferencesMessages.ClasspathVariablesPreferencePage_description);
- noDefaultAndApplyButton();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CP_VARIABLES_PREFERENCE_PAGE);
- }
-
- /*
- * @see PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- Control result= fVariableBlock.createContents(parent);
- Dialog.applyDialogFont(result);
- return result;
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- // not used (constructor calls noDefaultAndApplyButton())
-// fVariableBlock.performDefaults();
- super.performDefaults();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return fVariableBlock.performOk();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- // check if the stored settings have changed
- if (visible) {
- if (fStoredSettings != null && !fStoredSettings.equals(getCurrentSettings())) {
- fVariableBlock.refresh(null);
- }
- } else {
- if (fVariableBlock.hasChanges()) {
- String title= PreferencesMessages.ClasspathVariablesPreferencePage_savechanges_title;
- String message= PreferencesMessages.ClasspathVariablesPreferencePage_savechanges_message;
- if (MessageDialog.openQuestion(getShell(), title, message)) {
- performOk();
- }
- fVariableBlock.setChanges(false); // forget
- }
- fStoredSettings= getCurrentSettings();
- }
- super.setVisible(visible);
- }
-
- private String getCurrentSettings() {
- StringBuffer buf= new StringBuffer();
- String[] names= JavaScriptCore.getIncludepathVariableNames();
- for (int i= 0; i < names.length; i++) {
- String curr= names[i];
- buf.append(curr).append('\0');
- IPath val= JavaScriptCore.getIncludepathVariable(curr);
- if (val != null) {
- buf.append(val.toString());
- }
- buf.append('\0');
- }
- return buf.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- if (data instanceof Map) {
- Object id= ((Map) data).get(DATA_SELECT_VARIABLE);
- if (id instanceof String) {
- fVariableBlock.setSelection((String) id);
- }
- }
- super.applyData(data);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CleanUpPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CleanUpPreferencePage.java
deleted file mode 100644
index 8ee7ce9e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CleanUpPreferencePage.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CleanUpConfigurationBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileConfigurationBlock;
-
-/*
- * The page to configure the clean up options.
- */
-public class CleanUpPreferencePage extends ProfilePreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.CleanUpPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.CleanUpPreferencePage"; //$NON-NLS-1$
-
- public CleanUpPreferencePage() {
- // only used when page is shown programmatically
- setTitle(PreferencesMessages.CleanUpPreferencePage_Title );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.ProfilePreferencePage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
- }
-
- protected ProfileConfigurationBlock createConfigurationBlock(PreferencesAccess access) {
- return new CleanUpConfigurationBlock(getProject(), access);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
deleted file mode 100644
index 7a276fd9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
+++ /dev/null
@@ -1,768 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.IParameter;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.contexts.ContextManager;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.jface.bindings.Scheme;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.GC;
-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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalCategory;
-import org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalComputerRegistry;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- *
- *
- */
-final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_EXCLUDED_CATEGORIES= getJDTUIKey(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- private static final Key PREF_CATEGORY_ORDER= getJDTUIKey(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
- private static final Key PREF_CODEASSIST_TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC= getJDTCoreKey(JavaScriptCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC);
-
- private static Key[] getAllKeys() {
- return new Key[] {
- PREF_EXCLUDED_CATEGORIES,
- PREF_CATEGORY_ORDER,
- PREF_CODEASSIST_TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC
- };
- }
-
- private final class DefaultTableLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0)
- return ((ModelElement) element).getImage();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- switch (columnIndex) {
- case 0:
- return ((ModelElement) element).getName();
- case 1:
- return ((ModelElement) element).getKeybindingAsString();
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return getColumnText(element, 0); // needed to make the sorter work
- }
- }
-
- private final class SeparateTableLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0)
- return ((ModelElement) element).getImage();
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- switch (columnIndex) {
- case 0:
- return ((ModelElement) element).getName();
- default:
- Assert.isTrue(false);
- return null;
- }
- }
- }
-
- private final Comparator fCategoryComparator= new Comparator() {
- private int getRank(Object o) {
- return ((ModelElement) o).getRank();
- }
-
- public int compare(Object o1, Object o2) {
- return getRank(o1) - getRank(o2);
- }
- };
-
- private final class PreferenceModel {
- private static final int LIMIT= 0xffff;
- private static final String COLON= ":"; //$NON-NLS-1$
- private static final String SEPARATOR= "\0"; //$NON-NLS-1$
-
- private final List fElements;
- /**
- * The read-only list of elements.
- */
- final List elements;
-
- public PreferenceModel(CompletionProposalComputerRegistry registry) {
- List categories= registry.getProposalCategories();
- fElements= new ArrayList();
- for (Iterator it= categories.iterator(); it.hasNext();) {
- CompletionProposalCategory category= (CompletionProposalCategory) it.next();
- if (category.hasComputers()) {
- fElements.add(new ModelElement(category, this));
- }
- }
- Collections.sort(fElements, fCategoryComparator);
- elements= Collections.unmodifiableList(fElements);
- }
-
- public void moveUp(ModelElement category) {
- int index= fElements.indexOf(category);
- if (index > 0) {
- Object item= fElements.remove(index);
- fElements.add(index - 1, item);
- writeOrderPreference(null, false);
- }
- }
-
- public void moveDown(ModelElement category) {
- int index= fElements.indexOf(category);
- if (index < fElements.size() - 1) {
- Object item= fElements.remove(index);
- fElements.add(index + 1, item);
- writeOrderPreference(null, false);
- }
- }
-
- private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
- StringBuffer buf= new StringBuffer();
- for (Iterator it= fElements.iterator(); it.hasNext();) {
- ModelElement item= (ModelElement) it.next();
- boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory();
- if (!included)
- buf.append(item.getId() + SEPARATOR);
- }
-
- String newValue= buf.toString();
- String oldValue= setValue(PREF_EXCLUDED_CATEGORIES, newValue);
- validateSettings(PREF_EXCLUDED_CATEGORIES, oldValue, newValue);
- }
-
- private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
- StringBuffer buf= new StringBuffer();
- int i= 0;
- for (Iterator it= fElements.iterator(); it.hasNext(); i++) {
- ModelElement item= (ModelElement) it.next();
- boolean separate= changed == item ? isSeparate : item.isSeparateCommand();
- int rank= separate ? i : i + LIMIT;
- buf.append(item.getId() + COLON + rank + SEPARATOR);
- }
-
- String newValue= buf.toString();
- String oldValue= setValue(PREF_CATEGORY_ORDER, newValue);
- validateSettings(PREF_CATEGORY_ORDER, oldValue, newValue);
- }
-
-
- private boolean readInclusionPreference(CompletionProposalCategory cat) {
- String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
- for (int i= 0; i < ids.length; i++) {
- if (ids[i].equals(cat.getId()))
- return false;
- }
- return true;
- }
-
- private int readOrderPreference(CompletionProposalCategory cat) {
- String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
- for (int i= 0; i < sortOrderIds.length; i++) {
- String[] idAndRank= getTokens(sortOrderIds[i], COLON);
- if (idAndRank[0].equals(cat.getId()))
- return Integer.parseInt(idAndRank[1]);
- }
- return LIMIT + 1;
- }
-
- public void update() {
- Collections.sort(fElements, fCategoryComparator);
- }
- }
-
- private final class ModelElement {
- private final CompletionProposalCategory fCategory;
- private final Command fCommand;
- private final IParameter fParam;
- private final PreferenceModel fPreferenceModel;
-
- ModelElement(CompletionProposalCategory category, PreferenceModel model) {
- fCategory= category;
- ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- fCommand= commandSvc.getCommand("org.eclipse.wst.jsdt.ui.specific_content_assist.command"); //$NON-NLS-1$
- IParameter type;
- try {
- type= fCommand.getParameters()[0];
- } catch (NotDefinedException x) {
- Assert.isTrue(false);
- type= null;
- }
- fParam= type;
- fPreferenceModel= model;
- }
- Image getImage() {
- return CodeAssistAdvancedConfigurationBlock.this.getImage(fCategory.getImageDescriptor());
- }
- String getName() {
- return fCategory.getDisplayName();
- }
- String getKeybindingAsString() {
- final Parameterization[] params= { new Parameterization(fParam, fCategory.getId()) };
- final ParameterizedCommand pCmd= new ParameterizedCommand(fCommand, params);
- String key= getKeyboardShortcut(pCmd);
- return key;
- }
- boolean isInDefaultCategory() {
- return fPreferenceModel.readInclusionPreference(fCategory);
- }
- void setInDefaultCategory(boolean included) {
- if (included != isInDefaultCategory())
- fPreferenceModel.writeInclusionPreference(this, included);
- }
- String getId() {
- return fCategory.getId();
- }
- int getRank() {
- int rank= getInternalRank();
- if (rank > PreferenceModel.LIMIT)
- return rank - PreferenceModel.LIMIT;
- return rank;
- }
- void moveUp() {
- fPreferenceModel.moveUp(this);
- }
- void moveDown() {
- fPreferenceModel.moveDown(this);
- }
- private int getInternalRank() {
- return fPreferenceModel.readOrderPreference(fCategory);
- }
- boolean isSeparateCommand() {
- return getInternalRank() < PreferenceModel.LIMIT;
- }
-
- void setSeparateCommand(boolean separate) {
- if (separate != isSeparateCommand())
- fPreferenceModel.writeOrderPreference(this, separate);
- }
-
- void update() {
- fCategory.setIncluded(isInDefaultCategory());
- int rank= getInternalRank();
- fCategory.setSortOrder(rank);
- fCategory.setSeparateCommand(rank < PreferenceModel.LIMIT);
- }
- }
-
- /** element type: {@link ModelElement}. */
- private final PreferenceModel fModel;
- private final Map fImages= new HashMap();
-
- private CheckboxTableViewer fDefaultViewer;
- private CheckboxTableViewer fSeparateViewer;
- private Button fUpButton;
- private Button fDownButton;
-
- CodeAssistAdvancedConfigurationBlock(IStatusChangeListener statusListener, IWorkbenchPreferenceContainer container) {
- super(statusListener, null, getAllKeys(), container);
- fModel= new PreferenceModel(CompletionProposalComputerRegistry.getDefault());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
-
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
-
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Composite composite= new Composite(scrolled, SWT.NONE);
- int columns= 2;
- GridLayout layout= new GridLayout(columns, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
-
- createDefaultLabel(composite, columns);
- createDefaultViewer(composite, columns);
- createKeysLink(composite, columns);
-
- createFiller(composite, columns);
-
- createSeparateLabel(composite, columns);
- createSeparateSection(composite);
-
- createFiller(composite, columns);
-
- createParameterTimeoutControl(composite, columns);
-
- updateControls();
- if (fModel.elements.size() > 0) {
- fDefaultViewer.getTable().select(0);
- fSeparateViewer.getTable().select(0);
- handleTableSelection();
- }
-
- scrolled.setContent(composite);
- scrolled.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- return scrolled;
- }
-
- private void createDefaultLabel(Composite composite, int h_span) {
- final ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- final Command command= commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
- String key= getKeyboardShortcut(pCmd);
- if (key == null)
- key= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_no_shortcut;
-
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
-
- Label label= new Label(composite, SWT.NONE | SWT.WRAP);
- label.setText(Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description, new Object[] { key }));
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
- gd.widthHint= width;
- label.setLayoutData(gd);
-
- createFiller(composite, h_span);
-
- label= new Label(composite, SWT.NONE | SWT.WRAP);
- label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_description);
- gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
- gd.widthHint= width;
- label.setLayoutData(gd);
- }
-
- private void createDefaultViewer(Composite composite, int h_span) {
- fDefaultViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
- Table table= fDefaultViewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(false);
- table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, h_span, 1));
-
- TableColumn nameColumn= new TableColumn(table, SWT.NONE);
- nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_category_column_title);
- nameColumn.setResizable(false);
- TableColumn keyColumn= new TableColumn(table, SWT.NONE);
- keyColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title);
- keyColumn.setResizable(false);
-
- fDefaultViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- boolean checked= event.getChecked();
- ModelElement element= (ModelElement) event.getElement();
- element.setInDefaultCategory(checked);
- }
- });
-
- fDefaultViewer.setContentProvider(new ArrayContentProvider());
-
- DefaultTableLabelProvider labelProvider= new DefaultTableLabelProvider();
- fDefaultViewer.setLabelProvider(labelProvider);
- fDefaultViewer.setInput(fModel.elements);
- fDefaultViewer.setComparator(new ViewerComparator()); // sort alphabetically
-
- final int ICON_AND_CHECKBOX_WITH= 50;
- final int HEADER_MARGIN= 20;
- int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
- int minKeyWidth= computeWidth(table, keyColumn.getText()) + HEADER_MARGIN;
- for (int i= 0; i < fModel.elements.size(); i++) {
- minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
- minKeyWidth= Math.max(minKeyWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 1)));
- }
-
- nameColumn.setWidth(minNameWidth);
- keyColumn.setWidth(minKeyWidth);
- }
-
- private void createKeysLink(Composite composite, int h_span) {
- Link link= new Link(composite, SWT.NONE | SWT.WRAP);
- link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
- }
- });
-
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
-
- // limit the size of the Link as it would take all it can get
- GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
- gd.widthHint= width;
- link.setLayoutData(gd);
- }
-
- private void createFiller(Composite composite, int h_span) {
- Label filler= new Label(composite, SWT.NONE);
- filler.setVisible(false);
- filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, h_span, 1));
- }
-
- private void createSeparateLabel(Composite composite, int h_span) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
-
- Label label= new Label(composite, SWT.NONE | SWT.WRAP);
- label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_description);
- GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
- gd.widthHint= width;
- label.setLayoutData(gd);
- }
-
- private void createSeparateSection(Composite composite) {
- createSeparateViewer(composite);
- createButtonList(composite);
- }
-
- private void createSeparateViewer(Composite composite) {
- fSeparateViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
- Table table= fSeparateViewer.getTable();
- table.setHeaderVisible(false);
- table.setLinesVisible(false);
- table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1));
-
- TableColumn nameColumn= new TableColumn(table, SWT.NONE);
- nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
- nameColumn.setResizable(false);
-
- fSeparateViewer.setContentProvider(new ArrayContentProvider());
-
- ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
- fSeparateViewer.setLabelProvider(labelProvider);
- fSeparateViewer.setInput(fModel.elements);
-
- final int ICON_AND_CHECKBOX_WITH= 50;
- final int HEADER_MARGIN= 20;
- int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
- for (int i= 0; i < fModel.elements.size(); i++) {
- minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
- }
-
- nameColumn.setWidth(minNameWidth);
-
- fSeparateViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- boolean checked= event.getChecked();
- ModelElement element= (ModelElement) event.getElement();
- element.setSeparateCommand(checked);
- }
- });
-
- table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleTableSelection();
- }
- });
-
- }
-
- private void createButtonList(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
-
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- fUpButton= new Button(composite, SWT.PUSH | SWT.CENTER);
- fUpButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Up);
- fUpButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index= getSelectionIndex();
- if (index != -1) {
- ((ModelElement) fModel.elements.get(index)).moveUp();
- fSeparateViewer.refresh();
- handleTableSelection();
- }
- }
- });
- fUpButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fUpButton);
-
- fDownButton= new Button(composite, SWT.PUSH | SWT.CENTER);
- fDownButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Down);
- fDownButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index= getSelectionIndex();
- if (index != -1) {
- ((ModelElement) fModel.elements.get(index)).moveDown();
- fSeparateViewer.refresh();
- handleTableSelection();
- }
- }
- });
- fDownButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fDownButton);
- }
-
- private void createParameterTimeoutControl(Composite composite, int h_span) {
- Composite timeoutComposite= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout(4, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- timeoutComposite.setLayout(layout);
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
- timeoutComposite.setLayoutData(gd);
-
- PixelConverter pixelConverter= new PixelConverter(composite);
- String str= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout;
- addTextField(timeoutComposite, str, PREF_CODEASSIST_TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, 0, pixelConverter.convertWidthInCharsToPixels(7));
-
- Label ms= new Label(timeoutComposite, SWT.NONE);
- gd= new GridData();
- ms.setLayoutData(gd);
- ms.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_ms);
-
- }
-
- private void handleTableSelection() {
- ModelElement item= getSelectedItem();
- if (item != null) {
- int index= getSelectionIndex();
- fUpButton.setEnabled(index > 0);
- fDownButton.setEnabled(index < fModel.elements.size() - 1);
- } else {
- fUpButton.setEnabled(false);
- fDownButton.setEnabled(false);
- }
- }
-
- private ModelElement getSelectedItem() {
- return (ModelElement) ((IStructuredSelection) fSeparateViewer.getSelection()).getFirstElement();
- }
-
- private int getSelectionIndex() {
- return fSeparateViewer.getTable().getSelectionIndex();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
- */
- protected void updateControls() {
- super.updateControls();
-
- fModel.update();
- updateCheckedState();
- fDefaultViewer.refresh();
- fSeparateViewer.refresh();
- handleTableSelection();
- }
-
- private void updateCheckedState() {
- final int size= fModel.elements.size();
- List defaultChecked= new ArrayList(size);
- List separateChecked= new ArrayList(size);
-
- for (Iterator it= fModel.elements.iterator(); it.hasNext();) {
- ModelElement element= (ModelElement) it.next();
- if (element.isInDefaultCategory())
- defaultChecked.add(element);
- if (element.isSeparateCommand())
- separateChecked.add(element);
- }
-
- fDefaultViewer.setCheckedElements(defaultChecked.toArray(new Object[defaultChecked.size()]));
- fSeparateViewer.setCheckedElements(separateChecked.toArray(new Object[separateChecked.size()]));
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#processChanges(org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)
- */
- protected boolean processChanges(IWorkbenchPreferenceContainer container) {
- for (Iterator it= fModel.elements.iterator(); it.hasNext();) {
- ModelElement item= (ModelElement) it.next();
- item.update();
- }
-
- return super.processChanges(container);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String)
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (changedKey == PREF_CODEASSIST_TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC) {
- final StatusInfo status= new StatusInfo();
- if (newValue.length() == 0)
- status.setError(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_emptyInput);
- else {
- try {
- int number= Integer.parseInt(newValue);
- int min= 0;
- int max= 5000;
- if (number < min || number > max) {
- String msgFormat= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidRange;
- String msg= Messages.format(msgFormat, new Object[] {new Integer(min), new Integer(max)});
- status.setError(msg);
- }
- } catch (NumberFormatException ex) {
- String msgFormat= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidInput;
- String msg= Messages.format(msgFormat, newValue);
- status.setError(msg);
- }
- }
- fContext.statusChanged(status);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
- */
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- // no builds triggered by our settings
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#dispose()
- */
- public void dispose() {
- for (Iterator it= fImages.values().iterator(); it.hasNext();) {
- Image image= (Image) it.next();
- image.dispose();
- }
-
- super.dispose();
- }
-
- private int computeWidth(Control control, String name) {
- if (name == null)
- return 0;
- GC gc= new GC(control);
- try {
- gc.setFont(JFaceResources.getDialogFont());
- return gc.stringExtent(name).x + 10;
- } finally {
- gc.dispose();
- }
- }
-
- private static BindingManager fgLocalBindingManager;
- static {
- fgLocalBindingManager= new BindingManager(new ContextManager(), new CommandManager());
- final IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getService(IBindingService.class);
- final Scheme[] definedSchemes= bindingService.getDefinedSchemes();
- if (definedSchemes != null) {
- try {
- for (int i = 0; i < definedSchemes.length; i++) {
- final Scheme scheme= definedSchemes[i];
- final Scheme copy= fgLocalBindingManager.getScheme(scheme.getId());
- copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
- }
- } catch (final NotDefinedException e) {
- JavaScriptPlugin.log(e);
- }
- }
- fgLocalBindingManager.setLocale(bindingService.getLocale());
- fgLocalBindingManager.setPlatform(bindingService.getPlatform());
- }
-
- private static String getKeyboardShortcut(ParameterizedCommand command) {
- IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- fgLocalBindingManager.setBindings(bindingService.getBindings());
- try {
- Scheme activeScheme= bindingService.getActiveScheme();
- if (activeScheme != null)
- fgLocalBindingManager.setActiveScheme(activeScheme);
- } catch (NotDefinedException e) {
- JavaScriptPlugin.log(e);
- }
-
- TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
- if (bindings.length > 0)
- return bindings[0].format();
- return null;
- }
-
- private Image getImage(ImageDescriptor imgDesc) {
- if (imgDesc == null)
- return null;
-
- Image img= (Image) fImages.get(imgDesc);
- if (img == null) {
- img= imgDesc.createImage(false);
- fImages.put(imgDesc, img);
- }
- return img;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
deleted file mode 100644
index 66173071..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferencePage {
-
- private CodeAssistAdvancedConfigurationBlock fConfigurationBlock;
-
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new CodeAssistAdvancedConfigurationBlock(getNewStatusChangedListener(), container);
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return false;
- }
-
- protected String getPreferencePageID() {
- return "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferenceAdvanced"; //$NON-NLS-1$
- }
-
- protected String getPropertyPageID() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistConfigurationBlock.java
deleted file mode 100644
index 85636133..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistConfigurationBlock.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-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.swt.widgets.Link;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.text.java.ProposalSorterHandle;
-import org.eclipse.wst.jsdt.internal.ui.text.java.ProposalSorterRegistry;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Configures the content assist preferences.
- *
- *
- */
-class CodeAssistConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_CODEASSIST_AUTOACTIVATION= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
- private static final Key PREF_CODEASSIST_AUTOACTIVATION_DELAY= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY);
- private static final Key PREF_CODEASSIST_AUTOINSERT= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOINSERT);
- private static final Key PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- private static final Key PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC);
- private static final Key PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS= getJDTUIKey(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS);
- private static final Key PREF_CODEASSIST_SORTER= getJDTUIKey(PreferenceConstants.CODEASSIST_SORTER);
- private static final Key PREF_CODEASSIST_CASE_SENSITIVITY= getJDTUIKey(PreferenceConstants.CODEASSIST_CASE_SENSITIVITY);
- private static final Key PREF_CODEASSIST_ADDIMPORT= getJDTUIKey(PreferenceConstants.CODEASSIST_ADDIMPORT);
- private static final Key PREF_CODEASSIST_SUGGEST_STATIC_IMPORTS= getJDTCoreKey(JavaScriptCore.CODEASSIST_SUGGEST_STATIC_IMPORTS);
- private static final Key PREF_CODEASSIST_INSERT_COMPLETION= getJDTUIKey(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
- private static final Key PREF_CODEASSIST_FILL_ARGUMENT_NAMES= getJDTUIKey(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
- private static final Key PREF_CODEASSIST_GUESS_METHOD_ARGUMENTS= getJDTUIKey(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
- private static final Key PREF_CODEASSIST_PREFIX_COMPLETION= getJDTUIKey(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION);
- private static final Key PREF_CODEASSIST_FORBIDDEN_REFERENCE_CHECK= getJDTCoreKey(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK);
- private static final Key PREF_CODEASSIST_DISCOURAGED_REFERENCE_CHECK= getJDTCoreKey(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK);
- private static final Key PREF_CODEASSIST_DEPRECATION_CHECK= getJDTCoreKey(JavaScriptCore.CODEASSIST_DEPRECATION_CHECK);
- private static final Key PREF_CODEASSIST_CAMEL_CASE_MATCH= getJDTCoreKey(JavaScriptCore.CODEASSIST_CAMEL_CASE_MATCH);
-
- private static Key[] getAllKeys() {
- return new Key[] {
- PREF_CODEASSIST_AUTOACTIVATION,
- PREF_CODEASSIST_AUTOACTIVATION_DELAY,
- PREF_CODEASSIST_AUTOINSERT,
- PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA,
- PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC,
- PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS,
- PREF_CODEASSIST_SORTER,
- PREF_CODEASSIST_CASE_SENSITIVITY,
- PREF_CODEASSIST_ADDIMPORT,
- PREF_CODEASSIST_SUGGEST_STATIC_IMPORTS,
- PREF_CODEASSIST_INSERT_COMPLETION,
- PREF_CODEASSIST_FILL_ARGUMENT_NAMES,
- PREF_CODEASSIST_GUESS_METHOD_ARGUMENTS,
- PREF_CODEASSIST_PREFIX_COMPLETION,
- PREF_CODEASSIST_FORBIDDEN_REFERENCE_CHECK,
- PREF_CODEASSIST_DISCOURAGED_REFERENCE_CHECK,
- PREF_CODEASSIST_DEPRECATION_CHECK,
- PREF_CODEASSIST_CAMEL_CASE_MATCH,
- };
- }
-
- private static final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
- private static final String[] enabledDisabled= new String[] { JavaScriptCore.ENABLED, JavaScriptCore.DISABLED };
-
- private Button fCompletionInsertsRadioButton;
- private Button fCompletionOverwritesRadioButton;
-
- public CodeAssistConfigurationBlock(IStatusChangeListener statusListener, IWorkbenchPreferenceContainer workbenchcontainer) {
- super(statusListener, null, getAllKeys(), workbenchcontainer);
- }
-
- protected Control createContents(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Composite control= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- control.setLayout(layout);
-
- Composite composite;
-
- composite= createSubsection(control, PreferencesMessages.CodeAssistConfigurationBlock_insertionSection_title);
- addInsertionSection(composite);
-
- composite= createSubsection(control, PreferencesMessages.CodeAssistConfigurationBlock_sortingSection_title);
- addSortingSection(composite);
-
- composite= createSubsection(control, PreferencesMessages.CodeAssistConfigurationBlock_autoactivationSection_title);
- addAutoActivationSection(composite);
-
- initialize();
-
- scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
- return scrolled;
- }
-
- protected Composite createSubsection(Composite parent, String label) {
- Group group= new Group(parent, SWT.SHADOW_NONE);
- group.setText(label);
- GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
- group.setLayoutData(data);
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- group.setLayout(layout);
-
- return group;
- }
-
- private void addInsertionSection(Composite composite) {
- addCompletionRadioButtons(composite);
-
- String label;
- label= PreferencesMessages.JavaEditorPreferencePage_insertSingleProposalsAutomatically;
- addCheckBox(composite, label, PREF_CODEASSIST_AUTOINSERT, trueFalse, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_completePrefixes;
- addCheckBox(composite, label, PREF_CODEASSIST_PREFIX_COMPLETION, trueFalse, 0);
-
-// label= PreferencesMessages.JavaEditorPreferencePage_automaticallyAddImportInsteadOfQualifiedName;
-// Button master= addCheckBox(composite, label, PREF_CODEASSIST_ADDIMPORT, trueFalse, 0);
-
-// label= PreferencesMessages.JavaEditorPreferencePage_suggestStaticImports;
-// Button slave= addCheckBox(composite, label, PREF_CODEASSIST_SUGGEST_STATIC_IMPORTS, enabledDisabled, 20);
-// createSelectionDependency(master, slave);
-
-
- label= PreferencesMessages.JavaEditorPreferencePage_fillArgumentNamesOnMethodCompletion;
- Button master= addCheckBox(composite, label, PREF_CODEASSIST_FILL_ARGUMENT_NAMES, trueFalse, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_guessArgumentNamesOnMethodCompletion;
- Button slave= addCheckBox(composite, label, PREF_CODEASSIST_GUESS_METHOD_ARGUMENTS, trueFalse, 20);
- createSelectionDependency(master, slave);
- }
-
- /**
- * Creates a selection dependency between a master and a slave control.
- *
- * @param master
- * The master button that controls the state of the slave
- * @param slave
- * The slave control that is enabled only if the master is
- * selected
- */
- protected static void createSelectionDependency(final Button master, final Control slave) {
-
- master.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent event) {
- // Do nothing
- }
-
- public void widgetSelected(SelectionEvent event) {
- slave.setEnabled(master.getSelection());
- }
- });
- slave.setEnabled(master.getSelection());
- }
-
- private void addSortingSection(Composite composite) {
- String label;
- label= PreferencesMessages.JavaEditorPreferencePage_presentProposalsInAlphabeticalOrder;
- ProposalSorterHandle[] sorters= ProposalSorterRegistry.getDefault().getSorters();
- String[] labels= new String[sorters.length];
- String[] values= new String[sorters.length];
- for (int i= 0; i < sorters.length; i++) {
- ProposalSorterHandle handle= sorters[i];
- labels[i]= handle.getName();
- values[i]= handle.getId();
- }
-
- addComboBox(composite, label, PREF_CODEASSIST_SORTER, values, labels, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_showOnlyProposalsVisibleInTheInvocationContext;
- addCheckBox(composite, label, PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS, trueFalse, 0);
-
- label= PreferencesMessages.CodeAssistConfigurationBlock_matchCamelCase_label;
- addCheckBox(composite, label, PREF_CODEASSIST_CAMEL_CASE_MATCH, enabledDisabled, 0);
-
- label= PreferencesMessages.CodeAssistConfigurationBlock_restricted_link;
- Map targetInfo= new java.util.HashMap(2);
- targetInfo.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_KEY, JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE);
- targetInfo.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_QUALIFIER, JavaScriptCore.PLUGIN_ID);
- createPreferencePageLink(composite, label, targetInfo);
-
-
- label= PreferencesMessages.CodeAssistConfigurationBlock_hideForbidden_label;
- addCheckBox(composite, label, PREF_CODEASSIST_FORBIDDEN_REFERENCE_CHECK, enabledDisabled, 0);
-
- label= PreferencesMessages.CodeAssistConfigurationBlock_hideDiscouraged_label;
- addCheckBox(composite, label, PREF_CODEASSIST_DISCOURAGED_REFERENCE_CHECK, enabledDisabled, 0);
-
- label= PreferencesMessages.CodeAssistConfigurationBlock_hideDeprecated_label;
- addCheckBox(composite, label, PREF_CODEASSIST_DEPRECATION_CHECK, enabledDisabled, 0);
- }
-
- private void createPreferencePageLink(Composite composite, String label, final Map targetInfo) {
- final Link link= new Link(composite, SWT.NONE);
- link.setText(label);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null, targetInfo);
- }
- });
- }
-
- private void addAutoActivationSection(Composite composite) {
- String label;
- label= PreferencesMessages.JavaEditorPreferencePage_enableAutoActivation;
- final Button autoactivation= addCheckBox(composite, label, PREF_CODEASSIST_AUTOACTIVATION, trueFalse, 0);
- autoactivation.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- updateAutoactivationControls();
- }
- });
-
- label= PreferencesMessages.JavaEditorPreferencePage_autoActivationDelay;
- addLabelledTextField(composite, label, PREF_CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
-
- label= PreferencesMessages.JavaEditorPreferencePage_autoActivationTriggersForJava;
- addLabelledTextField(composite, label, PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
-
- label= PreferencesMessages.JavaEditorPreferencePage_autoActivationTriggersForJavaDoc;
- addLabelledTextField(composite, label, PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
- }
-
- protected Text addLabelledTextField(Composite parent, String label, Key key, int textlimit, int indent, boolean dummy) {
- PixelConverter pixelConverter= new PixelConverter(parent);
-
- Label labelControl= new Label(parent, SWT.WRAP);
- labelControl.setText(label);
- labelControl.setLayoutData(new GridData());
-
- Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
- textBox.setData(key);
- textBox.setLayoutData(new GridData());
-
- fLabels.put(textBox, labelControl);
-
- String currValue= getValue(key);
- if (currValue != null) {
- textBox.setText(currValue);
- }
- textBox.addModifyListener(getTextModifyListener());
-
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- if (textlimit != 0) {
- textBox.setTextLimit(textlimit);
- data.widthHint= pixelConverter.convertWidthInCharsToPixels(textlimit + 1);
- }
- data.horizontalIndent= indent;
- data.horizontalSpan= 2;
- textBox.setLayoutData(data);
-
- fTextBoxes.add(textBox);
- return textBox;
- }
-
- private void addCompletionRadioButtons(Composite contentAssistComposite) {
- Composite completionComposite= new Composite(contentAssistComposite, SWT.NONE);
- GridData ccgd= new GridData();
- ccgd.horizontalSpan= 2;
- completionComposite.setLayoutData(ccgd);
- GridLayout ccgl= new GridLayout();
- ccgl.marginWidth= 0;
- ccgl.numColumns= 2;
- completionComposite.setLayout(ccgl);
-
- SelectionListener completionSelectionListener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean insert= fCompletionInsertsRadioButton.getSelection();
- setValue(PREF_CODEASSIST_INSERT_COMPLETION, insert);
- }
- };
-
- fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT);
- fCompletionInsertsRadioButton.setText(PreferencesMessages.JavaEditorPreferencePage_completionInserts);
- fCompletionInsertsRadioButton.setLayoutData(new GridData());
- fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
-
- fCompletionOverwritesRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT);
- fCompletionOverwritesRadioButton.setText(PreferencesMessages.JavaEditorPreferencePage_completionOverwrites);
- fCompletionOverwritesRadioButton.setLayoutData(new GridData());
- fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
-
- Label label= new Label(completionComposite, SWT.NONE);
- label.setText(PreferencesMessages.JavaEditorPreferencePage_completionToggleHint);
- GridData gd= new GridData();
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
- }
-
- public void initialize() {
- initializeFields();
- }
-
- private void initializeFields() {
- boolean completionInserts= getBooleanValue(PREF_CODEASSIST_INSERT_COMPLETION);
- fCompletionInsertsRadioButton.setSelection(completionInserts);
- fCompletionOverwritesRadioButton.setSelection(!completionInserts);
-
- updateAutoactivationControls();
- }
-
- private void updateAutoactivationControls() {
- boolean autoactivation= getBooleanValue(PREF_CODEASSIST_AUTOACTIVATION);
- setControlEnabled(PREF_CODEASSIST_AUTOACTIVATION_DELAY, autoactivation);
- setControlEnabled(PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, autoactivation);
- setControlEnabled(PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, autoactivation);
- setControlEnabled(PREF_CODEASSIST_GUESS_METHOD_ARGUMENTS, getBooleanValue(PREF_CODEASSIST_FILL_ARGUMENT_NAMES));
- }
-
-
- public void performDefaults() {
- super.performDefaults();
- initializeFields();
- }
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- return null;
- }
-
- /**
- * Validates that the specified number is positive.
- *
- * @param number
- * The number to validate
- * @return The status of the validation
- */
- protected static IStatus validatePositiveNumber(final String number) {
-
- final StatusInfo status= new StatusInfo();
- if (number.length() == 0) {
- status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
- } else {
- try {
- final int value= Integer.parseInt(number);
- if (value < 0) {
- status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
- }
- } catch (NumberFormatException exception) {
- status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
- }
- }
- return status;
- }
-
- protected void validateSettings(Key key, String oldValue, String newValue) {
- if (key == null || PREF_CODEASSIST_AUTOACTIVATION_DELAY.equals(key))
- fContext.statusChanged(validatePositiveNumber(getValue(PREF_CODEASSIST_AUTOACTIVATION_DELAY)));
- }
-
- protected void setControlEnabled(Key key, boolean enabled) {
- Control control= getControl(key);
- control.setEnabled(enabled);
- Label label= (Label) fLabels.get(control);
- if (label != null)
- label.setEnabled(enabled);
- }
-
- private Control getControl(Key key) {
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fTextBoxes.get(i);
- Key currKey= (Key) curr.getData();
- if (key.equals(currKey)) {
- return curr;
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java
deleted file mode 100644
index e5b1f64b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.wst.jsdt.ui.IJavaScriptElementSearchConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-
-/**
- * Configures the Content Assist > Static Members preference page.
- *
- *
- */
-class CodeAssistFavoritesConfigurationBlock extends OptionsConfigurationBlock {
-
-
- private static class FavoriteStaticMemberInputDialog extends StatusDialog {
-
- private class StringButtonAdapter implements IDialogFieldListener, IStringButtonAdapter {
- /*
- * @see IDialogFieldListener#dialogFieldChanged(DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
-
- /*
- * @see IStringButtonAdapter#changeControlPressed(DialogField)
- */
- public void changeControlPressed(DialogField field) {
- doBrowseTypes();
- }
- }
-
- private StringButtonDialogField fNameDialogField;
- private List fExistingEntries;
- private final boolean fIsEditingMember;
-
- public FavoriteStaticMemberInputDialog(Shell parent, List existingEntries, boolean isEditingMember) {
- super(parent);
- fIsEditingMember= isEditingMember;
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- fExistingEntries= existingEntries;
-
- String label, title;
- if (isEditingMember) {
- title= PreferencesMessages.FavoriteStaticMemberInputDialog_member_title;
- label= PreferencesMessages.FavoriteStaticMemberInputDialog_member_labelText;
- } else {
- title= PreferencesMessages.FavoriteStaticMemberInputDialog_type_title;
- label= PreferencesMessages.FavoriteStaticMemberInputDialog_type_labelText;
- }
- setTitle(title);
-
- StringButtonAdapter adapter= new StringButtonAdapter();
-
- fNameDialogField= new StringButtonDialogField(adapter);
- fNameDialogField.setLabelText(label);
- fNameDialogField.setButtonLabel(PreferencesMessages.FavoriteStaticMemberInputDialog_browse_button);
- fNameDialogField.setDialogFieldListener(adapter);
- fNameDialogField.setText(""); //$NON-NLS-1$
- }
-
- public void setInitialSelection(String editedEntry) {
- Assert.isNotNull(editedEntry);
- if (editedEntry.length() == 0)
- fNameDialogField.setText(""); //$NON-NLS-1$
- else
- fNameDialogField.setText(editedEntry);
- }
-
- public String getResult() {
- String val= fNameDialogField.getText();
- if (!fIsEditingMember)
- val= val + WILDCARD;
- return val;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- initializeDialogUnits(parent);
-
- GridLayout layout= (GridLayout) composite.getLayout();
- layout.numColumns= 2;
-
- fNameDialogField.doFillIntoGrid(composite, 3);
-
- fNameDialogField.getChangeControl(null).setVisible(!fIsEditingMember);
-
- LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2);
-
- int fieldWidthHint= convertWidthInCharsToPixels(60);
- Text text= fNameDialogField.getTextControl(null);
- LayoutUtil.setWidthHint(text, fieldWidthHint);
- LayoutUtil.setHorizontalGrabbing(text);
- LayoutUtil.setHorizontalSpan(text, fIsEditingMember ? 2 : 1);
- TextFieldNavigationHandler.install(text);
-
- DialogField.createEmptySpace(composite, 1);
-
- fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
-
- applyDialogFont(composite);
- return composite;
- }
-
- private void doBrowseTypes() {
- IRunnableContext context= new BusyIndicatorRunnableContext();
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- int style= IJavaScriptElementSearchConstants.CONSIDER_ALL_TYPES;
- try {
- SelectionDialog dialog= JavaScriptUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
- dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
- dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
- if (dialog.open() == Window.OK) {
- IType res= (IType) dialog.getResult()[0];
- fNameDialogField.setText(res.getFullyQualifiedName('.'));
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
- }
- }
-
- void doDialogFieldChanged(DialogField field) {
- doValidation();
- }
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fNameDialogField.getText();
- if (newText.length() == 0) {
- status.setError(""); //$NON-NLS-1$
- } else {
- IStatus val= JavaScriptConventions.validateJavaScriptTypeName(newText, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3);
- if (val.matches(IStatus.ERROR)) {
- if (fIsEditingMember)
- status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidMemberName);
- else
- status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidTypeName);
- } else {
- if (doesExist(newText, fIsEditingMember)) {
- status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_entryExists);
- }
- }
- }
- updateStatus(status);
- }
-
- private boolean doesExist(String name, boolean isStatic) {
- for (int i= 0; i < fExistingEntries.size(); i++) {
- String entry= (String) fExistingEntries.get(i);
- if (name.equals(entry)) {
- return true;
- }
- }
- return false;
- }
-
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
- }
-
- }
-
-
- private static class ListLabelProvider extends LabelProvider {
-
- public final Image MEMBER_ICON;
- private final Image CLASS_ICON;
-
- public ListLabelProvider() {
- MEMBER_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, 0, JavaElementImageProvider.SMALL_SIZE);
- CLASS_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.SMALL_SIZE);
- }
-
- public Image getImage(Object element) {
- return ((String)element).endsWith(WILDCARD) ? CLASS_ICON : MEMBER_ICON;
- }
-
- public String getText(Object element) {
- return (String)element;
- }
- }
-
-
- private class ListAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(ListDialogField field) {
- List selected= field.getSelectedElements();
- return selected.size() == 1;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- fList.enableButton(IDX_EDIT, canEdit(field));
- }
-
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field)) {
- doButtonPressed(IDX_EDIT);
- }
- }
- }
-
-
- private static final Key PREF_CODEASSIST_FAVORITE_STATIC_MEMBERS= getJDTUIKey(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS);
-
- private static final String WILDCARD= ".*"; //$NON-NLS-1$
-
- private static final int IDX_NEW_TYPE= 0;
- private static final int IDX_NEW_MEMBER= 1;
- private static final int IDX_EDIT= 2;
- private static final int IDX_REMOVE= 3;
-
- private ListDialogField fList;
-
-
- private static Key[] getAllKeys() {
- return new Key[] {
- PREF_CODEASSIST_FAVORITE_STATIC_MEMBERS
- };
- }
-
-
- public CodeAssistFavoritesConfigurationBlock(IStatusChangeListener statusListener, IWorkbenchPreferenceContainer workbenchcontainer) {
- super(statusListener, null, getAllKeys(), workbenchcontainer);
- }
-
- protected Control createContents(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Composite control= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- control.setLayout(layout);
-
- createFavoriteList(control);
-
- initialize();
-
- scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
-
- Dialog.applyDialogFont(scrolled);
-
- return scrolled;
- }
-
- private void createFavoriteList(Composite parent) {
- String[] buttonLabels= new String[] {
- PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_newType_button,
- PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_newMember_button,
- PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_edit_button,
- PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_remove_button
- };
-
- ListAdapter adapter= new ListAdapter();
-
- fList= new ListDialogField(adapter, buttonLabels, new ListLabelProvider());
- fList.setDialogFieldListener(adapter);
- fList.setLabelText(PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_description);
- fList.setRemoveButtonIndex(IDX_REMOVE);
- fList.enableButton(IDX_EDIT, false);
- fList.setViewerComparator(new ViewerComparator());
-
- PixelConverter pixelConverter= new PixelConverter(parent);
-
- fList.doFillIntoGrid(parent, 3);
- LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2);
- LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60));
- LayoutUtil.setHorizontalGrabbing(fList.getListControl(null));
-
- Control listControl= fList.getListControl(null);
- GridData gd= (GridData)listControl.getLayoutData();
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(7);
- }
-
- public void initialize() {
- initializeFields();
- }
-
- private void initializeFields() {
- fList.setElements(Arrays.asList(getFavoriteStaticMembersPreference()));
- }
-
- public void performDefaults() {
- super.performDefaults();
- initializeFields();
- }
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- return null;
- }
-
- protected void validateSettings(Key key, String oldValue, String newValue) {
- // no validation
- }
-
- protected void setControlEnabled(Key key, boolean enabled) {
- Control control= getControl(key);
- control.setEnabled(enabled);
- Label label= (Label) fLabels.get(control);
- if (label != null)
- label.setEnabled(enabled);
- }
-
- private Control getControl(Key key) {
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Control curr= (Control) fTextBoxes.get(i);
- Key currKey= (Key) curr.getData();
- if (key.equals(currKey)) {
- return curr;
- }
- }
- return null;
- }
-
- private void doButtonPressed(int index) {
- if (index == IDX_NEW_TYPE || index == IDX_NEW_MEMBER) { // add new
- List existing= fList.getElements();
- FavoriteStaticMemberInputDialog dialog= new FavoriteStaticMemberInputDialog(getShell(), existing, index == IDX_NEW_MEMBER);
- if (dialog.open() == Window.OK) {
- fList.addElement(dialog.getResult());
- }
- } else if (index == IDX_EDIT) { // edit
- List selected= fList.getSelectedElements();
- if (selected.isEmpty())
- return;
-
- String editedEntry= (String)selected.get(0);
-
- List existing= fList.getElements();
- existing.remove(editedEntry);
- boolean isType= editedEntry.endsWith(WILDCARD);
- FavoriteStaticMemberInputDialog dialog= new FavoriteStaticMemberInputDialog(getShell(), existing, !isType);
- if (isType)
- dialog.setInitialSelection(editedEntry.substring(0, editedEntry.length() - 2));
- else
- dialog.setInitialSelection(editedEntry);
-
- if (dialog.open() == Window.OK) {
- fList.replaceElement(editedEntry, dialog.getResult());
- }
- }
- }
-
- protected final void doDialogFieldChanged(DialogField field) {
- // set values in working copy
- if (field == fList)
- setValue(PREF_CODEASSIST_FAVORITE_STATIC_MEMBERS, serializeFavorites(fList.getElements()));
- }
-
- private String[] getFavoriteStaticMembersPreference() {
- String str= getValue(PREF_CODEASSIST_FAVORITE_STATIC_MEMBERS);
- if (str != null && str.length() > 0)
- return deserializeFavorites(str);
- return new String[0];
- }
-
- private static String[] deserializeFavorites(String str) {
- return str.split(";"); //$NON-NLS-1$
- }
-
- private static String serializeFavorites(List favorites) {
- int size= favorites.size();
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < size; i++) {
- buf.append((String)favorites.get(i));
- if (i < size -1)
- buf.append(';');
- }
- return buf.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesPreferencePage.java
deleted file mode 100644
index 253cde45..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistFavoritesPreferencePage.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-/**
- * Content Assist > Static Members preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- *
- */
-public class CodeAssistFavoritesPreferencePage extends PropertyAndPreferencePage implements IWorkbenchPreferencePage {
-
- private CodeAssistFavoritesConfigurationBlock fConfigurationBlock;
-
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new CodeAssistFavoritesConfigurationBlock(getNewStatusChangedListener(), container);
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return false;
- }
-
- protected String getPreferencePageID() {
- return "org.eclipse.wst.jsdt.ui.preferences.CodeAssistStaticMembersPreferencePage"; //$NON-NLS-1$
- }
-
- protected String getPropertyPageID() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistPreferencePage.java
deleted file mode 100644
index 0dc0260d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeAssistPreferencePage.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-/**
- * Content Assist preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- *
- */
-public class CodeAssistPreferencePage extends PropertyAndPreferencePage implements IWorkbenchPreferencePage {
-
- private CodeAssistConfigurationBlock fConfigurationBlock;
-
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new CodeAssistConfigurationBlock(getNewStatusChangedListener(), container);
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return false;
- }
-
- protected String getPreferencePageID() {
- return "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
- }
-
- protected String getPropertyPageID() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreferencePage.java
deleted file mode 100644
index b249db55..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreferencePage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.CodeFormatterConfigurationBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileConfigurationBlock;
-
-/*
- * The page to configure the code formatter options.
- */
-public class CodeFormatterPreferencePage extends ProfilePreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$
-
- public CodeFormatterPreferencePage() {
- // only used when page is shown programatically
- setTitle(PreferencesMessages.CodeFormatterPreferencePage_title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.ProfilePreferencePage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
- }
-
- protected ProfileConfigurationBlock createConfigurationBlock(PreferencesAccess access) {
- return new CodeFormatterConfigurationBlock(getProject(), access);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreviewCode.txt b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreviewCode.txt
deleted file mode 100644
index bbe7fe29..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeFormatterPreviewCode.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * This header comment may be left unformatted.
- */
-
-package org.eclipse.formatter.example;
-
-/**
- * Example class displaying the effects of various code formatting preferences.
- * <p> See also {@link org.eclipse.editor.syntax}. </p>
- *
- * The blank line above may be cleared.
- * @version 3.0
- */
-public class Example extends Object {
- /* This comment may be wrapped to multiple lines depending on the maximal line length. */
- private int integer= 0;
- // This single-line comment may be wrapped too...
- private String string= "zero";
-
- /**
- * This comment shows the formatting of code snippets.
- * <pre>
- * while ((size = foo(size, max)) > 0) { System.out.println("bar"); }
- * </pre>
- * After this comment a blank line may be inserted.
- * @param size The size
- * @param max The maximum
- */
- public int foo(int size, int max) {
-
- if (size < max) {
- try {
- size=(long)stream.available();
- } catch (IOException e) {
-
- }
- } else if (size == max) {
- ++size;
- } else {
- --size;
- }
- return size;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeStylePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeStylePreferencePage.java
deleted file mode 100644
index d413a353..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeStylePreferencePage.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/*
- * The page to configure the naming style options.
- */
-public class CodeStylePreferencePage extends PropertyAndPreferencePage implements IWorkbenchPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.CodeStylePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.CodeStylePreferencePage"; //$NON-NLS-1$
-
- private NameConventionConfigurationBlock fConfigurationBlock;
-
- public CodeStylePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.getString("CodeStylePreferencePage.description")); //$NON-NLS-1$
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.CodeStylePreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new NameConventionConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
-
-}
-
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateBlock.java
deleted file mode 100644
index ce3d2be3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateBlock.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-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.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-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.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProjectTemplateStore;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.TreeListDialogField;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-/**
- */
-public class CodeTemplateBlock {
-
- private class CodeTemplateAdapter extends ViewerComparator implements ITreeListAdapter, IDialogFieldListener {
-
- private final Object[] NO_CHILDREN= new Object[0];
-
- public void customButtonPressed(TreeListDialogField field, int index) {
- doButtonPressed(index, field.getSelectedElements());
- }
-
- public void selectionChanged(TreeListDialogField field) {
- List selected= field.getSelectedElements();
- field.enableButton(IDX_EDIT, canEdit(selected));
- field.enableButton(IDX_EXPORT, !selected.isEmpty());
-
- updateSourceViewerInput(selected);
- }
-
- public void doubleClicked(TreeListDialogField field) {
- List selected= field.getSelectedElements();
- if (canEdit(selected)) {
- doButtonPressed(IDX_EDIT, selected);
- }
- }
-
- public Object[] getChildren(TreeListDialogField field, Object element) {
- if (element == COMMENT_NODE || element == CODE_NODE) {
- return getTemplateOfCategory(element == COMMENT_NODE);
- }
- return NO_CHILDREN;
- }
-
- public Object getParent(TreeListDialogField field, Object element) {
- if (element instanceof TemplatePersistenceData) {
- TemplatePersistenceData data= (TemplatePersistenceData) element;
- if (data.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
- return COMMENT_NODE;
- }
- return CODE_NODE;
- }
- return null;
- }
-
- public boolean hasChildren(TreeListDialogField field, Object element) {
- return (element == COMMENT_NODE || element == CODE_NODE);
- }
-
- public void dialogFieldChanged(DialogField field) {
- }
-
- public void keyPressed(TreeListDialogField field, KeyEvent event) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
- */
- public int category(Object element) {
- if (element == COMMENT_NODE) {
- return 1;
- } else if (element == CODE_NODE) {
- return 2;
- }
-
- TemplatePersistenceData data= (TemplatePersistenceData) element;
- String id= data.getId();
-
- if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
- return 101;
- } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
- return 102;
- } else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
- return 103;
- } else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
- return 104;
- } else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
- return 105;
- } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
- return 106;
- } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
- return 107;
- } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
- return 108;
- } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
- return 109;
- } else if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
- return 110;
- } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
- return 1;
- } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
- return 2;
- } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
- return 3;
- } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
- return 4;
- } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
- return 5;
- } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
- return 6;
- } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
- return 7;
- } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
- return 8;
- } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
- return 9;
- }
- return 1000;
- }
- }
-
- private static class CodeTemplateLabelProvider extends LabelProvider {
-
- /* (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) {
- if (element == COMMENT_NODE || element == CODE_NODE) {
- return (String) element;
- }
- TemplatePersistenceData data= (TemplatePersistenceData) element;
- String id=data.getId();
- if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_catchblock_label;
- } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_methodstub_label;
- } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
- } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_getterstub_label;
- } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_setterstub_label;
- } else if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_newtype_label;
- } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_classbody_label;
- } else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_interfacebody_label;
- } else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_enumbody_label;
- } else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_annotationbody_label;
- } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_filecomment_label;
- } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_typecomment_label;
- } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
- } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
- } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_overridecomment_label;
- } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_delegatecomment_label;
- } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
- } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_gettercomment_label;
- } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_settercomment_label;
- }
- return data.getTemplate().getDescription();
- }
- }
-
- private final static int IDX_EDIT= 0;
- private final static int IDX_IMPORT= 2;
- private final static int IDX_EXPORT= 3;
- private final static int IDX_EXPORTALL= 4;
-
- protected final static Object COMMENT_NODE= PreferencesMessages.CodeTemplateBlock_templates_comment_node;
- protected final static Object CODE_NODE= PreferencesMessages.CodeTemplateBlock_templates_code_node;
-
- private TreeListDialogField fCodeTemplateTree;
-
- protected ProjectTemplateStore fTemplateStore;
-
- private PixelConverter fPixelConverter;
- private SourceViewer fPatternViewer;
- private Control fSWTWidget;
- private TemplateVariableProcessor fTemplateProcessor;
-
- private final IProject fProject;
-
- public CodeTemplateBlock(IProject project) {
-
- fProject= project;
-
- fTemplateStore= new ProjectTemplateStore(project);
- try {
- fTemplateStore.load();
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- }
-
- fTemplateProcessor= new TemplateVariableProcessor();
-
- CodeTemplateAdapter adapter= new CodeTemplateAdapter();
-
- String[] buttonLabels= new String[] {
- PreferencesMessages.CodeTemplateBlock_templates_edit_button,
- /* */ null,
- PreferencesMessages.CodeTemplateBlock_templates_import_button,
- PreferencesMessages.CodeTemplateBlock_templates_export_button,
- PreferencesMessages.CodeTemplateBlock_templates_exportall_button
-
- };
- fCodeTemplateTree= new TreeListDialogField(adapter, buttonLabels, new CodeTemplateLabelProvider());
- fCodeTemplateTree.setDialogFieldListener(adapter);
- fCodeTemplateTree.setLabelText(PreferencesMessages.CodeTemplateBlock_templates_label);
- fCodeTemplateTree.setViewerComparator(adapter);
-
- fCodeTemplateTree.enableButton(IDX_EXPORT, false);
- fCodeTemplateTree.enableButton(IDX_EDIT, false);
-
- fCodeTemplateTree.addElement(COMMENT_NODE);
- fCodeTemplateTree.addElement(CODE_NODE);
-
- fCodeTemplateTree.selectFirstElement();
- }
-
- public void postSetSelection(Object element) {
- fCodeTemplateTree.postSetSelection(new StructuredSelection(element));
- }
-
- public boolean hasProjectSpecificOptions(IProject project) {
- if (project != null) {
- return ProjectTemplateStore.hasProjectSpecificTempates(project);
- }
- return false;
- }
-
- protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
- fSWTWidget= parent;
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- fCodeTemplateTree.doFillIntoGrid(composite, 3);
- LayoutUtil.setHorizontalSpan(fCodeTemplateTree.getLabelControl(null), 2);
- LayoutUtil.setHorizontalGrabbing(fCodeTemplateTree.getTreeControl(null));
-
- fPatternViewer= createViewer(composite, 2);
-
- return composite;
- }
-
- private Shell getShell() {
- if (fSWTWidget != null) {
- return fSWTWidget.getShell();
- }
- return JavaScriptPlugin.getActiveWorkbenchShell();
- }
-
- private SourceViewer createViewer(Composite parent, int nColumns) {
- Label label= new Label(parent, SWT.NONE);
- label.setText(PreferencesMessages.CodeTemplateBlock_preview);
- GridData data= new GridData();
- data.horizontalSpan= nColumns;
- label.setLayoutData(data);
-
- IDocument document= new Document();
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
- viewer.configure(configuration);
- viewer.setEditable(false);
- viewer.setDocument(document);
-
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- viewer.getTextWidget().setFont(font);
- new JavaSourcePreviewerUpdater(viewer, configuration, store);
-
- Control control= viewer.getControl();
- data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- data.horizontalSpan= nColumns;
- data.heightHint= fPixelConverter.convertHeightInCharsToPixels(5);
- control.setLayoutData(data);
-
- return viewer;
- }
-
- protected TemplatePersistenceData[] getTemplateOfCategory(boolean isComment) {
- ArrayList res= new ArrayList();
- TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
- for (int i= 0; i < templates.length; i++) {
- TemplatePersistenceData curr= templates[i];
- if (isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
- res.add(curr);
- }
- }
- return (TemplatePersistenceData[]) res.toArray(new TemplatePersistenceData[res.size()]);
- }
-
- protected static boolean canEdit(List selected) {
- return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData);
- }
-
- protected void updateSourceViewerInput(List selection) {
- if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
- return;
- }
- if (selection.size() == 1 && selection.get(0) instanceof TemplatePersistenceData) {
- TemplatePersistenceData data= (TemplatePersistenceData) selection.get(0);
- Template template= data.getTemplate();
- TemplateContextType type= JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(template.getContextTypeId());
- fTemplateProcessor.setContextType(type);
- fPatternViewer.getDocument().set(template.getPattern());
- } else {
- fPatternViewer.getDocument().set(""); //$NON-NLS-1$
- }
- }
-
- protected void doButtonPressed(int buttonIndex, List selected) {
- if (buttonIndex == IDX_EDIT) {
- edit((TemplatePersistenceData) selected.get(0));
- } else if (buttonIndex == IDX_EXPORT) {
- export(selected);
- } else if (buttonIndex == IDX_EXPORTALL) {
- exportAll();
- } else if (buttonIndex == IDX_IMPORT) {
- import_();
- }
- }
-
- private void edit(TemplatePersistenceData data) {
- Template newTemplate= new Template(data.getTemplate());
- EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, true, false, JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry());
- if (dialog.open() == Window.OK) {
- // changed
- data.setTemplate(dialog.getTemplate());
- fCodeTemplateTree.refresh(data);
- fCodeTemplateTree.selectElements(new StructuredSelection(data));
- }
- }
-
- private void import_() {
- FileDialog dialog= new FileDialog(getShell());
- dialog.setText(PreferencesMessages.CodeTemplateBlock_import_title);
- dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_import_extension});
- String path= dialog.open();
-
- if (path == null)
- return;
-
- try {
- TemplateReaderWriter reader= new TemplateReaderWriter();
- File file= new File(path);
- if (file.exists()) {
- InputStream input= new BufferedInputStream(new FileInputStream(file));
- try {
- TemplatePersistenceData[] datas= reader.read(input, null);
- for (int i= 0; i < datas.length; i++) {
- updateTemplate(datas[i]);
- }
- } finally {
- try {
- input.close();
- } catch (IOException x) {
- }
- }
- }
-
- fCodeTemplateTree.refresh();
- updateSourceViewerInput(fCodeTemplateTree.getSelectedElements());
-
- } catch (FileNotFoundException e) {
- openReadErrorDialog(e);
- } catch (IOException e) {
- openReadErrorDialog(e);
- }
-
- }
-
- private void updateTemplate(TemplatePersistenceData data) {
- TemplatePersistenceData[] datas= fTemplateStore.getTemplateData();
- for (int i= 0; i < datas.length; i++) {
- String id= datas[i].getId();
- if (id != null && id.equals(data.getId())) {
- datas[i].setTemplate(data.getTemplate());
- break;
- }
- }
- }
-
- private void exportAll() {
- export(fTemplateStore.getTemplateData());
- }
-
- private void export(List selected) {
- Set datas= new HashSet();
- for (int i= 0; i < selected.size(); i++) {
- Object curr= selected.get(i);
- if (curr instanceof TemplatePersistenceData) {
- datas.add(curr);
- } else {
- TemplatePersistenceData[] cat= getTemplateOfCategory(curr == COMMENT_NODE);
- datas.addAll(Arrays.asList(cat));
- }
- }
- export((TemplatePersistenceData[]) datas.toArray(new TemplatePersistenceData[datas.size()]));
- }
-
- private void export(TemplatePersistenceData[] templates) {
- FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(Messages.format(PreferencesMessages.CodeTemplateBlock_export_title, String.valueOf(templates.length)));
- dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_export_extension});
- dialog.setFileName(PreferencesMessages.CodeTemplateBlock_export_filename);
- String path= dialog.open();
-
- if (path == null)
- return;
-
- File file= new File(path);
-
- if (file.isHidden()) {
- String title= PreferencesMessages.CodeTemplateBlock_export_error_title;
- String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_hidden, file.getAbsolutePath());
- MessageDialog.openError(getShell(), title, message);
- return;
- }
-
- if (file.exists() && !file.canWrite()) {
- String title= PreferencesMessages.CodeTemplateBlock_export_error_title;
- String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_canNotWrite, file.getAbsolutePath());
- MessageDialog.openError(getShell(), title, message);
- return;
- }
-
- if (!file.exists() || confirmOverwrite(file)) {
- OutputStream output= null;
- try {
- output= new BufferedOutputStream(new FileOutputStream(file));
- TemplateReaderWriter writer= new TemplateReaderWriter();
- writer.save(templates, output);
- output.close();
- } catch (IOException e) {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e2) {
- // ignore
- }
- }
- openWriteErrorDialog(e);
- }
- }
-
- }
-
- private boolean confirmOverwrite(File file) {
- return MessageDialog.openQuestion(getShell(),
- PreferencesMessages.CodeTemplateBlock_export_exists_title,
- Messages.format(PreferencesMessages.CodeTemplateBlock_export_exists_message, file.getAbsolutePath()));
- }
-
- public void performDefaults() {
- fTemplateStore.restoreDefaults();
-
- // refresh
- fCodeTemplateTree.refresh();
- updateSourceViewerInput(fCodeTemplateTree.getSelectedElements());
- }
-
- public boolean performOk(boolean enabled) {
- if (fProject != null) {
- TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
- for (int i= 0; i < templateData.length; i++) {
- fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled);
- }
- }
- try {
- fTemplateStore.save();
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- openWriteErrorDialog(e);
- }
- return true;
- }
-
- public void performCancel() {
- try {
- fTemplateStore.revertChanges();
- } catch (IOException e) {
- openReadErrorDialog(e);
- }
- }
-
- private void openReadErrorDialog(Exception e) {
- String title= PreferencesMessages.CodeTemplateBlock_error_read_title;
-
- String message= e.getLocalizedMessage();
- if (message != null)
- message= Messages.format(PreferencesMessages.CodeTemplateBlock_error_parse_message, message);
- else
- message= PreferencesMessages.CodeTemplateBlock_error_read_message;
- MessageDialog.openError(getShell(), title, message);
- }
-
- private void openWriteErrorDialog(Exception e) {
- String title= PreferencesMessages.CodeTemplateBlock_error_write_title;
- String message= PreferencesMessages.CodeTemplateBlock_error_write_message;
- MessageDialog.openError(getShell(), title, message);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplatePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplatePreferencePage.java
deleted file mode 100644
index c9ba93b4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplatePreferencePage.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-
-/*
- * The page to configure the code templates.
- */
-public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.CodeTemplatePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.CodeTemplatePreferencePage"; //$NON-NLS-1$
-
- public static final String DATA_SELECT_TEMPLATE= "CodeTemplatePreferencePage.select_template"; //$NON-NLS-1$
-
- private CodeTemplateBlock fCodeTemplateConfigurationBlock;
-
- public CodeTemplatePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.getString("CodeTemplatesPreferencePage.description")); //$NON-NLS-1$
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.CodeTemplatesPreferencePage_title);
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- fCodeTemplateConfigurationBlock= new CodeTemplateBlock(getProject());
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_TEMPLATES_PREFERENCE_PAGE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
- */
- protected Control createPreferenceContent(Composite composite) {
- return fCodeTemplateConfigurationBlock.createContents(composite);
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fCodeTemplateConfigurationBlock != null) {
- return fCodeTemplateConfigurationBlock.performOk(useProjectSettings());
- }
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fCodeTemplateConfigurationBlock != null) {
- fCodeTemplateConfigurationBlock.performDefaults();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
- */
- public void statusChanged(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
- */
- public boolean performCancel() {
- if (fCodeTemplateConfigurationBlock != null) {
- fCodeTemplateConfigurationBlock.performCancel();
- }
- return super.performCancel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
- */
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fCodeTemplateConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- if (data instanceof Map) {
- Object id= ((Map) data).get(DATA_SELECT_TEMPLATE);
- if (id instanceof String) {
- final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
- TemplatePersistenceData template= null;
- for (int index= 0; index < templates.length; index++) {
- template= templates[index];
- if (template.getId().equals(id)) {
- fCodeTemplateConfigurationBlock.postSetSelection(template);
- break;
- }
- }
- }
- }
- super.applyData(data);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
deleted file mode 100644
index b7f6db39..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Iterator;
-
-import org.eclipse.wst.jsdt.internal.ui.text.html.HTMLTextPresenter;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateVariableResolver;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
-import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public class CodeTemplateSourceViewerConfiguration extends SimpleJavaSourceViewerConfiguration {
-
- private static class TemplateVariableTextHover implements ITextHover {
-
- private TemplateVariableProcessor fProcessor;
-
- /**
- * @param processor the template variable processor
- */
- public TemplateVariableTextHover(TemplateVariableProcessor processor) {
- fProcessor= processor;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
- */
- public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
- try {
- IDocument doc= textViewer.getDocument();
- int offset= subject.getOffset();
- if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
- String varName= doc.get(offset, subject.getLength());
- TemplateContextType contextType= fProcessor.getContextType();
- if (contextType != null) {
- Iterator iter= contextType.resolvers();
- while (iter.hasNext()) {
- TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
- if (varName.equals(var.getType())) {
- return var.getDescription();
- }
- }
- }
- }
- } catch (BadLocationException e) {
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- if (textViewer != null) {
- return JavaWordFinder.findWord(textViewer.getDocument(), offset);
- }
- return null;
- }
-
- }
-
- private final TemplateVariableProcessor fProcessor;
-
- public CodeTemplateSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) {
- super(colorManager, store, editor, IJavaScriptPartitions.JAVA_PARTITIONING, false);
- fProcessor= processor;
- }
-
- /*
- * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
-
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- IColorManager manager= textTools.getColorManager();
-
-
- ContentAssistant assistant= new ContentAssistant();
- assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
- // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
- assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_STRING);
- assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_CHARACTER);
- assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
- assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
- assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_DOC);
-
- assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
- assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
- assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
- assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setInformationControlCreator(new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
- }
- });
-
- Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
- assistant.setContextInformationPopupBackground(background);
- assistant.setContextSelectorBackground(background);
- assistant.setProposalSelectorBackground(background);
-
- Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
- assistant.setContextInformationPopupForeground(foreground);
- assistant.setContextSelectorForeground(foreground);
- assistant.setProposalSelectorForeground(foreground);
-
- return assistant;
- }
-
- private Color getColor(IPreferenceStore store, String key, IColorManager manager) {
- RGB rgb= PreferenceConverter.getColor(store, key);
- return manager.getColor(rgb);
- }
-
- /*
- * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
- *
- */
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
- return new TemplateVariableTextHover(fProcessor);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ColorSettingPreviewCode.txt
deleted file mode 100644
index 1af303f2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ColorSettingPreviewCode.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * This is about <code>Example.js</code>.
- * {@link com.yourCompany.aPackage.aFile}
- * @author author
- * @deprecated use <code>BetterExample.js</code>
- */
-var index = 0;
-var arr = [];
-
-function foo() {
- /* This comment may span multiple lines. */
- var var1 = new Object();
- var obj = [ make: "Toyota", model: "Celica", year: 2000 ];
- var s = "abc123";
- clear(var1);
-}
-
-function pop() {
- return arr[index--];
-}
-
-function push(elem) {
- // This comment may span only this line
- arr[index++] = elem;
-}
-
-function isEmpty() {
- // TASK: refactor
- return index == 0;
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ComplianceConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ComplianceConfigurationBlock.java
deleted file mode 100644
index 6106ae45..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ComplianceConfigurationBlock.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.swt.SWT;
-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.Link;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathSupport;
-import org.eclipse.wst.jsdt.launching.IVMInstall;
-import org.eclipse.wst.jsdt.launching.IVMInstall2;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-
-/**
- */
-public class ComplianceConfigurationBlock extends OptionsConfigurationBlock {
-
- // Preference store keys, see JavaScriptCore.getOptions
- private static final Key PREF_LOCAL_VARIABLE_ATTR= getJDTCoreKey(JavaScriptCore.COMPILER_LOCAL_VARIABLE_ATTR);
- private static final Key PREF_LINE_NUMBER_ATTR= getJDTCoreKey(JavaScriptCore.COMPILER_LINE_NUMBER_ATTR);
- private static final Key PREF_SOURCE_FILE_ATTR= getJDTCoreKey(JavaScriptCore.COMPILER_SOURCE_FILE_ATTR);
- private static final Key PREF_CODEGEN_UNUSED_LOCAL= getJDTCoreKey(JavaScriptCore.COMPILER_CODEGEN_UNUSED_LOCAL);
- private static final Key PREF_CODEGEN_TARGET_PLATFORM= getJDTCoreKey(JavaScriptCore.COMPILER_CODEGEN_TARGET_PLATFORM);
- private static final Key PREF_CODEGEN_INLINE_JSR_BYTECODE= getJDTCoreKey(JavaScriptCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE);
-
- private static final Key PREF_SOURCE_COMPATIBILITY= getJDTCoreKey(JavaScriptCore.COMPILER_SOURCE);
- private static final Key PREF_COMPLIANCE= getJDTCoreKey(JavaScriptCore.COMPILER_COMPLIANCE);
- private static final Key PREF_PB_ASSERT_AS_IDENTIFIER= getJDTCoreKey(JavaScriptCore.COMPILER_PB_ASSERT_IDENTIFIER);
- private static final Key PREF_PB_ENUM_AS_IDENTIFIER= getJDTCoreKey(JavaScriptCore.COMPILER_PB_ENUM_IDENTIFIER);
-
- private static final Key INTR_DEFAULT_COMPLIANCE= getJDTUIKey("internal.default.compliance"); //$NON-NLS-1$
-
- // values
-// private static final String GENERATE= JavaScriptCore.GENERATE;
-// private static final String DO_NOT_GENERATE= JavaScriptCore.DO_NOT_GENERATE;
-//
-// private static final String PRESERVE= JavaScriptCore.PRESERVE;
-// private static final String OPTIMIZE_OUT= JavaScriptCore.OPTIMIZE_OUT;
-
- private static final String VERSION_1_1= JavaScriptCore.VERSION_1_1;
- private static final String VERSION_1_2= JavaScriptCore.VERSION_1_2;
- private static final String VERSION_1_3= JavaScriptCore.VERSION_1_3;
- private static final String VERSION_1_4= JavaScriptCore.VERSION_1_4;
- private static final String VERSION_1_5= JavaScriptCore.VERSION_1_5;
- private static final String VERSION_1_6= JavaScriptCore.VERSION_1_6;
-
- private static final String ERROR= JavaScriptCore.ERROR;
- private static final String WARNING= JavaScriptCore.WARNING;
- private static final String IGNORE= JavaScriptCore.IGNORE;
-
- private static final String ENABLED= JavaScriptCore.ENABLED;
-// private static final String DISABLED= JavaScriptCore.DISABLED;
-
-
- private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
- private static final String USER_CONF= "user"; //$NON-NLS-1$
-
- private ArrayList fComplianceControls;
-// private PixelConverter fPixelConverter;
-
- private String[] fRememberedUserCompliance;
-
- private static final int IDX_ASSERT_AS_IDENTIFIER= 0;
- private static final int IDX_ENUM_AS_IDENTIFIER= 1;
- private static final int IDX_SOURCE_COMPATIBILITY= 2;
- private static final int IDX_CODEGEN_TARGET_PLATFORM= 3;
- private static final int IDX_COMPLIANCE= 4;
- private static final int IDX_INLINE_JSR_BYTECODE= 5;
-
- private IStatus fComplianceStatus;
-
- private Link fJRE50InfoText;
- private Composite fControlsComposite;
- private ControlEnableState fBlockEnableState;
-
- public ComplianceConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getKeys(), container);
-
- fBlockEnableState= null;
- fComplianceControls= new ArrayList();
-
- fComplianceStatus= new StatusInfo();
-
- fRememberedUserCompliance= new String[] { // caution: order depends on IDX_* constants
- getValue(PREF_PB_ASSERT_AS_IDENTIFIER),
- getValue(PREF_PB_ENUM_AS_IDENTIFIER),
- getValue(PREF_SOURCE_COMPATIBILITY),
- getValue(PREF_CODEGEN_TARGET_PLATFORM),
- getValue(PREF_COMPLIANCE),
- getValue(PREF_CODEGEN_INLINE_JSR_BYTECODE),
- };
- }
-
- private static Key[] getKeys() {
- return new Key[] {
- PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,
- PREF_CODEGEN_INLINE_JSR_BYTECODE,
- PREF_COMPLIANCE, PREF_SOURCE_COMPATIBILITY,
- PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER
- };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#settingsUpdated()
- */
- protected void settingsUpdated() {
- setValue(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance());
- super.settingsUpdated();
- }
-
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
-// fPixelConverter= new PixelConverter(parent);
- setShell(parent.getShell());
-
- Composite complianceComposite= createComplianceTabContent(parent);
-
- validateSettings(null, null, null);
-
- return complianceComposite;
- }
-
- public void enablePreferenceContent(boolean enable) {
- if (fControlsComposite != null && !fControlsComposite.isDisposed()) {
- if (enable) {
- if (fBlockEnableState != null) {
- fBlockEnableState.restore();
- fBlockEnableState= null;
- }
- } else {
- if (fBlockEnableState == null) {
- fBlockEnableState= ControlEnableState.disable(fControlsComposite);
- }
- }
- }
- }
-
- private Composite createComplianceTabContent(Composite folder) {
-
-
- String[] values3456= new String[] { VERSION_1_4, VERSION_1_5};
- String[] values3456Labels= new String[] {
-// PreferencesMessages.ComplianceConfigurationBlock_version13,
- PreferencesMessages.ComplianceConfigurationBlock_version14,
- PreferencesMessages.ComplianceConfigurationBlock_version15
-// PreferencesMessages.ComplianceConfigurationBlock_version16
- };
-
- final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
- Composite composite= sc1.getBody();
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- fControlsComposite= new Composite(composite, SWT.NONE);
- fControlsComposite.setFont(composite.getFont());
- fControlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
-
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 1;
- fControlsComposite.setLayout(layout);
-
- int nColumns= 3;
-
- layout= new GridLayout();
- layout.numColumns= nColumns;
-
- Group group= new Group(fControlsComposite, SWT.NONE);
- group.setFont(fControlsComposite.getFont());
- group.setText(PreferencesMessages.ComplianceConfigurationBlock_compliance_group_label);
- group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- group.setLayout(layout);
-
- String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
- Combo combo = addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);
- combo.setEnabled(false);
-
-// label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
-// addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0);
-//
-// int indent= fPixelConverter.convertWidthInCharsToPixels(2);
-// Control[] otherChildren= group.getChildren();
-//
-// String[] versions= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6 };
-// String[] versionsLabels= new String[] {
-// PreferencesMessages.ComplianceConfigurationBlock_version11,
-// PreferencesMessages.ComplianceConfigurationBlock_version12,
-// PreferencesMessages.ComplianceConfigurationBlock_version13,
-// PreferencesMessages.ComplianceConfigurationBlock_version14,
-// PreferencesMessages.ComplianceConfigurationBlock_version15,
-// PreferencesMessages.ComplianceConfigurationBlock_version16
-// };
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label;
-// addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label;
-// addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent);
-//
-// String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
-//
-// String[] errorWarningIgnoreLabels= new String[] {
-// PreferencesMessages.ComplianceConfigurationBlock_error,
-// PreferencesMessages.ComplianceConfigurationBlock_warning,
-// PreferencesMessages.ComplianceConfigurationBlock_ignore
-// };
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_pb_assert_as_identifier_label;
-// addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label;
-// addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
-//
-//
-// Control[] allChildren= group.getChildren();
-// fComplianceControls.addAll(Arrays.asList(allChildren));
-// fComplianceControls.removeAll(Arrays.asList(otherChildren));
-//
-// layout= new GridLayout();
-// layout.numColumns= nColumns;
-//
-// group= new Group(fControlsComposite, SWT.NONE);
-// group.setFont(fControlsComposite.getFont());
-// group.setText(PreferencesMessages.ComplianceConfigurationBlock_classfiles_group_label);
-// group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
-// group.setLayout(layout);
-//
-// String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE };
-// String[] enableDisableValues= new String[] { ENABLED, DISABLED };
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_variable_attr_label;
-// addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_line_number_attr_label;
-// addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_source_file_attr_label;
-// addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_codegen_unused_local_label;
-// addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0);
-//
-// label= PreferencesMessages.ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label;
-// addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0);
-//
-// fJRE50InfoText= new Link(composite, SWT.WRAP);
-// fJRE50InfoText.setFont(composite.getFont());
-// // set a text: not the real one, just for layouting
-// fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { VERSION_1_3, VERSION_1_3 }));
-// fJRE50InfoText.setVisible(false);
-// fJRE50InfoText.addSelectionListener(new SelectionListener() {
-// public void widgetDefaultSelected(SelectionEvent e) {
-// if ("1".equals(e.text)) { //$NON-NLS-1$
-// openJREInstallPreferencePage();
-// } else {
-// openBuildPathPropertyPage();
-// }
-// }
-// public void widgetSelected(SelectionEvent e) {
-// widgetDefaultSelected(e);
-// }
-// });
-// GridData gd= new GridData(GridData.FILL, GridData.FILL, true, true);
-// gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
-// fJRE50InfoText.setLayoutData(gd);
-// validateJRE50Status();
-
- return sc1;
- }
-
- protected final void openBuildPathPropertyPage() {
- if (getPreferenceContainer() != null) {
- Map data= new HashMap();
- data.put(BuildPathsPropertyPage.DATA_REVEAL_ENTRY, JavaRuntime.getDefaultJREContainerEntry());
- getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, data);
- }
- validateJRE50Status();
- }
-
- protected final void openJREInstallPreferencePage() {
- String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
- if (fProject == null && getPreferenceContainer() != null) {
- getPreferenceContainer().openPage(jreID, null);
- } else {
- PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID }, null).open();
- }
- validateJRE50Status();
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (!areSettingsEnabled()) {
- return;
- }
- if (changedKey != null) {
- if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) {
- updateComplianceEnableState();
- updateComplianceDefaultSettings(true, null);
- fComplianceStatus= validateCompliance();
- } else if (PREF_COMPLIANCE.equals(changedKey)) {
- // set compliance settings to default
-// Object oldDefault= setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
- updateComplianceEnableState();
-// updateComplianceDefaultSettings(USER_CONF.equals(oldDefault), oldValue);
- fComplianceStatus= validateCompliance();
- validateJRE50Status();
- } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) {
- updateAssertEnumAsIdentifierEnableState();
- fComplianceStatus= validateCompliance();
- } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) {
- updateInlineJSREnableState();
- fComplianceStatus= validateCompliance();
- } else if (PREF_PB_ENUM_AS_IDENTIFIER.equals(changedKey) ||
- PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) {
- fComplianceStatus= validateCompliance();
- } else {
- return;
- }
- } else {
-// updateComplianceEnableState();
-// updateAssertEnumAsIdentifierEnableState();
-// updateInlineJSREnableState();
- fComplianceStatus= validateCompliance();
-// validateJRE50Status();
- }
- fContext.statusChanged(fComplianceStatus);
- }
-
- private void validateJRE50Status() {
- if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
- boolean isVisible= false;
- String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value
- IVMInstall install= null;
- if (fProject != null) { // project specific settings: only test if a 50 JRE is installed
- try {
- install= JavaRuntime.getVMInstall(JavaScriptCore.create(fProject));
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- } else {
- install= JavaRuntime.getDefaultVMInstall();
- }
- if (install instanceof IVMInstall2) {
- String compilerCompliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance);
- if (JavaModelUtil.isVersionLessThan(compilerCompliance, compliance)) { // Discourage using compiler with version less than compliance
- String[] args= { getVersionLabel(compliance), getVersionLabel(compilerCompliance) };
- if (fProject == null) {
- fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
- } else {
- fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args));
- }
- isVisible= true;
- }
- }
- fJRE50InfoText.setVisible(isVisible);
- }
- }
-
- private String getVersionLabel(String version) {
- if (JavaModelUtil.isVersionLessThan(version, VERSION_1_5)) {
- return version; // for version <= 1.4, we can use the version as is
- }
- if (VERSION_1_5.equals(version))
- return PreferencesMessages.ComplianceConfigurationBlock_version15;
- return PreferencesMessages.ComplianceConfigurationBlock_version16;
- }
-
-
- private IStatus validateCompliance() {
- StatusInfo status= new StatusInfo();
- String compliance= getValue(PREF_COMPLIANCE);
- String source= getValue(PREF_SOURCE_COMPATIBILITY);
- String target= getValue(PREF_CODEGEN_TARGET_PLATFORM);
-
- // compliance must not be smaller than source or target
- if (JavaModelUtil.isVersionLessThan(compliance, source)) {
- status.setError(PreferencesMessages.ComplianceConfigurationBlock_src_greater_compliance);
- return status;
- }
-
- if (JavaModelUtil.isVersionLessThan(compliance, target)) {
- status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_compliance);
- return status;
- }
-
- // target must not be smaller than source
- if (!VERSION_1_3.equals(source) && JavaModelUtil.isVersionLessThan(target, source)) {
- status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_source);
- return status;
- }
-
- return status;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#useProjectSpecificSettings(boolean)
- */
- public void useProjectSpecificSettings(boolean enable) {
- super.useProjectSpecificSettings(enable);
- validateJRE50Status();
- }
-
- /*
- * Update the compliance controls' enable state
- */
- private void updateComplianceEnableState() {
- boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF);
- for (int i= fComplianceControls.size() - 1; i >= 0; i--) {
- Control curr= (Control) fComplianceControls.get(i);
- curr.setEnabled(enabled);
- }
- }
-
- private void updateAssertEnumAsIdentifierEnableState() {
- if (checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF)) {
- String compatibility= getValue(PREF_SOURCE_COMPATIBILITY);
-
- boolean isLessThan14= VERSION_1_3.equals(compatibility);
- updateRememberedComplianceOption(PREF_PB_ASSERT_AS_IDENTIFIER, IDX_ASSERT_AS_IDENTIFIER, isLessThan14);
-
- boolean isLessThan15= isLessThan14 || VERSION_1_4.equals(compatibility);
- updateRememberedComplianceOption(PREF_PB_ENUM_AS_IDENTIFIER, IDX_ENUM_AS_IDENTIFIER, isLessThan15);
- }
- }
-
- private void updateRememberedComplianceOption(Key prefKey, int idx, boolean enabled) {
- Combo combo= getComboBox(prefKey);
- combo.setEnabled(enabled);
-
- if (!enabled) {
- String val= getValue(prefKey);
- if (!ERROR.equals(val)) {
- setValue(prefKey, ERROR);
- updateCombo(combo);
- fRememberedUserCompliance[idx]= val;
- }
- } else {
- String val= fRememberedUserCompliance[idx];
- if (!ERROR.equals(val)) {
- setValue(prefKey, val);
- updateCombo(combo);
- }
- }
- }
-
- private void updateInlineJSREnableState() {
- String target= getValue(PREF_CODEGEN_TARGET_PLATFORM);
-
- boolean enabled= JavaModelUtil.isVersionLessThan(target, VERSION_1_5);
- Button checkBox= getCheckBox(PREF_CODEGEN_INLINE_JSR_BYTECODE);
- checkBox.setEnabled(enabled);
-
- if (!enabled) {
- String val= getValue(PREF_CODEGEN_INLINE_JSR_BYTECODE);
- fRememberedUserCompliance[IDX_INLINE_JSR_BYTECODE]= val;
-
- if (!ENABLED.equals(val)) {
- setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, ENABLED);
- updateCheckBox(checkBox);
- }
- } else {
- String val= fRememberedUserCompliance[IDX_INLINE_JSR_BYTECODE];
- if (!ENABLED.equals(val)) {
- setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, val);
- updateCheckBox(checkBox);
- }
- }
- }
-
- /*
- * Set the default compliance values derived from the chosen level
- */
- private void updateComplianceDefaultSettings(boolean rememberOld, String oldComplianceLevel) {
- String assertAsId, enumAsId, source, target;
- boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
- String complianceLevel= getValue(PREF_COMPLIANCE);
-
- if (isDefault) {
- if (rememberOld) {
- if (oldComplianceLevel == null) {
- oldComplianceLevel= complianceLevel;
- }
-
- fRememberedUserCompliance[IDX_ASSERT_AS_IDENTIFIER]= getValue(PREF_PB_ASSERT_AS_IDENTIFIER);
- fRememberedUserCompliance[IDX_ENUM_AS_IDENTIFIER]= getValue(PREF_PB_ENUM_AS_IDENTIFIER);
- fRememberedUserCompliance[IDX_SOURCE_COMPATIBILITY]= getValue(PREF_SOURCE_COMPATIBILITY);
- fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM);
- fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel;
- }
-
- if (VERSION_1_4.equals(complianceLevel)) {
- assertAsId= WARNING;
- enumAsId= WARNING;
- source= VERSION_1_3;
- target= VERSION_1_2;
- } else if (VERSION_1_5.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_5;
- target= VERSION_1_5;
- } else if (VERSION_1_6.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_6;
- target= VERSION_1_6;
- } else {
- assertAsId= IGNORE;
- enumAsId= IGNORE;
- source= VERSION_1_3;
- target= VERSION_1_1;
- }
- } else {
- if (rememberOld && complianceLevel.equals(fRememberedUserCompliance[IDX_COMPLIANCE])) {
- assertAsId= fRememberedUserCompliance[IDX_ASSERT_AS_IDENTIFIER];
- enumAsId= fRememberedUserCompliance[IDX_ENUM_AS_IDENTIFIER];
- source= fRememberedUserCompliance[IDX_SOURCE_COMPATIBILITY];
- target= fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM];
- } else {
- updateInlineJSREnableState();
- updateAssertEnumAsIdentifierEnableState();
- return;
- }
- }
- setValue(PREF_PB_ASSERT_AS_IDENTIFIER, assertAsId);
- setValue(PREF_PB_ENUM_AS_IDENTIFIER, enumAsId);
- setValue(PREF_SOURCE_COMPATIBILITY, source);
- setValue(PREF_CODEGEN_TARGET_PLATFORM, target);
- updateControls();
- updateInlineJSREnableState();
- updateAssertEnumAsIdentifierEnableState();
- }
-
- /*
- * Evaluate if the current compliance setting correspond to a default setting
- */
- private String getCurrentCompliance() {
- Object complianceLevel= getValue(PREF_COMPLIANCE);
- if ((VERSION_1_3.equals(complianceLevel)
- && IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_1.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_4.equals(complianceLevel)
- && WARNING.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && WARNING.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_2.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_5.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_5.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_5.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_6.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_6.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_6.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))) {
- return DEFAULT_CONF;
- }
- return USER_CONF;
- }
-
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title;
- String message;
- if (workspaceSettings) {
- message= PreferencesMessages.ComplianceConfigurationBlock_needsfullbuild_message;
- } else {
- message= PreferencesMessages.ComplianceConfigurationBlock_needsprojectbuild_message;
- }
- return new String[] { title, message };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#performOk()
- */
- public boolean performOk() {
- setValue(INTR_DEFAULT_COMPLIANCE, null);
- return super.performOk();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#performApply()
- */
- public boolean performApply() {
- setValue(INTR_DEFAULT_COMPLIANCE, null);
- boolean result= super.performApply();
- setValue(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance());
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CompliancePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CompliancePreferencePage.java
deleted file mode 100644
index db3c85c2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/CompliancePreferencePage.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.launching.JavaRuntime;
-
-/**
- * Page used to configure both workspace and project specific compiler settings
- */
-public class CompliancePreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.CompliancePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
-
- private ComplianceConfigurationBlock fConfigurationBlock;
-
- public CompliancePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.CompliancePreferencePage_description);
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.CompliancePreferencePage_title);
-
- JavaRuntime.getDefaultVMInstall(); // make sure the default JRE is detected (bug 152384)
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- if (isProjectPreferencePage()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
- }
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean)
- */
- protected void enablePreferenceContent(boolean enable) {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.enablePreferenceContent(enable);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/EditTemplateDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/EditTemplateDialog.java
deleted file mode 100644
index e8b621bd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/EditTemplateDialog.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateException;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-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.Font;
-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.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
-import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-/**
- * Dialog to edit a template.
- */
-class EditTemplateDialog extends StatusDialog {
-
- private static class TextViewerAction extends Action implements IUpdate {
-
- private int fOperationCode= -1;
- private ITextOperationTarget fOperationTarget;
-
- /**
- * Creates a new action.
- *
- * @param viewer the viewer
- * @param operationCode the opcode
- */
- 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 Template fTemplate;
-
- private Text fNameText;
- private Text fDescriptionText;
- private Combo fContextCombo;
- private SourceViewer fPatternEditor;
- private Button fInsertVariableButton;
- private Button fAutoInsertCheckbox;
- private boolean fIsNameModifiable;
-
- private StatusInfo fValidationStatus;
- private boolean fSuppressError= true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=4354
- private Map fGlobalActions= new HashMap(10);
- private List fSelectionActions = new ArrayList(3);
- private String[][] fContextTypes;
-
- private ContextTypeRegistry fContextTypeRegistry;
-
- private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor();
-
- /**
- * Creates a new dialog.
- *
- * @param parent the shell parent of the dialog
- * @param template the template to edit
- * @param edit whether this is a new template or an existing being edited
- * @param isNameModifiable whether the name of the template may be modified
- * @param registry the context type registry to use
- */
- public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) {
- super(parent);
-
- setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
-
- String title= edit
- ? PreferencesMessages.EditTemplateDialog_title_edit
- : PreferencesMessages.EditTemplateDialog_title_new;
- setTitle(title);
-
- fTemplate= template;
- fIsNameModifiable= isNameModifiable;
-
- String delim= new Document().getLegalLineDelimiters()[0];
-
- List contexts= new ArrayList();
- for (Iterator it= registry.contextTypes(); it.hasNext();) {
- TemplateContextType type= (TemplateContextType) it.next();
- if (type.getId().equals("javadoc")) //$NON-NLS-1$
- contexts.add(new String[] { type.getId(), type.getName(), "/**" + delim }); //$NON-NLS-1$
- else
- contexts.add(0, new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
- }
- fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]);
-
- fValidationStatus= new StatusInfo();
-
- fContextTypeRegistry= registry;
-
- TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
- fTemplateProcessor.setContextType(type);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.dialogs.StatusDialog#create()
- */
- public void create() {
- super.create();
- updateStatusAndButtons();
- boolean isEmpty= fNameText != null && fNameText.getText().length() == 0;
- getButton(IDialogConstants.OK_ID).setEnabled(!isEmpty);
- }
-
- /*
- * @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));
-
- ModifyListener listener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doTextWidgetChanged(e.widget);
- }
- };
-
- if (fIsNameModifiable) {
- createLabel(parent, PreferencesMessages.EditTemplateDialog_name);
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layout= new GridLayout();
- layout.numColumns= 4;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- fNameText= createText(composite);
- fNameText.addFocusListener(new FocusListener() {
-
- public void focusGained(FocusEvent e) {
- }
-
- public void focusLost(FocusEvent e) {
- if (fSuppressError) {
- fSuppressError= false;
- updateStatusAndButtons();
- }
- }
- });
-
- createLabel(composite, PreferencesMessages.EditTemplateDialog_context);
- fContextCombo= new Combo(composite, SWT.READ_ONLY);
-
- for (int i= 0; i < fContextTypes.length; i++) {
- fContextCombo.add(fContextTypes[i][1]);
- }
-
- fContextCombo.addModifyListener(listener);
-
- fAutoInsertCheckbox= createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert);
- fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
- }
-
- createLabel(parent, PreferencesMessages.EditTemplateDialog_description);
-
- int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
- fDescriptionText= new Text(parent, descFlags );
- fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fDescriptionText.addModifyListener(listener);
-
- Label patternLabel= createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern);
- patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- fPatternEditor= createEditor(parent);
-
- Label filler= new Label(parent, SWT.NONE);
- filler.setLayoutData(new GridData());
-
- Composite composite= new Composite(parent, SWT.NONE);
- layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData());
-
- fInsertVariableButton= new Button(composite, SWT.NONE);
- fInsertVariableButton.setLayoutData(getButtonGridData(fInsertVariableButton));
- fInsertVariableButton.setText(PreferencesMessages.EditTemplateDialog_insert_variable);
- fInsertVariableButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fPatternEditor.getTextWidget().setFocus();
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- });
-
- fDescriptionText.setText(fTemplate.getDescription());
- if (fIsNameModifiable) {
- fNameText.setText(fTemplate.getName());
- fNameText.addModifyListener(listener);
- fContextCombo.select(getIndex(fTemplate.getContextTypeId()));
- } else {
- fPatternEditor.getControl().setFocus();
- }
- initializeActions();
-
- applyDialogFont(parent);
- return composite;
- }
-
- protected void doTextWidgetChanged(Widget w) {
- if (w == fNameText) {
- fSuppressError= false;
- updateStatusAndButtons();
- } else if (w == fContextCombo) {
- String contextId= getContextId();
- fTemplateProcessor.setContextType(fContextTypeRegistry.getContextType(contextId));
- IDocument document= fPatternEditor.getDocument();
- String prefix= getPrefix();
- document.set(prefix + getPattern());
- fPatternEditor.setVisibleRegion(prefix.length(), document.getLength() - prefix.length());
- } else if (w == fDescriptionText) {
- // nothing
- }
- }
-
- private String getContextId() {
- if (fContextCombo != null && !fContextCombo.isDisposed()) {
- String name= fContextCombo.getText();
- for (int i= 0; i < fContextTypes.length; i++) {
- if (name.equals(fContextTypes[i][1])) {
- return fContextTypes[i][0];
- }
- }
- }
-
- return fTemplate.getContextTypeId();
- }
-
- protected void doSourceChanged(IDocument document) {
- String text= document.get();
- fValidationStatus.setOK();
- TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId());
- if (contextType != null) {
- try {
- contextType.validate(text);
- } catch (TemplateException e) {
- fValidationStatus.setError(e.getLocalizedMessage());
- }
- }
-
- updateUndoAction();
- updateStatusAndButtons();
- }
-
- private static GridData getButtonGridData(Button button) {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- 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 Button createCheckbox(Composite parent, String name) {
- Button button= new Button(parent, SWT.CHECK);
- button.setText(name);
- button.setLayoutData(new GridData());
-
- return button;
- }
-
- 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) {
- String prefix= getPrefix();
- IDocument document= new Document(prefix + fTemplate.getPattern());
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
- viewer.configure(configuration);
- viewer.setEditable(true);
- viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
-
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- viewer.getTextWidget().setFont(font);
- new JavaSourcePreviewerUpdater(viewer, configuration, store);
-
- int nLines= document.getNumberOfLines();
- if (nLines < 5) {
- nLines= 5;
- } else if (nLines > 12) {
- nLines= 12;
- }
-
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= convertWidthInCharsToPixels(80);
- data.heightHint= convertHeightInCharsToPixels(nLines);
- control.setLayoutData(data);
-
- viewer.addTextListener(new ITextListener() {
- public void textChanged(TextEvent event) {
- if (event .getDocumentEvent() != null)
- doSourceChanged(event.getDocumentEvent().getDocument());
- }
- });
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateSelectionDependentActions();
- }
- });
-
- viewer.prependVerifyKeyListener(new VerifyKeyListener() {
- public void verifyKey(VerifyEvent event) {
- handleVerifyKeyPressed(event);
- }
- });
-
- return viewer;
- }
-
- private String getPrefix() {
- String id= getContextId();
- int idx= getIndex(id);
- if (idx != -1)
- return fContextTypes[idx][2];
- else
- return ""; //$NON-NLS-1$
- }
-
- private void handleVerifyKeyPressed(VerifyEvent event) {
- if (!event.doit)
- return;
-
- if (event.stateMask != SWT.MOD1)
- return;
-
- switch (event.character) {
- case ' ':
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- event.doit= false;
- break;
-
- // CTRL-Z
- case 'z' - 'a' + 1:
- fPatternEditor.doOperation(ITextOperationTarget.UNDO);
- event.doit= false;
- break;
- }
- }
-
- private void initializeActions() {
- TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
- action.setText(PreferencesMessages.EditTemplateDialog_undo);
- fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
- action.setText(PreferencesMessages.EditTemplateDialog_cut);
- fGlobalActions.put(ITextEditorActionConstants.CUT, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
- action.setText(PreferencesMessages.EditTemplateDialog_copy);
- fGlobalActions.put(ITextEditorActionConstants.COPY, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
- action.setText(PreferencesMessages.EditTemplateDialog_paste);
- fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
-
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
- action.setText(PreferencesMessages.EditTemplateDialog_select_all);
- fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
-
- action= new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
- action.setText(PreferencesMessages.EditTemplateDialog_content_assist);
- 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);
- }
-
- private 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 contextid) {
-
- if (contextid == null)
- return -1;
-
- for (int i= 0; i < fContextTypes.length; i++) {
- if (contextid.equals(fContextTypes[i][0])) {
- return i;
- }
- }
- return -1;
- }
-
- protected void okPressed() {
- String name= fNameText == null ? fTemplate.getName() : fNameText.getText();
- boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection();
- fTemplate= new Template(name, fDescriptionText.getText(), getContextId(), getPattern(), isAutoInsertable);
- super.okPressed();
- }
-
- private void updateStatusAndButtons() {
- StatusInfo status= fValidationStatus;
- boolean isEmpty= fNameText != null && fNameText.getText().length() == 0;
- if (!fSuppressError && isEmpty) {
- status= new StatusInfo();
- status.setError(PreferencesMessages.EditTemplateDialog_error_noname);
- } else if (fNameText != null && fNameText.getText().indexOf(' ') > -1) {
- status= new StatusInfo();
- status.setError(PreferencesMessages.EditTemplateDialog_error_spaces);
- }
- updateStatus(status);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.EDIT_TEMPLATE_DIALOG);
- }
-
- /**
- * Returns the created template.
- *
- * @return the created template
- *
- */
- public Template getTemplate() {
- return fTemplate;
- }
-
- private String getPattern() {
- IDocument doc= fPatternEditor.getDocument();
- IRegion visible= fPatternEditor.getVisibleRegion();
- try {
- return doc.get(visible.getOffset(), doc.getLength() - visible.getOffset());
- } catch (BadLocationException e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- /*
- * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
- *
- */
- protected IDialogSettings getDialogBoundsSettings() {
- String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- IDialogSettings section= settings.getSection(sectionName);
- if (section == null)
- section= settings.addNewSection(sectionName);
- return section;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingConfigurationBlock.java
deleted file mode 100644
index 83bbd78b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingConfigurationBlock.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-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.Label;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.folding.JavaFoldingStructureProviderDescriptor;
-import org.eclipse.wst.jsdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.folding.IJavaFoldingPreferenceBlock;
-
-/**
- * Configures Java Editor folding preferences.
- *
- *
- */
-class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
-
- private static class ErrorPreferences implements IJavaFoldingPreferenceBlock {
- private String fMessage;
-
- protected ErrorPreferences(String message) {
- fMessage= message;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.folding.IJavaFoldingPreferences#createControl(org.eclipse.swt.widgets.Group)
- */
- public Control createControl(Composite composite) {
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setLayout(new FillLayout(SWT.VERTICAL));
-
- Label label= new Label(inner, SWT.CENTER);
- label.setText(fMessage);
-
- return inner;
- }
-
- public void initialize() {
- }
-
- public void performOk() {
- }
-
- public void performDefaults() {
- }
-
- public void dispose() {
- }
-
- }
-
- /** The overlay preference store. */
- private final OverlayPreferenceStore fStore;
-
- /* The controls */
- private Combo fProviderCombo;
- private Button fFoldingCheckbox;
- private ComboViewer fProviderViewer;
- private Composite fGroup;
- private StackLayout fStackLayout;
-
- /* the model */
- private final Map fProviderDescriptors;
- private final Map fProviderPreferences;
- private final Map fProviderControls;
-
-
- public FoldingConfigurationBlock(OverlayPreferenceStore store) {
- Assert.isNotNull(store);
- fStore= store;
- fStore.addKeys(createOverlayStoreKeys());
- fProviderDescriptors= createListModel();
- fProviderPreferences= new HashMap();
- fProviderControls= new HashMap();
- }
-
- private Map createListModel() {
- JavaFoldingStructureProviderRegistry reg= JavaScriptPlugin.getDefault().getFoldingStructureProviderRegistry();
- reg.reloadExtensions();
- JavaFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
- Map map= new HashMap();
- for (int i= 0; i < descs.length; i++) {
- map.put(descs[i].getId(), descs[i]);
- }
- return map;
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates page for folding preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(Composite parent) {
-
- Composite composite= new Composite(parent, SWT.NULL);
- // assume parent page uses griddata
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
- composite.setLayoutData(gd);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- PixelConverter pc= new PixelConverter(composite);
- layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
- composite.setLayout(layout);
-
-
- /* check box for new editors */
- fFoldingCheckbox= new Button(composite, SWT.CHECK);
- fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- fFoldingCheckbox.setLayoutData(gd);
- fFoldingCheckbox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean enabled= fFoldingCheckbox.getSelection();
- fStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, enabled);
- updateCheckboxDependencies();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- Label label= new Label(composite, SWT.CENTER);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- label.setLayoutData(gd);
-
- if (fProviderDescriptors.size() > 1) {
- /* list */
- Composite comboComp= new Composite(composite, SWT.NONE);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- GridLayout gridLayout= new GridLayout(2, false);
- gridLayout.marginWidth= 0;
- comboComp.setLayout(gridLayout);
-
- Label comboLabel= new Label(comboComp, SWT.CENTER);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
- comboLabel.setLayoutData(gd);
- comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption);
-
- label= new Label(composite, SWT.CENTER);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- label.setLayoutData(gd);
-
- fProviderCombo= new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
- fProviderCombo.setLayoutData(gd);
-
- fProviderViewer= createProviderViewer();
- }
-
- Composite groupComp= new Composite(composite, SWT.NONE);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
- groupComp.setLayoutData(gd);
- GridLayout gridLayout= new GridLayout(1, false);
- gridLayout.marginWidth= 0;
- groupComp.setLayout(gridLayout);
-
- /* contributed provider preferences. */
- fGroup= new Composite(groupComp, SWT.NONE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- fGroup.setLayoutData(gd);
- fStackLayout= new StackLayout();
- fGroup.setLayout(fStackLayout);
-
- return composite;
- }
-
- private ComboViewer createProviderViewer() {
- /* list viewer */
- ComboViewer viewer= new ComboViewer(fProviderCombo);
- viewer.setContentProvider(new IStructuredContentProvider() {
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- }
-
- /*
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return fProviderDescriptors.values().toArray();
- }
- });
- viewer.setLabelProvider(new LabelProvider() {
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return ((JavaFoldingStructureProviderDescriptor) element).getName();
- }
- });
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel= (IStructuredSelection) event.getSelection();
- if (!sel.isEmpty()) {
- fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER, ((JavaFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
- updateListDependencies();
- }
- }
- });
- viewer.setInput(fProviderDescriptors);
- viewer.refresh();
-
- return viewer;
- }
-
- private void updateCheckboxDependencies() {
- }
-
- void updateListDependencies() {
- String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- JavaFoldingStructureProviderDescriptor desc= (JavaFoldingStructureProviderDescriptor) fProviderDescriptors.get(id);
- IJavaFoldingPreferenceBlock prefs;
-
- if (desc == null) {
- // safety in case there is no such descriptor
- String message= Messages.format(PreferencesMessages.FoldingConfigurationBlock_error_not_exist, id);
- JavaScriptPlugin.log(new Status(IStatus.WARNING, JavaScriptPlugin.getPluginId(), IStatus.OK, message, null));
- prefs= new ErrorPreferences(message);
- } else {
- prefs= (IJavaFoldingPreferenceBlock) fProviderPreferences.get(id);
- if (prefs == null) {
- try {
- prefs= desc.createPreferences();
- fProviderPreferences.put(id, prefs);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- prefs= new ErrorPreferences(e.getLocalizedMessage());
- }
- }
- }
-
- Control control= (Control) fProviderControls.get(id);
- if (control == null) {
- control= prefs.createControl(fGroup);
- if (control == null) {
- String message= PreferencesMessages.FoldingConfigurationBlock_info_no_preferences;
- control= new ErrorPreferences(message).createControl(fGroup);
- } else {
- fProviderControls.put(id, control);
- }
- }
- Dialog.applyDialogFont(control);
- fStackLayout.topControl= control;
- control.pack();
- fGroup.layout();
- fGroup.getParent().layout();
-
- prefs.initialize();
- }
-
- public void initialize() {
- restoreFromPreferences();
- }
-
- public void performOk() {
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
- prefs.performOk();
- }
- }
-
- public void performDefaults() {
- restoreFromPreferences();
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
- prefs.performDefaults();
- }
- }
-
- public void dispose() {
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
- prefs.dispose();
- }
- }
-
- private void restoreFromPreferences() {
- boolean enabled= fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
- fFoldingCheckbox.setSelection(enabled);
- updateCheckboxDependencies();
-
- String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- Object provider= fProviderDescriptors.get(id);
-
- // Fallback to default
- if (provider == null) {
- String message= Messages.format(PreferencesMessages.FoldingConfigurationBlock_warning_providerNotFound_resetToDefault, id);
- JavaScriptPlugin.log(new Status(IStatus.WARNING, JavaScriptPlugin.getPluginId(), IStatus.OK, message, null));
-
- id= JavaScriptPlugin.getDefault().getPreferenceStore().getDefaultString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
-
- provider= fProviderDescriptors.get(id);
- Assert.isNotNull(provider);
-
- fStore.setToDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- }
-
- if (fProviderViewer == null)
- updateListDependencies();
- else
- fProviderViewer.setSelection(new StructuredSelection(provider), true);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingPreferencePage.java
deleted file mode 100644
index 7c9b5750..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/FoldingPreferencePage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * The page for setting the editor options.
- */
-public final class FoldingPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.JavaEditorPreferencePage_folding_title;
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null; // no description for new look.
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new FoldingConfigurationBlock(overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceAndPropertyConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceAndPropertyConfigurationBlock.java
deleted file mode 100644
index d4333af3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceAndPropertyConfigurationBlock.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-/**
- * Interface for preference and property configuration blocks which can either be
- * wrapped by a {@link org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigurationBlockPreferenceAndPropertyPage}
- * or be included some preference page.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- *
- */
-public interface IPreferenceAndPropertyConfigurationBlock extends IPreferenceConfigurationBlock {
-
- /**
- * Disable project specific settings for the settings configured by this block.
- */
- public abstract void disableProjectSettings();
-
- /**
- * Enabled project specific settings for the settings configured by this block.
- */
- public abstract void enableProjectSettings();
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
deleted file mode 100644
index b3f92b85..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Interface for preference configuration blocks which can either be
- * wrapped by a {@link org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage}
- * or be included some preference page.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- *
- */
-public interface IPreferenceConfigurationBlock {
-
- /**
- * Creates the preference control.
- *
- * @param parent the parent composite to which to add the preferences control
- * @return the control that was added to <code>parent</code>
- */
- Control createControl(Composite parent);
-
- /**
- * Called after creating the control. Implementations should load the
- * preferences values and update the controls accordingly.
- */
- void initialize();
-
- /**
- * Called when the <code>OK</code> button is pressed on the preference
- * page. Implementations should commit the configured preference settings
- * into their form of preference storage.
- */
- void performOk();
-
- /**
- * Called when the <code>Defaults</code> button is pressed on the
- * preference page. Implementation should reset any preference settings to
- * their default values and adjust the controls accordingly.
- */
- void performDefaults();
-
- /**
- * Called when the preference page is being disposed. Implementations should
- * free any resources they are holding on to.
- */
- void dispose();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java
deleted file mode 100644
index 72b540d8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-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.FileDialog;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/*
- * The page for setting the organize import settings
- */
-public class ImportOrganizeConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_IMPORTORDER= getJDTUIKey(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
- private static final Key PREF_ONDEMANDTHRESHOLD= getJDTUIKey(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
- private static final Key PREF_IGNORELOWERCASE= getJDTUIKey(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE);
- private static final Key PREF_STATICONDEMANDTHRESHOLD= getJDTUIKey(PreferenceConstants.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD);
-
- private static final String DIALOGSETTING_LASTLOADPATH= JavaScriptUI.ID_PLUGIN + ".importorder.loadpath"; //$NON-NLS-1$
- private static final String DIALOGSETTING_LASTSAVEPATH= JavaScriptUI.ID_PLUGIN + ".importorder.savepath"; //$NON-NLS-1$
-
- private static Key[] getAllKeys() {
- return new Key[] {
- PREF_IMPORTORDER, PREF_ONDEMANDTHRESHOLD, PREF_STATICONDEMANDTHRESHOLD, PREF_IGNORELOWERCASE
- };
- }
-
- public static class ImportOrderEntry {
-
- public final String name;
- public final boolean isStatic;
-
- public ImportOrderEntry(String name, boolean isStatic) {
- this.name= name;
- this.isStatic= isStatic;
- }
-
- public String serialize() {
- return isStatic ? '#' + name : name;
- }
-
- public static ImportOrderEntry fromSerialized(String str) {
- if (str.length() > 0 && str.charAt(0) == '#') {
- return new ImportOrderEntry(str.substring(1), true);
- }
- return new ImportOrderEntry(str, false);
- }
-
- }
-
-
- private static class ImportOrganizeLabelProvider extends LabelProvider {
-
- private final Image PCK_ICON;
- private final Image STATIC_CLASS_ICON;
-
- public ImportOrganizeLabelProvider() {
- PCK_ICON= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_PACKAGE);
- STATIC_CLASS_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, JavaScriptElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
- }
-
- public Image getImage(Object element) {
- return ((ImportOrderEntry) element).isStatic ? STATIC_CLASS_ICON : PCK_ICON;
- }
-
- public String getText(Object element) {
- ImportOrderEntry entry= (ImportOrderEntry) element;
- String name= entry.name;
- if (name.length() > 0) {
- return name;
- }
- if (entry.isStatic) {
- return PreferencesMessages.ImportOrganizeConfigurationBlock_other_static;
- }
- return PreferencesMessages.ImportOrganizeConfigurationBlock_other_normal;
- }
- }
-
- private class ImportOrganizeAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(ListDialogField field) {
- List selected= field.getSelectedElements();
- return selected.size() == 1;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- fOrderListField.enableButton(IDX_EDIT, canEdit(field));
- }
-
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field)) {
- doButtonPressed(IDX_EDIT);
- }
- }
- }
-
- private static final int IDX_ADD= 0;
- private static final int IDX_ADD_STATIC= 1;
- private static final int IDX_EDIT= 2;
- private static final int IDX_REMOVE= 3;
- private static final int IDX_UP= 5;
- private static final int IDX_DOWN= 6;
-
- private ListDialogField fOrderListField;
- private StringDialogField fThresholdField;
- private StringDialogField fStaticThresholdField;
- private SelectionButtonDialogField fIgnoreLowerCaseTypesField;
- private SelectionButtonDialogField fExportButton;
- private SelectionButtonDialogField fImportButton;
-
- private PixelConverter fPixelConverter;
-
- public ImportOrganizeConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getAllKeys(), container);
-
- String[] buttonLabels= new String[] {
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_button,
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_static_button,
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_edit_button,
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_remove_button,
- /* 4 */ null,
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_up_button,
- PreferencesMessages.ImportOrganizeConfigurationBlock_order_down_button,
- };
-
- ImportOrganizeAdapter adapter= new ImportOrganizeAdapter();
-
- fOrderListField= new ListDialogField(adapter, buttonLabels, new ImportOrganizeLabelProvider());
- fOrderListField.setDialogFieldListener(adapter);
- fOrderListField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_order_label);
- fOrderListField.setUpButtonIndex(IDX_UP);
- fOrderListField.setDownButtonIndex(IDX_DOWN);
- fOrderListField.setRemoveButtonIndex(IDX_REMOVE);
-
- fOrderListField.enableButton(IDX_EDIT, false);
-
- fImportButton= new SelectionButtonDialogField(SWT.PUSH);
- fImportButton.setDialogFieldListener(adapter);
- fImportButton.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_order_load_button);
-
- fExportButton= new SelectionButtonDialogField(SWT.PUSH);
- fExportButton.setDialogFieldListener(adapter);
- fExportButton.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_order_save_button);
-
- fThresholdField= new StringDialogField();
- fThresholdField.setDialogFieldListener(adapter);
- fThresholdField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_threshold_label);
-
- fStaticThresholdField= new StringDialogField();
- fStaticThresholdField.setDialogFieldListener(adapter);
- fStaticThresholdField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_staticthreshold_label);
-
- fIgnoreLowerCaseTypesField= new SelectionButtonDialogField(SWT.CHECK);
- fIgnoreLowerCaseTypesField.setDialogFieldListener(adapter);
- fIgnoreLowerCaseTypesField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_ignoreLowerCase_label);
-
- updateControls();
- }
-
- protected Control createContents(Composite parent) {
- setShell(parent.getShell());
-
- fPixelConverter= new PixelConverter(parent);
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
-
- composite.setLayout(layout);
-
- fOrderListField.doFillIntoGrid(composite, 3);
- LayoutUtil.setHorizontalSpan(fOrderListField.getLabelControl(null), 2);
- LayoutUtil.setWidthHint(fOrderListField.getLabelControl(null), fPixelConverter.convertWidthInCharsToPixels(60));
- LayoutUtil.setHorizontalGrabbing(fOrderListField.getListControl(null));
-
- Composite importExportComp= new Composite(composite, SWT.NONE);
- importExportComp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
-
- importExportComp.setLayout(layout);
-
- fImportButton.doFillIntoGrid(importExportComp, 1);
- fExportButton.doFillIntoGrid(importExportComp, 1);
-
- fThresholdField.doFillIntoGrid(composite, 2);
- ((GridData) fThresholdField.getTextControl(null).getLayoutData()).grabExcessHorizontalSpace= false;
- fStaticThresholdField.doFillIntoGrid(composite, 2);
- fIgnoreLowerCaseTypesField.doFillIntoGrid(composite, 2);
-
- Dialog.applyDialogFont(composite);
-
- return composite;
- }
-
- private boolean doThresholdChanged(String thresholdString) {
- StatusInfo status= new StatusInfo();
- try {
- int threshold= Integer.parseInt(thresholdString);
- if (threshold < 0) {
- status.setError(PreferencesMessages.ImportOrganizeConfigurationBlock_error_invalidthreshold);
- }
- } catch (NumberFormatException e) {
- status.setError(PreferencesMessages.ImportOrganizeConfigurationBlock_error_invalidthreshold);
- }
- updateStatus(status);
- return status.isOK();
- }
-
- private void doButtonPressed(int index) {
- if (index == IDX_ADD || index == IDX_ADD_STATIC) { // add new
- List existing= fOrderListField.getElements();
- ImportOrganizeInputDialog dialog= new ImportOrganizeInputDialog(getShell(), existing, index == IDX_ADD_STATIC);
- if (dialog.open() == Window.OK) {
- List selectedElements= fOrderListField.getSelectedElements();
- if (selectedElements.size() == 1) {
- int insertionIndex= fOrderListField.getIndexOfElement(selectedElements.get(0)) + 1;
- fOrderListField.addElement(dialog.getResult(), insertionIndex);
- } else {
- fOrderListField.addElement(dialog.getResult());
- }
- }
- } else if (index == IDX_EDIT) { // edit
- List selected= fOrderListField.getSelectedElements();
- if (selected.isEmpty()) {
- return;
- }
- ImportOrderEntry editedEntry= (ImportOrderEntry) selected.get(0);
-
- List existing= fOrderListField.getElements();
- existing.remove(editedEntry);
-
- ImportOrganizeInputDialog dialog= new ImportOrganizeInputDialog(getShell(), existing, editedEntry.isStatic);
- dialog.setInitialSelection(editedEntry);
- if (dialog.open() == Window.OK) {
- fOrderListField.replaceElement(editedEntry, dialog.getResult());
- }
- }
- }
-
-
- /*
- * The import order file is a property file. The keys are
- * "0", "1" ... last entry. The values must be valid package names.
- */
- private List loadFromProperties(Properties properties) {
- ArrayList res= new ArrayList();
- int nEntries= properties.size();
- for (int i= 0 ; i < nEntries; i++) {
- String curr= properties.getProperty(String.valueOf(i));
- if (curr != null) {
- ImportOrderEntry entry= ImportOrderEntry.fromSerialized(curr);
- if (!JavaScriptConventions.validatePackageName(entry.name, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_5).matches(IStatus.ERROR)) {
- res.add(entry);
- } else {
- return null;
- }
- } else {
- return res;
- }
- }
- return res;
- }
-
- private List loadImportOrder() {
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
-
- FileDialog dialog= new FileDialog(getShell(), SWT.OPEN);
- dialog.setText(PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_title);
- dialog.setFilterExtensions(new String[] {"*.importorder", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- String lastPath= dialogSettings.get(DIALOGSETTING_LASTLOADPATH);
- if (lastPath != null) {
- dialog.setFilterPath(lastPath);
- }
- String fileName= dialog.open();
- if (fileName != null) {
- dialogSettings.put(DIALOGSETTING_LASTLOADPATH, dialog.getFilterPath());
-
- Properties properties= new Properties();
- FileInputStream fis= null;
- try {
- fis= new FileInputStream(fileName);
- properties.load(fis);
- List res= loadFromProperties(properties);
- if (res != null) {
- return res;
- }
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- } finally {
- if (fis != null) {
- try { fis.close(); } catch (IOException e) {}
- }
- }
- String title= PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_error_title;
- String message= PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_error_message;
- MessageDialog.openError(getShell(), title, message);
- }
- return null;
- }
-
- private void saveImportOrder(List elements) {
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
-
- FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_title);
- dialog.setFilterExtensions(new String[] {"*.importorder", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- dialog.setFileName("example.importorder"); //$NON-NLS-1$
- String lastPath= dialogSettings.get(DIALOGSETTING_LASTSAVEPATH);
- if (lastPath != null) {
- dialog.setFilterPath(lastPath);
- }
- String fileName= dialog.open();
- if (fileName != null) {
- dialogSettings.put(DIALOGSETTING_LASTSAVEPATH, dialog.getFilterPath());
-
- Properties properties= new Properties();
- for (int i= 0; i < elements.size(); i++) {
- ImportOrderEntry entry= (ImportOrderEntry) elements.get(i);
- properties.setProperty(String.valueOf(i), entry.serialize());
- }
- FileOutputStream fos= null;
- try {
- fos= new FileOutputStream(fileName);
- properties.store(fos, "Organize Import Order"); //$NON-NLS-1$
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- String title= PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_error_title;
- String message= PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_error_message;
- MessageDialog.openError(getShell(), title, message);
- } finally {
- if (fos != null) {
- try { fos.close(); } catch (IOException e) {}
- }
- }
- }
- }
-
- private void updateStatus(IStatus status) {
- fContext.statusChanged(status);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String, java.lang.String)
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- // no validation
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
- */
- protected void updateControls() {
- ImportOrderEntry[] importOrder= getImportOrderPreference();
- int threshold= getImportNumberThreshold(PREF_ONDEMANDTHRESHOLD);
- int staticThreshold= getImportNumberThreshold(PREF_STATICONDEMANDTHRESHOLD);
- boolean ignoreLowerCase= Boolean.valueOf(getValue(PREF_IGNORELOWERCASE)).booleanValue();
-
- fOrderListField.removeAllElements();
- for (int i= 0; i < importOrder.length; i++) {
- fOrderListField.addElement(importOrder[i]);
- }
- fThresholdField.setText(String.valueOf(threshold));
- fStaticThresholdField.setText(String.valueOf(staticThreshold));
- fIgnoreLowerCaseTypesField.setSelection(ignoreLowerCase);
- }
-
-
- protected final void doDialogFieldChanged(DialogField field) {
- // set values in working copy
- if (field == fOrderListField) {
- setValue(PREF_IMPORTORDER, packOrderList(fOrderListField.getElements()));
- } else if (field == fThresholdField) {
- if (doThresholdChanged(fThresholdField.getText())) {
- setValue(PREF_ONDEMANDTHRESHOLD, fThresholdField.getText());
- }
- } else if (field == fStaticThresholdField) {
- if (doThresholdChanged(fStaticThresholdField.getText())) {
- setValue(PREF_STATICONDEMANDTHRESHOLD, fStaticThresholdField.getText());
- }
- } else if (field == fIgnoreLowerCaseTypesField) {
- setValue(PREF_IGNORELOWERCASE, fIgnoreLowerCaseTypesField.isSelected());
- } else if (field == fImportButton) {
- List order= loadImportOrder();
- if (order != null) {
- fOrderListField.setElements(order);
- }
- } else if (field == fExportButton) {
- saveImportOrder(fOrderListField.getElements());
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
- */
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- return null; // no build required
- }
-
- private static ImportOrderEntry[] unpackOrderList(String str) {
- ArrayList res= new ArrayList();
- int start= 0;
- do {
- int end= str.indexOf(';', start);
- if (end == -1) {
- end= str.length();
- }
- res.add(ImportOrderEntry.fromSerialized(str.substring(start, end)));
- start= end + 1;
- } while (start < str.length());
-
- return (ImportOrderEntry[]) res.toArray(new ImportOrderEntry[res.size()]);
- }
-
- private static String packOrderList(List orderList) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < orderList.size(); i++) {
- ImportOrderEntry entry= (ImportOrderEntry) orderList.get(i);
- buf.append(entry.serialize());
- buf.append(';');
- }
- return buf.toString();
- }
-
- private ImportOrderEntry[] getImportOrderPreference() {
- String str= getValue(PREF_IMPORTORDER);
- if (str != null) {
- return unpackOrderList(str);
- }
- return new ImportOrderEntry[0];
- }
-
- private int getImportNumberThreshold(Key key) {
- String thresholdStr= getValue(key);
- try {
- int threshold= Integer.parseInt(thresholdStr);
- if (threshold < 0) {
- threshold= Integer.MAX_VALUE;
- }
- return threshold;
- } catch (NumberFormatException e) {
- return Integer.MAX_VALUE;
- }
- }
-
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeInputDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeInputDialog.java
deleted file mode 100644
index 346c3cfa..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizeInputDialog.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.window.Window;
-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.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.PackageSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.preferences.ImportOrganizeConfigurationBlock.ImportOrderEntry;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.wst.jsdt.ui.IJavaScriptElementSearchConstants;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Dialog to enter a new package entry in the organize import preference page.
- */
-public class ImportOrganizeInputDialog extends StatusDialog {
-
- private class ImportOrganizeInputAdapter implements IDialogFieldListener, IStringButtonAdapter {
- /**
- * @see IDialogFieldListener#dialogFieldChanged(DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- doDialogFieldChanged(field);
- }
-
- /**
- * @see IStringButtonAdapter#changeControlPressed(DialogField)
- */
- public void changeControlPressed(DialogField field) {
- doBrowsePackages();
- }
- }
-
- private StringButtonDialogField fNameDialogField;
- private SelectionButtonDialogField fBrowseTypeButton;
- private List fExistingEntries;
- private final boolean fIsStatic;
-
- public ImportOrganizeInputDialog(Shell parent, List/*<ImportOrderEntry>*/ existingEntries, boolean isStatic) {
- super(parent);
- fIsStatic= isStatic;
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- fExistingEntries= existingEntries;
-
- String label, title;
- if (isStatic) {
- title= PreferencesMessages.ImportOrganizeInputDialog_title_static;
- label= PreferencesMessages.ImportOrganizeInputDialog_name_group_static_label;
- } else {
- title= PreferencesMessages.ImportOrganizeInputDialog_title;
- label= PreferencesMessages.ImportOrganizeInputDialog_name_group_label;
- }
- setTitle(title);
-
- ImportOrganizeInputAdapter adapter= new ImportOrganizeInputAdapter();
-
- fNameDialogField= new StringButtonDialogField(adapter);
- fNameDialogField.setLabelText(label);
- fNameDialogField.setButtonLabel(PreferencesMessages.ImportOrganizeInputDialog_browse_packages_button);
- fNameDialogField.setDialogFieldListener(adapter);
- fNameDialogField.setText(""); //$NON-NLS-1$
-
- fBrowseTypeButton= new SelectionButtonDialogField(SWT.PUSH);
- fBrowseTypeButton.setLabelText(PreferencesMessages.ImportOrganizeInputDialog_browse_types_label);
- fBrowseTypeButton.setDialogFieldListener(adapter);
- }
-
- public void setInitialSelection(ImportOrderEntry editedEntry) {
- Assert.isNotNull(editedEntry);
- if (editedEntry.name.length() == 0) {
- fNameDialogField.setText(""); //$NON-NLS-1$
- } else {
- fNameDialogField.setText(editedEntry.name);
- }
- }
-
- public ImportOrderEntry getResult() {
- String val= fNameDialogField.getText();
- if ("*".equals(val)) { //$NON-NLS-1$
- return new ImportOrderEntry("", fIsStatic); //$NON-NLS-1$
- } else {
- return new ImportOrderEntry(val, fIsStatic);
- }
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- initializeDialogUnits(parent);
-
- GridLayout layout= (GridLayout) composite.getLayout();
- layout.numColumns= 2;
-
- fNameDialogField.doFillIntoGrid(composite, 3);
-
- LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2);
-
- int fieldWidthHint= convertWidthInCharsToPixels(60);
- Text text= fNameDialogField.getTextControl(null);
- LayoutUtil.setWidthHint(text, fieldWidthHint);
- LayoutUtil.setHorizontalGrabbing(text);
- TextFieldNavigationHandler.install(text);
-
- DialogField.createEmptySpace(composite, 1);
- fBrowseTypeButton.doFillIntoGrid(composite, 1);
-
- fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
- return composite;
- }
-
- final void doBrowsePackages() {
- IRunnableContext context= new BusyIndicatorRunnableContext();
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- int style= PackageSelectionDialog.F_REMOVE_DUPLICATES | PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE;
- PackageSelectionDialog dialog= new PackageSelectionDialog(getShell(), context, style, scope);
- dialog.setFilter(fNameDialogField.getText());
- dialog.setIgnoreCase(false);
- dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChoosePackageDialog_title);
- dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChoosePackageDialog_description);
- dialog.setEmptyListMessage(PreferencesMessages.ImportOrganizeInputDialog_ChoosePackageDialog_empty);
- if (dialog.open() == Window.OK) {
- IPackageFragment res= (IPackageFragment) dialog.getFirstResult();
- fNameDialogField.setText(res.getElementName());
- }
- }
-
- private void doBrowseTypes() {
- IRunnableContext context= new BusyIndicatorRunnableContext();
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- int style= IJavaScriptElementSearchConstants.CONSIDER_ALL_TYPES;
- try {
- SelectionDialog dialog= JavaScriptUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
- dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title);
- dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_description);
- if (dialog.open() == Window.OK) {
- IType res= (IType) dialog.getResult()[0];
- fNameDialogField.setText(res.getFullyQualifiedName('.'));
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message);
- }
- }
-
- /**
- * @param field
- */
- final void doDialogFieldChanged(DialogField field) {
- if (field == fBrowseTypeButton) {
- doBrowseTypes();
- } else {
- doValidation();
- }
- }
-
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fNameDialogField.getText();
- if (newText.length() == 0) {
- status.setError(""); //$NON-NLS-1$
- } else {
- if (newText.equals("*")) { //$NON-NLS-1$
- if (doesExist("", fIsStatic)) { //$NON-NLS-1$
- status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
- }
- } else {
- IStatus val= JavaScriptConventions.validateJavaScriptTypeName(newText, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3);
- if (val.matches(IStatus.ERROR)) {
- status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_invalidName);
- } else {
- if (doesExist(newText, fIsStatic)) {
- status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
- }
- }
- }
- }
- updateStatus(status);
- }
-
- private boolean doesExist(String name, boolean isStatic) {
- for (int i= 0; i < fExistingEntries.size(); i++) {
- ImportOrderEntry entry= (ImportOrderEntry) fExistingEntries.get(i);
- if (name.equals(entry.name) && isStatic == entry.isStatic) {
- return true;
- }
- }
- return false;
- }
-
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.IMPORT_ORGANIZE_INPUT_DIALOG);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizePreferencePage.java
deleted file mode 100644
index f4922a3f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ImportOrganizePreferencePage.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/*
- * The page to configure the naming style options.
- */
-public class ImportOrganizePreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.ImportOrganizePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.ImportOrganizePreferencePage"; //$NON-NLS-1$
-
-
- private ImportOrganizeConfigurationBlock fConfigurationBlock;
-
- public ImportOrganizePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.ImportOrganizePreferencePage_description);
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.ImportOrganizePreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new ImportOrganizeConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.ORGANIZE_IMPORTS_PREFERENCE_PAGE);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-
-}
-
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBasePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBasePreferencePage.java
deleted file mode 100644
index c916368b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBasePreferencePage.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-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.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.IUIConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.OptionalMessageDialog;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSavePreferences;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/*
- * The page for setting general java plugin preferences.
- * See PreferenceConstants to access or change these values through public API.
- */
-public class JavaBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String JAVA_BASE_PREF_PAGE_ID= "org.eclipse.wst.jsdt.ui.preferences.JavaBasePreferencePage"; //$NON-NLS-1$
-
- private static final String OPEN_TYPE_HIERARCHY= PreferenceConstants.OPEN_TYPE_HIERARCHY;
- private static final String OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE= PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE;
- private static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_VIEW_PART;
-
- private static final String DOUBLE_CLICK= PreferenceConstants.DOUBLE_CLICK;
- private static final String DOUBLE_CLICK_GOES_INTO= PreferenceConstants.DOUBLE_CLICK_GOES_INTO;
- private static final String DOUBLE_CLICK_EXPANDS= PreferenceConstants.DOUBLE_CLICK_EXPANDS;
-
- private ArrayList fCheckBoxes;
- private ArrayList fRadioButtons;
- private ArrayList fTextControls;
-
- public JavaBasePreferencePage() {
- super();
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.JavaBasePreferencePage_description);
-
- fRadioButtons= new ArrayList();
- fCheckBoxes= new ArrayList();
- fTextControls= new ArrayList();
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_BASE_PREFERENCE_PAGE);
- }
-
- private Button addRadioButton(Composite parent, String label, String key, String value) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-
- Button button= new Button(parent, SWT.RADIO);
- button.setText(label);
- button.setData(new String[] { key, value });
- button.setLayoutData(gd);
-
- button.setSelection(value.equals(getPreferenceStore().getString(key)));
-
- fRadioButtons.add(button);
- return button;
- }
-
- private Button addCheckBox(Composite parent, String label, String key) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-
- Button button= new Button(parent, SWT.CHECK);
- button.setText(label);
- button.setData(key);
- button.setLayoutData(gd);
-
- button.setSelection(getPreferenceStore().getBoolean(key));
-
- fCheckBoxes.add(button);
- return button;
- }
-
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- result.setLayout(layout);
-
- // new Label(composite, SWT.NONE); // spacer
- // Group linkSettings= new Group(result, SWT.NONE);
- // linkSettings.setLayout(new GridLayout());
- // linkSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // linkSettings.setText(PreferencesMessages.getString("JavaBasePreferencePage.linkSettings.text")); //$NON-NLS-1$
- //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkJavaBrowsingViewsCheckbox.text"), LINK_BROWSING_VIEW_TO_EDITOR); //$NON-NLS-1$
- //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkPackageView"), LINK_PACKAGES_TO_EDITOR); //$NON-NLS-1$
- //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkTypeHierarchy"), LINK_TYPEHIERARCHY_TO_EDITOR); //$NON-NLS-1$
-
- // new Label(result, SWT.NONE); // spacer
-
- Group doubleClickGroup= new Group(result, SWT.NONE);
- doubleClickGroup.setLayout(new GridLayout());
- doubleClickGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- doubleClickGroup.setText(PreferencesMessages.JavaBasePreferencePage_doubleclick_action);
- addRadioButton(doubleClickGroup, PreferencesMessages.JavaBasePreferencePage_doubleclick_gointo, DOUBLE_CLICK, DOUBLE_CLICK_GOES_INTO);
- addRadioButton(doubleClickGroup, PreferencesMessages.JavaBasePreferencePage_doubleclick_expand, DOUBLE_CLICK, DOUBLE_CLICK_EXPANDS);
-
- // new Label(result, SWT.NONE); // spacer
-
- Group typeHierarchyGroup= new Group(result, SWT.NONE);
- typeHierarchyGroup.setLayout(new GridLayout());
- typeHierarchyGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- typeHierarchyGroup.setText(PreferencesMessages.JavaBasePreferencePage_openTypeHierarchy);
- addRadioButton(typeHierarchyGroup, PreferencesMessages.JavaBasePreferencePage_inPerspective, OPEN_TYPE_HIERARCHY, OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE);
- addRadioButton(typeHierarchyGroup, PreferencesMessages.JavaBasePreferencePage_inView, OPEN_TYPE_HIERARCHY, OPEN_TYPE_HIERARCHY_IN_VIEW_PART);
-
- if ( IUIConstants.SUPPORT_REFACTORING ) {
- Group refactoringGroup= new Group(result, SWT.NONE);
- refactoringGroup.setLayout(new GridLayout());
- refactoringGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- refactoringGroup.setText(PreferencesMessages.JavaBasePreferencePage_refactoring_title);
- addCheckBox(refactoringGroup,
- PreferencesMessages.JavaBasePreferencePage_refactoring_auto_save,
- RefactoringSavePreferences.PREF_SAVE_ALL_EDITORS);
- addCheckBox(refactoringGroup,
- PreferencesMessages.JavaBasePreferencePage_refactoring_lightweight,
- PreferenceConstants.REFACTOR_LIGHTWEIGHT);
- }
-
- Group group= new Group(result, SWT.NONE);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setText(PreferencesMessages.JavaBasePreferencePage_search);
-
- addCheckBox(group, PreferencesMessages.JavaBasePreferencePage_search_small_menu, PreferenceConstants.SEARCH_USE_REDUCED_MENU);
-
-
- layout= new GridLayout();
- layout.numColumns= 2;
-
- Group dontAskGroup= new Group(result, SWT.NONE);
- dontAskGroup.setLayout(layout);
- dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- dontAskGroup.setText(PreferencesMessages.JavaBasePreferencePage_dialogs);
-
- Label label= new Label(dontAskGroup, SWT.WRAP);
- label.setText(PreferencesMessages.JavaBasePreferencePage_do_not_hide_description);
- GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
- data.widthHint= convertVerticalDLUsToPixels(50);
- label.setLayoutData(data);
-
- Button clearButton= new Button(dontAskGroup, SWT.PUSH);
- clearButton.setText(PreferencesMessages.JavaBasePreferencePage_do_not_hide_button);
- clearButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
- clearButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- unhideAllDialogs();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- unhideAllDialogs();
- }
- });
-
-
- SWTUtil.setButtonDimensionHint(clearButton);
- Dialog.applyDialogFont(result);
- return result;
- }
-
- protected final void unhideAllDialogs() {
- OptionalMessageDialog.clearAllRememberedStates();
- MessageDialog.openInformation(getShell(), PreferencesMessages.JavaBasePreferencePage_do_not_hide_dialog_title, PreferencesMessages.JavaBasePreferencePage_do_not_hide_dialog_message);
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- button.setSelection(store.getDefaultBoolean(key));
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- String[] info= (String[]) button.getData();
- button.setSelection(info[1].equals(store.getDefaultString(info[0])));
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- text.setText(store.getDefaultString(key));
- }
- super.performDefaults();
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- store.setValue(key, button.getSelection());
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- if (button.getSelection()) {
- String[] info= (String[]) button.getData();
- store.setValue(info[0], info[1]);
- }
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- store.setValue(key, text.getText());
- }
-
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return super.performOk();
- }
-
-
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildConfigurationBlock.java
deleted file mode 100644
index a9e3271b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildConfigurationBlock.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogSettings;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-
-/**
- */
-public class JavaBuildConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final String SETTINGS_SECTION_NAME= "JavaBuildConfigurationBlock"; //$NON-NLS-1$
-
- private static final Key PREF_PB_MAX_PER_UNIT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MAX_PER_UNIT);
-
- private static final Key PREF_RESOURCE_FILTER= getJDTCoreKey(JavaScriptCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
- private static final Key PREF_BUILD_INVALID_CLASSPATH= getJDTCoreKey(JavaScriptCore.CORE_JAVA_BUILD_INVALID_CLASSPATH);
- private static final Key PREF_BUILD_CLEAN_OUTPUT_FOLDER= getJDTCoreKey(JavaScriptCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
- private static final Key PREF_ENABLE_EXCLUSION_PATTERNS= getJDTCoreKey(JavaScriptCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
- private static final Key PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= getJDTCoreKey(JavaScriptCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
-
- private static final Key PREF_PB_INCOMPLETE_BUILDPATH= getJDTCoreKey(JavaScriptCore.CORE_INCOMPLETE_CLASSPATH);
- private static final Key PREF_PB_CIRCULAR_BUILDPATH= getJDTCoreKey(JavaScriptCore.CORE_CIRCULAR_CLASSPATH);
- private static final Key PREF_PB_INCOMPATIBLE_JDK_LEVEL= getJDTCoreKey(JavaScriptCore.CORE_INCOMPATIBLE_JDK_LEVEL);
- private static final Key PREF_PB_DUPLICATE_RESOURCE= getJDTCoreKey(JavaScriptCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
- private static final Key PREF_RECREATE_MODIFIED_CLASS_FILES= getJDTCoreKey(JavaScriptCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER);
-
-
- // values
- private static final String ERROR= JavaScriptCore.ERROR;
- private static final String WARNING= JavaScriptCore.WARNING;
- private static final String IGNORE= JavaScriptCore.IGNORE;
-
- private static final String ABORT= JavaScriptCore.ABORT;
- private static final String CLEAN= JavaScriptCore.CLEAN;
-
- private static final String ENABLED= JavaScriptCore.ENABLED;
- private static final String DISABLED= JavaScriptCore.DISABLED;
-
- private PixelConverter fPixelConverter;
-
- private IStatus fMaxNumberProblemsStatus, fResourceFilterStatus;
-
- public JavaBuildConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getKeys(), container);
- fMaxNumberProblemsStatus= new StatusInfo();
- fResourceFilterStatus= new StatusInfo();
- }
-
- private static Key[] getKeys() {
- Key[] keys= new Key[] {
- PREF_PB_MAX_PER_UNIT, PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_INCOMPLETE_BUILDPATH, PREF_PB_CIRCULAR_BUILDPATH,
- PREF_BUILD_CLEAN_OUTPUT_FOLDER, PREF_PB_DUPLICATE_RESOURCE,
- PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, PREF_RECREATE_MODIFIED_CLASS_FILES,
- };
- return keys;
- }
-
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
- setShell(parent.getShell());
-
- Composite mainComp= new Composite(parent, SWT.NONE);
- mainComp.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- mainComp.setLayout(layout);
-
- Composite othersComposite= createBuildPathTabContent(mainComp);
- GridData gridData= new GridData(GridData.FILL, GridData.FILL, true, true);
- gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(20);
- othersComposite.setLayoutData(gridData);
-
- validateSettings(null, null, null);
-
- return mainComp;
- }
-
-
- private Composite createBuildPathTabContent(Composite parent) {
- String[] abortIgnoreValues= new String[] { ABORT, IGNORE };
- String[] cleanIgnoreValues= new String[] { CLEAN, IGNORE };
- String[] enableDisableValues= new String[] { ENABLED, DISABLED };
- String[] enableIgnoreValues= new String[] { ENABLED, IGNORE };
-
- String[] errorWarning= new String[] { ERROR, WARNING };
-
- String[] errorWarningLabels= new String[] {
- PreferencesMessages.JavaBuildConfigurationBlock_error,
- PreferencesMessages.JavaBuildConfigurationBlock_warning
- };
-
- String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
- String[] errorWarningIgnoreLabels= new String[] {
- PreferencesMessages.JavaBuildConfigurationBlock_error,
- PreferencesMessages.JavaBuildConfigurationBlock_warning,
- PreferencesMessages.JavaBuildConfigurationBlock_ignore
- };
-
- int nColumns= 3;
-
- final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= nColumns;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
-
- Composite composite= pageContent.getBody();
- composite.setLayout(layout);
-
- String label= PreferencesMessages.JavaBuildConfigurationBlock_section_general;
- ExpandableComposite excomposite= createStyleSection(composite, label, nColumns);
-
- Composite othersComposite= new Composite(excomposite, SWT.NONE);
- excomposite.setClient(othersComposite);
- othersComposite.setLayout(new GridLayout(nColumns, false));
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_pb_max_per_unit_label;
- Text text= addTextField(othersComposite, label, PREF_PB_MAX_PER_UNIT, 0, 0);
- GridData gd= (GridData) text.getLayoutData();
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(8);
- gd.horizontalAlignment= GridData.END;
- text.setTextLimit(6);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_enable_exclusion_patterns_label;
- addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_enable_multiple_outputlocations_label;
- addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_section_build_path_problems;
- excomposite= createStyleSection(composite, label, nColumns);
-
- othersComposite= new Composite(excomposite, SWT.NONE);
- excomposite.setClient(othersComposite);
- othersComposite.setLayout(new GridLayout(nColumns, false));
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_build_invalid_classpath_label;
- addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_pb_incomplete_build_path_label;
- addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_pb_build_path_cycles_label;
- addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_pb_check_prereq_binary_level_label;
- addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_section_output_folder;
- excomposite= createStyleSection(composite, label, nColumns);
-
- othersComposite= new Composite(excomposite, SWT.NONE);
- excomposite.setClient(othersComposite);
- othersComposite.setLayout(new GridLayout(nColumns, false));
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_pb_duplicate_resources_label;
- addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_build_clean_outputfolder_label;
- addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_build_recreate_modified;
- addCheckBox(othersComposite, label, PREF_RECREATE_MODIFIED_CLASS_FILES, enableIgnoreValues, 0);
-
- label= PreferencesMessages.JavaBuildConfigurationBlock_resource_filter_label;
- text= addTextField(othersComposite, label, PREF_RESOURCE_FILTER, 0, 0);
- gd= (GridData) text.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(10);
-
- Label description= new Label(othersComposite, SWT.WRAP);
- description.setText(PreferencesMessages.JavaBuildConfigurationBlock_resource_filter_description);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= nColumns;
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
- description.setLayoutData(gd);
-
- IDialogSettings section= JavaScriptPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
- restoreSectionExpansionStates(section);
-
- return pageContent;
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (!areSettingsEnabled()) {
- return;
- }
-
- if (changedKey != null) {
- if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) {
- fMaxNumberProblemsStatus= validateMaxNumberProblems();
- } else if (PREF_RESOURCE_FILTER.equals(changedKey)) {
- fResourceFilterStatus= validateResourceFilters();
- } else {
- return;
- }
- } else {
- updateEnableStates();
- fMaxNumberProblemsStatus= validateMaxNumberProblems();
- fResourceFilterStatus= validateResourceFilters();
- }
- IStatus status= StatusUtil.getMostSevere(new IStatus[] { fMaxNumberProblemsStatus, fResourceFilterStatus });
- fContext.statusChanged(status);
- }
-
- private void updateEnableStates() {
- }
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.JavaBuildConfigurationBlock_needsbuild_title;
- String message;
- if (workspaceSettings) {
- message= PreferencesMessages.JavaBuildConfigurationBlock_needsfullbuild_message;
- } else {
- message= PreferencesMessages.JavaBuildConfigurationBlock_needsprojectbuild_message;
- }
- return new String[] { title, message };
- }
-
- private IStatus validateMaxNumberProblems() {
- String number= getValue(PREF_PB_MAX_PER_UNIT);
- StatusInfo status= new StatusInfo();
- if (number.length() == 0) {
- status.setError(PreferencesMessages.JavaBuildConfigurationBlock_empty_input);
- } else {
- try {
- int value= Integer.parseInt(number);
- if (value <= 0) {
- status.setError(Messages.format(PreferencesMessages.JavaBuildConfigurationBlock_invalid_input, number));
- }
- } catch (NumberFormatException e) {
- status.setError(Messages.format(PreferencesMessages.JavaBuildConfigurationBlock_invalid_input, number));
- }
- }
- return status;
- }
-
- private IStatus validateResourceFilters() {
- String text= getValue(PREF_RESOURCE_FILTER);
-
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
-
- String[] filters= getTokens(text, ","); //$NON-NLS-1$
- for (int i= 0; i < filters.length; i++) {
- String fileName= filters[i].replace('*', 'x');
- int resourceType= IResource.FILE;
- int lastCharacter= fileName.length() - 1;
- if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') {
- fileName= fileName.substring(0, lastCharacter);
- resourceType= IResource.FOLDER;
- }
- IStatus status= workspace.validateName(fileName, resourceType);
- if (status.matches(IStatus.ERROR)) {
- String message= Messages.format(PreferencesMessages.JavaBuildConfigurationBlock_filter_invalidsegment_error, status.getMessage());
- return new StatusInfo(IStatus.ERROR, message);
- }
- }
- return new StatusInfo();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#dispose()
- */
- public void dispose() {
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION_NAME);
- storeSectionExpansionStates(settings);
- super.dispose();
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildPreferencePage.java
deleted file mode 100644
index 61f4802d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaBuildPreferencePage.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Page used to configure both workspace and project specific compiler settings
- */
-public class JavaBuildPreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.JavaBuildPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.JavaBuildPreferencePage"; //$NON-NLS-1$
-
- private JavaBuildConfigurationBlock fConfigurationBlock;
-
- public JavaBuildPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.JavaBuildPreferencePage_description);
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.JavaBuildPreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new JavaBuildConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- if (isProjectPreferencePage()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_BUILD_PROPERTY_PAGE);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_BUILD_PREFERENCE_PAGE);
- }
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaCategoryPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaCategoryPropertyPage.java
deleted file mode 100644
index 0e9ec501..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaCategoryPropertyPage.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-
-/**
- * Top level node for Java property pages
- */
-public class JavaCategoryPropertyPage extends PropertyPage {
-
- private IProject fProject;
-
- private final static String HREF_BUILDPATH= BuildPathsPropertyPage.PROP_ID;
- private final static String HREF_COMPILER= CompliancePreferencePage.PROP_ID;
- private final static String HREF_CODESTYLE= CodeStylePreferencePage.PROP_ID;
- private final static String HREF_JLOC= JavadocConfigurationPropertyPage.PROP_ID;
- private final static String HREF_TODO= TodoTaskPreferencePage.PROP_ID;
- private final static String HREF_PSEVERITIES= ProblemSeveritiesPreferencePage.PROP_ID;
- private final static String HREF_JAVADOC= JavadocProblemsPreferencePage.PROP_ID;
- private final static String HREF_FORMATTER= CodeFormatterPreferencePage.PROP_ID;
- private final static String HREF_TEMPLATES= ""; // Code //$NON-NLS-1$
- private final static String HREF_IMPORTORDER= ImportOrganizePreferencePage.PROP_ID;
- private final static String HREF_BUILDING= JavaBuildPreferencePage.PROP_ID;
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(new TableWrapLayout());
-
- FormToolkit toolkit= new FormToolkit(parent.getDisplay());
- try {
- String[] args= {
- fProject.getName(), HREF_BUILDPATH, HREF_COMPILER, HREF_TODO, HREF_PSEVERITIES, HREF_JAVADOC, HREF_BUILDING,
- HREF_CODESTYLE, HREF_FORMATTER, HREF_TEMPLATES, HREF_IMPORTORDER, HREF_JLOC
- };
- String msg= Messages.format(PreferencesMessages.JavaCategoryPropertyPage_text, args);
-
- FormText formText = toolkit.createFormText(composite, true);
- try {
- formText.setText(msg, true, false);
- } catch (SWTException e) {
- formText.setText(e.getMessage(), false, false);
- }
-
- formText.setBackground(null);
- formText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- formText.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- doLinkActivated(e.data.toString());
- }
- });
- } finally {
- toolkit.dispose();
- }
-
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- protected void doLinkActivated(String string) {
- if (string.length() > 0) {
- IPreferencePageContainer container= getContainer();
- if (container instanceof PreferenceDialog) {
- //see bug 80689: ((PreferenceDialog) container).setCurrentPageId(string);
- }
- }
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
- */
- public IAdaptable getElement() {
- return fProject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- fProject= (IProject) element.getAdapter(IResource.class);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorAppearanceConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorAppearanceConfigurationBlock.java
deleted file mode 100644
index 2438a0c2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorAppearanceConfigurationBlock.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.ColorSelector;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Configures Java Editor hover preferences.
- *
- *
- */
-class JavaEditorAppearanceConfigurationBlock extends AbstractConfigurationBlock {
-
- private final String[][] fAppearanceColorListModel= new String[][] {
- {PreferencesMessages.JavaEditorPreferencePage_matchingBracketsHighlightColor2, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, null},
- {PreferencesMessages.JavaEditorPreferencePage_backgroundForCompletionProposals, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_foregroundForCompletionProposals, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_backgroundForMethodParameters, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_foregroundForMethodParameters, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_backgroundForCompletionReplacement, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_foregroundForCompletionReplacement, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, null },
- {PreferencesMessages.JavaEditorPreferencePage_sourceHoverBackgroundColor, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT},
-
- };
-
- private List fAppearanceColorList;
- private ColorSelector fAppearanceColorEditor;
- private Button fAppearanceColorDefault;
-
- private FontMetrics fFontMetrics;
-
- public JavaEditorAppearanceConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
- super(store, mainPreferencePage);
- getPreferenceStore().addKeys(createOverlayStoreKeys());
- }
-
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_SEGMENTS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates page for appearance preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
-
- Composite composite= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createHeader(composite);
- createAppearancePage(composite);
-
- scrolled.setContent(composite);
- final Point size= composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
- return scrolled;
-
- }
-
- private void createHeader(Composite contents) {
- final Shell shell= contents.getShell();
- String text= PreferencesMessages.JavaEditorPreferencePage_link;
- Link link= new Link(contents, SWT.NONE);
- link.setText(text);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.ui.preferencePages.GeneralTextEditor", null, null); //$NON-NLS-1$
- }
- });
- // TODO replace by link-specific tooltips when
- // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
- link.setToolTipText(PreferencesMessages.JavaEditorPreferencePage_link_tooltip);
-
-
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= 150; // only expand further if anyone else requires it
- link.setLayoutData(gridData);
-
- addFiller(contents);
- }
-
- private void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
-
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
- filler.setLayoutData(gd);
- }
-
- /**
- * Returns the number of pixels corresponding to the width of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- protected int convertWidthInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
-
- /**
- * Returns the number of pixels corresponding to the height of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- protected int convertHeightInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
- private Control createAppearancePage(Composite parent) {
-
- Composite appearanceComposite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- appearanceComposite.setLayout(layout);
-
- String label;
-
- label= PreferencesMessages.JavaEditorPreferencePage_subWordNavigation;
- addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_analyseAnnotationsWhileTyping;
- addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
-
- String text= PreferencesMessages.SmartTypingConfigurationBlock_annotationReporting_link;
- addLink(appearanceComposite, text, INDENT);
-
- Label spacer= new Label(appearanceComposite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= convertHeightInCharsToPixels(1) / 2;
- spacer.setLayoutData(gd);
-
- label= PreferencesMessages.JavaEditorPreferencePage_highlightMatchingBrackets;
- addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_quickassist_lightbulb;
- addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_showJavaElementOnly;
- addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SHOW_SEGMENTS, 0);
-
- Label l= new Label(appearanceComposite, SWT.LEFT );
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= convertHeightInCharsToPixels(1) / 2;
- l.setLayoutData(gd);
-
- l= new Label(appearanceComposite, SWT.LEFT);
- l.setText(PreferencesMessages.JavaEditorPreferencePage_appearanceOptions);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- l.setLayoutData(gd);
-
- Composite editorComposite= new Composite(appearanceComposite, 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.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint= convertHeightInCharsToPixels(12);
- 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(PreferencesMessages.JavaEditorPreferencePage_color);
- gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- l.setLayoutData(gd);
-
- fAppearanceColorEditor= new ColorSelector(stylesComposite);
- Button foregroundColorButton= fAppearanceColorEditor.getButton();
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- SelectionListener colorDefaultSelectionListener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean systemDefault= fAppearanceColorDefault.getSelection();
- fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
-
- int i= fAppearanceColorList.getSelectionIndex();
- if (i == -1)
- return;
-
- String key= fAppearanceColorListModel[i][2];
- if (key != null)
- getPreferenceStore().setValue(key, systemDefault);
- }
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
-
- fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
- fAppearanceColorDefault.setText(PreferencesMessages.JavaEditorPreferencePage_systemDefault);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fAppearanceColorDefault.setLayoutData(gd);
- fAppearanceColorDefault.setVisible(false);
- fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
-
- 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();
- if (i == -1)
- return;
-
- String key= fAppearanceColorListModel[i][1];
- PreferenceConverter.setValue(getPreferenceStore(), key, fAppearanceColorEditor.getColorValue());
- }
- });
- return appearanceComposite;
- }
-
-
- private void addLink(Composite composite, String text, int indent) {
- GridData gd;
- final Link link= new Link(composite, SWT.NONE);
- link.setText(text);
- gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gd.widthHint= 300; // don't get wider initially
- gd.horizontalSpan= 2;
- gd.horizontalIndent= indent;
- link.setLayoutData(gd);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null, null);
- }
- });
- }
-
- private void handleAppearanceColorListSelection() {
- int i= fAppearanceColorList.getSelectionIndex();
- if (i == -1)
- return;
- String key= fAppearanceColorListModel[i][1];
- RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), key);
- fAppearanceColorEditor.setColorValue(rgb);
- updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]);
- }
-
- private void updateAppearanceColorWidgets(String systemDefaultKey) {
- if (systemDefaultKey == null) {
- fAppearanceColorDefault.setSelection(false);
- fAppearanceColorDefault.setVisible(false);
- fAppearanceColorEditor.getButton().setEnabled(true);
- } else {
- boolean systemDefault= getPreferenceStore().getBoolean(systemDefaultKey);
- fAppearanceColorDefault.setSelection(systemDefault);
- fAppearanceColorDefault.setVisible(true);
- fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
- */
- public void initialize() {
- super.initialize();
- initializeDefaultColors();
-
- for (int i= 0; i < fAppearanceColorListModel.length; i++)
- fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
-
- fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
- fAppearanceColorList.select(0);
- handleAppearanceColorListSelection();
- }
- }
- });
-
- }
-
- /**
- * Initializes the default colors.
- *
- *
- */
- private void initializeDefaultColors() {
- if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
- RGB rgb= fAppearanceColorList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
- PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
- */
- public void performDefaults() {
- super.performDefaults();
- initializeDefaultColors();
- handleAppearanceColorListSelection();
- }
-
- /**
- * Initializes the computation of horizontal and vertical dialog units based
- * on the size of current font.
- * <p>
- * This method must be called before any of the dialog unit based conversion
- * methods are called.
- * </p>
- *
- * @param testControl
- * a control from which to obtain the current font
- */
- protected void initializeDialogUnits(Control testControl) {
- // Compute and store a font metric
- GC gc = new GC(testControl);
- gc.setFont(JFaceResources.getDialogFont());
- fFontMetrics = gc.getFontMetrics();
- gc.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java
deleted file mode 100644
index 830a6bba..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java
+++ /dev/null
@@ -1,960 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.ColorSelector;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Scrollable;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlighting;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightings;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.SemanticHighlightingManager.HighlightedRange;
-import org.eclipse.wst.jsdt.internal.ui.text.JavaColorManager;
-import org.eclipse.wst.jsdt.internal.ui.text.PreferencesAdapter;
-import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-/**
- * Configures Java Editor hover preferences.
- *
- *
- */
-class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
-
- /**
- * Item in the highlighting color list.
- *
- *
- */
- private static class HighlightingColorListItem {
- /** Display name */
- private String fDisplayName;
- /** Color preference key */
- private String fColorKey;
- /** Bold preference key */
- private String fBoldKey;
- /** Italic preference key */
- private String fItalicKey;
- /**
- * Strikethrough preference key.
- *
- */
- private String fStrikethroughKey;
- /** Underline preference key.
- *
- */
- private String fUnderlineKey;
-
- /**
- * Initialize the item with the given values.
- * @param displayName the display name
- * @param colorKey the color preference key
- * @param boldKey the bold preference key
- * @param italicKey the italic preference key
- * @param strikethroughKey the strikethrough preference key
- * @param underlineKey the underline preference key
- */
- public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
- fDisplayName= displayName;
- fColorKey= colorKey;
- fBoldKey= boldKey;
- fItalicKey= italicKey;
- fStrikethroughKey= strikethroughKey;
- fUnderlineKey= underlineKey;
- }
-
- /**
- * @return the bold preference key
- */
- public String getBoldKey() {
- return fBoldKey;
- }
-
- /**
- * @return the bold preference key
- */
- public String getItalicKey() {
- return fItalicKey;
- }
-
- /**
- * @return the strikethrough preference key
- *
- */
- public String getStrikethroughKey() {
- return fStrikethroughKey;
- }
-
- /**
- * @return the underline preference key
- *
- */
- public String getUnderlineKey() {
- return fUnderlineKey;
- }
-
- /**
- * @return the color preference key
- */
- public String getColorKey() {
- return fColorKey;
- }
-
- /**
- * @return the display name
- */
- public String getDisplayName() {
- return fDisplayName;
- }
- }
-
- private static class SemanticHighlightingColorListItem extends HighlightingColorListItem {
-
- /** Enablement preference key */
- private final String fEnableKey;
-
- /**
- * Initialize the item with the given values.
- * @param displayName the display name
- * @param colorKey the color preference key
- * @param boldKey the bold preference key
- * @param italicKey the italic preference key
- * @param strikethroughKey the strikethroughKey preference key
- * @param underlineKey the underlineKey preference key
- * @param enableKey the enable preference key
- */
- public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey, String enableKey) {
- super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey);
- fEnableKey= enableKey;
- }
-
- /**
- * @return the enablement preference key
- */
- public String getEnableKey() {
- return fEnableKey;
- }
- }
-
- /**
- * Color list label provider.
- *
- *
- */
- private class ColorListLabelProvider extends LabelProvider {
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (element instanceof String)
- return (String) element;
- return ((HighlightingColorListItem)element).getDisplayName();
- }
- }
-
- /**
- * Color list content provider.
- *
- *
- */
- private class ColorListContentProvider implements ITreeContentProvider {
-
- /*
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return new String[] {fJavaCategory, fJavadocCategory, fCommentsCategory};
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof String) {
- String entry= (String) parentElement;
- if (fJavaCategory.equals(entry))
- return fListModel.subList(7, fListModel.size()).toArray();
- if (fJavadocCategory.equals(entry))
- return fListModel.subList(0, 4).toArray();
- if (fCommentsCategory.equals(entry))
- return fListModel.subList(4, 7).toArray();
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- if (element instanceof String)
- return null;
- int index= fListModel.indexOf(element);
- if (index < 4)
- return fJavadocCategory;
- if (index >= 7)
- return fJavaCategory;
- return fCommentsCategory;
- }
-
- public boolean hasChildren(Object element) {
- return element instanceof String;
- }
- }
-
- private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
- /**
- * Preference key suffix for italic preferences.
- *
- */
- private static final String ITALIC= PreferenceConstants.EDITOR_ITALIC_SUFFIX;
- /**
- * Preference key suffix for strikethrough preferences.
- *
- */
- private static final String STRIKETHROUGH= PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
- /**
- * Preference key suffix for underline preferences.
- *
- */
- private static final String UNDERLINE= PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
-
- private static final String COMPILER_TASK_TAGS= JavaScriptCore.COMPILER_TASK_TAGS;
- /**
- * The keys of the overlay store.
- */
- private final String[][] fSyntaxColorListModel= new String[][] {
- { PreferencesMessages.JavaEditorPreferencePage_javaDocKeywords, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_javaDocHtmlTags, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_javaDocLinks, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_javaDocOthers, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_multiLineComment, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_singleLineComment, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_javaCommentTaskTags, PreferenceConstants.EDITOR_TASK_TAG_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_keywords, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_returnKeyword, PreferenceConstants.EDITOR_JAVA_KEYWORD_RETURN_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_operators, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_brackets, PreferenceConstants.EDITOR_JAVA_BRACKET_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_strings, PreferenceConstants.EDITOR_STRING_COLOR },
- { PreferencesMessages.JavaEditorPreferencePage_others, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR },
- };
-
- private final String fJavaCategory= PreferencesMessages.JavaEditorPreferencePage_coloring_category_java;
- private final String fJavadocCategory= PreferencesMessages.JavaEditorPreferencePage_coloring_category_javadoc;
- private final String fCommentsCategory= PreferencesMessages.JavaEditorPreferencePage_coloring_category_comments;
-
- private ColorSelector fSyntaxForegroundColorEditor;
- private Label fColorEditorLabel;
- private Button fBoldCheckBox;
- private Button fEnableCheckbox;
- /**
- * Check box for italic preference.
- *
- */
- private Button fItalicCheckBox;
- /**
- * Check box for strikethrough preference.
- *
- */
- private Button fStrikethroughCheckBox;
- /**
- * Check box for underline preference.
- *
- */
- private Button fUnderlineCheckBox;
- /**
- * Highlighting color list
- *
- */
- private final java.util.List fListModel= new ArrayList();
- /**
- * Highlighting color list viewer
- *
- */
- private StructuredViewer fListViewer;
- /**
- * Semantic highlighting manager
- *
- */
- private SemanticHighlightingManager fSemanticHighlightingManager;
- /**
- * The previewer.
- *
- */
- private JavaSourceViewer fPreviewViewer;
- /**
- * The color manager.
- *
- */
- private IColorManager fColorManager;
- /**
- * The font metrics.
- *
- */
- private FontMetrics fFontMetrics;
-
- public JavaEditorColoringConfigurationBlock(OverlayPreferenceStore store) {
- super(store);
-
- fColorManager= new JavaColorManager(false);
-
- for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++)
- fListModel.add(new HighlightingColorListItem (fSyntaxColorListModel[i][0],
- fSyntaxColorListModel[i][1],
- fSyntaxColorListModel[i][1] + BOLD,
- fSyntaxColorListModel[i][1] + ITALIC,
- fSyntaxColorListModel[i][1] + STRIKETHROUGH,
- fSyntaxColorListModel[i][1] + UNDERLINE));
-
- SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
- for (int i= 0, n= semanticHighlightings.length; i < n; i++)
- fListModel.add(
- new SemanticHighlightingColorListItem(
- semanticHighlightings[i].getDisplayName(),
- SemanticHighlightings.getColorPreferenceKey(semanticHighlightings[i]),
- SemanticHighlightings.getBoldPreferenceKey(semanticHighlightings[i]),
- SemanticHighlightings.getItalicPreferenceKey(semanticHighlightings[i]),
- SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlightings[i]),
- SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlightings[i]),
- SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i])
- ));
-
- store.addKeys(createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList overlayKeys= new ArrayList();
-
- for (int i= 0, n= fListModel.size(); i < n; i++) {
- HighlightingColorListItem item= (HighlightingColorListItem) fListModel.get(i);
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getColorKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getBoldKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getItalicKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getUnderlineKey()));
-
- if (item instanceof SemanticHighlightingColorListItem)
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ((SemanticHighlightingColorListItem) item).getEnableKey()));
- }
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates page for hover preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Control control= createSyntaxPage(scrolled);
-
- scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
-
- return scrolled;
- }
-
- /**
- * Returns the number of pixels corresponding to the width of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- private int convertWidthInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
-
- /**
- * Returns the number of pixels corresponding to the height of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- private int convertHeightInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
- public void initialize() {
- super.initialize();
-
- fListViewer.setInput(fListModel);
- fListViewer.setSelection(new StructuredSelection(fJavaCategory));
- }
-
- public void performDefaults() {
- super.performDefaults();
-
- handleSyntaxColorListSelection();
-
- uninstallSemanticHighlighting();
- installSemanticHighlighting();
-
- fPreviewViewer.invalidateTextPresentation();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
- */
- public void dispose() {
- uninstallSemanticHighlighting();
- fColorManager.dispose();
-
- super.dispose();
- }
-
- private void handleSyntaxColorListSelection() {
- HighlightingColorListItem item= getHighlightingColorListItem();
- if (item == null) {
- fEnableCheckbox.setEnabled(false);
- fSyntaxForegroundColorEditor.getButton().setEnabled(false);
- fColorEditorLabel.setEnabled(false);
- fBoldCheckBox.setEnabled(false);
- fItalicCheckBox.setEnabled(false);
- fStrikethroughCheckBox.setEnabled(false);
- fUnderlineCheckBox.setEnabled(false);
- return;
- }
- RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey());
- fSyntaxForegroundColorEditor.setColorValue(rgb);
- fBoldCheckBox.setSelection(getPreferenceStore().getBoolean(item.getBoldKey()));
- fItalicCheckBox.setSelection(getPreferenceStore().getBoolean(item.getItalicKey()));
- fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey()));
- fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey()));
- if (item instanceof SemanticHighlightingColorListItem) {
- fEnableCheckbox.setEnabled(true);
- boolean enable= getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
- fEnableCheckbox.setSelection(enable);
- fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
- fColorEditorLabel.setEnabled(enable);
- fBoldCheckBox.setEnabled(enable);
- fItalicCheckBox.setEnabled(enable);
- fStrikethroughCheckBox.setEnabled(enable);
- fUnderlineCheckBox.setEnabled(enable);
- } else {
- fSyntaxForegroundColorEditor.getButton().setEnabled(true);
- fColorEditorLabel.setEnabled(true);
- fBoldCheckBox.setEnabled(true);
- fItalicCheckBox.setEnabled(true);
- fStrikethroughCheckBox.setEnabled(true);
- fUnderlineCheckBox.setEnabled(true);
- fEnableCheckbox.setEnabled(false);
- fEnableCheckbox.setSelection(true);
- }
- }
-
- private Control createSyntaxPage(final Composite parent) {
-
- Composite colorComposite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- colorComposite.setLayout(layout);
-
- Link link= new Link(colorComposite, SWT.NONE);
- link.setText(PreferencesMessages.JavaEditorColoringConfigurationBlock_link);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
- }
- });
- // TODO replace by link-specific tooltips when
- // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
-// link.setToolTipText(PreferencesMessages.JavaEditorColoringConfigurationBlock_link_tooltip);
-
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= 150; // only expand further if anyone else requires it
- gridData.horizontalSpan= 2;
- link.setLayoutData(gridData);
-
- addFiller(colorComposite, 1);
-
- Label label;
- label= new Label(colorComposite, SWT.LEFT);
- label.setText(PreferencesMessages.JavaEditorPreferencePage_coloring_element);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite editorComposite= new Composite(colorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- editorComposite.setLayout(layout);
- GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- editorComposite.setLayoutData(gd);
-
- fListViewer= new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
- fListViewer.setLabelProvider(new ColorListLabelProvider());
- fListViewer.setContentProvider(new ColorListContentProvider());
- fListViewer.setComparator(new ViewerComparator() {
- public int category(Object element) {
- // don't sort the top level categories
- if (fJavaCategory.equals(element))
- return 0;
- if (fJavadocCategory.equals(element))
- return 1;
- if (fCommentsCategory.equals(element))
- return 2;
- // to sort semantic settings after partition based ones:
-// if (element instanceof SemanticHighlightingColorListItem)
-// return 1;
- return 0;
- }
- });
- gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
- gd.heightHint= convertHeightInCharsToPixels(9);
- int maxWidth= 0;
- for (Iterator it= fListModel.iterator(); it.hasNext();) {
- HighlightingColorListItem item= (HighlightingColorListItem) it.next();
- maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
- }
- ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar();
- if (vBar != null)
- maxWidth += vBar.getSize().x * 3; // scrollbars and tree indentation guess
- gd.widthHint= maxWidth;
-
- fListViewer.getControl().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));
-
- fEnableCheckbox= new Button(stylesComposite, SWT.CHECK);
- fEnableCheckbox.setText(PreferencesMessages.JavaEditorPreferencePage_enable);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fEnableCheckbox.setLayoutData(gd);
-
- fColorEditorLabel= new Label(stylesComposite, SWT.LEFT);
- fColorEditorLabel.setText(PreferencesMessages.JavaEditorPreferencePage_color);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- fColorEditorLabel.setLayoutData(gd);
-
- fSyntaxForegroundColorEditor= new ColorSelector(stylesComposite);
- Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- foregroundColorButton.setLayoutData(gd);
-
- fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
- fBoldCheckBox.setText(PreferencesMessages.JavaEditorPreferencePage_bold);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
- fBoldCheckBox.setLayoutData(gd);
-
- fItalicCheckBox= new Button(stylesComposite, SWT.CHECK);
- fItalicCheckBox.setText(PreferencesMessages.JavaEditorPreferencePage_italic);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
- fItalicCheckBox.setLayoutData(gd);
-
- fStrikethroughCheckBox= new Button(stylesComposite, SWT.CHECK);
- fStrikethroughCheckBox.setText(PreferencesMessages.JavaEditorPreferencePage_strikethrough);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
- fStrikethroughCheckBox.setLayoutData(gd);
-
- fUnderlineCheckBox= new Button(stylesComposite, SWT.CHECK);
- fUnderlineCheckBox.setText(PreferencesMessages.JavaEditorPreferencePage_underline);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
- fUnderlineCheckBox.setLayoutData(gd);
-
- label= new Label(colorComposite, SWT.LEFT);
- label.setText(PreferencesMessages.JavaEditorPreferencePage_preview);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control previewer= createPreviewer(colorComposite);
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(20);
- gd.heightHint= convertHeightInCharsToPixels(5);
- previewer.setLayoutData(gd);
-
- fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleSyntaxColorListSelection();
- }
- });
-
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
- }
- });
-
- fBoldCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection());
- }
- });
-
- fItalicCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection());
- }
- });
- fStrikethroughCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection());
- }
- });
-
- fUnderlineCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection());
- }
- });
-
- fEnableCheckbox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- if (item instanceof SemanticHighlightingColorListItem) {
- boolean enable= fEnableCheckbox.getSelection();
- getPreferenceStore().setValue(((SemanticHighlightingColorListItem) item).getEnableKey(), enable);
- fEnableCheckbox.setSelection(enable);
- fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
- fColorEditorLabel.setEnabled(enable);
- fBoldCheckBox.setEnabled(enable);
- fItalicCheckBox.setEnabled(enable);
- fStrikethroughCheckBox.setEnabled(enable);
- fUnderlineCheckBox.setEnabled(enable);
- uninstallSemanticHighlighting();
- installSemanticHighlighting();
- }
- }
- });
-
- colorComposite.layout(false);
-
- return colorComposite;
- }
-
- private void addFiller(Composite composite, int horizontalSpan) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= horizontalSpan;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
- filler.setLayoutData(gd);
- }
-
- private Control createPreviewer(Composite parent) {
-
- IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
- IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
- fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
- SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
- fPreviewViewer.configure(configuration);
- // fake 1.5 source to get 1.5 features right.
- configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaScriptCore.COMPILER_SOURCE, JavaScriptCore.VERSION_1_4, JavaScriptCore.VERSION_1_5));
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- fPreviewViewer.getTextWidget().setFont(font);
- new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
- fPreviewViewer.setEditable(false);
-
- String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
- IDocument document= new Document(content);
- JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- fPreviewViewer.setDocument(document);
-
- installSemanticHighlighting();
-
- return fPreviewViewer.getControl();
- }
-
-
- private Preferences createTemporaryCorePreferenceStore() {
- Preferences result= new Preferences();
-
- result.setValue(COMPILER_TASK_TAGS, "TASK,TODO"); //$NON-NLS-1$
-
- return result;
- }
-
-
- 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) {
- JavaScriptPlugin.log(io);
- } finally {
- if (reader != null) {
- try { reader.close(); } catch (IOException e) {}
- }
- }
- return buffer.toString();
- }
-
-
- /**
- * Install Semantic Highlighting on the previewer
- *
- *
- */
- private void installSemanticHighlighting() {
- if (fSemanticHighlightingManager == null) {
- fSemanticHighlightingManager= new SemanticHighlightingManager();
- fSemanticHighlightingManager.install(fPreviewViewer, fColorManager, getPreferenceStore(), createPreviewerRanges());
- }
- }
-
-
- /**
- * Uninstall Semantic Highlighting from the previewer
- *
- *
- */
- private void uninstallSemanticHighlighting() {
- if (fSemanticHighlightingManager != null) {
- fSemanticHighlightingManager.uninstall();
- fSemanticHighlightingManager= null;
- }
- }
-
-
- /**
- * Create the hard coded previewer ranges
- *
- * @return the hard coded previewer ranges
- *
- */
- private SemanticHighlightingManager.HighlightedRange[][] createPreviewerRanges() {
- return new SemanticHighlightingManager.HighlightedRange[][] {
- // Function Declaration
- { createHighlightedRange( 9, 9, 3,SemanticHighlightings.METHOD_DECLARATION) },
- { createHighlightedRange(17, 9, 3,SemanticHighlightings.METHOD_DECLARATION) },
- { createHighlightedRange(21, 9, 4,SemanticHighlightings.METHOD_DECLARATION) },
- { createHighlightedRange(26, 9, 7,SemanticHighlightings.METHOD_DECLARATION) },
- // Function
- { createHighlightedRange(11,19, 6,SemanticHighlightings.METHOD) },
- { createHighlightedRange(14, 4, 5,SemanticHighlightings.METHOD) },
- // Local Variable Declaration
- { createHighlightedRange(11, 8, 4,SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
- { createHighlightedRange(12, 8, 3,SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
- { createHighlightedRange(13, 8, 1,SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
- // Local Variable
- { createHighlightedRange(14,10, 4,SemanticHighlightings.LOCAL_VARIABLE) },
- // Object Initializer
- { createHighlightedRange(12,14,47,SemanticHighlightings.OBJECT_INITIALIZER) },
- // Parameter Variable
- { createHighlightedRange(20,16, 4,SemanticHighlightings.PARAMETER_VARIABLE) },
-// { createHighlightedRange( 6, 13, 9, SemanticHighlightings.DEPRECATED_MEMBER), createHighlightedRange( 6, 13, 9, SemanticHighlightings.CLASS), },
-// { createHighlightedRange( 6, 23, 1, SemanticHighlightings.TYPE_VARIABLE), createHighlightedRange( 6, 23, 1, SemanticHighlightings.TYPE_ARGUMENT), },
-// { createHighlightedRange( 6, 37, 9, SemanticHighlightings.INTERFACE) },
-// { createHighlightedRange( 6, 47, 6, SemanticHighlightings.TYPE_ARGUMENT), createHighlightedRange( 6, 47, 6, SemanticHighlightings.CLASS) },
-// { createHighlightedRange( 7, 6, 5, SemanticHighlightings.ENUM), },
-// {/* createHighlightedRange( 7, 14, 3, SemanticHighlightings.STATIC_FINAL_FIELD), createHighlightedRange(7, 14, 3, SemanticHighlightings.STATIC_FIELD), */createHighlightedRange(7, 14, 3, SemanticHighlightings.FIELD) },
-// { createHighlightedRange( 7, 19, 5, SemanticHighlightings.STATIC_FINAL_FIELD), createHighlightedRange(7, 19, 5, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(7, 19, 5, SemanticHighlightings.FIELD) },
-// { createHighlightedRange( 7, 26, 4, SemanticHighlightings.STATIC_FINAL_FIELD), createHighlightedRange(7, 26, 4, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(7, 26, 4, SemanticHighlightings.FIELD) },
-// { createHighlightedRange( 9, 8, 6, SemanticHighlightings.CLASS), },
-// { createHighlightedRange( 9, 15, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(9, 15, 11, SemanticHighlightings.FIELD) },
-// { createHighlightedRange(11, 9, 1, SemanticHighlightings.TYPE_VARIABLE) },
-// { createHighlightedRange(11, 11, 5, SemanticHighlightings.FIELD) },
-// { createHighlightedRange(13, 2, 16, SemanticHighlightings.ANNOTATION) },
-// { createHighlightedRange(13, 19, 5, SemanticHighlightings.ANNOTATION_ELEMENT_REFERENCE) },
-// { createHighlightedRange(14, 12, 3, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(14, 12, 3, SemanticHighlightings.METHOD) },
-// { createHighlightedRange(14, 24, 9, SemanticHighlightings.PARAMETER_VARIABLE) },
-// { createHighlightedRange(15, 2, 14, SemanticHighlightings.ABSTRACT_METHOD_INVOCATION), createHighlightedRange(15, 2, 14, SemanticHighlightings.METHOD) },
-// { createHighlightedRange(16, 6, 5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
-// { createHighlightedRange(16, 16, 8, SemanticHighlightings.INHERITED_METHOD_INVOCATION), createHighlightedRange(16, 16, 8, SemanticHighlightings.METHOD) },
-// { createHighlightedRange(17, 2, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(17, 2, 12, SemanticHighlightings.METHOD) },
-// { createHighlightedRange(18, 9, 3, SemanticHighlightings.METHOD) },
-// { createHighlightedRange(18, 13, 5, SemanticHighlightings.LOCAL_VARIABLE) },
-// { createHighlightedRange(18, 22, 9, SemanticHighlightings.AUTOBOXING) },
- };
- }
-
-
- /**
- * Create a highlighted range on the previewers document with the given line, column, length and key.
- *
- * @param line the line
- * @param column the column
- * @param length the length
- * @param key the key
- * @return the highlighted range
- *
- */
- private HighlightedRange createHighlightedRange(int line, int column, int length, String key) {
- try {
- IDocument document= fPreviewViewer.getDocument();
- int offset= document.getLineOffset(line) + column;
- return new HighlightedRange(offset, length, key);
- } catch (BadLocationException x) {
- JavaScriptPlugin.log(x);
- }
- return null;
- }
-
-
- /**
- * Returns the current highlighting color list item.
- *
- * @return the current highlighting color list item
- *
- */
- private HighlightingColorListItem getHighlightingColorListItem() {
- IStructuredSelection selection= (IStructuredSelection) fListViewer.getSelection();
- Object element= selection.getFirstElement();
- if (element instanceof String)
- return null;
- return (HighlightingColorListItem) element;
- }
-
- /**
- * Initializes the computation of horizontal and vertical dialog units based
- * on the size of current font.
- * <p>
- * This method must be called before any of the dialog unit based conversion
- * methods are called.
- * </p>
- *
- * @param testControl
- * a control from which to obtain the current font
- */
- private void initializeDialogUnits(Control testControl) {
- // Compute and store a font metric
- GC gc = new GC(testControl);
- gc.setFont(JFaceResources.getDialogFont());
- fFontMetrics = gc.getFontMetrics();
- gc.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringPreferencePage.java
deleted file mode 100644
index 35970670..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorColoringPreferencePage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-
-/**
- * Quick Diff preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- *
- */
-public class JavaEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.JavaEditorPreferencePage_colors;
- setDescription(description);
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null;
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new JavaEditorColoringConfigurationBlock(overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java
deleted file mode 100644
index 3aa8ad4c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-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.swt.SWT;
-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.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-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.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TableLayoutComposite;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Configures Java Editor hover preferences.
- *
- *
- */
-class JavaEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock {
-
- private static final String DELIMITER= PreferencesMessages.JavaEditorHoverConfigurationBlock_delimiter;
-
- private static final int ENABLED_PROP= 0;
- private static final int MODIFIER_PROP= 1;
-
- // Data structure to hold the values which are edited by the user
- private static class HoverConfig {
-
- private String fModifierString;
- private boolean fIsEnabled;
- private int fStateMask;
-
- private HoverConfig(String modifier, int stateMask, boolean enabled) {
- fModifierString= modifier;
- fIsEnabled= enabled;
- fStateMask= stateMask;
- }
- }
-
-
- private class JavaEditorTextHoverDescriptorLabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- switch (columnIndex) {
- case ENABLED_PROP:
- return ((JavaEditorTextHoverDescriptor)element).getLabel();
-
- case MODIFIER_PROP:
- TableItem item= (TableItem)fHoverTableViewer.testFindItem(element);
- int index= fHoverTable.indexOf(item);
- return fHoverConfigs[index].fModifierString;
-
- default:
- break;
- }
-
- return null;
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-
-
- private class JavaEditorTextHoverDescriptorContentProvider implements IStructuredContentProvider {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // Do nothing since the viewer listens to resource deltas
- }
-
- public void dispose() {
- }
-
- public boolean isDeleted(Object element) {
- return false;
- }
-
- public Object[] getElements(Object element) {
- return (Object[])element;
- }
- }
-
-
- private OverlayPreferenceStore fStore;
- private HoverConfig[] fHoverConfigs;
- private Text fModifierEditor;
- private Table fHoverTable;
- private TableViewer fHoverTableViewer;
- private TableColumn fNameColumn;
- private TableColumn fModifierColumn;
- private Text fDescription;
-
- private PreferencePage fMainPreferencePage;
-
- private StatusInfo fStatus;
-
- private Map fCheckBoxes= new HashMap();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
-
- public JavaEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
- Assert.isNotNull(mainPreferencePage);
- Assert.isNotNull(store);
- fMainPreferencePage= mainPreferencePage;
- fStore= store;
- fStore.addKeys(createOverlayStoreKeys());
- }
-
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates page for hover preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(Composite parent) {
-
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
-
- Composite hoverComposite= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- hoverComposite.setLayout(layout);
-
- String rollOverLabel= PreferencesMessages.JavaEditorHoverConfigurationBlock_annotationRollover;
- addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0);
-
- addFiller(hoverComposite);
-
- Label label= new Label(hoverComposite, SWT.NONE);
- label.setText(PreferencesMessages.JavaEditorHoverConfigurationBlock_hoverPreferences);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
-
- TableLayoutComposite layouter= new TableLayoutComposite(hoverComposite, SWT.NONE);
- addColumnLayoutData(layouter);
-
- // Hover table
- fHoverTable= new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
- fHoverTable.setHeaderVisible(true);
- fHoverTable.setLinesVisible(true);
-
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= SWTUtil.getTableHeightHint(fHoverTable, 10);
- gd.horizontalSpan= 2;
- gd.widthHint= new PixelConverter(parent).convertWidthInCharsToPixels(30);
- layouter.setLayoutData(gd);
-
- fHoverTable.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- handleHoverListSelection();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- TableLayout tableLayout= new TableLayout();
- fHoverTable.setLayout(tableLayout);
-
- fNameColumn= new TableColumn(fHoverTable, SWT.NONE);
- fNameColumn.setText(PreferencesMessages.JavaEditorHoverConfigurationBlock_nameColumnTitle);
- fNameColumn.setResizable(true);
-
- fModifierColumn= new TableColumn(fHoverTable, SWT.NONE);
- fModifierColumn.setText(PreferencesMessages.JavaEditorHoverConfigurationBlock_modifierColumnTitle);
- fModifierColumn.setResizable(true);
-
- fHoverTableViewer= new CheckboxTableViewer(fHoverTable);
- fHoverTableViewer.setUseHashlookup(true);
- fHoverTableViewer.setContentProvider(new JavaEditorTextHoverDescriptorContentProvider());
- fHoverTableViewer.setLabelProvider(new JavaEditorTextHoverDescriptorLabelProvider());
-
- ((CheckboxTableViewer)fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
- /*
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
- public void checkStateChanged(CheckStateChangedEvent event) {
- String id= ((JavaEditorTextHoverDescriptor)event.getElement()).getId();
- if (id == null)
- return;
- JavaEditorTextHoverDescriptor[] descriptors= getContributedHovers();
- HoverConfig hoverConfig= null;
- int i= 0, length= fHoverConfigs.length;
- while (i < length) {
- if (id.equals(descriptors[i].getId())) {
- hoverConfig= fHoverConfigs[i];
- hoverConfig.fIsEnabled= event.getChecked();
- fModifierEditor.setEnabled(event.getChecked());
- fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
- }
- i++;
- }
- handleHoverListSelection();
- updateStatus(hoverConfig);
- }
- });
-
- // Text field for modifier string
- label= new Label(hoverComposite, SWT.LEFT);
- label.setText(PreferencesMessages.JavaEditorHoverConfigurationBlock_keyModifier);
- fModifierEditor= new Text(hoverComposite, SWT.BORDER);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fModifierEditor.setLayoutData(gd);
-
- fModifierEditor.addKeyListener(new KeyListener() {
- private boolean isModifierCandidate;
- public void keyPressed(KeyEvent e) {
- isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
- }
-
- public void keyReleased(KeyEvent e) {
- if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
- String text= fModifierEditor.getText();
- Point selection= fModifierEditor.getSelection();
- int i= selection.x - 1;
- while (i > -1 && Character.isWhitespace(text.charAt(i))) {
- i--;
- }
- boolean needsPrefixDelimiter= i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
-
- i= selection.y;
- while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
- i++;
- }
- boolean needsPostfixDelimiter= i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
-
- String insertString;
-
- if (needsPrefixDelimiter && needsPostfixDelimiter)
- insertString= Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)});
- else if (needsPrefixDelimiter)
- insertString= Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_insertDelimiterAndModifier, new String[] {Action.findModifierString(e.stateMask)});
- else if (needsPostfixDelimiter)
- insertString= Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_insertModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)});
- else
- insertString= Action.findModifierString(e.stateMask);
-
- if (insertString != null)
- fModifierEditor.insert(insertString);
- }
- }
- });
-
- fModifierEditor.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleModifierModified();
- }
- });
-
- // Description
- Label descriptionLabel= new Label(hoverComposite, SWT.LEFT);
- descriptionLabel.setText(PreferencesMessages.JavaEditorHoverConfigurationBlock_description);
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- gd.horizontalSpan= 2;
- descriptionLabel.setLayoutData(gd);
- fDescription= new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
- fDescription.setLayoutData(gd);
-
- initialize();
-
- scrolled.setContent(hoverComposite);
- final Point size= hoverComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
-
- Dialog.applyDialogFont(scrolled);
-
- return scrolled;
-
- }
-
- private void addColumnLayoutData(TableLayoutComposite layouter) {
- layouter.addColumnData(new ColumnWeightData(40, true));
- layouter.addColumnData(new ColumnWeightData(60, true));
- }
-
- private JavaEditorTextHoverDescriptor[] getContributedHovers() {
- return JavaScriptPlugin.getDefault().getJavaEditorTextHoverDescriptors();
- }
-
- public void initialize() {
- JavaEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
- fHoverConfigs= new HoverConfig[hoverDescs.length];
- for (int i= 0; i < hoverDescs.length; i++)
- fHoverConfigs[i]= new HoverConfig(hoverDescs[i].getModifierString(), hoverDescs[i].getStateMask(), hoverDescs[i].isEnabled());
-
- fHoverTableViewer.setInput(hoverDescs);
-
- initializeFields();
- }
-
- void initializeFields() {
- fModifierEditor.setEnabled(false);
-
- Iterator e= fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b= (Button) e.next();
- String key= (String) fCheckBoxes.get(b);
- b.setSelection(fStore.getBoolean(key));
- }
-
- for (int i= 0; i < fHoverConfigs.length; i++)
- fHoverTable.getItem(i).setChecked(fHoverConfigs[i].fIsEnabled);
- fHoverTableViewer.refresh();
- }
-
- public void performOk() {
- StringBuffer buf= new StringBuffer();
- StringBuffer maskBuf= new StringBuffer();
- for (int i= 0; i < fHoverConfigs.length; i++) {
- buf.append(getContributedHovers()[i].getId());
- buf.append(JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
- if (!fHoverConfigs[i].fIsEnabled)
- buf.append(JavaEditorTextHoverDescriptor.DISABLED_TAG);
- String modifier= fHoverConfigs[i].fModifierString;
- if (modifier == null || modifier.length() == 0)
- modifier= JavaEditorTextHoverDescriptor.NO_MODIFIER;
- buf.append(modifier);
- buf.append(JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
-
- maskBuf.append(getContributedHovers()[i].getId());
- maskBuf.append(JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
- maskBuf.append(fHoverConfigs[i].fStateMask);
- maskBuf.append(JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
- }
- fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, buf.toString());
- fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, maskBuf.toString());
-
- JavaScriptPlugin.getDefault().resetJavaEditorTextHoverDescriptors();
- }
-
- public void performDefaults() {
- restoreFromPreferences();
- initializeFields();
- updateStatus(null);
- }
-
- private void restoreFromPreferences() {
- String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
-
- StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
- HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2);
-
- while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
- if (tokenizer.hasMoreTokens())
- idToModifier.put(id, tokenizer.nextToken());
- }
-
- String compiledTextHoverModifierMasks= JavaScriptPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
-
- tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, JavaEditorTextHoverDescriptor.VALUE_SEPARATOR);
- HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2);
-
- while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
- if (tokenizer.hasMoreTokens())
- idToModifierMask.put(id, tokenizer.nextToken());
- }
-
- for (int i= 0; i < fHoverConfigs.length; i++) {
- String modifierString= (String)idToModifier.get(getContributedHovers()[i].getId());
- boolean enabled= true;
- if (modifierString == null)
- modifierString= JavaEditorTextHoverDescriptor.DISABLED_TAG;
-
- if (modifierString.startsWith(JavaEditorTextHoverDescriptor.DISABLED_TAG)) {
- enabled= false;
- modifierString= modifierString.substring(1);
- }
-
- if (modifierString.equals(JavaEditorTextHoverDescriptor.NO_MODIFIER))
- modifierString= ""; //$NON-NLS-1$
-
- fHoverConfigs[i].fModifierString= modifierString;
- fHoverConfigs[i].fIsEnabled= enabled;
- fHoverConfigs[i].fStateMask= JavaEditorTextHoverDescriptor.computeStateMask(modifierString);
-
- if (fHoverConfigs[i].fStateMask == -1) {
- try {
- fHoverConfigs[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(getContributedHovers()[i].getId()));
- } catch (NumberFormatException ex) {
- fHoverConfigs[i].fStateMask= -1;
- }
- }
- }
- }
-
- private void handleModifierModified() {
- int i= fHoverTable.getSelectionIndex();
- if (i == -1)
- return;
-
- String modifiers= fModifierEditor.getText();
- fHoverConfigs[i].fModifierString= modifiers;
- fHoverConfigs[i].fStateMask= JavaEditorTextHoverDescriptor.computeStateMask(modifiers);
-
- // update table
- fHoverTableViewer.refresh(getContributedHovers()[i]);
-
- updateStatus(fHoverConfigs[i]);
- }
-
- private void handleHoverListSelection() {
- int i= fHoverTable.getSelectionIndex();
-
- if (i == -1) {
- if (fHoverTable.getSelectionCount() == 0)
- fModifierEditor.setEnabled(false);
- return;
- }
-
- boolean enabled= fHoverConfigs[i].fIsEnabled;
- fModifierEditor.setEnabled(enabled);
- fModifierEditor.setText(fHoverConfigs[i].fModifierString);
- String description= getContributedHovers()[i].getDescription();
- if (description == null)
- description= ""; //$NON-NLS-1$
- fDescription.setText(description);
- }
-
- IStatus getStatus() {
- if (fStatus == null)
- fStatus= new StatusInfo();
- return fStatus;
- }
-
- private void updateStatus(HoverConfig hoverConfig) {
- if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1)
- fStatus= new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_modifierIsNotValid, hoverConfig.fModifierString));
- else
- fStatus= new StatusInfo();
-
- int i= 0;
- HashMap stateMasks= new HashMap(fHoverConfigs.length);
- while (fStatus.isOK() && i < fHoverConfigs.length) {
- if (fHoverConfigs[i].fIsEnabled) {
- String label= getContributedHovers()[i].getLabel();
- Integer stateMask= new Integer(fHoverConfigs[i].fStateMask);
- if (fHoverConfigs[i].fStateMask == -1)
- fStatus= new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label}));
- else if (stateMasks.containsKey(stateMask))
- fStatus= new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.JavaEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, (String)stateMasks.get(stateMask)}));
- else
- stateMasks.put(stateMask, label);
- }
- i++;
- }
-
- fMainPreferencePage.setValid(fStatus.isOK());
- StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
- }
-
- 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.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- private void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
- filler.setLayoutData(gd);
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
- // nothing to dispose
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverPreferencePage.java
deleted file mode 100644
index d3cd23b6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorHoverPreferencePage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-
-/**
- * Quick Diff preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- *
- */
-public class JavaEditorHoverPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.JavaEditorPreferencePage_hoverTab_title;
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null; // no description for new look.
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new JavaEditorHoverConfigurationBlock(this, overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPreferencePage.java
deleted file mode 100644
index e877be8a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPreferencePage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * The page for setting the editor options.
- */
-public final class JavaEditorPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.JavaEditorPreferencePage_general;
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null; // no description for new look.
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new JavaEditorAppearanceConfigurationBlock(this, overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPropertyPage.java
deleted file mode 100644
index 266d9be5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaEditorPropertyPage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
-public class JavaEditorPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
-
- public JavaEditorPropertyPage() {}
-
- protected Control createContents(Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setLayout(new GridLayout());
-
- Link link= new Link(composite, SWT.WRAP);
- GridData data= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- data.widthHint= 300;
- link.setLayoutData(data);
- link.setText(PreferencesMessages.JavaEditorPropertyPage_SaveActionLink_Text);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)getContainer();
- container.openPage(SaveParticipantPreferencePage.PROPERTY_PAGE_ID, null);
- }
- });
-
- return composite;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaElementInfoPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaElementInfoPage.java
deleted file mode 100644
index fd972a3f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaElementInfoPage.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.dialogs.Dialog;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Resources;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-
-/**
- * This is a dummy PropertyPage for JavaElements.
- * Copied from the ResourceInfoPage
- */
-public class JavaElementInfoPage extends PropertyPage {
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_ELEMENT_INFO_PAGE);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- // ensure the page has no special buttons
- noDefaultAndApplyButton();
-
- IJavaScriptElement element= (IJavaScriptElement)getElement();
-
- IResource resource= element.getResource();
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
-
- Label nameLabel= new Label(composite, SWT.NONE);
- nameLabel.setText(PreferencesMessages.JavaElementInfoPage_nameLabel);
-
- Label nameValueLabel= new Label(composite, SWT.NONE);
- nameValueLabel.setText(element.getElementName());
-
- if (resource != null) {
- // path label
- Label pathLabel= new Label(composite, SWT.NONE);
- pathLabel.setText(PreferencesMessages.JavaElementInfoPage_resource_path);
-
- // path value label
- Label pathValueLabel= new Label(composite, SWT.NONE);
- pathValueLabel.setText(resource.getFullPath().toString());
- }
- if (element instanceof IJavaScriptUnit) {
- IJavaScriptUnit unit= (IJavaScriptUnit)element;
- Label packageLabel= new Label(composite, SWT.NONE);
- packageLabel.setText(PreferencesMessages.JavaElementInfoPage_package);
- Label packageName= new Label(composite, SWT.NONE);
- packageName.setText(unit.getParent().getElementName());
-
- } else if (element instanceof IPackageFragment) {
- IPackageFragment packageFragment= (IPackageFragment)element;
- Label packageContents= new Label(composite, SWT.NONE);
- packageContents.setText(PreferencesMessages.JavaElementInfoPage_package_contents);
- Label packageContentsType= new Label(composite, SWT.NONE);
- try {
- if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE)
- packageContentsType.setText(PreferencesMessages.JavaElementInfoPage_source);
- else
- packageContentsType.setText(PreferencesMessages.JavaElementInfoPage_binary);
- } catch (JavaScriptModelException e) {
- packageContentsType.setText(PreferencesMessages.JavaElementInfoPage_not_present);
- }
- } else if (element instanceof IPackageFragmentRoot) {
- Label rootContents= new Label(composite, SWT.NONE);
- rootContents.setText(PreferencesMessages.JavaElementInfoPage_classpath_entry_kind);
- Label rootContentsType= new Label(composite, SWT.NONE);
- try {
- IIncludePathEntry entry= ((IPackageFragmentRoot)element).getRawIncludepathEntry();
- if (entry != null) {
- switch (entry.getEntryKind()) {
- case IIncludePathEntry.CPE_SOURCE:
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_source); break;
- case IIncludePathEntry.CPE_PROJECT:
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_project); break;
- case IIncludePathEntry.CPE_LIBRARY:
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_library); break;
- case IIncludePathEntry.CPE_VARIABLE:
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_variable);
- Label varPath= new Label(composite, SWT.NONE);
- varPath.setText(PreferencesMessages.JavaElementInfoPage_variable_path);
- Label varPathVar= new Label(composite, SWT.NONE);
- varPathVar.setText(entry.getPath().makeRelative().toString());
- break;
- }
- } else {
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_not_present);
- }
- } catch (JavaScriptModelException e) {
- rootContentsType.setText(PreferencesMessages.JavaElementInfoPage_not_present);
- }
- } else if (element instanceof IJavaScriptProject) {
- Label packageLabel= new Label(composite, SWT.NONE);
- packageLabel.setText(PreferencesMessages.JavaElementInfoPage_location);
- String location= Resources.getLocationString(((IJavaScriptProject)element).getProject());
- if (location != null) {
- Label packageName= new Label(composite, SWT.NONE);
- packageName.setText(location);
- }
- }
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaPreferencesSettings.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaPreferencesSettings.java
deleted file mode 100644
index 5305c85e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaPreferencesSettings.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.CodeGenerationSettings;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class JavaPreferencesSettings {
-
-
- public static CodeGenerationSettings getCodeGenerationSettings(IJavaScriptProject project) {
- CodeGenerationSettings res= new CodeGenerationSettings();
- res.createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, project)).booleanValue();
- res.useKeywordThis= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_KEYWORD_THIS, project)).booleanValue();
- res.overrideAnnotation= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION, project)).booleanValue();
- res.importOrder= getImportOrderPreference(project);
- res.importThreshold= getImportNumberThreshold(project);
- res.staticImportThreshold= getStaticImportNumberThreshold(project);
- res.importIgnoreLowercase= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, project)).booleanValue();
- res.tabWidth= CodeFormatterUtil.getTabWidth(project);
- res.indentWidth= CodeFormatterUtil.getIndentWidth(project);
- return res;
- }
-
- /**
- * @deprecated Use getCodeGenerationSettings(IJavaScriptProject) instead
- */
- public static CodeGenerationSettings getCodeGenerationSettings() {
- return getCodeGenerationSettings(null);
- }
-
- public static int getImportNumberThreshold(IJavaScriptProject project) {
- String thresholdStr= PreferenceConstants.getPreference(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, project);
- try {
- int threshold= Integer.parseInt(thresholdStr);
- if (threshold < 0) {
- threshold= Integer.MAX_VALUE;
- }
- return threshold;
- } catch (NumberFormatException e) {
- return Integer.MAX_VALUE;
- }
- }
-
- public static int getStaticImportNumberThreshold(IJavaScriptProject project) {
- String thresholdStr= PreferenceConstants.getPreference(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, project);
- try {
- int threshold= Integer.parseInt(thresholdStr);
- if (threshold < 0) {
- threshold= Integer.MAX_VALUE;
- }
- return threshold;
- } catch (NumberFormatException e) {
- return Integer.MAX_VALUE;
- }
- }
-
- public static String[] getImportOrderPreference(IJavaScriptProject project) {
- String str= PreferenceConstants.getPreference(PreferenceConstants.ORGIMPORTS_IMPORTORDER, project);
- if (str != null) {
- return unpackList(str, ";"); //$NON-NLS-1$
- }
- return new String[0];
- }
-
- /**
- * @deprecated Use getImportNumberThreshold(IJavaScriptProject) instead
- */
- public static int getImportNumberThreshold(IPreferenceStore prefs) {
- int threshold= prefs.getInt(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
- if (threshold < 0) {
- threshold= Integer.MAX_VALUE;
- }
- return threshold;
- }
-
- /**
- * @deprecated Use getImportOrderPreference(IJavaScriptProject) instead
- */
- public static String[] getImportOrderPreference(IPreferenceStore prefs) {
- String str= prefs.getString(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
- if (str != null) {
- return unpackList(str, ";"); //$NON-NLS-1$
- }
- return new String[0];
- }
-
- private static String[] unpackList(String str, String separator) {
- StringTokenizer tok= new StringTokenizer(str, separator);
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < nTokens; i++) {
- res[i]= tok.nextToken().trim();
- }
- return res;
- }
-
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaScriptMainPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaScriptMainPage.java
deleted file mode 100644
index 17d289d9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaScriptMainPage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.SWT;
-//import org.eclipse.swt.events.SelectionAdapter;
-//import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-//import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.dialogs.PropertyPage;
-//import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
-/**
- * @author childsb
- *
-
- */
-
-
-public class JavaScriptMainPage extends PropertyPage implements IWorkbenchPropertyPage{
-
- public static final String PROP_ID= "org.eclipse.wst.jsdt.internal.ui.preferences.JavaScriptMainPage"; //$NON-NLS-1$
-
- public JavaScriptMainPage() {}
-
- protected Control createContents(Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setLayout(new GridLayout());
-
-// Link link= new Link(composite, SWT.WRAP);
-// GridData data= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
-// data.widthHint= 300;
-// link.setLayoutData(data);
-// link.setText(PreferencesMessages.JavaEditorPropertyPage_SaveActionLink_Text);
-// link.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)getContainer();
-// container.openPage(SaveParticipantPreferencePage.PROPERTY_PAGE_ID, null);
-// }
-// });
-
- return composite;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java
deleted file mode 100644
index 44e6d4ad..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-/**
- * Handles Java editor font changes for Java source preview viewers.
- *
- *
- */
-class JavaSourcePreviewerUpdater {
-
- /**
- * Creates a Java source preview updater for the given viewer, configuration and preference store.
- *
- * @param viewer the viewer
- * @param configuration the configuration
- * @param preferenceStore the preference store
- */
- JavaSourcePreviewerUpdater(final SourceViewer viewer, final JavaScriptSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) {
- Assert.isNotNull(viewer);
- Assert.isNotNull(configuration);
- Assert.isNotNull(preferenceStore);
- final IPropertyChangeListener fontChangeListener= new IPropertyChangeListener() {
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- viewer.getTextWidget().setFont(font);
- }
- }
- };
- final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (configuration.affectsTextPresentation(event)) {
- configuration.handlePropertyChangeEvent(event);
- viewer.invalidateTextPresentation();
- }
- }
- };
- viewer.getTextWidget().addDisposeListener(new DisposeListener() {
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- preferenceStore.removePropertyChangeListener(propertyChangeListener);
- JFaceResources.getFontRegistry().removeListener(fontChangeListener);
- }
- });
- JFaceResources.getFontRegistry().addListener(fontChangeListener);
- preferenceStore.addPropertyChangeListener(propertyChangeListener);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaTemplatePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaTemplatePreferencePage.java
deleted file mode 100644
index 62bdcb9c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavaTemplatePreferencePage.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-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.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-public class JavaTemplatePreferencePage extends TemplatePreferencePage implements IWorkbenchPreferencePage {
-
- private TemplateVariableProcessor fTemplateProcessor;
-
- public JavaTemplatePreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setTemplateStore(JavaScriptPlugin.getDefault().getTemplateStore());
- setContextTypeRegistry(JavaScriptPlugin.getDefault().getTemplateContextRegistry());
- fTemplateProcessor= new TemplateVariableProcessor();
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TEMPLATE_PREFERENCE_PAGE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- *
- */
- protected Control createContents(Composite ancestor) {
- ScrolledPageContent scrolled= new ScrolledPageContent(ancestor, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Control control= super.createContents(scrolled);
-
- scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
-
- return scrolled;
- }
-
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- boolean ok= super.performOk();
-
- JavaScriptPlugin.getDefault().savePluginPreferences();
-
- return ok;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#getFormatterPreferenceKey()
- */
- protected String getFormatterPreferenceKey() {
- return PreferenceConstants.TEMPLATES_USE_CODEFORMATTER;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createTemplateEditDialog2(org.eclipse.jface.text.templates.Template, boolean, boolean)
- */
- protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
- org.eclipse.wst.jsdt.internal.ui.preferences.EditTemplateDialog dialog= new org.eclipse.wst.jsdt.internal.ui.preferences.EditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
- if (dialog.open() == Window.OK) {
- return dialog.getTemplate();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite)
- */
- protected SourceViewer createViewer(Composite parent) {
- IDocument document= new Document();
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
- viewer.configure(configuration);
- viewer.setEditable(false);
- viewer.setDocument(document);
-
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- viewer.getTextWidget().setFont(font);
- new JavaSourcePreviewerUpdater(viewer, configuration, store);
-
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- control.setLayoutData(data);
-
- return viewer;
- }
-
-
- /*
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#updateViewerInput()
- */
- protected void updateViewerInput() {
- IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
- SourceViewer viewer= getViewer();
-
- if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
- TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
- Template template= data.getTemplate();
- String contextId= template.getContextTypeId();
- TemplateContextType type= JavaScriptPlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
- fTemplateProcessor.setContextType(type);
-
- IDocument doc= viewer.getDocument();
-
- String start= null;
- if ("javadoc".equals(contextId)) { //$NON-NLS-1$
- start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
- } else
- start= ""; //$NON-NLS-1$
-
- doc.set(start + template.getPattern());
- int startLen= start.length();
- viewer.setDocument(doc, startLen, doc.getLength() - startLen);
-
- } else {
- viewer.getDocument().set(""); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationBlock.java
deleted file mode 100644
index 8d1eb392..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationBlock.java
+++ /dev/null
@@ -1,920 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-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.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-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.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.views.navigator.ResourceComparator;
-import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
-import org.eclipse.wst.jsdt.internal.corext.javadoc.JavaDocLocations;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.OpenBrowserUtil;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.TypedElementSelectionValidator;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.ArchiveFileFilter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavadocConfigurationBlock {
- private static final String FILE_IMPORT_MASK= "*.jar;*.zip"; //$NON-NLS-1$
- private static final String ERROR_DIALOG_TITLE= "Error Dialog"; //$NON-NLS-1$
-
- private StringDialogField fURLField;
- private StringDialogField fArchiveField;
- private StringDialogField fArchivePathField;
- private URL fInitialURL;
- private SelectionButtonDialogField fValidateURLButton;
- private SelectionButtonDialogField fValidateArchiveButton;
- private SelectionButtonDialogField fBrowseFolder;
- private SelectionButtonDialogField fURLRadioButton;
- private SelectionButtonDialogField fArchiveRadioButton;
- private SelectionButtonDialogField fBrowseArchive;
- private SelectionButtonDialogField fExternalRadio, fWorkspaceRadio;
- private SelectionButtonDialogField fBrowseArchivePath;
- private Shell fShell;
- private IStatusChangeListener fContext;
-
- private IStatus fURLStatus;
- private IStatus fArchiveStatus;
- private IStatus fArchivePathStatus;
-
- private URL fURLResult;
- private URL fArchiveURLResult;
-
- boolean fIsForSource;
-
-
- public JavadocConfigurationBlock(Shell shell, IStatusChangeListener context, URL initURL, boolean forSource) {
- fShell= shell;
- fContext= context;
- fInitialURL= initURL;
- fIsForSource= forSource;
-
- JDocConfigurationAdapter adapter= new JDocConfigurationAdapter();
-
- if (!forSource) {
- fURLRadioButton= new SelectionButtonDialogField(SWT.RADIO);
- fURLRadioButton.setDialogFieldListener(adapter);
- fURLRadioButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_location_type_path_label);
- }
-
- fURLField= new StringDialogField();
- fURLField.setDialogFieldListener(adapter);
- fURLField.setLabelText(PreferencesMessages.JavadocConfigurationBlock_location_path_label);
-
- fBrowseFolder= new SelectionButtonDialogField(SWT.PUSH);
- fBrowseFolder.setDialogFieldListener(adapter);
- fBrowseFolder.setLabelText(PreferencesMessages.JavadocConfigurationBlock_browse_folder_button);
-
- fValidateURLButton= new SelectionButtonDialogField(SWT.PUSH);
- fValidateURLButton.setDialogFieldListener(adapter);
- fValidateURLButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_validate_button);
-
- if (!forSource) {
- fArchiveRadioButton= new SelectionButtonDialogField(SWT.RADIO);
- fArchiveRadioButton.setDialogFieldListener(adapter);
- fArchiveRadioButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_location_type_jar_label);
-
- fExternalRadio= new SelectionButtonDialogField(SWT.RADIO);
- fExternalRadio.setDialogFieldListener(adapter);
- fExternalRadio.setLabelText(PreferencesMessages.JavadocConfigurationBlock_external_radio);
-
- fWorkspaceRadio= new SelectionButtonDialogField(SWT.RADIO);
- fWorkspaceRadio.setDialogFieldListener(adapter);
- fWorkspaceRadio.setLabelText(PreferencesMessages.JavadocConfigurationBlock_workspace_radio);
-
- fArchiveField= new StringDialogField();
- fArchiveField.setDialogFieldListener(adapter);
- fArchiveField.setLabelText(PreferencesMessages.JavadocConfigurationBlock_location_jar_label);
-
- fBrowseArchive= new SelectionButtonDialogField(SWT.PUSH);
- fBrowseArchive.setDialogFieldListener(adapter);
- fBrowseArchive.setLabelText(PreferencesMessages.JavadocConfigurationBlock_browse_archive_button);
-
- fArchivePathField= new StringDialogField();
- fArchivePathField.setDialogFieldListener(adapter);
- fArchivePathField.setLabelText(PreferencesMessages.JavadocConfigurationBlock_jar_path_label);
-
- fBrowseArchivePath= new SelectionButtonDialogField(SWT.PUSH);
- fBrowseArchivePath.setDialogFieldListener(adapter);
- fBrowseArchivePath.setLabelText(PreferencesMessages.JavadocConfigurationBlock_browse_archive_path_button);
-
- fValidateArchiveButton= new SelectionButtonDialogField(SWT.PUSH);
- fValidateArchiveButton.setDialogFieldListener(adapter);
- fValidateArchiveButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_validate_button);
- }
-
- fURLStatus= new StatusInfo();
- fArchiveStatus= new StatusInfo();
- fArchivePathStatus= new StatusInfo();
-
- initializeSelections();
- }
-
- public Control createContents(Composite parent) {
- fShell= parent.getShell();
-
- PixelConverter converter= new PixelConverter(parent);
- Composite topComp= new Composite(parent, SWT.NONE);
- GridLayout topLayout= new GridLayout();
- topLayout.numColumns= 3;
- topLayout.marginWidth= 0;
- topLayout.marginHeight= 0;
- topComp.setLayout(topLayout);
-
- // Add the first radio button for the path
- if (!fIsForSource) {
- fURLRadioButton.doFillIntoGrid(topComp, 3);
- }
-
- fURLField.doFillIntoGrid(topComp, 2);
- LayoutUtil.setWidthHint(fURLField.getTextControl(null), converter.convertWidthInCharsToPixels(43));
- LayoutUtil.setHorizontalGrabbing(fURLField.getTextControl(null));
-
- fBrowseFolder.doFillIntoGrid(topComp, 1);
-
- DialogField.createEmptySpace(topComp, 2);
- fValidateURLButton.doFillIntoGrid(topComp, 1);
-
- //DialogField.createEmptySpace(topComp, 3);
-
- if (!fIsForSource) {
- // Add the second radio button for the jar/zip
- fArchiveRadioButton.doFillIntoGrid(topComp, 3);
-
-
- // external - workspace selection
- DialogField.createEmptySpace(topComp, 1);
- Composite radioComposite= new Composite(topComp, SWT.NONE);
- radioComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
- GridLayout layout= new GridLayout(2, true);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- radioComposite.setLayout(layout);
- fExternalRadio.doFillIntoGrid(radioComposite, 1);
- fWorkspaceRadio.doFillIntoGrid(radioComposite, 1);
- DialogField.createEmptySpace(topComp, 1);
-
- // Add the jar/zip field
- fArchiveField.doFillIntoGrid(topComp, 2);
- LayoutUtil.setWidthHint(fArchiveField.getTextControl(null), converter.convertWidthInCharsToPixels(43));
- LayoutUtil.setHorizontalGrabbing(fArchiveField.getTextControl(null));
-
- fBrowseArchive.doFillIntoGrid(topComp, 1);
-
- // Add the path chooser for the jar/zip
- fArchivePathField.doFillIntoGrid(topComp, 2);
- LayoutUtil.setWidthHint(fArchivePathField.getTextControl(null), converter.convertWidthInCharsToPixels(43));
- LayoutUtil.setHorizontalGrabbing(fArchivePathField.getTextControl(null));
-
- fBrowseArchivePath.doFillIntoGrid(topComp, 1);
-
- DialogField.createEmptySpace(topComp, 2);
- fValidateArchiveButton.doFillIntoGrid(topComp, 1);
-
- int indent= converter.convertWidthInCharsToPixels(2);
- LayoutUtil.setHorizontalIndent(fArchiveField.getLabelControl(null), indent);
- LayoutUtil.setHorizontalIndent(fArchivePathField.getLabelControl(null), indent);
- LayoutUtil.setHorizontalIndent(fURLField.getLabelControl(null), indent);
-
- fURLRadioButton.attachDialogFields(new DialogField[] {fURLField, fBrowseFolder, fValidateURLButton });
- fArchiveRadioButton.attachDialogFields(new DialogField[] {fArchiveField, fBrowseArchive, fExternalRadio, fWorkspaceRadio, fArchivePathField, fBrowseArchivePath, fValidateArchiveButton });
- }
-
-
- return topComp;
- }
-
- private void initializeSelections() {
- String initialValue = fInitialURL != null ? fInitialURL.toExternalForm() : ""; //$NON-NLS-1$
-
- if (fIsForSource) {
- fURLField.setText(initialValue);
- return;
- }
- String prefix= JavaDocLocations.ARCHIVE_PREFIX;
- boolean isArchive= initialValue.startsWith(prefix);
-
- boolean isWorkspaceArchive= false;
-
- fURLRadioButton.setSelection(!isArchive);
- fArchiveRadioButton.setSelection(isArchive);
-
- if (isArchive) {
- String jarPathStr;
- String insidePath= ""; //$NON-NLS-1$
- int excIndex= initialValue.indexOf("!/"); //$NON-NLS-1$
- if (excIndex == -1) {
- jarPathStr= initialValue.substring(prefix.length());
- } else {
- jarPathStr= initialValue.substring(prefix.length(), excIndex);
- insidePath= initialValue.substring(excIndex + 2);
- }
-
- final String fileProtocol= "file:/"; //$NON-NLS-1$
- final String resourceProtocol= "platform:/resource/"; //$NON-NLS-1$
-
- if (jarPathStr.startsWith(fileProtocol)) {
- jarPathStr= jarPathStr.substring(fileProtocol.length());
- } else if (jarPathStr.startsWith(resourceProtocol)) {
- jarPathStr= jarPathStr.substring(resourceProtocol.length());
- isWorkspaceArchive= true;
- } else {
- fURLField.setText(initialValue);
- return;
- }
- IPath jarPath= new Path(decodeExclamationMarks(jarPathStr));
- fArchivePathField.setText(decodeExclamationMarks(insidePath));
- if (isWorkspaceArchive) {
- fArchiveField.setText(jarPath.makeRelative().toString());
- } else {
- fArchiveField.setText(jarPath.makeAbsolute().toOSString());
- }
- } else {
- fURLField.setText(initialValue);
- }
- fExternalRadio.setSelection(!isWorkspaceArchive);
- fWorkspaceRadio.setSelection(isWorkspaceArchive);
-
- }
-
- public void setFocus() {
- fURLField.postSetFocusOnDialogField(fShell.getDisplay());
- }
-
- public void performDefaults() {
- initializeSelections();
- }
-
- public URL getJavadocLocation() {
- if (fIsForSource || fURLRadioButton.isSelected()) {
- return fURLResult;
- }
- return fArchiveURLResult;
- }
-
- private class EntryValidator implements Runnable {
-
- private String fInvalidMessage= PreferencesMessages.JavadocConfigurationBlock_InvalidLocation_message;
- private String fValidMessage= PreferencesMessages.JavadocConfigurationBlock_ValidLocation_message;
- private String fTitle= PreferencesMessages.JavadocConfigurationBlock_MessageDialog_title;
- private String fUnable= PreferencesMessages.JavadocConfigurationBlock_UnableToValidateLocation_message;
- public void run() {
-
- URL location= getJavadocLocation();
- if (location == null) {
- MessageDialog.openWarning(fShell, fTitle, fInvalidMessage);
- return;
- }
-
- try {
- String protocol = location.getProtocol();
- if (protocol.startsWith("http") || protocol.equals("jar")) { //$NON-NLS-1$ //$NON-NLS-2$
- validateURL(location);
- } else if (protocol.equals("file")) { //$NON-NLS-1$
- validateFile(location);
- } else {
- MessageDialog.openWarning(fShell, fTitle, fUnable);
- }
- } catch (MalformedURLException e) {
- MessageDialog.openWarning(fShell, fTitle, fUnable);
- }
-
- }
-
- public void spawnInBrowser(URL url) {
- OpenBrowserUtil.open(url, fShell.getDisplay(), fTitle);
- }
-
- private void validateFile(URL location) throws MalformedURLException {
- File folder = new File(location.getFile());
- if (folder.isDirectory()) {
- File indexFile= new File(folder, "index.html"); //$NON-NLS-1$
- if (indexFile.isFile()) {
- File packageList= new File(folder, "package-list"); //$NON-NLS-1$
- if (packageList.exists()) {
- if (MessageDialog.openConfirm(fShell, fTitle, fValidMessage)) {
- spawnInBrowser(indexFile.toURL());
- }
- return;
- }
- }
- }
- MessageDialog.openWarning(fShell, fTitle, fInvalidMessage);
- }
-
- private void validateURL(URL location) throws MalformedURLException {
- IPath path= new Path(location.toExternalForm());
- IPath index = path.append("index.html"); //$NON-NLS-1$
- IPath packagelist = path.append("package-list"); //$NON-NLS-1$
- URL indexURL = new URL(index.toString());
- URL packagelistURL = new URL(packagelist.toString());
-
- boolean suc= checkURLConnection(indexURL) && checkURLConnection(packagelistURL);
- if (suc) {
- if (MessageDialog.openConfirm(fShell, fTitle, fValidMessage))
- spawnInBrowser(indexURL);
- } else {
- MessageDialog.openWarning(fShell, fTitle, fInvalidMessage);
- }
- }
- }
-
- private boolean checkURLConnection(URL url) {
- int res= 0;
- URLConnection connection= null;
- try {
- connection= url.openConnection();
- if (connection instanceof HttpURLConnection) {
- connection.connect();
- res= ((HttpURLConnection) connection).getResponseCode();
- }
- InputStream is= null;
- try {
- is= connection.getInputStream();
- byte[] buffer= new byte[256];
- while (is.read(buffer) != -1) {
- }
- } finally {
- if (is != null)
- is.close();
- }
- } catch (IllegalArgumentException e) {
- return false; // bug 91072
- } catch (IOException e) {
- return false;
- }
- return res < 400;
- }
-
-
- private class JDocConfigurationAdapter implements IDialogFieldListener {
-
- // ---------- IDialogFieldListener --------
- public void dialogFieldChanged(DialogField field) {
- jdocDialogFieldChanged(field);
- }
- }
-
-
- private void jdocDialogFieldChanged(DialogField field) {
- if (field == fURLField) {
- fURLStatus= updateURLStatus();
- statusChanged();
- } else if (field == fArchiveField) {
- fArchiveStatus= updateArchiveStatus();
- statusChanged();
- } else if (field == fArchivePathField) {
- fArchivePathStatus= updateArchivePathStatus();
- statusChanged();
- } else if (field == fValidateURLButton || field == fValidateArchiveButton) {
- EntryValidator validator= new EntryValidator();
- BusyIndicator.showWhile(fShell.getDisplay(), validator);
- } else if (field == fBrowseFolder) {
- String url= chooseJavaDocFolder();
- if (url != null) {
- fURLField.setText(url);
- }
- } else if (field == fBrowseArchive) {
- String jarPath= chooseArchive();
- if (jarPath != null) {
- fArchiveField.setText(jarPath);
- }
- } else if (field == fExternalRadio || field == fWorkspaceRadio) {
- fArchiveStatus= updateArchiveStatus();
- statusChanged();
- } else if (field == fBrowseArchivePath) {
- String archivePath= chooseArchivePath();
- if (archivePath != null) {
- fArchivePathField.setText(archivePath);
- }
- } else if (field == fURLRadioButton || field == fArchiveRadioButton) {
- statusChanged();
- }
- }
-
- private void statusChanged() {
- IStatus status;
- boolean isURL= fIsForSource || fURLRadioButton.isSelected();
- if (isURL) {
- status= fURLStatus;
- } else {
- status= StatusUtil.getMoreSevere(fArchiveStatus, fArchivePathStatus);
- }
- if (!fIsForSource) {
- boolean canBrowseArchivePath= !isURL && fArchiveStatus.isOK() && fArchiveField.getText().length() > 0;
- if (canBrowseArchivePath && fWorkspaceRadio.isSelected()) {
- IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(fArchiveField.getText()));
- canBrowseArchivePath= resource != null && resource.getLocation() != null;
- }
- fBrowseArchivePath.setEnabled(canBrowseArchivePath);
- }
- fContext.statusChanged(status);
- }
-
-
- private String chooseArchivePath() {
- final String[] res= new String[] { null };
- BusyIndicator.showWhile(fShell.getDisplay(), new Runnable() {
- public void run() {
- res[0]= internalChooseArchivePath();
- }
- });
- return res[0];
- }
-
- private String encodeExclamationMarks(String str) {
- StringBuffer buf= new StringBuffer(str.length());
- for (int i= 0; i < str.length(); i++) {
- char ch= str.charAt(i);
- if (ch == '!') {
- buf.append("%21"); //$NON-NLS-1$
- } else {
- buf.append(ch);
- }
- }
- return buf.toString();
- }
-
- private String decodeExclamationMarks(String str) {
- StringBuffer buf= new StringBuffer(str.length());
- int length= str.length();
- for (int i= 0; i < length; i++) {
- char ch= str.charAt(i);
- if (ch == '%' && (i < length - 2) && str.charAt(i + 1) == '2' && str.charAt(i + 2) == '1') {
- buf.append('!');
- i+= 2;
- } else {
- buf.append(ch);
- }
- }
- return buf.toString();
- }
-
-
-
- private String internalChooseArchivePath() {
- ZipFile zipFile= null;
- try {
- if (fWorkspaceRadio.isSelected()) {
- IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(fArchiveField.getText()));
- if (resource != null) {
- IPath location= resource.getLocation();
- if (location != null) {
- zipFile= new ZipFile(location.toOSString());
- }
- }
- } else {
- zipFile= new ZipFile(fArchiveField.getText());
- }
- if (zipFile == null) {
- return null;
- }
-
- ZipFileStructureProvider provider= new ZipFileStructureProvider(zipFile);
-
- ILabelProvider lp= new ZipDialogLabelProvider(provider);
- ZipDialogContentProvider cp= new ZipDialogContentProvider(provider);
-
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
- dialog.setAllowMultiple(false);
- dialog.setValidator(new ZipDialogValidator());
- dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_browse_jarorzip_path_title);
- dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_location_in_jarorzip_message);
- dialog.setComparator(new ViewerComparator());
-
- String init= fArchivePathField.getText();
- if (init.length() == 0) {
- init= "docs/api"; //$NON-NLS-1$
- }
- dialog.setInitialSelection(cp.findElement(new Path(init)));
-
- dialog.setInput(this);
- if (dialog.open() == Window.OK) {
- String name= provider.getFullPath(dialog.getFirstResult());
- return new Path(name).removeTrailingSeparator().toString();
- }
- } catch (IOException e) {
- JavaScriptPlugin.log(e);
- } finally {
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (IOException e1) {
- // ignore
- }
- }
- }
- return null;
- }
-
- private String chooseArchive() {
- if (fWorkspaceRadio.isSelected()) {
- return chooseWorkspaceArchive();
- }
-
- IPath currPath= new Path(fArchiveField.getText());
- if (ArchiveFileFilter.isArchivePath(currPath)) {
- currPath= currPath.removeLastSegments(1);
- }
-
- FileDialog dialog= new FileDialog(fShell, SWT.OPEN);
- dialog.setFilterExtensions(new String[] { FILE_IMPORT_MASK });
- dialog.setText(PreferencesMessages.JavadocConfigurationBlock_zipImportSource_title);
- dialog.setFilterPath(currPath.toOSString());
-
- return dialog.open();
- }
-
- private String chooseWorkspaceArchive() {
- String initSelection= fArchiveField.getText();
-
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new WorkbenchContentProvider();
- Class[] acceptedClasses= new Class[] { IFile.class };
- TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
-
- IResource initSel= null;
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- if (initSelection.length() > 0) {
- initSel= root.findMember(new Path(initSelection));
- }
-
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
- dialog.addFilter(new ArchiveFileFilter((List) null, true));
- dialog.setAllowMultiple(false);
- dialog.setValidator(validator);
- dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
- dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title);
- dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description);
- dialog.setInput(root);
- dialog.setInitialSelection(initSel);
- dialog.setHelpAvailable(false);
- if (dialog.open() == Window.OK) {
- IResource res= (IResource) dialog.getFirstResult();
- return res.getFullPath().makeRelative().toString();
- }
- return null;
- }
-
- /**
- * Display an error dialog with the specified message.
- *
- * @param message the error message
- */
- protected void displayErrorDialog(String message) {
- MessageDialog.openError(fShell, ERROR_DIALOG_TITLE, message);
- }
-
- private String chooseJavaDocFolder() {
- String initPath= ""; //$NON-NLS-1$
- if (fURLResult != null && "file".equals(fURLResult.getProtocol())) { //$NON-NLS-1$
- initPath= (new File(fURLResult.getFile())).getPath();
- }
- DirectoryDialog dialog= new DirectoryDialog(fShell);
- dialog.setText(PreferencesMessages.JavadocConfigurationBlock_javadocFolderDialog_label);
- dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_javadocFolderDialog_message);
- dialog.setFilterPath(initPath);
- String result= dialog.open();
- if (result != null) {
- try {
- URL url= new File(result).toURL();
- return url.toExternalForm();
- } catch (MalformedURLException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return null;
- }
-
- private IStatus updateURLStatus() {
- StatusInfo status= new StatusInfo();
- fURLResult= null;
- try {
- String jdocLocation= fURLField.getText();
- if (jdocLocation.length() == 0) {
- return status;
- }
- URL url= new URL(jdocLocation);
- if ("file".equals(url.getProtocol())) { //$NON-NLS-1$
- if (url.getFile() == null) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_notafolder);
- return status;
- }
- }
- fURLResult= url;
- } catch (MalformedURLException e) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_MalformedURL_error);
- return status;
- }
-
- return status;
- }
-
- private IStatus updateArchiveStatus() {
- try {
- fArchiveURLResult= null;
-
- StatusInfo status= new StatusInfo();
- String jdocLocation= fArchiveField.getText();
- if (jdocLocation.length() > 0) {
- if (!Path.ROOT.isValidPath(jdocLocation)) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_invalidarchivepath);
- return status;
- }
- if (fWorkspaceRadio.isSelected()) {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IResource res= root.findMember(new Path(jdocLocation));
- if (res != null) {
- if (!(res instanceof IFile)) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_archive_not_found_in_workspace);
- return status;
- }
- } else {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_archive_not_found_in_workspace);
- return status;
- }
- } else {
- IPath path= Path.fromOSString(jdocLocation);
- if (!path.isAbsolute()) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_archivepathnotabsolute);
- return status;
- }
- File jarFile= new File(jdocLocation);
- if (jarFile.isDirectory()) {
- status.setError(PreferencesMessages.JavadocConfigurationBlock_error_notafile);
- return status;
- }
- if (!jarFile.exists()) {
- status.setWarning(PreferencesMessages.JavadocConfigurationBlock_error_notafile);
- }
- }
- fArchiveURLResult= getArchiveURL();
- }
- return status;
- } catch (MalformedURLException e) {
- StatusInfo status= new StatusInfo();
- status.setError(e.getMessage());
- return status;
- }
- }
-
- private IStatus updateArchivePathStatus() {
- // no validation yet
- try {
- fArchiveURLResult= getArchiveURL();
- } catch (MalformedURLException e) {
- fArchiveURLResult= null;
- StatusInfo status= new StatusInfo();
- status.setError(e.getMessage());
- //status.setError(PreferencesMessages.getString("JavadocConfigurationBlock.MalformedURL.error")); //$NON-NLS-1$
- return status;
- }
- return new StatusInfo();
-
- }
-
-
- private URL getArchiveURL() throws MalformedURLException {
- String jarLoc= fArchiveField.getText();
- String innerPath= fArchivePathField.getText().trim();
-
- StringBuffer buf= new StringBuffer();
- buf.append("jar:"); //$NON-NLS-1$
-
- if (fWorkspaceRadio.isSelected()) {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IResource res= root.findMember(new Path(jarLoc));
- if (res != null) {
- buf.append("platform:/resource").append(encodeExclamationMarks(res.getFullPath().toString())); //$NON-NLS-1$
- }
- } else {
- buf.append(encodeExclamationMarks(new File(jarLoc).toURL().toExternalForm()));
- }
- buf.append('!');
- if (innerPath.length() > 0) {
- if (innerPath.charAt(0) != '/') {
- buf.append('/');
- }
- buf.append(innerPath);
- } else {
- buf.append('/');
- }
- return new URL(buf.toString());
- }
-
-
- /**
- * An adapter for presenting a zip file in a tree viewer.
- */
- private static class ZipDialogContentProvider implements ITreeContentProvider {
-
- private ZipFileStructureProvider fProvider;
-
- public ZipDialogContentProvider(ZipFileStructureProvider provider) {
- fProvider= provider;
- }
-
- public Object findElement(IPath path) {
- String[] segments= path.segments();
-
- Object elem= fProvider.getRoot();
- for (int i= 0; i < segments.length && elem != null; i++) {
- List list= fProvider.getChildren(elem);
- String name= segments[i];
- elem= null;
- for (int k= 0; k < list.size(); k++) {
- Object curr= list.get(k);
- if (fProvider.isFolder(curr) && name.equals(fProvider.getLabel(curr))) {
- elem= curr;
- break;
- }
- }
- }
- return elem;
- }
-
- private Object recursiveFind(Object element, String name) {
- if (name.equals(fProvider.getLabel(element))) {
- return element;
- }
- List list= fProvider.getChildren(element);
- if (list != null) {
- for (int k= 0; k < list.size(); k++) {
- Object res= recursiveFind(list.get(k), name);
- if (res != null) {
- return res;
- }
- }
- }
- return null;
- }
-
- public Object findFileByName(String name) {
- return recursiveFind(fProvider.getRoot(), name);
- }
-
- /* non java-doc
- * @see ITreeContentProvider#inputChanged
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /* non java-doc
- * @see ITreeContentProvider#getParent
- */
- public Object getParent(Object element) {
- if (element.equals(fProvider.getRoot())) {
- return null;
- }
- IPath path= new Path(fProvider.getFullPath(element));
- if (path.segmentCount() > 0) {
- return findElement(path.removeLastSegments(1));
- }
- return fProvider.getRoot();
- }
-
- /* non java-doc
- * @see ITreeContentProvider#hasChildren
- */
- public boolean hasChildren(Object element) {
- List list= fProvider.getChildren(element);
- if (list != null) {
- for (int i= 0; i < list.size(); i++) {
- if (fProvider.isFolder(list.get(i))) {
- return true;
- }
- }
- }
- return false;
- }
-
- /* non java-doc
- * @see ITreeContentProvider#getChildren
- */
- public Object[] getChildren(Object element) {
- List list= fProvider.getChildren(element);
- ArrayList res= new ArrayList();
- if (list != null) {
- for (int i= 0; i < list.size(); i++) {
- Object curr= list.get(i);
- if (fProvider.isFolder(curr)) {
- res.add(curr);
- }
- }
- }
- return res.toArray();
- }
-
- /* non java-doc
- * @see ITreeContentProvider#getElements
- */
- public Object[] getElements(Object element) {
- return new Object[] {fProvider.getRoot() };
- }
-
- /* non java-doc
- * @see IContentProvider#dispose
- */
- public void dispose() {
- }
- }
-
- private static class ZipDialogLabelProvider extends LabelProvider {
-
- private final Image IMG_JAR=
- JavaScriptUI.getSharedImages().getImage(org.eclipse.wst.jsdt.ui.ISharedImages.IMG_OBJS_JAR);
- private final Image IMG_FOLDER=
- PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
-
- private ZipFileStructureProvider fProvider;
-
- public ZipDialogLabelProvider(ZipFileStructureProvider provider) {
- fProvider= provider;
- }
-
- public Image getImage(Object element) {
- if (element == fProvider.getRoot()) {
- return IMG_JAR;
- } else {
- return IMG_FOLDER;
- }
- }
-
- public String getText(Object element) {
- if (element == fProvider.getRoot()) {
- return fProvider.getZipFile().getName();
- }
- return fProvider.getLabel(element);
- }
- }
-
- private static class ZipDialogValidator implements ISelectionStatusValidator {
- public ZipDialogValidator() {
- super();
- }
-
- /*
- * @see ISelectionValidator#validate(Object[])
- */
- public IStatus validate(Object[] selection) {
- String message= ""; //$NON-NLS-1$
- return new StatusInfo(IStatus.INFO, message);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java
deleted file mode 100644
index 60f315e8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
-import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
-import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.ArchiveFileFilter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathSupport;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListElement;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * Property page used to set the project's Javadoc location for sources
- */
-public class JavadocConfigurationPropertyPage extends PropertyPage implements IStatusChangeListener {
-
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.JavadocConfigurationPropertyPage"; //$NON-NLS-1$
-
- private JavadocConfigurationBlock fJavadocConfigurationBlock;
- private boolean fIsValidElement;
-
- private IPath fContainerPath;
- private IIncludePathEntry fEntry;
- private URL fInitalLocation;
-
- public JavadocConfigurationPropertyPage() {
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IJavaScriptElement elem= getJavaElement();
- try {
- if (elem instanceof IPackageFragmentRoot && ((IPackageFragmentRoot) elem).getKind() == IPackageFragmentRoot.K_BINARY) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) elem;
-
- IIncludePathEntry entry= root.getRawIncludepathEntry();
- if (entry == null) {
- fIsValidElement= false;
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
- } else {
- if (entry.getEntryKind() == IIncludePathEntry.CPE_CONTAINER) {
- fContainerPath= entry.getPath();
- fEntry= handleContainerEntry(fContainerPath, elem.getJavaScriptProject(), root.getPath());
- fIsValidElement= fEntry != null;
- } else {
- fContainerPath= null;
- fEntry= entry;
- fIsValidElement= true;
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
- }
- }
-
- } else if (elem instanceof IJavaScriptProject) {
- fIsValidElement= true;
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsJavaProject_description);
- } else {
- fIsValidElement= false;
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
- }
- } catch (JavaScriptModelException e) {
- fIsValidElement= false;
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
- }
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVADOC_CONFIGURATION_PROPERTY_PAGE);
- }
-
- private IIncludePathEntry handleContainerEntry(IPath containerPath, IJavaScriptProject jproject, IPath jarPath) throws JavaScriptModelException {
- JsGlobalScopeContainerInitializer initializer= JavaScriptCore.getJsGlobalScopeContainerInitializer(containerPath.segment(0));
- IJsGlobalScopeContainer container= JavaScriptCore.getJsGlobalScopeContainer(containerPath, jproject);
- if (initializer == null || container == null) {
- setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_invalid_container, containerPath.toString()));
- return null;
- }
- String containerName= container.getDescription();
- IStatus status= initializer.getAttributeStatus(containerPath, jproject, IIncludePathAttribute.JSDOC_LOCATION_ATTRIBUTE_NAME);
- if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
- setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_not_supported, containerName));
- return null;
- }
- if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_READ_ONLY) {
- setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_read_only, containerName));
- return null;
- }
- IIncludePathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath);
- Assert.isNotNull(entry);
- setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
- return entry;
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- if (!fIsValidElement) {
- return new Composite(parent, SWT.NONE);
- }
-
- IJavaScriptElement elem= getJavaElement();
- fInitalLocation= null;
- if (elem != null) {
- try {
- fInitalLocation= JavaScriptUI.getJSdocBaseLocation(elem);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- boolean isProject= (elem instanceof IJavaScriptProject);
- fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, isProject);
- Control control= fJavadocConfigurationBlock.createContents(parent);
- control.setVisible(elem != null);
-
- Dialog.applyDialogFont(control);
- return control;
- }
-
- private IJavaScriptElement getJavaElement() {
- IAdaptable adaptable= getElement();
- IJavaScriptElement elem= (IJavaScriptElement) adaptable.getAdapter(IJavaScriptElement.class);
- if (elem == null) {
-
- IResource resource= (IResource) adaptable.getAdapter(IResource.class);
- //special case when the .jar is a file
- try {
- if (resource instanceof IFile && ArchiveFileFilter.isArchivePath(resource.getFullPath())) {
- IProject proj= resource.getProject();
- if (proj.hasNature(JavaScriptCore.NATURE_ID)) {
- IJavaScriptProject jproject= JavaScriptCore.create(proj);
- elem= jproject.getPackageFragmentRoot(resource); // create a handle
- }
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return elem;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- if (fJavadocConfigurationBlock != null) {
- fJavadocConfigurationBlock.performDefaults();
- }
- super.performDefaults();
- }
-
- /**
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fJavadocConfigurationBlock != null) {
- URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation();
- if (javadocLocation == null && fInitalLocation == null || javadocLocation != null && javadocLocation.equals(fInitalLocation)) {
- return true; // no change
- }
-
-
- IJavaScriptElement elem= getJavaElement();
- try {
- IRunnableWithProgress runnable= getRunnable(getShell(), elem, javadocLocation, fEntry, fContainerPath);
- PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
- } catch (InvocationTargetException e) {
- String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title;
- String message= PreferencesMessages.SourceAttachmentPropertyPage_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
- }
- return true;
- }
-
-
- private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaScriptElement elem, final URL javadocLocation, final IIncludePathEntry entry, final IPath containerPath) {
- return new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- IJavaScriptProject project= elem.getJavaScriptProject();
- if (elem instanceof IPackageFragmentRoot) {
- CPListElement cpElem= CPListElement.createFromExisting(entry, project);
- String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null;
- cpElem.setAttribute(CPListElement.JAVADOC, loc);
- IIncludePathEntry newEntry= cpElem.getClasspathEntry();
- String[] changedAttributes= { CPListElement.JAVADOC };
- BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, monitor);
- } else {
- JavaScriptUI.setProjectJSdocLocation(project, javadocLocation);
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
- };
- }
-
-
- /**
- * @see IStatusChangeListener#statusChanged(IStatus)
- */
- public void statusChanged(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java
deleted file mode 100644
index f5fce56b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.ControlEnableState;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-
-/**
- */
-public class JavadocProblemsConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_JAVADOC_SUPPORT= getJDTCoreKey(JavaScriptCore.COMPILER_DOC_COMMENT_SUPPORT);
-
- private static final Key PREF_PB_INVALID_JAVADOC= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC);
- private static final Key PREF_PB_INVALID_JAVADOC_TAGS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC_TAGS);
- private static final Key PREF_PB_INVALID_JAVADOC_TAGS_NOT_VISIBLE_REF= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF);
- private static final Key PREF_PB_INVALID_JAVADOC_TAGS_DEPRECATED_REF= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF);
- private static final Key PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY);
-
- private static final Key PREF_PB_MISSING_JAVADOC_TAGS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_TAGS);
- private static final Key PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY);
- private static final Key PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING);
-
- private static final Key PREF_PB_MISSING_JAVADOC_COMMENTS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS);
- private static final Key PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY);
- private static final Key PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING);
-
-
- // values
- private static final String ERROR= JavaScriptCore.ERROR;
- private static final String WARNING= JavaScriptCore.WARNING;
- private static final String IGNORE= JavaScriptCore.IGNORE;
-
- private static final String ENABLED= JavaScriptCore.ENABLED;
- private static final String DISABLED= JavaScriptCore.DISABLED;
-
- private static final String PUBLIC= JavaScriptCore.PUBLIC;
- private static final String PROTECTED= JavaScriptCore.PROTECTED;
- private static final String DEFAULT= JavaScriptCore.DEFAULT;
- private static final String PRIVATE= JavaScriptCore.PRIVATE;
-
- private PixelConverter fPixelConverter;
- private Composite fJavadocComposite;
-
- private ControlEnableState fBlockEnableState;
-
-
- public JavadocProblemsConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getKeys(), container);
- fBlockEnableState= null;
- }
-
- private static Key[] getKeys() {
- Key[] keys= new Key[] {
- PREF_JAVADOC_SUPPORT,
- PREF_PB_INVALID_JAVADOC, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, PREF_PB_INVALID_JAVADOC_TAGS,
- PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
- PREF_PB_INVALID_JAVADOC_TAGS_NOT_VISIBLE_REF, PREF_PB_INVALID_JAVADOC_TAGS_DEPRECATED_REF,
- PREF_PB_MISSING_JAVADOC_TAGS, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING,
- PREF_PB_MISSING_JAVADOC_COMMENTS, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING,
- };
- return keys;
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
- setShell(parent.getShell());
-
- Composite javadocComposite= createJavadocTabContent(parent);
-
- validateSettings(null, null, null);
-
- return javadocComposite;
- }
-
-
- private Composite createJavadocTabContent(Composite folder) {
- String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
-
- String[] errorWarningIgnoreLabels= new String[] {
- PreferencesMessages.JavadocProblemsConfigurationBlock_error,
- PreferencesMessages.JavadocProblemsConfigurationBlock_warning,
- PreferencesMessages.JavadocProblemsConfigurationBlock_ignore
- };
-
- String[] enabledDisabled= new String[] { ENABLED, DISABLED };
-
- String[] visibilities= new String[] { PUBLIC, PROTECTED, DEFAULT, PRIVATE };
-
- String[] visibilitiesLabels= new String[] {
- PreferencesMessages.JavadocProblemsConfigurationBlock_public,
- PreferencesMessages.JavadocProblemsConfigurationBlock_protected,
- PreferencesMessages.JavadocProblemsConfigurationBlock_default,
- PreferencesMessages.JavadocProblemsConfigurationBlock_private
- };
- int nColumns= 3;
-
-
- final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
-
- Composite outer= sc1.getBody();
-
- GridLayout layout = new GridLayout();
- layout.numColumns= nColumns;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- outer.setLayout(layout);
-
- String label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_javadoc_support_label;
- addCheckBox(outer, label, PREF_JAVADOC_SUPPORT, enabledDisabled, 0);
-
- layout = new GridLayout();
- layout.numColumns= nColumns;
- layout.marginHeight= 0;
- //layout.marginWidth= 0;
-
- Composite composite= new Composite(outer, SWT.NONE);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
-
- fJavadocComposite= composite;
-
- Label description= new Label(composite, SWT.WRAP);
- description.setText(PreferencesMessages.JavadocProblemsConfigurationBlock_javadoc_description);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- //gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
- description.setLayoutData(gd);
-
- int indent= fPixelConverter.convertWidthInCharsToPixels(2);
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_invalid_javadoc_label;
- addComboBox(composite, label, PREF_PB_INVALID_JAVADOC, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_visibility_label;
- addComboBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
-
- label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_label;
- addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS, enabledDisabled, indent);
-
- label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_not_visible_ref_label;
- addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_NOT_VISIBLE_REF, enabledDisabled, indent);
-
- label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_deprecated_label;
- addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_DEPRECATED_REF, enabledDisabled, indent);
-
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= nColumns;
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_javadoc_label;
- addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_visibility_label;
- addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
-
- label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_overriding_label;
- addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING, enabledDisabled, indent);
-
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= nColumns;
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_comments_label;
- addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
- label = PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_comments_visibility_label;
- addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, visibilities, visibilitiesLabels, indent);
-
- label= PreferencesMessages.JavadocProblemsConfigurationBlock_pb_missing_comments_overriding_label;
- addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, enabledDisabled, indent);
-
- return sc1;
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (!areSettingsEnabled()) {
- return;
- }
-
- if (changedKey != null) {
- if (PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
- PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
- PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
- PREF_JAVADOC_SUPPORT.equals(changedKey)) {
- updateEnableStates();
- } else {
- return;
- }
- } else {
- updateEnableStates();
- }
- fContext.statusChanged(new StatusInfo());
- }
-
- private void updateEnableStates() {
- boolean enableJavadoc= checkValue(PREF_JAVADOC_SUPPORT, ENABLED);
- enableConfigControls(enableJavadoc);
-
- if (enableJavadoc) {
- boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC, IGNORE);
- getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors);
- getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS_NOT_VISIBLE_REF).setEnabled(enableInvalidTagsErrors);
- getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS_DEPRECATED_REF).setEnabled(enableInvalidTagsErrors);
- setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, enableInvalidTagsErrors);
-
- boolean enableMissingTagsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE);
- getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors);
- setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, enableMissingTagsErrors);
-
- boolean enableMissingCommentsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE);
- getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors);
- setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, enableMissingCommentsErrors);
- }
- }
-
- protected void enableConfigControls(boolean enable) {
- if (enable) {
- if (fBlockEnableState != null) {
- fBlockEnableState.restore();
- fBlockEnableState= null;
- }
- } else {
- if (fBlockEnableState == null) {
- fBlockEnableState= ControlEnableState.disable(fJavadocComposite);
- }
- }
- }
-
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.JavadocProblemsConfigurationBlock_needsbuild_title;
- String message;
- if (workspaceSettings) {
- message= PreferencesMessages.JavadocProblemsConfigurationBlock_needsfullbuild_message;
- } else {
- message= PreferencesMessages.JavadocProblemsConfigurationBlock_needsprojectbuild_message;
- }
- return new String[] { title, message };
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsPreferencePage.java
deleted file mode 100644
index 70f51833..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/JavadocProblemsPreferencePage.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Page used to configure both workspace and project specific compiler settings
- */
-public class JavadocProblemsPreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.JavadocProblemsPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.JavadocProblemsPreferencePage"; //$NON-NLS-1$
-
- private JavadocProblemsConfigurationBlock fConfigurationBlock;
-
- public JavadocProblemsPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.getString("JavadocProblemsPreferencePage.description")); //$NON-NLS-1$
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.JavadocProblemsPreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new JavadocProblemsConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- if (isProjectPreferencePage()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVADOC_PROBLEMS_PROPERTY_PAGE);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVADOC_PROBLEMS_PREFERENCE_PAGE);
- }
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
deleted file mode 100644
index 46fb9947..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Configures Java Editor hover preferences.
- *
- *
- */
-class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock {
-
- private OverlayPreferenceStore fStore;
-
-
- private Map fCheckBoxes= new HashMap();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
- /**
- * List of master/slave listeners when there's a dependency.
- *
- * @see #createDependency(Button, String, Control)
- *
- */
- private ArrayList fMasterSlaveListeners= new ArrayList();
-
- private StatusInfo fStatus;
-
- public MarkOccurrencesConfigurationBlock(OverlayPreferenceStore store) {
- Assert.isNotNull(store);
- fStore= store;
-
- fStore.addKeys(createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_IMPLEMENTORS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates page for mark occurrences preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(final Composite parent) {
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- Link link= new Link(composite, SWT.NONE);
- link.setText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
- }
- });
- // TODO replace by link-specific tooltips when
- // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
- link.setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip);
-
- addFiller(composite);
-
- String label;
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences;
- Button master= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
-
- addFiller(composite);
-
-// label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markTypeOccurrences;
-// Button slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES, 0);
-// createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markMethodOccurrences;
- Button slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES, 0);
- createDependency(master, PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES, slave);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markConstantOccurrences;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES, 0);
- createDependency(master, PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES, slave);
-
-// label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markFieldOccurrences;
-// slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES, 0);
-// createDependency(master, PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES, slave);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markLocalVariableOccurrences;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES, 0);
- createDependency(master, PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES, slave);
-
-// label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markExceptionOccurrences;
-// slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES, 0);
-// createDependency(master, PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES, slave);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markMethodExitPoints;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS, 0);
- createDependency(master, PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS, slave);
-
-// label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markImplementors;
-// slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_IMPLEMENTORS, 0);
-// createDependency(master, PreferenceConstants.EDITOR_MARK_IMPLEMENTORS, slave);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markBreakContinueTargets;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS, 0);
- createDependency(master, PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS, slave);
-
- addFiller(composite);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0);
- createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
-
- return composite;
- }
-
- private void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
-
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
- filler.setLayoutData(gd);
- }
-
- 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.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- private void createDependency(final Button master, String masterKey, final Control slave) {
- indent(slave);
- boolean masterState= fStore.getBoolean(masterKey);
- slave.setEnabled(masterState);
- SelectionListener listener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- slave.setEnabled(master.getSelection());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
- master.addSelectionListener(listener);
- fMasterSlaveListeners.add(listener);
- }
-
- private static void indent(Control control) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= 10;
- control.setLayoutData(gridData);
- }
-
- public void initialize() {
- initializeFields();
- }
-
- void initializeFields() {
-
- Iterator iter= fCheckBoxes.keySet().iterator();
- while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= (String) fCheckBoxes.get(b);
- b.setSelection(fStore.getBoolean(key));
- }
-
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
-
- }
-
- public void performOk() {
- }
-
- public void performDefaults() {
- restoreFromPreferences();
- initializeFields();
- }
-
- private void restoreFromPreferences() {
-
- }
-
- IStatus getStatus() {
- if (fStatus == null)
- fStatus= new StatusInfo();
- return fStatus;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
- *
- */
- public void dispose() {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
deleted file mode 100644
index 14c8c198..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * The page for setting the editor options.
- */
-public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.MarkOccurrencesConfigurationBlock_title;
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null; // no description for new look.
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new MarkOccurrencesConfigurationBlock(overlayPreferenceStore);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferenceCache.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferenceCache.java
deleted file mode 100644
index f26715f9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferenceCache.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- */
-public class MembersOrderPreferenceCache implements IPropertyChangeListener {
-
- public static final int TYPE_INDEX= 0;
- public static final int CONSTRUCTORS_INDEX= 1;
- public static final int METHOD_INDEX= 2;
- public static final int FIELDS_INDEX= 3;
- public static final int INIT_INDEX= 4;
- public static final int STATIC_FIELDS_INDEX= 5;
- public static final int STATIC_INIT_INDEX= 6;
- public static final int STATIC_METHODS_INDEX= 7;
- public static final int ENUM_CONSTANTS_INDEX= 8;
- public static final int N_CATEGORIES= ENUM_CONSTANTS_INDEX + 1;
-
- private static final int PUBLIC_INDEX= 0;
- private static final int PRIVATE_INDEX= 1;
- private static final int PROTECTED_INDEX= 2;
- private static final int DEFAULT_INDEX= 3;
- private static final int N_VISIBILITIES= DEFAULT_INDEX + 1;
-
- private int[] fCategoryOffsets= null;
-
- private boolean fSortByVisibility;
- private int[] fVisibilityOffsets= null;
-
- private IPreferenceStore fPreferenceStore;
-
- public MembersOrderPreferenceCache() {
- fPreferenceStore= null;
- fCategoryOffsets= null;
- fSortByVisibility= false;
- fVisibilityOffsets= null;
- }
-
- public void install(IPreferenceStore store) {
- fPreferenceStore= store;
- store.addPropertyChangeListener(this);
- fSortByVisibility= store.getBoolean(PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER);
- }
-
- public void dispose() {
- fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore= null;
- }
-
- public static boolean isMemberOrderProperty(String property) {
- return PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(property)
- || PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)
- || PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String property= event.getProperty();
-
- if (PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(property)) {
- fCategoryOffsets= null;
- } else if (PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)) {
- fVisibilityOffsets= null;
- } else if (PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property)) {
- fSortByVisibility= fPreferenceStore.getBoolean(PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER);
- }
- }
-
- public int getCategoryIndex(int kind) {
- if (fCategoryOffsets == null) {
- fCategoryOffsets= getCategoryOffsets();
- }
- return fCategoryOffsets[kind];
- }
-
- private int[] getCategoryOffsets() {
- int[] offsets= new int[N_CATEGORIES];
- IPreferenceStore store= fPreferenceStore;
- String key= PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER;
- boolean success= fillCategoryOffsetsFromPreferenceString(store.getString(key), offsets);
- if (!success) {
- store.setToDefault(key);
- fillCategoryOffsetsFromPreferenceString(store.getDefaultString(key), offsets);
- }
- return offsets;
- }
-
- private boolean fillCategoryOffsetsFromPreferenceString(String str, int[] offsets) {
- StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
- int i= 0;
- offsets[ENUM_CONSTANTS_INDEX]= i++; // enum constants always on top
-
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if ("T".equals(token)) { //$NON-NLS-1$
- offsets[TYPE_INDEX]= i++;
- } else if ("M".equals(token)) { //$NON-NLS-1$
- offsets[METHOD_INDEX]= i++;
- } else if ("F".equals(token)) { //$NON-NLS-1$
- offsets[FIELDS_INDEX]= i++;
- } else if ("I".equals(token)) { //$NON-NLS-1$
- offsets[INIT_INDEX]= i++;
- } else if ("SF".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_FIELDS_INDEX]= i++;
- } else if ("SI".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_INIT_INDEX]= i++;
- } else if ("SM".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_METHODS_INDEX]= i++;
- } else if ("C".equals(token)) { //$NON-NLS-1$
- offsets[CONSTRUCTORS_INDEX]= i++;
- }
- }
- return i == N_CATEGORIES;
- }
-
- public boolean isSortByVisibility() {
- return fSortByVisibility;
- }
-
- public int getVisibilityIndex(int modifierFlags) {
- if (fVisibilityOffsets == null) {
- fVisibilityOffsets= getVisibilityOffsets();
- }
- int kind= DEFAULT_INDEX;
- if (Flags.isPublic(modifierFlags)) {
- kind= PUBLIC_INDEX;
- } else if (Flags.isProtected(modifierFlags)) {
- kind= PROTECTED_INDEX;
- } else if (Flags.isPrivate(modifierFlags)) {
- kind= PRIVATE_INDEX;
- }
-
- return fVisibilityOffsets[kind];
- }
-
- private int[] getVisibilityOffsets() {
- int[] offsets= new int[N_VISIBILITIES];
- IPreferenceStore store= fPreferenceStore;
- String key= PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER;
- boolean success= fillVisibilityOffsetsFromPreferenceString(store.getString(key), offsets);
- if (!success) {
- store.setToDefault(key);
- fillVisibilityOffsetsFromPreferenceString(store.getDefaultString(key), offsets);
- }
- return offsets;
- }
-
- private boolean fillVisibilityOffsetsFromPreferenceString(String str, int[] offsets) {
- StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
- int i= 0;
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if ("B".equals(token)) { //$NON-NLS-1$
- offsets[PUBLIC_INDEX]= i++;
- } else if ("V".equals(token)) { //$NON-NLS-1$
- offsets[PRIVATE_INDEX]= i++;
- } else if ("R".equals(token)) { //$NON-NLS-1$
- offsets[PROTECTED_INDEX]= i++;
- } else if ("D".equals(token)) { //$NON-NLS-1$
- offsets[DEFAULT_INDEX]= i++;
- }
- }
- return i == N_VISIBILITIES;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferencePage.java
deleted file mode 100644
index 0190ed97..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MembersOrderPreferencePage.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-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.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class MembersOrderPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.MembersOrderPreferencePage"; //$NON-NLS-1$
-
-// private static final String ALL_SORTMEMBER_ENTRIES= "T,SI,SF,SM,I,F,C,M"; //$NON-NLS-1$
- private static final String ALL_SORTMEMBER_ENTRIES= "T,F,C,M"; //$NON-NLS-1$
- private static final String ALL_VISIBILITY_ENTRIES= "B,V,R,D"; //$NON-NLS-1$
- private static final String PREF_OUTLINE_SORT_OPTION= PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER;
- private static final String PREF_VISIBILITY_SORT_OPTION= PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER;
- private static final String PREF_USE_VISIBILITY_SORT_OPTION= PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER;
-
- public static final String CONSTRUCTORS= "C"; //$NON-NLS-1$
-// public static final String FIELDS= "F"; //$NON-NLS-1$
- public static final String VARS= "F"; //$NON-NLS-1$
- public static final String METHODS= "M"; //$NON-NLS-1$
-// public static final String STATIC_METHODS= "SM"; //$NON-NLS-1$
-// public static final String STATIC_FIELDS= "SF"; //$NON-NLS-1$
- public static final String INIT= "I"; //$NON-NLS-1$
-// public static final String STATIC_INIT= "SI"; //$NON-NLS-1$
- public static final String TYPES= "T"; //$NON-NLS-1$
-
- public static final String PUBLIC= "B"; //$NON-NLS-1$
- public static final String PRIVATE= "V"; //$NON-NLS-1$
- public static final String PROTECTED= "R"; //$NON-NLS-1$
- public static final String DEFAULT= "D"; //$NON-NLS-1$
-
- private boolean fUseVisibilitySort;
- private ListDialogField fSortOrderList;
- private ListDialogField fVisibilityOrderList;
- private SelectionButtonDialogField fUseVisibilitySortField;
-
- private static boolean isValidEntries(List entries, String entryString) {
- StringTokenizer tokenizer= new StringTokenizer(entryString, ","); //$NON-NLS-1$
- int i= 0;
- for (; tokenizer.hasMoreTokens(); i++) {
- String token= tokenizer.nextToken();
- if (!entries.contains(token))
- return false;
- }
- return i == entries.size();
- }
-
- public MembersOrderPreferencePage() {
- //set the preference store
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
-
- setDescription(PreferencesMessages.MembersOrderPreferencePage_label_description);
-
-// String memberSortString= getPreferenceStore().getString(PREF_OUTLINE_SORT_OPTION);
- String memberSortString = ALL_SORTMEMBER_ENTRIES;
-
- String upLabel= PreferencesMessages.MembersOrderPreferencePage_category_button_up;
- String downLabel= PreferencesMessages.MembersOrderPreferencePage_category_button_down;
-
- // category sort
-
- fSortOrderList= new ListDialogField(null, new String[] { upLabel, downLabel }, new MemberSortLabelProvider());
- fSortOrderList.setDownButtonIndex(1);
- fSortOrderList.setUpButtonIndex(0);
-
- //validate entries stored in store, false get defaults
- List entries= parseList(memberSortString);
- if (!isValidEntries(entries, ALL_SORTMEMBER_ENTRIES)) {
- memberSortString= getPreferenceStore().getDefaultString(PREF_OUTLINE_SORT_OPTION);
- entries= parseList(memberSortString);
- }
-
- fSortOrderList.setElements(entries);
-
- // visibility sort
-
- fUseVisibilitySort= getPreferenceStore().getBoolean(PREF_USE_VISIBILITY_SORT_OPTION);
-
- String visibilitySortString= getPreferenceStore().getString(PREF_VISIBILITY_SORT_OPTION);
-
- upLabel= PreferencesMessages.MembersOrderPreferencePage_visibility_button_up;
- downLabel= PreferencesMessages.MembersOrderPreferencePage_visibility_button_down;
-
- fVisibilityOrderList= new ListDialogField(null, new String[] { upLabel, downLabel }, new VisibilitySortLabelProvider());
- fVisibilityOrderList.setDownButtonIndex(1);
- fVisibilityOrderList.setUpButtonIndex(0);
-
- //validate entries stored in store, false get defaults
- entries= parseList(visibilitySortString);
- if (!isValidEntries(entries, ALL_VISIBILITY_ENTRIES)) {
- visibilitySortString= getPreferenceStore().getDefaultString(PREF_VISIBILITY_SORT_OPTION);
- entries= parseList(visibilitySortString);
- }
- fVisibilityOrderList.setElements(entries);
- }
-
- private static List parseList(String string) {
- StringTokenizer tokenizer= new StringTokenizer(string, ","); //$NON-NLS-1$
- List entries= new ArrayList();
- for (int i= 0; tokenizer.hasMoreTokens(); i++) {
- String token= tokenizer.nextToken();
- entries.add(token);
- }
- return entries;
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.SORT_ORDER_PREFERENCE_PAGE);
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- // Create both the dialog lists
- Composite sortComposite= new Composite(parent, SWT.NONE);
- sortComposite.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- sortComposite.setLayout(layout);
-
- GridData gd= new GridData();
- gd.verticalAlignment= GridData.FILL;
- gd.horizontalAlignment= GridData.FILL_HORIZONTAL;
- sortComposite.setLayoutData(gd);
-
- createListDialogField(sortComposite, fSortOrderList);
-
- fUseVisibilitySortField= new SelectionButtonDialogField(SWT.CHECK);
- fUseVisibilitySortField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- fVisibilityOrderList.setEnabled(fUseVisibilitySortField.isSelected());
- }
- });
- fUseVisibilitySortField.setLabelText(PreferencesMessages.MembersOrderPreferencePage_usevisibilitysort_label);
- fUseVisibilitySortField.doFillIntoGrid(sortComposite, 2);
- fUseVisibilitySortField.setSelection(fUseVisibilitySort);
-
- createListDialogField(sortComposite, fVisibilityOrderList);
- fVisibilityOrderList.setEnabled(fUseVisibilitySortField.isSelected());
-
- Dialog.applyDialogFont(sortComposite);
-
- return sortComposite;
- }
-
-
- private void createListDialogField(Composite composite, ListDialogField dialogField) {
- Control list= dialogField.getListControl(composite);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.widthHint= convertWidthInCharsToPixels(50);
-
- list.setLayoutData(gd);
-
- Composite buttons= dialogField.getButtonBox(composite);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
-
- buttons.setLayoutData(gd);
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore prefs= JavaScriptPlugin.getDefault().getPreferenceStore();
- String str= prefs.getDefaultString(PREF_OUTLINE_SORT_OPTION);
- if (str != null)
- fSortOrderList.setElements(parseList(str));
- else
- fSortOrderList.setElements(parseList(ALL_SORTMEMBER_ENTRIES));
-
- str= prefs.getDefaultString(PREF_VISIBILITY_SORT_OPTION);
- if (str != null)
- fVisibilityOrderList.setElements(parseList(str));
- else
- fVisibilityOrderList.setElements(parseList(ALL_VISIBILITY_ENTRIES));
-
- fUseVisibilitySortField.setSelection(prefs.getDefaultBoolean(PREF_USE_VISIBILITY_SORT_OPTION));
-
- super.performDefaults();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- //reorders elements in the Outline based on selection
- public boolean performOk() {
-
- //save preferences for both dialog lists
- IPreferenceStore store= getPreferenceStore();
- updateList(store, fSortOrderList, PREF_OUTLINE_SORT_OPTION);
- updateList(store, fVisibilityOrderList, PREF_VISIBILITY_SORT_OPTION);
-
- //update the button setting
- store.setValue(PREF_USE_VISIBILITY_SORT_OPTION, fUseVisibilitySortField.isSelected());
- JavaScriptPlugin.getDefault().savePluginPreferences();
-
- return true;
- }
-
- private void updateList(IPreferenceStore store, ListDialogField list, String str) {
- StringBuffer buf= new StringBuffer();
- List curr= list.getElements();
- for (Iterator iter= curr.iterator(); iter.hasNext();) {
- String s= (String) iter.next();
- buf.append(s);
- buf.append(',');
- }
- store.setValue(str, buf.toString());
- }
-
- private class MemberSortLabelProvider extends LabelProvider {
-
- public MemberSortLabelProvider() {
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
- */
- public Image getImage(Object element) {
- //access to image registry
- ImageDescriptorRegistry registry= JavaScriptPlugin.getImageDescriptorRegistry();
- ImageDescriptor descriptor= null;
-
- if (element instanceof String) {
- int visibility= Flags.AccPublic;
- String s= (String) element;
-// if (s.equals(FIELDS)) {
- if (s.equals(VARS)) {
- //0 will give the default field image
- descriptor= JavaElementImageProvider.getFieldImageDescriptor(false, visibility);
- } else if (s.equals(CONSTRUCTORS)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
- //add a constructor adornment to the image descriptor
- descriptor= new JavaScriptElementImageDescriptor(descriptor, JavaScriptElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE);
- } else if (s.equals(METHODS)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
-// } else if (s.equals(STATIC_FIELDS)) {
-// descriptor= JavaElementImageProvider.getFieldImageDescriptor(false, visibility);
- //add a static fields adornment to the image descriptor
-// descriptor= new JavaScriptElementImageDescriptor(descriptor, JavaScriptElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
-// } else if (s.equals(STATIC_METHODS)) {
-// descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
- //add a static methods adornment to the image descriptor
-// descriptor= new JavaScriptElementImageDescriptor(descriptor, JavaScriptElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
- } else if (s.equals(INIT)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
-// } else if (s.equals(STATIC_INIT)) {
-// descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
-// descriptor= new JavaScriptElementImageDescriptor(descriptor, JavaScriptElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
- } else if (s.equals(TYPES)) {
- descriptor= JavaElementImageProvider.getTypeImageDescriptor(true, false, Flags.AccPublic, false);
- } else {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, Flags.AccPublic);
- }
- return registry.get(descriptor);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
-
- if (element instanceof String) {
- String s= (String) element;
-// if (s.equals(FIELDS)) {
- if (s.equals(VARS)) {
-// return PreferencesMessages.MembersOrderPreferencePage_fields_label;
- return PreferencesMessages.MembersOrderPreferencePage_vars_label;
- } else if (s.equals(METHODS)) {
- return PreferencesMessages.MembersOrderPreferencePage_methods_label;
-// } else if (s.equals(STATIC_FIELDS)) {
-// return PreferencesMessages.MembersOrderPreferencePage_staticfields_label;
-// } else if (s.equals(STATIC_METHODS)) {
-// return PreferencesMessages.MembersOrderPreferencePage_staticmethods_label;
- } else if (s.equals(CONSTRUCTORS)) {
- return PreferencesMessages.MembersOrderPreferencePage_constructors_label;
- } else if (s.equals(INIT)) {
- return PreferencesMessages.MembersOrderPreferencePage_initialisers_label;
-// } else if (s.equals(STATIC_INIT)) {
-// return PreferencesMessages.MembersOrderPreferencePage_staticinitialisers_label;
- } else if (s.equals(TYPES)) {
- return PreferencesMessages.MembersOrderPreferencePage_types_label;
- }
- }
- return ""; //$NON-NLS-1$
- }
- }
-
-
- private class VisibilitySortLabelProvider extends LabelProvider {
-
- public VisibilitySortLabelProvider() {
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
- */
- public Image getImage(Object element) {
- //access to image registry
- ImageDescriptorRegistry registry= JavaScriptPlugin.getImageDescriptorRegistry();
- ImageDescriptor descriptor= null;
-
- if (element instanceof String) {
- String s= (String) element;
- if (s.equals(PUBLIC)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, Flags.AccPublic);
- } else if (s.equals(PRIVATE)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, Flags.AccPrivate);
- } else if (s.equals(PROTECTED)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, Flags.AccProtected);
- } else if (s.equals(DEFAULT)) {
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, Flags.AccDefault);
- }
- return registry.get(descriptor);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
- if (element instanceof String) {
- String s= (String) element;
-
- if (s.equals(PUBLIC)) {
- return PreferencesMessages.MembersOrderPreferencePage_public_label;
- } else if (s.equals(PRIVATE)) {
- return PreferencesMessages.MembersOrderPreferencePage_private_label;
- } else if (s.equals(PROTECTED)) {
- return PreferencesMessages.MembersOrderPreferencePage_protected_label;
- } else if (s.equals(DEFAULT)) {
- return PreferencesMessages.MembersOrderPreferencePage_default_label;
- }
- }
- return ""; //$NON-NLS-1$
- }
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MockupPreferenceStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MockupPreferenceStore.java
deleted file mode 100644
index 7c95f882..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/MockupPreferenceStore.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-/**
- * Mockup preference store, for registering listeners and firing events,
- * without being an actual store.
- * <p>
- * All methods except firing, adding and removing listeners throw
- * an {@link java.lang.UnsupportedOperationException}.
- * </p>
- *
- *
- */
-public class MockupPreferenceStore implements IPreferenceStore {
-
- /** Listeners on this store */
- private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
-
- /**
- * {@inheritDoc}
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- fListeners.add(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fListeners.remove(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean contains(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- firePropertyChangeEvent(this, name, oldValue, newValue);
- }
-
- /**
- * Fires a property change event with the given source, property name, old and new value. Used
- * when the event source should be different from this mockup preference store.
- * @param source The event source
- * @param name The property name
- * @param oldValue The property's old value
- * @param newValue The property's new value
- */
- public void firePropertyChangeEvent(Object source, String name, Object oldValue, Object newValue) {
- PropertyChangeEvent event= new PropertyChangeEvent(source, name, oldValue, newValue);
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++)
- ((IPropertyChangeListener) listeners[i]).propertyChange(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getBoolean(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getDefaultBoolean(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDefaultDouble(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public float getDefaultFloat(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getDefaultInt(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public long getDefaultLong(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDefaultString(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public double getDouble(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public float getFloat(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getInt(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public long getLong(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public String getString(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDefault(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean needsSaving() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void putValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, String defaultObject) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDefault(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setToDefault(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setValue(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NameConventionConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NameConventionConfigurationBlock.java
deleted file mode 100644
index a2ccf839..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NameConventionConfigurationBlock.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-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.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/*
- * The page to configure name conventions
- */
-public class NameConventionConfigurationBlock extends OptionsConfigurationBlock {
-
- private final static int FIELD= 1;
- private final static int STATIC= 2;
- private final static int ARGUMENT= 3;
- private final static int LOCAL= 4;
-
- // Preference store keys
- private static final Key PREF_FIELD_PREFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_FIELD_PREFIXES);
- private static final Key PREF_FIELD_SUFFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_FIELD_SUFFIXES);
- private static final Key PREF_STATIC_FIELD_PREFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES);
- private static final Key PREF_STATIC_FIELD_SUFFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES);
- private static final Key PREF_ARGUMENT_PREFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_ARGUMENT_PREFIXES);
- private static final Key PREF_ARGUMENT_SUFFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_ARGUMENT_SUFFIXES);
- private static final Key PREF_LOCAL_PREFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_LOCAL_PREFIXES);
- private static final Key PREF_LOCAL_SUFFIXES= getJDTCoreKey(JavaScriptCore.CODEASSIST_LOCAL_SUFFIXES);
-
- private static final Key PREF_KEYWORD_THIS= getJDTUIKey(PreferenceConstants.CODEGEN_KEYWORD_THIS);
- private static final Key PREF_IS_FOR_GETTERS= getJDTUIKey(PreferenceConstants.CODEGEN_IS_FOR_GETTERS);
- private static final Key PREF_EXCEPTION_NAME= getJDTUIKey(PreferenceConstants.CODEGEN_EXCEPTION_VAR_NAME);
-
- private static final Key PREF_USE_OVERRIDE_ANNOT= getJDTUIKey(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION);
- private static final Key PREF_GENERATE_COMMENTS= getJDTUIKey(PreferenceConstants.CODEGEN_ADD_COMMENTS);
-
- private static class NameConventionEntry {
- public int kind;
- public String prefix;
- public String suffix;
- public Key prefixkey;
- public Key suffixkey;
- }
-
- private class NameConventionInputDialog extends StatusDialog implements IDialogFieldListener {
-
- private StringDialogField fPrefixField;
- private StringDialogField fSuffixField;
- private NameConventionEntry fEntry;
- private DialogField fMessageField;
-
- public NameConventionInputDialog(Shell parent, String title, String message, NameConventionEntry entry) {
- super(parent);
- fEntry= entry;
-
- setTitle(title);
-
- fMessageField= new DialogField();
- fMessageField.setLabelText(message);
-
- fPrefixField= new StringDialogField();
- fPrefixField.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_dialog_prefix);
- fPrefixField.setDialogFieldListener(this);
-
- fSuffixField= new StringDialogField();
- fSuffixField.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_dialog_suffix);
- fSuffixField.setDialogFieldListener(this);
-
- fPrefixField.setText(entry.prefix);
- fSuffixField.setText(entry.suffix);
- }
-
- public NameConventionEntry getResult() {
- NameConventionEntry res= new NameConventionEntry();
- res.prefix= Strings.removeTrailingCharacters(fPrefixField.getText(), ',');
- res.suffix= Strings.removeTrailingCharacters(fSuffixField.getText(), ',');
- res.prefixkey= fEntry.prefixkey;
- res.suffixkey= fEntry.suffixkey;
- res.kind= fEntry.kind;
- return res;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setFont(composite.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- inner.setLayout(layout);
-
- fMessageField.doFillIntoGrid(inner, 2);
- fPrefixField.doFillIntoGrid(inner, 2);
- fSuffixField.doFillIntoGrid(inner, 2);
-
- LayoutUtil.setHorizontalGrabbing(fPrefixField.getTextControl(null));
- LayoutUtil.setWidthHint(fPrefixField.getTextControl(null), convertWidthInCharsToPixels(45));
- LayoutUtil.setWidthHint(fSuffixField.getTextControl(null), convertWidthInCharsToPixels(45));
-
- fPrefixField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CODE_STYLE_EDIT_PREFIX_SUFFIX);
-
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- // validate
- IStatus prefixStatus= validateIdentifiers(getTokens(fPrefixField.getText(), ","), true); //$NON-NLS-1$
- IStatus suffixStatus= validateIdentifiers(getTokens(fSuffixField.getText(), ","), false); //$NON-NLS-1$
-
- updateStatus(StatusUtil.getMoreSevere(suffixStatus, prefixStatus));
- }
-
- private IStatus validateIdentifiers(String[] values, boolean prefix) {
- for (int i= 0; i < values.length; i++) {
- String val= values[i];
- if (val.length() == 0) {
- if (prefix) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptyprefix);
- } else {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptysuffix);
- }
- }
- String name= prefix ? val + "x" : "x" + val; //$NON-NLS-2$ //$NON-NLS-1$
- IStatus status= JavaScriptConventions.validateFieldName(name);
- if (status.matches(IStatus.ERROR)) {
- if (prefix) {
- return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidprefix, val));
- } else {
- return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidsuffix, val));
- }
- }
- }
- return new StatusInfo();
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.IMPORT_ORGANIZE_INPUT_DIALOG);
- }
- }
-
- private static class NameConventionLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return getColumnImage(element, 0);
- }
-
- /* (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) {
- if (columnIndex != 0) {
- return null;
- }
-
- NameConventionEntry entry= (NameConventionEntry) element;
- ImageDescriptorRegistry registry= JavaScriptPlugin.getImageDescriptorRegistry();
- switch (entry.kind) {
- case FIELD:
- return registry.get(JavaPluginImages.DESC_FIELD_PUBLIC);
- case STATIC:
- return registry.get(new JavaScriptElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaScriptElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE));
- case ARGUMENT:
- return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
- default:
- return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- NameConventionEntry entry= (NameConventionEntry) element;
- if (columnIndex == 0) {
- switch (entry.kind) {
- case FIELD:
- return PreferencesMessages.NameConventionConfigurationBlock_field_label;
- case STATIC:
- return PreferencesMessages.NameConventionConfigurationBlock_static_label;
- case ARGUMENT:
- return PreferencesMessages.NameConventionConfigurationBlock_arg_label;
- default:
- return PreferencesMessages.NameConventionConfigurationBlock_local_label;
- }
- } else if (columnIndex == 1) {
- return entry.prefix;
- } else {
- return entry.suffix;
- }
- }
- }
-
- private class NameConventionAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(ListDialogField field) {
- return field.getSelectedElements().size() == 1;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doEditButtonPressed();
- }
-
- public void selectionChanged(ListDialogField field) {
- field.enableButton(0, canEdit(field));
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field)) {
- doEditButtonPressed();
- }
- }
-
- public void dialogFieldChanged(DialogField field) {
- updateModel(field);
- }
- }
-
- private ListDialogField fNameConventionList;
-// private SelectionButtonDialogField fUseKeywordThisBox;
- private SelectionButtonDialogField fUseIsForBooleanGettersBox;
-
- private StringDialogField fExceptionName;
-// Commented out next 1 line (STP 20070430)
-// private SelectionButtonDialogField fUseOverrideAnnotation;
- private SelectionButtonDialogField fGenerateComments;
-
-
- public NameConventionConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getAllKeys(), container);
-
- NameConventionAdapter adapter= new NameConventionAdapter();
- String[] buttons= new String[] {
- PreferencesMessages.NameConventionConfigurationBlock_list_edit_button
- };
- fNameConventionList= new ListDialogField(adapter, buttons, new NameConventionLabelProvider());
- fNameConventionList.setDialogFieldListener(adapter);
- fNameConventionList.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_list_label);
-
- String[] columnsHeaders= new String[] {
- PreferencesMessages.NameConventionConfigurationBlock_list_name_column,
- PreferencesMessages.NameConventionConfigurationBlock_list_prefix_column,
- PreferencesMessages.NameConventionConfigurationBlock_list_suffix_column,
- };
- ColumnLayoutData[] data= new ColumnLayoutData[] {
- new ColumnWeightData(3),
- new ColumnWeightData(2),
- new ColumnWeightData(2)
- };
-
- fNameConventionList.setTableColumns(new ListDialogField.ColumnsDescription(data, columnsHeaders, true));
-
- if (fNameConventionList.getSize() > 0) {
- fNameConventionList.selectFirstElement();
- } else {
- fNameConventionList.enableButton(0, false);
- }
-
- fExceptionName= new StringDialogField();
- fExceptionName.setDialogFieldListener(adapter);
- fExceptionName.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_exceptionname_label);
-
-// fUseKeywordThisBox= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
-// fUseKeywordThisBox.setDialogFieldListener(adapter);
-// fUseKeywordThisBox.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_keywordthis_label);
-
- fUseIsForBooleanGettersBox= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
- fUseIsForBooleanGettersBox.setDialogFieldListener(adapter);
- fUseIsForBooleanGettersBox.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_isforbooleangetters_label);
-
-// Commented out next 3 lines (STP 20070430)
-// fUseOverrideAnnotation= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
-// fUseOverrideAnnotation.setDialogFieldListener(adapter);
-// fUseOverrideAnnotation.setLabelText(PreferencesMessages.NameConventionConfigurationBlock_use_override_annotation_label);
-
- fGenerateComments= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
- fGenerateComments.setDialogFieldListener(adapter);
- fGenerateComments.setLabelText(PreferencesMessages.CodeTemplateBlock_createcomment_label);
-
- updateControls();
- }
-
- private static Key[] getAllKeys() {
- return new Key[] {
- PREF_FIELD_PREFIXES, PREF_FIELD_SUFFIXES, PREF_STATIC_FIELD_PREFIXES, PREF_STATIC_FIELD_SUFFIXES,
- PREF_ARGUMENT_PREFIXES, PREF_ARGUMENT_SUFFIXES, PREF_LOCAL_PREFIXES, PREF_LOCAL_SUFFIXES,
- PREF_EXCEPTION_NAME, PREF_KEYWORD_THIS, PREF_IS_FOR_GETTERS, PREF_USE_OVERRIDE_ANNOT, PREF_GENERATE_COMMENTS
- };
- }
-
- protected Control createContents(Composite parent) {
- setShell(parent.getShell());
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- composite.setLayout(layout);
-
- fNameConventionList.doFillIntoGrid(composite, 4);
- LayoutUtil.setHorizontalSpan(fNameConventionList.getLabelControl(null), 2);
- Table table= fNameConventionList.getTableViewer().getTable();
- GridData data= (GridData)fNameConventionList.getListControl(null).getLayoutData();
- data.heightHint= SWTUtil.getTableHeightHint(table, 5);
- data.grabExcessHorizontalSpace= true;
- data.verticalAlignment= GridData.BEGINNING;
- data.grabExcessVerticalSpace= false;
-
- data= (GridData)fNameConventionList.getButtonBox(null).getLayoutData();
- data.grabExcessVerticalSpace= false;
- data.verticalAlignment= GridData.BEGINNING;
-
-// fUseKeywordThisBox.doFillIntoGrid(composite, 3);
- fUseIsForBooleanGettersBox.doFillIntoGrid(composite, 3);
- DialogField.createEmptySpace(composite, 3);
-
- fGenerateComments.doFillIntoGrid(composite, 3);
-// Commented out next 1 line (STP 20070430)
-// fUseOverrideAnnotation.doFillIntoGrid(composite, 3);
- DialogField.createEmptySpace(composite, 3);
-
- fExceptionName.doFillIntoGrid(composite, 2);
-
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String, java.lang.String)
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- // no validation here
- }
-
- protected final void updateModel(DialogField field) {
- if (field == fNameConventionList) {
- for (int i= 0; i < fNameConventionList.getSize(); i++) {
- NameConventionEntry entry= (NameConventionEntry) fNameConventionList.getElement(i);
- setValue(entry.suffixkey, entry.suffix);
- setValue(entry.prefixkey, entry.prefix);
- }
- } else if (field == fExceptionName) {
- String name= fExceptionName.getText();
-
- setValue(PREF_EXCEPTION_NAME, name);
-
- // validation
- IStatus status = JavaScriptConventions.validateIdentifier(name);
- if (!status.isOK()) {
- fContext.statusChanged(status);
- } else {
- fContext.statusChanged(new StatusInfo());
- }
-// } else if (field == fUseKeywordThisBox) {
-// setValue(PREF_KEYWORD_THIS, fUseKeywordThisBox.isSelected());
- } else if (field == fUseIsForBooleanGettersBox) {
- setValue(PREF_IS_FOR_GETTERS, fUseIsForBooleanGettersBox.isSelected());
-// Commented out next 2 lines (STP 20070430)
-// } else if (field == fUseOverrideAnnotation) {
-// setValue(PREF_USE_OVERRIDE_ANNOT, fUseOverrideAnnotation.isSelected());
- } else if (field == fGenerateComments) {
- setValue(PREF_GENERATE_COMMENTS, fGenerateComments.isSelected());
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
- */
- protected void updateControls() {
-// Added next 1 line (STP 20070430)
- ArrayList list= new ArrayList(2);
-// Commented out next 3 lines (STP 20070430)
-// ArrayList list= new ArrayList(4);
-// createEntry(list, PREF_FIELD_PREFIXES, PREF_FIELD_SUFFIXES, FIELD);
-// createEntry(list, PREF_STATIC_FIELD_PREFIXES, PREF_STATIC_FIELD_SUFFIXES, STATIC);
- createEntry(list, PREF_ARGUMENT_PREFIXES, PREF_ARGUMENT_SUFFIXES, ARGUMENT);
- createEntry(list, PREF_LOCAL_PREFIXES, PREF_LOCAL_SUFFIXES, LOCAL);
- fNameConventionList.setElements(list);
-
- fExceptionName.setText(getValue(PREF_EXCEPTION_NAME));
-// fUseKeywordThisBox.setSelection(getBooleanValue(PREF_KEYWORD_THIS));
- fUseIsForBooleanGettersBox.setSelection(getBooleanValue(PREF_IS_FOR_GETTERS));
-// Commented out next 1 line (STP 20070430)
-// fUseOverrideAnnotation.setSelection(getBooleanValue(PREF_USE_OVERRIDE_ANNOT));
- fGenerateComments.setSelection(getBooleanValue(PREF_GENERATE_COMMENTS));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
- */
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- return null; // no build required
- }
-
- private void createEntry(List list, Key prefixKey, Key suffixKey, int kind) {
- NameConventionEntry entry= new NameConventionEntry();
- entry.kind= kind;
- entry.suffixkey= suffixKey;
- entry.prefixkey= prefixKey;
- entry.suffix= getPreferenceValue(suffixKey);
- entry.prefix= getPreferenceValue(prefixKey);
- list.add(entry);
- }
-
- private String getPreferenceValue(Key key) {
- String value= getValue(key);
- if (value == null) {
- value= ""; //$NON-NLS-1$
- JavaScriptPlugin.logErrorMessage("JavaScriptCore preference is null. Key:" + key); //$NON-NLS-1$
- }
- return value;
- }
-
- private void doEditButtonPressed() {
- NameConventionEntry entry= (NameConventionEntry) fNameConventionList.getSelectedElements().get(0);
-
- String title;
- String message;
- switch (entry.kind) {
- case FIELD:
- title= PreferencesMessages.NameConventionConfigurationBlock_field_dialog_title;
- message= PreferencesMessages.NameConventionConfigurationBlock_field_dialog_message;
- break;
- case STATIC:
- title= PreferencesMessages.NameConventionConfigurationBlock_static_dialog_title;
- message= PreferencesMessages.NameConventionConfigurationBlock_static_dialog_message;
- break;
- case ARGUMENT:
- title= PreferencesMessages.NameConventionConfigurationBlock_arg_dialog_title;
- message= PreferencesMessages.NameConventionConfigurationBlock_arg_dialog_message;
- break;
- default:
- title= PreferencesMessages.NameConventionConfigurationBlock_local_dialog_title;
- message= PreferencesMessages.NameConventionConfigurationBlock_local_dialog_message;
- }
-
- NameConventionInputDialog dialog= new NameConventionInputDialog(getShell(), title, message, entry);
- if (dialog.open() == Window.OK) {
- fNameConventionList.replaceElement(entry, dialog.getResult());
- updateModel(fNameConventionList);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NewJavaProjectPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NewJavaProjectPreferencePage.java
deleted file mode 100644
index 5c366b95..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/NewJavaProjectPreferencePage.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// AW
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-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.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-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.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.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/*
- * The page for defaults for classpath entries in new java projects.
- * See PreferenceConstants to access or change these values through public API.
- */
-public class NewJavaProjectPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String ID= "org.eclipse.wst.jsdt.ui.preferences.BuildPathPreferencePage"; //$NON-NLS-1$
-
- private static final String SRCBIN_FOLDERS_IN_NEWPROJ= PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ;
- private static final String SRCBIN_SRCNAME= PreferenceConstants.SRCBIN_SRCNAME;
- private static final String SRCBIN_BINNAME= PreferenceConstants.SRCBIN_BINNAME;
-
- private static final String CLASSPATH_JRELIBRARY_INDEX= PreferenceConstants.NEWPROJECT_JRELIBRARY_INDEX;
- private static final String CLASSPATH_JRELIBRARY_LIST= PreferenceConstants.NEWPROJECT_JRELIBRARY_LIST;
-
-
- private static String fgDefaultEncoding= System.getProperty("file.encoding"); //$NON-NLS-1$
-
- public static IIncludePathEntry[] getDefaultJRELibrary() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
-
- String str= store.getString(CLASSPATH_JRELIBRARY_LIST);
- int index= store.getInt(CLASSPATH_JRELIBRARY_INDEX);
-
- StringTokenizer tok= new StringTokenizer(str, ";"); //$NON-NLS-1$
- while (tok.hasMoreTokens() && index > 0) {
- tok.nextToken();
- index--;
- }
-
- if (tok.hasMoreTokens()) {
- IIncludePathEntry[] res= decodeJRELibraryClasspathEntries(tok.nextToken());
- if (res.length > 0) {
- return res;
- }
- }
- return new IIncludePathEntry[] { getJREContainerEntry() };
- }
-
- // JRE Entry
-
- public static String decodeJRELibraryDescription(String encoded) {
- int end= encoded.indexOf(' ');
- if (end != -1) {
- return decode(encoded.substring(0, end));
- }
- return ""; //$NON-NLS-1$
- }
-
- private static String decode(String str) {
- try {
- return URLDecoder.decode(str, fgDefaultEncoding);
- } catch (UnsupportedEncodingException e) {
- JavaScriptPlugin.log(e);
- }
- return ""; //$NON-NLS-1$
- }
-
- private static String encode(String str) {
- try {
- return URLEncoder.encode(str, fgDefaultEncoding);
- } catch (UnsupportedEncodingException e) {
- JavaScriptPlugin.log(e);
- }
- return ""; //$NON-NLS-1$
- }
-
- public static IIncludePathEntry[] decodeJRELibraryClasspathEntries(String encoded) {
- StringTokenizer tok= new StringTokenizer(encoded, " "); //$NON-NLS-1$
- ArrayList res= new ArrayList();
- while (tok.hasMoreTokens()) {
- try {
- tok.nextToken(); // desc: ignore
- int kind= Integer.parseInt(tok.nextToken());
- IPath path= decodePath(tok.nextToken());
- IPath attachPath= decodePath(tok.nextToken());
- IPath attachRoot= decodePath(tok.nextToken());
- boolean isExported= Boolean.valueOf(tok.nextToken()).booleanValue();
- switch (kind) {
- case IIncludePathEntry.CPE_SOURCE:
- res.add(JavaScriptCore.newSourceEntry(path));
- break;
- case IIncludePathEntry.CPE_LIBRARY:
- res.add(JavaScriptCore.newLibraryEntry(path, attachPath, attachRoot, isExported));
- break;
- case IIncludePathEntry.CPE_VARIABLE:
- res.add(JavaScriptCore.newVariableEntry(path, attachPath, attachRoot, isExported));
- break;
- case IIncludePathEntry.CPE_PROJECT:
- res.add(JavaScriptCore.newProjectEntry(path, isExported));
- break;
- case IIncludePathEntry.CPE_CONTAINER:
- res.add(JavaScriptCore.newContainerEntry(path, isExported));
- break;
- }
- } catch (NumberFormatException e) {
- String message= PreferencesMessages.NewJavaProjectPreferencePage_error_decode;
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.ERROR, message, e));
- } catch (NoSuchElementException e) {
- String message= PreferencesMessages.NewJavaProjectPreferencePage_error_decode;
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, IStatus.ERROR, message, e));
- }
- }
- return (IIncludePathEntry[]) res.toArray(new IIncludePathEntry[res.size()]);
- }
-
-
- public static String encodeJRELibrary(String desc, IIncludePathEntry[] cpentries) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < cpentries.length; i++) {
- IIncludePathEntry entry= cpentries[i];
- buf.append(encode(desc));
- buf.append(' ');
- buf.append(entry.getEntryKind());
- buf.append(' ');
- buf.append(encodePath(entry.getPath()));
- buf.append(' ');
- buf.append(encodePath(entry.getSourceAttachmentPath()));
- buf.append(' ');
- buf.append(encodePath(entry.getSourceAttachmentRootPath()));
- buf.append(' ');
- buf.append(entry.isExported());
- buf.append(' ');
- }
- return buf.toString();
- }
-
- private static String encodePath(IPath path) {
- if (path == null) {
- return "#"; //$NON-NLS-1$
- } else if (path.isEmpty()) {
- return "&"; //$NON-NLS-1$
- } else {
- return encode(path.toPortableString());
- }
- }
-
- private static IPath decodePath(String str) {
- if ("#".equals(str)) { //$NON-NLS-1$
- return null;
- } else if ("&".equals(str)) { //$NON-NLS-1$
- return Path.EMPTY;
- } else {
- return Path.fromPortableString(decode(str));
- }
- }
-
-
- private ArrayList fCheckBoxes;
- private ArrayList fRadioButtons;
- private ArrayList fTextControls;
-
- private SelectionListener fSelectionListener;
- private ModifyListener fModifyListener;
-
- //private Text fBinFolderNameText;
- private Text fSrcFolderNameText;
-
- private Combo fJRECombo;
-
- private Button fProjectAsSourceFolder;
- private Button fFoldersAsSourceFolder;
-
- private Label fSrcFolderNameLabel;
- //private Label fBinFolderNameLabel;
-
- public NewJavaProjectPreferencePage() {
- super();
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.NewJavaProjectPreferencePage_description);
-
- // title used when opened programatically
- setTitle(PreferencesMessages.NewJavaProjectPreferencePage_title);
-
- fRadioButtons= new ArrayList();
- fCheckBoxes= new ArrayList();
- fTextControls= new ArrayList();
-
- fSelectionListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged(e.widget);
- }
- };
-
- fModifyListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- controlModified(e.widget);
- }
- };
-
- }
-
- public static void initDefaults(IPreferenceStore store) {
- store.setDefault(SRCBIN_FOLDERS_IN_NEWPROJ, false);
- store.setDefault(SRCBIN_SRCNAME, "script"); //$NON-NLS-1$
- store.setDefault(SRCBIN_BINNAME, ""); //$NON-NLS-1$
-
-// store.setDefault(CLASSPATH_JRELIBRARY_LIST, getDefaultJRELibraries());
- store.setDefault(CLASSPATH_JRELIBRARY_INDEX, 0);
- }
-
-// private static String getDefaultJRELibraries() {
-// StringBuffer buf= new StringBuffer();
-// IIncludePathEntry cntentry= getJREContainerEntry();
-// buf.append(encodeJRELibrary(PreferencesMessages.NewJavaProjectPreferencePage_jre_container_description, new IIncludePathEntry[] { cntentry} ));
-// buf.append(';');
-// IIncludePathEntry varentry= getJREVariableEntry();
-// buf.append(encodeJRELibrary(PreferencesMessages.NewJavaProjectPreferencePage_jre_variable_description, new IIncludePathEntry[] { varentry }));
-// buf.append(';');
-// return buf.toString();
-// }
-
- private static IIncludePathEntry getJREContainerEntry() {
- return JavaScriptCore.newContainerEntry(new Path("org.eclipse.wst.jsdt.launching.JRE_CONTAINER")); //$NON-NLS-1$
- }
-
- private static IIncludePathEntry getJREVariableEntry() {
- return JavaScriptCore.newVariableEntry(new Path("JRE_LIB"), new Path("JRE_SRC"), new Path("JRE_SRCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.NEW_JAVA_PROJECT_PREFERENCE_PAGE);
- }
-
-
- private Button addRadioButton(Composite parent, String label, String key, String value, int indent) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.horizontalIndent= indent;
-
- Button button= new Button(parent, SWT.RADIO);
- button.setText(label);
- button.setData(new String[] { key, value });
- button.setLayoutData(gd);
-
- button.setSelection(value.equals(getPreferenceStore().getString(key)));
-
- fRadioButtons.add(button);
- return button;
- }
-
- private Text addTextControl(Composite parent, Label labelControl, String key, int indent) {
- GridData gd= new GridData();
- gd.horizontalIndent= indent;
-
- labelControl.setLayoutData(gd);
-
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(30);
-
- Text text= new Text(parent, SWT.SINGLE | SWT.BORDER);
- text.setText(getPreferenceStore().getString(key));
- text.setData(key);
- text.setLayoutData(gd);
-
- fTextControls.add(text);
- return text;
- }
-
-
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.numColumns= 2;
- result.setLayout(layout);
-
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
-
- Group sourceFolderGroup= new Group(result, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- sourceFolderGroup.setLayout(layout);
- sourceFolderGroup.setLayoutData(gd);
- sourceFolderGroup.setText(PreferencesMessages.NewJavaProjectPreferencePage_sourcefolder_label);
-
- int indent= 0;
-
- fProjectAsSourceFolder= addRadioButton(sourceFolderGroup, PreferencesMessages.NewJavaProjectPreferencePage_sourcefolder_project, SRCBIN_FOLDERS_IN_NEWPROJ, IPreferenceStore.FALSE, indent);
- fProjectAsSourceFolder.addSelectionListener(fSelectionListener);
-
- fFoldersAsSourceFolder= addRadioButton(sourceFolderGroup, PreferencesMessages.NewJavaProjectPreferencePage_sourcefolder_folder, SRCBIN_FOLDERS_IN_NEWPROJ, IPreferenceStore.TRUE, indent);
- fFoldersAsSourceFolder.addSelectionListener(fSelectionListener);
-
- indent= convertWidthInCharsToPixels(4);
-
- fSrcFolderNameLabel= new Label(sourceFolderGroup, SWT.NONE);
- fSrcFolderNameLabel.setText(PreferencesMessages.NewJavaProjectPreferencePage_folders_src);
- fSrcFolderNameText= addTextControl(sourceFolderGroup, fSrcFolderNameLabel, SRCBIN_SRCNAME, indent);
- fSrcFolderNameText.addModifyListener(fModifyListener);
-
- //fBinFolderNameLabel= new Label(sourceFolderGroup, SWT.NONE);
- //fBinFolderNameLabel.setText(PreferencesMessages.NewJavaProjectPreferencePage_folders_bin);
- //fBinFolderNameText= addTextControl(sourceFolderGroup, fBinFolderNameLabel, SRCBIN_BINNAME, indent);
- //fBinFolderNameText.addModifyListener(fModifyListener);
-
-// String[] jreNames= getJRENames();
-// if (jreNames.length > 0) {
-// Label jreSelectionLabel= new Label(result, SWT.NONE);
-// jreSelectionLabel.setText(PreferencesMessages.NewJavaProjectPreferencePage_jrelibrary_label);
-// jreSelectionLabel.setLayoutData(new GridData());
-//
-// int index= getPreferenceStore().getInt(CLASSPATH_JRELIBRARY_INDEX);
-// fJRECombo= new Combo(result, SWT.READ_ONLY);
-// fJRECombo.setItems(jreNames);
-// fJRECombo.select(index);
-// fJRECombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-// }
-
- validateFolders();
-
- Dialog.applyDialogFont(result);
- return result;
- }
-
- private void validateFolders() {
- boolean useFolders= fFoldersAsSourceFolder.getSelection();
-
- fSrcFolderNameText.setEnabled(useFolders);
- //fBinFolderNameText.setEnabled(useFolders);
- fSrcFolderNameLabel.setEnabled(useFolders);
- //fBinFolderNameLabel.setEnabled(useFolders);
- if (useFolders) {
- String srcName= fSrcFolderNameText.getText();
- String binName= ""; //$NON-NLS-1$
- if (srcName.length() + binName.length() == 0) {
- updateStatus(new StatusInfo(IStatus.ERROR, PreferencesMessages.NewJavaProjectPreferencePage_folders_error_namesempty));
- return;
- }
- IWorkspace workspace= JavaScriptPlugin.getWorkspace();
- IProject dmy= workspace.getRoot().getProject("project"); //$NON-NLS-1$
-
- IStatus status;
- IPath srcPath= dmy.getFullPath().append(srcName);
- if (srcName.length() != 0) {
- status= workspace.validatePath(srcPath.toString(), IResource.FOLDER);
- if (!status.isOK()) {
- String message= Messages.format(PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidsrcname, status.getMessage());
- updateStatus(new StatusInfo(IStatus.ERROR, message));
- return;
- }
- }
- IPath binPath= dmy.getFullPath().append(binName);
-// if (binName.length() != 0) {
-// status= workspace.validatePath(binPath.toString(), IResource.FOLDER);
-// if (!status.isOK()) {
-// String message= Messages.format(PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidbinname, status.getMessage());
-// updateStatus(new StatusInfo(IStatus.ERROR, message));
-// return;
-// }
-// }
- IIncludePathEntry entry= JavaScriptCore.newSourceEntry(srcPath);
- status= JavaScriptConventions.validateClasspath(JavaScriptCore.create(dmy), new IIncludePathEntry[] { entry }, binPath);
- if (!status.isOK()) {
- String message= PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidcp;
- updateStatus(new StatusInfo(IStatus.ERROR, message));
- return;
- }
- }
- updateStatus(new StatusInfo()); // set to OK
- }
-
- private void updateStatus(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- private void controlChanged(Widget widget) {
- if (widget == fFoldersAsSourceFolder || widget == fProjectAsSourceFolder) {
- validateFolders();
- }
- }
-
- private void controlModified(Widget widget) {
- if (widget == fSrcFolderNameText ) {
- validateFolders();
- }
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- button.setSelection(store.getDefaultBoolean(key));
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- String[] info= (String[]) button.getData();
- button.setSelection(info[1].equals(store.getDefaultString(info[0])));
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- text.setText(store.getDefaultString(key));
- }
- if (fJRECombo != null) {
- fJRECombo.select(store.getDefaultInt(CLASSPATH_JRELIBRARY_INDEX));
- }
-
- validateFolders();
- super.performDefaults();
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- store.setValue(key, button.getSelection());
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- if (button.getSelection()) {
- String[] info= (String[]) button.getData();
- store.setValue(info[0], info[1]);
- }
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- store.setValue(key, text.getText());
- }
-
- if (fJRECombo != null) {
- store.setValue(CLASSPATH_JRELIBRARY_INDEX, fJRECombo.getSelectionIndex());
- }
-
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return super.performOk();
- }
-
-// private String[] getJRENames() {
-// String prefString= getPreferenceStore().getString(CLASSPATH_JRELIBRARY_LIST);
-// ArrayList list= new ArrayList();
-// StringTokenizer tok= new StringTokenizer(prefString, ";"); //$NON-NLS-1$
-// while (tok.hasMoreTokens()) {
-// list.add(decodeJRELibraryDescription(tok.nextToken()));
-// }
-// return (String[]) list.toArray(new String[list.size()]);
-// }
-
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OccurrencesPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OccurrencesPreferencePage.java
deleted file mode 100644
index 7059604a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OccurrencesPreferencePage.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-
-/**
- * Occurrences preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- *
- */
-public class OccurrencesPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- // This page has no description
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.wst.jsdt.internal.ui.preferences.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new MarkOccurrencesConfigurationBlock(overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OptionsConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OptionsConfigurationBlock.java
deleted file mode 100644
index 010eee9c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OptionsConfigurationBlock.java
+++ /dev/null
@@ -1,881 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-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.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.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.ui.preferences.IWorkingCopyManager;
-import org.eclipse.ui.preferences.WorkingCopyManager;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.CoreUtility;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Abstract options configuration block providing a general implementation for setting up
- * an options configuration page.
- *
- *
- */
-public abstract class OptionsConfigurationBlock {
-
- public static final class Key {
-
- private String fQualifier;
- private String fKey;
-
- public Key(String qualifier, String key) {
- fQualifier= qualifier;
- fKey= key;
- }
-
- public String getName() {
- return fKey;
- }
-
- private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
- IEclipsePreferences node= context.getNode(fQualifier);
- if (manager != null) {
- return manager.getWorkingCopy(node);
- }
- return node;
- }
-
- public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) {
- return getNode(context, manager).get(fKey, null);
- }
-
- public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
- for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
- String value= getStoredValue(lookupOrder[i], manager);
- if (value != null) {
- return value;
- }
- }
- return null;
- }
-
- public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) {
- if (value != null) {
- getNode(context, manager).put(fKey, value);
- } else {
- getNode(context, manager).remove(fKey);
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return fQualifier + '/' + fKey;
- }
-
- public String getQualifier() {
- return fQualifier;
- }
-
- }
-
-
- protected static class ControlData {
- private Key fKey;
- private String[] fValues;
-
- public ControlData(Key key, String[] values) {
- fKey= key;
- fValues= values;
- }
-
- public Key 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) {
- if (value != null) {
- for (int i= 0; i < fValues.length; i++) {
- if (value.equals(fValues[i])) {
- return i;
- }
- }
- }
- return fValues.length -1; // assume the last option is the least severe
- }
- }
-
- private static final String REBUILD_COUNT_KEY= "preferences_build_requested"; //$NON-NLS-1$
-
- private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
-
- protected final ArrayList fCheckBoxes;
- protected final ArrayList fComboBoxes;
- protected final ArrayList fTextBoxes;
- protected final HashMap fLabels;
- protected final ArrayList fExpandedComposites;
-
- private SelectionListener fSelectionListener;
- private ModifyListener fTextModifyListener;
-
- protected IStatusChangeListener fContext;
- protected final IProject fProject; // project or null
- protected final Key[] fAllKeys;
-
- private IScopeContext[] fLookupOrder;
-
- private Shell fShell;
-
- private final IWorkingCopyManager fManager;
- private IWorkbenchPreferenceContainer fContainer;
-
- private Map fDisabledProjectSettings; // null when project specific settings are turned off
-
- private int fRebuildCount; /// used to prevent multiple dialogs that ask for a rebuild
-
- public OptionsConfigurationBlock(IStatusChangeListener context, IProject project, Key[] allKeys, IWorkbenchPreferenceContainer container) {
- fContext= context;
- fProject= project;
- fAllKeys= allKeys;
- fContainer= container;
- if (container == null) {
- fManager= new WorkingCopyManager();
- } else {
- fManager= container.getWorkingCopyManager();
- }
-
- if (fProject != null) {
- fLookupOrder= new IScopeContext[] {
- new ProjectScope(fProject),
- new InstanceScope(),
- new DefaultScope()
- };
- } else {
- fLookupOrder= new IScopeContext[] {
- new InstanceScope(),
- new DefaultScope()
- };
- }
-
- testIfOptionsComplete(allKeys);
- if (fProject == null || hasProjectSpecificOptions(fProject)) {
- fDisabledProjectSettings= null;
- } else {
- fDisabledProjectSettings= new IdentityHashMap();
- for (int i= 0; i < allKeys.length; i++) {
- Key curr= allKeys[i];
- fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
- }
- }
-
- settingsUpdated();
-
- fCheckBoxes= new ArrayList();
- fComboBoxes= new ArrayList();
- fTextBoxes= new ArrayList(2);
- fLabels= new HashMap();
- fExpandedComposites= new ArrayList();
-
- fRebuildCount= getRebuildCount();
- }
-
- protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
- return fContainer;
- }
-
- protected static Key getKey(String plugin, String key) {
- return new Key(plugin, key);
- }
-
- protected final static Key getJDTCoreKey(String key) {
- return getKey(JavaScriptCore.PLUGIN_ID, key);
- }
-
- protected final static Key getJDTUIKey(String key) {
- return getKey(JavaScriptUI.ID_PLUGIN, key);
- }
-
-
- private void testIfOptionsComplete(Key[] allKeys) {
- for (int i= 0; i < allKeys.length; i++) {
- if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
- JavaScriptPlugin.logErrorMessage("preference option missing: " + allKeys[i] + " (" + this.getClass().getName() +')'); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- }
-
- private int getRebuildCount() {
- return fManager.getWorkingCopy(new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN)).getInt(REBUILD_COUNT_KEY, 0);
- }
-
- private void incrementRebuildCount() {
- fRebuildCount++;
- fManager.getWorkingCopy(new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN)).putInt(REBUILD_COUNT_KEY, fRebuildCount);
- }
-
-
- protected void settingsUpdated() {
- }
-
-
- public void selectOption(String key, String qualifier) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- if (curr.getName().equals(key) && curr.getQualifier().equals(qualifier)) {
- selectOption(curr);
- }
- }
- }
-
- public void selectOption(Key key) {
- Control control= findControl(key);
- if (control != null) {
- if (!fExpandedComposites.isEmpty()) {
- ExpandableComposite expandable= getParentExpandableComposite(control);
- if (expandable != null) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= (ExpandableComposite) fExpandedComposites.get(i);
- curr.setExpanded(curr == expandable);
- }
- expandedStateChanged(expandable);
- }
- }
- control.setFocus();
- }
- }
-
-
- public final boolean hasProjectSpecificOptions(IProject project) {
- if (project != null) {
- IScopeContext projectContext= new ProjectScope(project);
- Key[] allKeys= fAllKeys;
- for (int i= 0; i < allKeys.length; i++) {
- if (allKeys[i].getStoredValue(projectContext, fManager) != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- protected Shell getShell() {
- return fShell;
- }
-
- protected void setShell(Shell shell) {
- fShell= shell;
- }
-
- protected abstract Control createContents(Composite parent);
-
- protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
-
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setFont(JFaceResources.getDialogFont());
- checkBox.setText(label);
- checkBox.setData(data);
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(getSelectionListener());
-
- makeScrollableCompositeAware(checkBox);
-
- String currValue= getValue(key);
- checkBox.setSelection(data.getSelection(currValue) == 0);
-
- fCheckBoxes.add(checkBox);
-
- return checkBox;
- }
-
- protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent, int widthHint, SelectionListener listener) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- composite.setLayout(layout);
- composite.setLayoutData(gd);
-
- Button checkBox= new Button(composite, SWT.CHECK);
- checkBox.setFont(JFaceResources.getDialogFont());
- checkBox.setData(data);
- checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
- checkBox.addSelectionListener(getSelectionListener());
-
- gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
- gd.widthHint= widthHint;
-
- Link link= new Link(composite, SWT.NONE);
- link.setText(label);
- link.setLayoutData(gd);
- if (listener != null) {
- link.addSelectionListener(listener);
- }
-
- makeScrollableCompositeAware(link);
- makeScrollableCompositeAware(checkBox);
-
- String currValue= getValue(key);
- checkBox.setSelection(data.getSelection(currValue) == 0);
-
- fCheckBoxes.add(checkBox);
-
- return checkBox;
- }
-
- protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
- gd.horizontalIndent= indent;
-
- Label labelControl= new Label(parent, SWT.LEFT);
- labelControl.setFont(JFaceResources.getDialogFont());
- labelControl.setText(label);
- labelControl.setLayoutData(gd);
-
- Combo comboBox= newComboControl(parent, key, values, valueLabels);
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- fLabels.put(comboBox, labelControl);
-
- return comboBox;
- }
-
- protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indent;
- gd.horizontalSpan= 3;
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- composite.setLayout(layout);
- composite.setLayoutData(gd);
-
- Combo comboBox= newComboControl(composite, key, values, valueLabels);
- comboBox.setFont(JFaceResources.getDialogFont());
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
- labelControl.setText(label);
- labelControl.setLayoutData(new GridData());
-
- fLabels.put(comboBox, labelControl);
- return comboBox;
- }
-
- protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
- ControlData data= new ControlData(key, values);
-
- Combo comboBox= new Combo(composite, SWT.READ_ONLY);
- comboBox.setItems(valueLabels);
- comboBox.setData(data);
- comboBox.addSelectionListener(getSelectionListener());
- comboBox.setFont(JFaceResources.getDialogFont());
-
- makeScrollableCompositeAware(comboBox);
-
- String currValue= getValue(key);
- comboBox.select(data.getSelection(currValue));
-
- fComboBoxes.add(comboBox);
- return comboBox;
- }
-
- protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
- Label labelControl= new Label(parent, SWT.WRAP);
- labelControl.setText(label);
- labelControl.setFont(JFaceResources.getDialogFont());
- labelControl.setLayoutData(new GridData());
-
- Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
- textBox.setData(key);
- textBox.setLayoutData(new GridData());
-
- makeScrollableCompositeAware(textBox);
-
- fLabels.put(textBox, labelControl);
-
- String currValue= getValue(key);
- if (currValue != null) {
- textBox.setText(currValue);
- }
- textBox.addModifyListener(getTextModifyListener());
-
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- if (widthHint != 0) {
- data.widthHint= widthHint;
- }
- data.horizontalIndent= indent;
- data.horizontalSpan= 2;
- textBox.setLayoutData(data);
-
- fTextBoxes.add(textBox);
- return textBox;
- }
-
- protected ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ScrolledPageContent) {
- return (ScrolledPageContent) parent;
- }
- return null;
- }
-
- protected ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ExpandableComposite) {
- return (ExpandableComposite) parent;
- }
- return null;
- }
-
- private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.adaptChild(control);
- }
- }
-
- protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
- ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- excomposite.setText(label);
- excomposite.setExpanded(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
- excomposite.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- expandedStateChanged((ExpandableComposite) e.getSource());
- }
- });
- fExpandedComposites.add(excomposite);
- makeScrollableCompositeAware(excomposite);
- return excomposite;
- }
-
- protected final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.reflow(true);
- }
- }
-
- protected void restoreSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite excomposite= (ExpandableComposite) fExpandedComposites.get(i);
- if (settings == null) {
- excomposite.setExpanded(i == 0); // only expand the first node by default
- } else {
- excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
- }
- }
- }
-
- protected void storeSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= (ExpandableComposite) fExpandedComposites.get(i);
- settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
- }
- }
-
- 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;
- }
- String oldValue= setValue(data.getKey(), newValue);
- validateSettings(data.getKey(), oldValue, newValue);
- }
-
- protected void textChanged(Text textControl) {
- Key key= (Key) textControl.getData();
- String number= textControl.getText();
- String oldValue= setValue(key, number);
- validateSettings(key, oldValue, number);
- }
-
- protected boolean checkValue(Key key, String value) {
- return value.equals(getValue(key));
- }
-
- protected String getValue(Key key) {
- if (fDisabledProjectSettings != null) {
- return (String) fDisabledProjectSettings.get(key);
- }
- return key.getStoredValue(fLookupOrder, false, fManager);
- }
-
-
- protected boolean getBooleanValue(Key key) {
- return Boolean.valueOf(getValue(key)).booleanValue();
- }
-
- protected String setValue(Key key, String value) {
- if (fDisabledProjectSettings != null) {
- return (String) fDisabledProjectSettings.put(key, value);
- }
- String oldValue= getValue(key);
- key.setStoredValue(fLookupOrder[0], value, fManager);
- return oldValue;
- }
-
- protected String setValue(Key key, boolean value) {
- return setValue(key, String.valueOf(value));
- }
-
- /**
- * Returns the value as actually stored in the preference store.
- * @param key
- * @return the value as actually stored in the preference store.
- */
- protected String getStoredValue(Key key) {
- return key.getStoredValue(fLookupOrder, false, fManager);
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
-
-
- protected String[] getTokens(String text, String separator) {
- StringTokenizer tok= new StringTokenizer(text, separator);
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken().trim();
- }
- return res;
- }
-
- private boolean getChanges(IScopeContext currContext, List changedSettings) {
- boolean needsBuild= false;
- for (int i= 0; i < fAllKeys.length; i++) {
- Key key= fAllKeys[i];
- String oldVal= key.getStoredValue(currContext, null);
- String val= key.getStoredValue(currContext, fManager);
- if (val == null) {
- if (oldVal != null) {
- changedSettings.add(key);
- needsBuild |= !oldVal.equals(key.getStoredValue(fLookupOrder, true, fManager));
- }
- } else if (!val.equals(oldVal)) {
- changedSettings.add(key);
- needsBuild |= oldVal != null || !val.equals(key.getStoredValue(fLookupOrder, true, fManager));
- }
- }
- return needsBuild;
- }
-
- public void useProjectSpecificSettings(boolean enable) {
- boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
- if (enable != hasProjectSpecificOption && fProject != null) {
- if (enable) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String val= (String) fDisabledProjectSettings.get(curr);
- curr.setStoredValue(fLookupOrder[0], val, fManager);
- }
- fDisabledProjectSettings= null;
- updateControls();
- validateSettings(null, null, null);
- } else {
- fDisabledProjectSettings= new IdentityHashMap();
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String oldSetting= curr.getStoredValue(fLookupOrder, false, fManager);
- fDisabledProjectSettings.put(curr, oldSetting);
- curr.setStoredValue(fLookupOrder[0], null, fManager); // clear project settings
- }
- }
- }
- }
-
- public boolean areSettingsEnabled() {
- return fDisabledProjectSettings == null || fProject == null;
- }
-
-
- public boolean performOk() {
- return processChanges(fContainer);
- }
-
- public boolean performApply() {
- return processChanges(null); // apply directly
- }
-
- protected boolean processChanges(IWorkbenchPreferenceContainer container) {
- IScopeContext currContext= fLookupOrder[0];
-
- List /* <Key>*/ changedOptions= new ArrayList();
- boolean needsBuild= getChanges(currContext, changedOptions);
- if (changedOptions.isEmpty()) {
- return true;
- }
- if (needsBuild) {
- int count= getRebuildCount();
- if (count > fRebuildCount) {
- needsBuild= false; // build already requested
- fRebuildCount= count;
- }
- }
-
- boolean doBuild= false;
- if (needsBuild) {
- String[] strings= getFullBuildDialogStrings(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) {
- doBuild= true;
- } else if (res != 1) {
- return false; // cancel pressed
- }
- }
- }
- if (container != null) {
- // no need to apply the changes to the original store: will be done by the page container
- if (doBuild) { // post build
- incrementRebuildCount();
- container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
- }
- } else {
- // apply changes right away
- try {
- fManager.applyChanges();
- } catch (BackingStoreException e) {
- JavaScriptPlugin.log(e);
- return false;
- }
- if (doBuild) {
- CoreUtility.getBuildJob(fProject).schedule();
- }
-
- }
- return true;
- }
-
- protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings);
-
-
- public void performDefaults() {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String defValue= curr.getStoredValue(fLookupOrder, true, fManager);
- setValue(curr, defValue);
- }
-
- settingsUpdated();
- updateControls();
- validateSettings(null, null, null);
- }
-
- /**
- *
- */
- public void performRevert() {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String origValue= curr.getStoredValue(fLookupOrder, false, null);
- setValue(curr, origValue);
- }
-
- settingsUpdated();
- updateControls();
- validateSettings(null, null, null);
- }
-
- public void dispose() {
- }
-
- protected void updateControls() {
- // update the UI
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- updateCheckBox((Button) fCheckBoxes.get(i));
- }
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- updateCombo((Combo) fComboBoxes.get(i));
- }
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- updateText((Text) fTextBoxes.get(i));
- }
- }
-
- protected void updateCombo(Combo curr) {
- ControlData data= (ControlData) curr.getData();
-
- String currValue= getValue(data.getKey());
- curr.select(data.getSelection(currValue));
- }
-
- protected void updateCheckBox(Button curr) {
- ControlData data= (ControlData) curr.getData();
-
- String currValue= getValue(data.getKey());
- curr.setSelection(data.getSelection(currValue) == 0);
- }
-
- protected void updateText(Text curr) {
- Key key= (Key) curr.getData();
-
- String currValue= getValue(key);
- if (currValue != null) {
- curr.setText(currValue);
- }
- }
-
- protected Button getCheckBox(Key key) {
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Button curr= (Button) fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- protected Combo getComboBox(Key key) {
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Combo curr= (Combo) fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- protected Text getTextControl(Key key) {
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Text curr= (Text) fTextBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- protected Control findControl(Key key) {
- Combo comboBox= getComboBox(key);
- if (comboBox != null) {
- return comboBox;
- }
- Button checkBox= getCheckBox(key);
- if (checkBox != null) {
- return checkBox;
- }
- Text text= getTextControl(key);
- if (text != null) {
- return text;
- }
- return null;
- }
-
- protected void setComboEnabled(Key key, boolean enabled) {
- Combo combo= getComboBox(key);
- Label label= (Label) fLabels.get(combo);
- combo.setEnabled(enabled);
- label.setEnabled(enabled);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OverlayPreferenceStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OverlayPreferenceStore.java
deleted file mode 100644
index 3446cddb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/OverlayPreferenceStore.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.Assert;
-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 {
- private 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);
- }
- }
-
-
- private IPreferenceStore fParent;
- private IPreferenceStore fStore;
- private OverlayKey[] fOverlayKeys;
-
- private PropertyListener fPropertyListener;
- private boolean fLoaded;
-
-
- public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
- fParent= parent;
- fOverlayKeys= overlayKeys;
- fStore= new PreferenceStore();
- }
-
- private 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);
- }
-
- private 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"); //$NON-NLS-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);
-
- fLoaded= 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);
- }
-
- /**
- * The keys to add to the list of overlay keys.
- * <p>
- * Note: This method must be called before {@link #load()} is called.
- * </p>
- *
- * @param keys
- *
- */
- public void addKeys(OverlayKey[] keys) {
- Assert.isTrue(!fLoaded);
- Assert.isNotNull(keys);
-
- int overlayKeysLength= fOverlayKeys.length;
- OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength];
-
- for (int i= 0, length= overlayKeysLength; i < length; i++)
- result[i]= fOverlayKeys[i];
-
- for (int i= 0, length= keys.length; i < length; i++)
- result[overlayKeysLength + i]= keys[i];
-
- fOverlayKeys= result;
-
- if (fLoaded)
- load();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesAccess.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesAccess.java
deleted file mode 100644
index f41fbcac..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesAccess.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.ui.preferences.IWorkingCopyManager;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- *
- */
-public class PreferencesAccess {
-
- public static PreferencesAccess getOriginalPreferences() {
- return new PreferencesAccess();
- }
-
- public static PreferencesAccess getWorkingCopyPreferences(IWorkingCopyManager workingCopyManager) {
- return new WorkingCopyPreferencesAccess(workingCopyManager);
- }
-
- private PreferencesAccess() {
- // can only extends in this file
- }
-
- public IScopeContext getDefaultScope() {
- return new DefaultScope();
- }
-
- public IScopeContext getInstanceScope() {
- return new InstanceScope();
- }
-
- public IScopeContext getProjectScope(IProject project) {
- return new ProjectScope(project);
- }
-
- public void applyChanges() throws BackingStoreException {
- }
-
-
- private static class WorkingCopyPreferencesAccess extends PreferencesAccess {
-
- private final IWorkingCopyManager fWorkingCopyManager;
-
- private WorkingCopyPreferencesAccess(IWorkingCopyManager workingCopyManager) {
- fWorkingCopyManager= workingCopyManager;
- }
-
- private final IScopeContext getWorkingCopyScopeContext(IScopeContext original) {
- return new WorkingCopyScopeContext(fWorkingCopyManager, original);
- }
-
- public IScopeContext getDefaultScope() {
- return getWorkingCopyScopeContext(super.getDefaultScope());
- }
-
- public IScopeContext getInstanceScope() {
- return getWorkingCopyScopeContext(super.getInstanceScope());
- }
-
- public IScopeContext getProjectScope(IProject project) {
- return getWorkingCopyScopeContext(super.getProjectScope(project));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess#applyChanges()
- */
- public void applyChanges() throws BackingStoreException {
- fWorkingCopyManager.applyChanges();
- }
- }
-
-
- private static class WorkingCopyScopeContext implements IScopeContext {
-
- private final IWorkingCopyManager fWorkingCopyManager;
- private final IScopeContext fOriginal;
-
- public WorkingCopyScopeContext(IWorkingCopyManager workingCopyManager, IScopeContext original) {
- fWorkingCopyManager= workingCopyManager;
- fOriginal= original;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
- */
- public String getName() {
- return fOriginal.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
- */
- public IEclipsePreferences getNode(String qualifier) {
- return fWorkingCopyManager.getWorkingCopy(fOriginal.getNode(qualifier));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
- */
- public IPath getLocation() {
- return fOriginal.getLocation();
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.java
deleted file mode 100644
index 4ea43354..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.java
+++ /dev/null
@@ -1,775 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
- * Sebastian Davids, sdavids@gmx.de - 187316 [preferences] Mark Occurences Pref Page; Link to
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class PreferencesMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$
-
- private PreferencesMessages() {
- // Do not instantiate
- }
-
- public static String AppearancePreferencePage_coloredlabels_label;
- public static String BuildPathsPropertyPage_error_message;
- public static String BuildPathsPropertyPage_error_title;
- public static String BuildPathsPropertyPage_job_title;
- public static String BuildPathsPropertyPage_no_java_project_message;
- public static String BuildPathsPropertyPage_closed_project_message;
- public static String BuildPathsPropertyPage_unsavedchanges_title;
- public static String BuildPathsPropertyPage_unsavedchanges_message;
- public static String BuildPathsPropertyPage_unsavedchanges_button_save;
- public static String BuildPathsPropertyPage_unsavedchanges_button_discard;
- public static String BuildPathsPropertyPage_unsavedchanges_button_ignore;
- public static String ClasspathVariablesPreferencePage_title;
- public static String ClasspathVariablesPreferencePage_description;
- public static String ClasspathVariablesPreferencePage_savechanges_title;
- public static String ClasspathVariablesPreferencePage_savechanges_message;
- public static String CleanUpPreferencePage_Description;
- public static String CleanUpPreferencePage_Title;
- public static String CodeAssistAdvancedConfigurationBlock_default_table_category_column_title;
- public static String CodeAssistAdvancedConfigurationBlock_default_table_description;
- public static String CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title;
- public static String CodeAssistAdvancedConfigurationBlock_key_binding_hint;
- public static String CodeAssistAdvancedConfigurationBlock_page_description;
- public static String CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title;
- public static String CodeAssistAdvancedConfigurationBlock_separate_table_description;
- public static String CodeAssistAdvancedConfigurationBlock_no_shortcut;
- public static String CodeAssistAdvancedConfigurationBlock_Up;
- public static String CodeAssistAdvancedConfigurationBlock_Down;
- public static String CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout;
- public static String CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_ms;
- public static String CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_emptyInput;
- public static String CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidInput;
- public static String CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidRange;
- public static String ImportOrganizeConfigurationBlock_emptylines_between_groups_label;
- public static String ImportOrganizeConfigurationBlock_error_invalidnumberofemptylines;
- public static String ImportOrganizePreferencePage_description;
- public static String ImportOrganizePreferencePage_title;
- public static String ImportOrganizeConfigurationBlock_order_label;
- public static String ImportOrganizeConfigurationBlock_other_static;
- public static String ImportOrganizeConfigurationBlock_other_normal;
- public static String ImportOrganizeConfigurationBlock_other_normal_label;
- public static String ImportOrganizeConfigurationBlock_order_add_button;
- public static String ImportOrganizeConfigurationBlock_order_edit_button;
- public static String ImportOrganizeConfigurationBlock_order_up_button;
- public static String ImportOrganizeConfigurationBlock_order_down_button;
- public static String ImportOrganizeConfigurationBlock_order_remove_button;
- public static String ImportOrganizeConfigurationBlock_order_add_static_button;
- public static String ImportOrganizeConfigurationBlock_order_load_button;
- public static String ImportOrganizeConfigurationBlock_order_save_button;
- public static String ImportOrganizeConfigurationBlock_other_description;
- public static String ImportOrganizeConfigurationBlock_ignoreLowerCase_label;
- public static String ImportOrganizeConfigurationBlock_threshold_label;
- public static String ImportOrganizeConfigurationBlock_error_invalidthreshold;
- public static String ImportOrganizeConfigurationBlock_loadDialog_title;
- public static String ImportOrganizeConfigurationBlock_loadDialog_error_title;
- public static String ImportOrganizeConfigurationBlock_loadDialog_error_message;
- public static String ImportOrganizeConfigurationBlock_saveDialog_title;
- public static String ImportOrganizeConfigurationBlock_saveDialog_error_title;
- public static String ImportOrganizeConfigurationBlock_staticthreshold_label;
- public static String ImportOrganizeConfigurationBlock_saveDialog_error_message;
- public static String ImportOrganizeInputDialog_title;
- public static String ImportOrganizeInputDialog_browse_packages_button;
- public static String ImportOrganizeInputDialog_browse_types_label;
- public static String ImportOrganizeInputDialog_title_static;
- public static String ImportOrganizeInputDialog_ChoosePackageDialog_title;
- public static String ImportOrganizeInputDialog_ChoosePackageDialog_description;
- public static String ImportOrganizeInputDialog_ChoosePackageDialog_empty;
- public static String ImportOrganizeInputDialog_ChooseTypeDialog_title;
- public static String ImportOrganizeInputDialog_ChooseTypeDialog_description;
- public static String ImportOrganizeInputDialog_ChooseTypeDialog_error_message;
- public static String ImportOrganizeInputDialog_error_enterName;
- public static String ImportOrganizeInputDialog_error_invalidName;
- public static String ImportOrganizeInputDialog_error_entryExists;
- public static String ImportOrganizeInputDialog_name_group_label;
- public static String ImportOrganizeInputDialog_name_group_static_label;
- public static String JavaBasePreferencePage_description;
- public static String JavaBasePreferencePage_doubleclick_action;
- public static String JavaBasePreferencePage_doubleclick_gointo;
- public static String JavaBasePreferencePage_doubleclick_expand;
- public static String JavaBasePreferencePage_refactoring_lightweight;
- public static String JavaBasePreferencePage_refactoring_title;
- public static String JavaBasePreferencePage_refactoring_auto_save;
- public static String JavaBasePreferencePage_search;
- public static String JavaBasePreferencePage_search_small_menu;
- public static String JavaBuildConfigurationBlock_build_recreate_modified;
- public static String JavadocConfigurationBlock_error_archive_not_found_in_workspace;
- public static String JavadocConfigurationBlock_external_radio;
- public static String JavadocConfigurationBlock_workspace_archive_selection_dialog_description;
- public static String JavadocConfigurationBlock_workspace_archive_selection_dialog_title;
- public static String JavadocConfigurationBlock_workspace_radio;
- public static String JavadocConfigurationPropertyPage_invalid_container;
- public static String JavadocConfigurationPropertyPage_not_supported;
- public static String JavadocConfigurationPropertyPage_read_only;
- public static String JavaEditorPropertyPage_SaveActionLink_Text;
- public static String NewJavaProjectPreferencePage_title;
- public static String NewJavaProjectPreferencePage_description;
- public static String NewJavaProjectPreferencePage_sourcefolder_label;
- public static String NewJavaProjectPreferencePage_sourcefolder_project;
- public static String NewJavaProjectPreferencePage_sourcefolder_folder;
- public static String NewJavaProjectPreferencePage_folders_src;
- public static String NewJavaProjectPreferencePage_folders_error_namesempty;
- public static String NewJavaProjectPreferencePage_folders_error_invalidsrcname;
- public static String NewJavaProjectPreferencePage_folders_error_invalidcp;
- public static String NewJavaProjectPreferencePage_error_decode;
- public static String JavaEditorPreferencePage_showQuickFixables;
- public static String JavaEditorPreferencePage_analyseAnnotationsWhileTyping;
- public static String JavaEditorPreferencePage_multiLineComment;
- public static String JavaEditorPreferencePage_singleLineComment;
- public static String JavaEditorPreferencePage_returnKeyword;
- public static String JavaEditorPreferencePage_keywords;
- public static String JavaEditorPreferencePage_strings;
- public static String JavaEditorPreferencePage_others;
- public static String JavaEditorPreferencePage_operators;
- public static String JavaEditorPreferencePage_brackets;
- public static String JavaEditorPreferencePage_javaCommentTaskTags;
- public static String JavaEditorPreferencePage_javaDocKeywords;
- public static String JavaEditorPreferencePage_javaDocHtmlTags;
- public static String JavaEditorPreferencePage_javaDocLinks;
- public static String JavaEditorPreferencePage_javaDocOthers;
- public static String JavaEditorPreferencePage_backgroundColor;
- public static String JavaEditorPreferencePage_systemDefault;
- public static String JavaEditorPreferencePage_custom;
- public static String JavaEditorPreferencePage_semanticHighlighting_option;
- public static String JavaEditorPreferencePage_foreground;
- public static String JavaEditorPreferencePage_color;
- public static String JavaEditorPreferencePage_bold;
- public static String JavaEditorPreferencePage_italic;
- public static String JavaEditorPreferencePage_strikethrough;
- public static String JavaEditorPreferencePage_underline;
- public static String JavaEditorPreferencePage_enable;
- public static String JavaEditorPreferencePage_preview;
- public static String JavaEditorPreferencePage_displayedTabWidth;
- public static String JavaEditorPreferencePage_insertSpaceForTabs;
- public static String JavaEditorPreferencePage_showOverviewRuler;
- public static String JavaEditorPreferencePage_highlightMatchingBrackets;
- public static String JavaEditorPreferencePage_highlightCurrentLine;
- public static String JavaEditorPreferencePage_showPrintMargin;
- public static String JavaEditorPreferencePage_printMarginColumn;
- public static String JavaEditorPreferencePage_insertSingleProposalsAutomatically;
- public static String JavaEditorPreferencePage_showOnlyProposalsVisibleInTheInvocationContext;
- public static String JavaEditorPreferencePage_presentProposalsInAlphabeticalOrder;
- public static String JavaEditorPreferencePage_coloring_element;
- public static String JavaEditorPreferencePage_enableAutoActivation;
-// public static String JavaEditorPreferencePage_automaticallyAddImportInsteadOfQualifiedName;
-// public static String JavaEditorPreferencePage_suggestStaticImports;
- public static String JavaEditorPreferencePage_completionInserts;
- public static String JavaEditorPreferencePage_completionOverwrites;
- public static String JavaEditorPreferencePage_completionToggleHint;
- public static String JavaEditorPreferencePage_fillArgumentNamesOnMethodCompletion;
- public static String JavaEditorPreferencePage_guessArgumentNamesOnMethodCompletion;
- public static String JavaEditorPreferencePage_autoActivationDelay;
- public static String JavaEditorPreferencePage_autoActivationTriggersForJava;
- public static String JavaEditorPreferencePage_autoActivationTriggersForJavaDoc;
- public static String JavaEditorPreferencePage_completePrefixes;
- public static String JavaEditorPreferencePage_backgroundForCompletionProposals;
- public static String JavaEditorPreferencePage_foregroundForCompletionProposals;
- public static String JavaEditorPreferencePage_backgroundForMethodParameters;
- public static String JavaEditorPreferencePage_foregroundForMethodParameters;
- public static String JavaEditorPreferencePage_backgroundForCompletionReplacement;
- public static String JavaEditorPreferencePage_foregroundForCompletionReplacement;
- public static String JavaEditorPreferencePage_sourceHoverBackgroundColor;
- public static String JavaEditorPreferencePage_general;
- public static String JavaEditorPreferencePage_colors;
- public static String JavaEditorPreferencePage_empty_input;
- public static String JavaEditorPreferencePage_invalid_input;
- public static String JavaEditorPreferencePage_showLineNumbers;
- public static String JavaEditorPreferencePage_lineNumberForegroundColor;
- public static String JavaEditorPreferencePage_matchingBracketsHighlightColor2;
- public static String JavaEditorPreferencePage_currentLineHighlighColor;
- public static String JavaEditorPreferencePage_printMarginColor2;
- public static String JavaEditorPreferencePage_appearanceOptions;
- public static String JavaEditorPreferencePage_typing_tabTitle;
- public static String JavaEditorPreferencePage_typing_description;
- public static String JavaEditorPreferencePage_closeStrings;
- public static String JavaEditorPreferencePage_closeBrackets;
- public static String JavaEditorPreferencePage_closeBraces;
- public static String JavaEditorPreferencePage_closeJavaDocs;
- public static String JavaEditorPreferencePage_wrapStrings;
- public static String JavaEditorPreferencePage_escapeStrings;
- public static String JavaEditorPreferencePage_addJavaDocTags;
- public static String JavaEditorPreferencePage_smartPaste;
- public static String JavaEditorPreferencePage_link;
- public static String JavaEditorPreferencePage_link_tooltip;
- public static String JavaEditorPreferencePage_importsOnPaste;
- public static String JavaEditorPreferencePage_subWordNavigation;
- public static String JavaEditorPreferencePage_typing_smartSemicolon;
- public static String JavaEditorPreferencePage_typing_smartOpeningBrace;
- public static String JavaEditorPreferencePage_typing_smartTab;
- public static String JavaEditorPreferencePage_hoverTab_title;
- public static String JavaEditorColoringConfigurationBlock_link;
- public static String JavaBasePreferencePage_openTypeHierarchy;
- public static String JavaBasePreferencePage_inView;
- public static String JavaBasePreferencePage_inPerspective;
- public static String JavaEditorPreferencePage_quickassist_lightbulb;
- public static String JavaEditorPreferencePage_showJavaElementOnly;
- public static String JavaEditorPreferencePage_accessibility_disableCustomCarets;
- public static String JavaEditorPreferencePage_accessibility_wideCaret;
- public static String JavaEditorHoverConfigurationBlock_annotationRollover;
- public static String JavaEditorHoverConfigurationBlock_hoverPreferences;
- public static String JavaEditorHoverConfigurationBlock_enabled;
- public static String JavaEditorHoverConfigurationBlock_keyModifier;
- public static String JavaEditorHoverConfigurationBlock_description;
- public static String JavaEditorHoverConfigurationBlock_modifierIsNotValid;
- public static String JavaEditorHoverConfigurationBlock_modifierIsNotValidForHover;
- public static String JavaEditorHoverConfigurationBlock_duplicateModifier;
- public static String JavaEditorHoverConfigurationBlock_nameColumnTitle;
- public static String JavaEditorHoverConfigurationBlock_modifierColumnTitle;
- public static String JavaEditorHoverConfigurationBlock_delimiter;
- public static String JavaEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter;
- public static String JavaEditorHoverConfigurationBlock_insertModifierAndDelimiter;
- public static String JavaEditorHoverConfigurationBlock_insertDelimiterAndModifier;
- public static String MarkOccurrencesConfigurationBlock_title;
- public static String MarkOccurrencesConfigurationBlock_link;
- public static String MarkOccurrencesConfigurationBlock_link_tooltip;
- public static String MarkOccurrencesConfigurationBlock_markOccurrences;
-// public static String MarkOccurrencesConfigurationBlock_markTypeOccurrences;
- public static String MarkOccurrencesConfigurationBlock_markMethodOccurrences;
- public static String MarkOccurrencesConfigurationBlock_markConstantOccurrences;
-// public static String MarkOccurrencesConfigurationBlock_markFieldOccurrences;
- public static String MarkOccurrencesConfigurationBlock_markLocalVariableOccurrences;
-// public static String MarkOccurrencesConfigurationBlock_markExceptionOccurrences;
- public static String MarkOccurrencesConfigurationBlock_markMethodExitPoints;
-// public static String MarkOccurrencesConfigurationBlock_markImplementors;
- public static String MarkOccurrencesConfigurationBlock_markBreakContinueTargets;
- public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
- public static String JavaElementInfoPage_binary;
- public static String JavaElementInfoPage_classpath_entry_kind;
- public static String JavaElementInfoPage_library;
- public static String JavaElementInfoPage_nameLabel;
- public static String JavaElementInfoPage_not_present;
- public static String JavaElementInfoPage_package;
- public static String JavaElementInfoPage_package_contents;
- public static String JavaElementInfoPage_project;
- public static String JavaElementInfoPage_resource_path;
- public static String JavaElementInfoPage_source;
- public static String JavaElementInfoPage_variable;
- public static String JavaElementInfoPage_variable_path;
- public static String JavaElementInfoPage_location;
- public static String JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description;
- public static String JavadocConfigurationPropertyPage_IsIncorrectElement_description;
- public static String JavadocConfigurationPropertyPage_IsJavaProject_description;
- public static String JavadocConfigurationBlock_browse_folder_button;
- public static String JavadocConfigurationBlock_error_notafolder;
- public static String JavadocConfigurationBlock_javadocFolderDialog_label;
- public static String JavadocConfigurationBlock_javadocFolderDialog_message;
- public static String JavadocConfigurationBlock_MalformedURL_error;
- public static String JavadocConfigurationBlock_validate_button;
- public static String JavadocConfigurationBlock_InvalidLocation_message;
- public static String JavadocConfigurationBlock_ValidLocation_message;
- public static String JavadocConfigurationBlock_UnableToValidateLocation_message;
- public static String JavadocConfigurationBlock_MessageDialog_title;
- public static String JavadocConfigurationBlock_location_type_path_label;
- public static String JavadocConfigurationBlock_location_type_jar_label;
- public static String JavadocConfigurationBlock_location_path_label;
- public static String JavadocConfigurationBlock_location_jar_label;
- public static String JavadocConfigurationBlock_jar_path_label;
- public static String JavadocConfigurationBlock_zipImportSource_title;
- public static String JavadocConfigurationBlock_location_in_jarorzip_message;
- public static String JavadocConfigurationBlock_browse_jarorzip_path_title;
- public static String JavadocConfigurationBlock_error_notafile;
- public static String JavadocConfigurationBlock_error_invalidarchivepath;
- public static String JavadocConfigurationBlock_error_archivepathnotabsolute;
- public static String JavadocConfigurationBlock_browse_archive_button;
- public static String JavadocConfigurationBlock_browse_archive_path_button;
- public static String ProblemSeveritiesConfigurationBlock_ignore_documented_unused_parameters;
- public static String ProblemSeveritiesConfigurationBlock_LooselyDeclaredGlobalVar;
- public static String ProblemSeveritiesConfigurationBlock_Optionalsemicolon;
- public static String ProblemSeveritiesConfigurationBlock_pb_redundant_null_check;
- public static String ProblemSeveritiesConfigurationBlock_Resolution;
- public static String ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
- public static String ProblemSeveritiesConfigurationBlock_UnresolvedFields;
- public static String ProblemSeveritiesConfigurationBlock_UnresolvedMethods;
- public static String ProblemSeveritiesConfigurationBlock_UnresolvedTypes;
- public static String SourceAttachmentPropertyPage_error_title;
- public static String SourceAttachmentPropertyPage_error_message;
- public static String SourceAttachmentPropertyPage_invalid_container;
- public static String SourceAttachmentPropertyPage_noarchive_message;
- public static String SourceAttachmentPropertyPage_containerentry_message;
- public static String AppearancePreferencePage_description;
- //public static String AppearancePreferencePage_methodreturntype_label;
- public static String AppearancePreferencePage_inferredmethodreturntype_label;
- public static String AppearancePreferencePage_showCategory_label;
-// public static String AppearancePreferencePage_methodtypeparams_label;
-// public static String AppearancePreferencePage_pkgNamePatternEnable_label;
-// public static String AppearancePreferencePage_pkgNamePattern_label;
- public static String AppearancePreferencePage_showMembersInPackagesView;
- public static String AppearancePreferencePage_stackViewsVerticallyInTheJavaBrowsingPerspective;
-// public static String AppearancePreferencePage_note;
-// public static String AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives;
- public static String AppearancePreferencePage_packageNameCompressionPattern_error_isEmpty;
-// public static String AppearancePreferencePage_foldEmptyPackages;
- public static String AppearancePreferencePage_foldEmptySourceFolders;
- public static String CodeFormatterPreferencePage_title;
- public static String CodeFormatterPreferencePage_description;
- public static String SourceAttachmentPropertyPage_not_supported;
- public static String SourceAttachmentPropertyPage_read_only;
- public static String TodoTaskPreferencePage_title;
- public static String TodoTaskPreferencePage_description;
- public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
- public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority;
- public static String TodoTaskConfigurationBlock_markers_tasks_low_priority;
- public static String TodoTaskConfigurationBlock_markers_tasks_add_button;
- public static String TodoTaskConfigurationBlock_markers_tasks_remove_button;
- public static String TodoTaskConfigurationBlock_markers_tasks_edit_button;
- public static String TodoTaskConfigurationBlock_markers_tasks_name_column;
- public static String TodoTaskConfigurationBlock_markers_tasks_priority_column;
- public static String TodoTaskConfigurationBlock_markers_tasks_setdefault_button;
- public static String TodoTaskConfigurationBlock_casesensitive_label;
- public static String TodoTaskConfigurationBlock_needsbuild_title;
- public static String TodoTaskConfigurationBlock_tasks_default;
- public static String TodoTaskConfigurationBlock_needsfullbuild_message;
- public static String TodoTaskConfigurationBlock_needsprojectbuild_message;
- public static String TodoTaskInputDialog_new_title;
- public static String TodoTaskInputDialog_edit_title;
- public static String TodoTaskInputDialog_name_label;
- public static String TodoTaskInputDialog_priority_label;
- public static String TodoTaskInputDialog_priority_high;
- public static String TodoTaskInputDialog_priority_normal;
- public static String TodoTaskInputDialog_priority_low;
- public static String TodoTaskInputDialog_error_enterName;
- public static String TodoTaskInputDialog_error_comma;
- public static String TodoTaskInputDialog_error_entryExists;
- public static String TodoTaskInputDialog_error_noSpace;
- public static String PropertyAndPreferencePage_useworkspacesettings_change;
- public static String PropertyAndPreferencePage_showprojectspecificsettings_label;
- public static String PropertyAndPreferencePage_useprojectsettings_label;
- public static String JavaBuildPreferencePage_title;
- public static String JavaBuildPreferencePage_description;
- public static String JavaBuildConfigurationBlock_section_general;
- public static String JavaBuildConfigurationBlock_section_output_folder;
- public static String JavaBuildConfigurationBlock_section_access_rules;
- public static String JavaBuildConfigurationBlock_section_build_path_problems;
- public static String JavaBuildConfigurationBlock_error;
- public static String JavaBuildConfigurationBlock_warning;
- public static String JavaBuildConfigurationBlock_ignore;
- public static String JavaBuildConfigurationBlock_needsbuild_title;
- public static String JavaBuildConfigurationBlock_needsfullbuild_message;
- public static String JavaBuildConfigurationBlock_needsprojectbuild_message;
- public static String JavaBuildConfigurationBlock_resource_filter_description;
- public static String JavaBuildConfigurationBlock_resource_filter_label;
- public static String JavaBuildConfigurationBlock_build_invalid_classpath_label;
- public static String JavaBuildConfigurationBlock_build_clean_outputfolder_label;
- public static String JavaBuildConfigurationBlock_enable_exclusion_patterns_label;
- public static String JavaBuildConfigurationBlock_enable_multiple_outputlocations_label;
- public static String JavaBuildConfigurationBlock_pb_incomplete_build_path_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_discourraged_reference_label;
- public static String JavaBuildConfigurationBlock_pb_build_path_cycles_label;
- public static String JavaBuildConfigurationBlock_pb_duplicate_resources_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_forbidden_reference_label;
- public static String JavaBuildConfigurationBlock_pb_max_per_unit_label;
- public static String JavaBuildConfigurationBlock_pb_check_prereq_binary_level_label;
- public static String JavaBuildConfigurationBlock_empty_input;
- public static String JavaBuildConfigurationBlock_invalid_input;
- public static String JavaBuildConfigurationBlock_filter_invalidsegment_error;
- public static String ProblemSeveritiesPreferencePage_title;
- public static String ProblemSeveritiesConfigurationBlock_error;
- public static String ProblemSeveritiesConfigurationBlock_warning;
- public static String ProblemSeveritiesConfigurationBlock_ignore;
- public static String ProblemSeveritiesConfigurationBlock_section_potential_programming_problems;
- public static String ProblemSeveritiesConfigurationBlock_section_unnecessary_code;
- public static String ProblemSeveritiesConfigurationBlock_section_nls;
- public static String ProblemSeveritiesConfigurationBlock_section_code_style;
- public static String ProblemSeveritiesConfigurationBlock_section_deprecations;
- public static String ProblemSeveritiesConfigurationBlock_section_name_shadowing;
- public static String ProblemSeveritiesConfigurationBlock_section_annotations;
- public static String ProblemSeveritiesConfigurationBlock_needsbuild_title;
- public static String ProblemSeveritiesConfigurationBlock_needsfullbuild_message;
- public static String ProblemSeveritiesConfigurationBlock_needsprojectbuild_message;
- public static String ProblemSeveritiesConfigurationBlock_common_description;
- public static String ProblemSeveritiesConfigurationBlock_pb_unsafe_type_op_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_raw_type_reference;
- public static String ProblemSeveritiesConfigurationBlock_pb_final_param_bound_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_inexact_vararg_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_accidential_assignement_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_local_variable_hiding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_field_hiding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_special_param_hiding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unqualified_field_access_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_finally_block_not_completing_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_undocumented_empty_block_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_when_overriding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_missing_serial_version_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_undefined_field_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_method_naming_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_no_effect_assignment_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_incompatible_interface_method_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_indirect_access_to_static_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_hidden_catchblock_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_static_access_receiver_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_imports_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_local_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_signal_param_in_overriding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_private_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_non_externalized_strings_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_deprecation_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_deprecation_in_deprecation_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_deprecation_when_overriding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_empty_statement_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unnecessary_type_check_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_incomplete_enum_switch_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_synth_access_emul_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_autoboxing_problem_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_char_array_in_concat_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_missing_override_annotation_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_missing_deprecated_annotation_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_annotation_super_interface_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unused_label_label;
- public static String JavadocProblemsPreferencePage_title;
- public static String JavadocProblemsConfigurationBlock_public;
- public static String JavadocProblemsConfigurationBlock_protected;
- public static String JavadocProblemsConfigurationBlock_default;
- public static String JavadocProblemsConfigurationBlock_private;
- public static String JavadocProblemsConfigurationBlock_error;
- public static String JavadocProblemsConfigurationBlock_warning;
- public static String JavadocProblemsConfigurationBlock_ignore;
- public static String JavadocProblemsConfigurationBlock_needsbuild_title;
- public static String JavadocProblemsConfigurationBlock_needsfullbuild_message;
- public static String JavadocProblemsConfigurationBlock_needsprojectbuild_message;
- public static String JavadocProblemsConfigurationBlock_javadoc_description;
- public static String JavadocProblemsConfigurationBlock_pb_javadoc_support_label;
- public static String JavadocProblemsConfigurationBlock_pb_invalid_javadoc_label;
- public static String JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_label;
- public static String JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_visibility_label;
- public static String JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_not_visible_ref_label;
- public static String JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_deprecated_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_javadoc_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_visibility_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_overriding_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_comments_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_comments_visibility_label;
- public static String JavadocProblemsConfigurationBlock_pb_missing_comments_overriding_label;
- public static String CompliancePreferencePage_title;
- public static String CompliancePreferencePage_description;
- public static String ComplianceConfigurationBlock_error;
- public static String ComplianceConfigurationBlock_warning;
- public static String ComplianceConfigurationBlock_ignore;
- public static String ComplianceConfigurationBlock_version11;
- public static String ComplianceConfigurationBlock_version12;
- public static String ComplianceConfigurationBlock_version13;
- public static String ComplianceConfigurationBlock_version14;
- public static String ComplianceConfigurationBlock_version15;
- public static String ComplianceConfigurationBlock_needsbuild_title;
- public static String ComplianceConfigurationBlock_needsfullbuild_message;
- public static String ComplianceConfigurationBlock_needsprojectbuild_message;
- public static String ComplianceConfigurationBlock_variable_attr_label;
- public static String ComplianceConfigurationBlock_line_number_attr_label;
- public static String ComplianceConfigurationBlock_source_file_attr_label;
- public static String ComplianceConfigurationBlock_codegen_unused_local_label;
- public static String ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label;
- public static String ComplianceConfigurationBlock_compiler_compliance_label;
- public static String ComplianceConfigurationBlock_default_settings_label;
- public static String ComplianceConfigurationBlock_source_compatibility_label;
- public static String ComplianceConfigurationBlock_codegen_targetplatform_label;
- public static String ComplianceConfigurationBlock_pb_assert_as_identifier_label;
- public static String ComplianceConfigurationBlock_pb_enum_as_identifier_label;
- public static String ComplianceConfigurationBlock_compliance_group_label;
- public static String ComplianceConfigurationBlock_classfiles_group_label;
- public static String OptionsConfigurationBlock_job_title;
- public static String OptionsConfigurationBlock_buildall_taskname;
- public static String OptionsConfigurationBlock_buildproject_taskname;
- public static String CodeStylePreferencePage_title;
- public static String CodeTemplatesPreferencePage_title;
- public static String JavaCategoryPropertyPage_text;
- public static String NameConventionConfigurationBlock_field_label;
- public static String NameConventionConfigurationBlock_static_label;
- public static String NameConventionConfigurationBlock_arg_label;
- public static String NameConventionConfigurationBlock_local_label;
-// public static String NameConventionConfigurationBlock_keywordthis_label;
- public static String NameConventionConfigurationBlock_isforbooleangetters_label;
- public static String NameConventionConfigurationBlock_dialog_prefix;
- public static String NameConventionConfigurationBlock_dialog_suffix;
- public static String NameConventionConfigurationBlock_exceptionname_label;
- public static String NameConventionConfigurationBlock_error_emptyprefix;
- public static String NameConventionConfigurationBlock_error_emptysuffix;
- public static String NameConventionConfigurationBlock_error_invalidprefix;
- public static String NameConventionConfigurationBlock_error_invalidsuffix;
- public static String NameConventionConfigurationBlock_list_label;
- public static String NameConventionConfigurationBlock_list_edit_button;
- public static String NameConventionConfigurationBlock_list_name_column;
- public static String NameConventionConfigurationBlock_list_prefix_column;
- public static String NameConventionConfigurationBlock_list_suffix_column;
- public static String NameConventionConfigurationBlock_field_dialog_title;
- public static String NameConventionConfigurationBlock_field_dialog_message;
- public static String NameConventionConfigurationBlock_static_dialog_title;
- public static String NameConventionConfigurationBlock_static_dialog_message;
- public static String NameConventionConfigurationBlock_arg_dialog_title;
- public static String NameConventionConfigurationBlock_arg_dialog_message;
- public static String NameConventionConfigurationBlock_local_dialog_title;
- public static String NameConventionConfigurationBlock_local_dialog_message;
- public static String MembersOrderPreferencePage_category_button_up;
- public static String MembersOrderPreferencePage_category_button_down;
- public static String MembersOrderPreferencePage_visibility_button_up;
- public static String MembersOrderPreferencePage_visibility_button_down;
- public static String MembersOrderPreferencePage_label_description;
-// public static String MembersOrderPreferencePage_fields_label;
- public static String MembersOrderPreferencePage_vars_label;
- public static String MembersOrderPreferencePage_constructors_label;
- public static String MembersOrderPreferencePage_methods_label;
- public static String MembersOrderPreferencePage_staticfields_label;
- public static String MembersOrderPreferencePage_staticmethods_label;
- public static String MembersOrderPreferencePage_initialisers_label;
- public static String MembersOrderPreferencePage_staticinitialisers_label;
- public static String MembersOrderPreferencePage_types_label;
- public static String MembersOrderPreferencePage_public_label;
- public static String MembersOrderPreferencePage_private_label;
- public static String MembersOrderPreferencePage_protected_label;
- public static String MembersOrderPreferencePage_default_label;
- public static String MembersOrderPreferencePage_usevisibilitysort_label;
- public static String CodeTemplateBlock_link_tooltip;
- public static String CodeTemplateBlock_templates_comment_node;
- public static String CodeTemplateBlock_templates_code_node;
- public static String CodeTemplateBlock_catchblock_label;
- public static String CodeTemplateBlock_methodstub_label;
- public static String CodeTemplateBlock_constructorstub_label;
- public static String CodeTemplateBlock_newtype_label;
- public static String CodeTemplateBlock_classbody_label;
- public static String CodeTemplateBlock_interfacebody_label;
- public static String CodeTemplateBlock_enumbody_label;
- public static String CodeTemplateBlock_annotationbody_label;
- public static String CodeTemplateBlock_typecomment_label;
- public static String CodeTemplateBlock_fieldcomment_label;
- public static String CodeTemplateBlock_filecomment_label;
- public static String CodeTemplateBlock_methodcomment_label;
- public static String CodeTemplateBlock_overridecomment_label;
- public static String CodeTemplateBlock_delegatecomment_label;
- public static String CodeTemplateBlock_constructorcomment_label;
- public static String CodeTemplateBlock_gettercomment_label;
- public static String CodeTemplateBlock_settercomment_label;
- public static String CodeTemplateBlock_getterstub_label;
- public static String CodeTemplateBlock_setterstub_label;
- public static String CodeTemplateBlock_templates_edit_button;
- public static String CodeTemplateBlock_templates_import_button;
- public static String CodeTemplateBlock_templates_export_button;
- public static String CodeTemplateBlock_templates_exportall_button;
- public static String CodeTemplateBlock_createcomment_label;
- public static String CodeTemplateBlock_templates_label;
- public static String CodeTemplateBlock_preview;
- public static String CodeTemplateBlock_import_title;
- public static String CodeTemplateBlock_import_extension;
- public static String CodeTemplateBlock_export_title;
- public static String CodeTemplateBlock_export_filename;
- public static String CodeTemplateBlock_export_extension;
- public static String CodeTemplateBlock_export_exists_title;
- public static String CodeTemplateBlock_export_exists_message;
- public static String CodeTemplateBlock_error_read_title;
- public static String CodeTemplateBlock_error_read_message;
- public static String CodeTemplateBlock_error_parse_message;
- public static String CodeTemplateBlock_error_write_title;
- public static String CodeTemplateBlock_error_write_message;
- public static String CodeTemplateBlock_export_error_title;
- public static String CodeTemplateBlock_export_error_hidden;
- public static String CodeTemplateBlock_export_error_canNotWrite;
- public static String TypeFilterPreferencePage_description;
- public static String TypeFilterPreferencePage_list_label;
- public static String TypeFilterPreferencePage_add_button;
- public static String TypeFilterPreferencePage_addpackage_button;
- public static String TypeFilterPreferencePage_edit_button;
- public static String TypeFilterPreferencePage_remove_button;
- public static String TypeFilterPreferencePage_selectall_button;
- public static String TypeFilterPreferencePage_deselectall_button;
- public static String TypeFilterPreferencePage_choosepackage_label;
- public static String TypeFilterPreferencePage_choosepackage_description;
- public static String TypeFilterInputDialog_title;
- public static String TypeFilterInputDialog_message;
- public static String TypeFilterInputDialog_browse_button;
- public static String TypeFilterInputDialog_error_enterName;
- public static String TypeFilterInputDialog_error_invalidName;
- public static String TypeFilterInputDialog_error_entryExists;
- public static String TypeFilterInputDialog_choosepackage_label;
- public static String TypeFilterInputDialog_choosepackage_description;
- public static String JavaEditorPreferencePage_selectionBackgroundColor;
- public static String JavaEditorPreferencePage_selectionForegroundColor;
- public static String SpellingPreferencePage_empty_threshold;
- public static String SpellingPreferencePage_invalid_threshold;
- public static String SpellingPreferencePage_ignore_digits_label;
- public static String SpellingPreferencePage_ignore_mixed_label;
- public static String SpellingPreferencePage_ignore_sentence_label;
- public static String SpellingPreferencePage_ignore_upper_label;
- public static String SpellingPreferencePage_ignore_url_label;
- public static String SpellingPreferencePage_ignore_non_letters_label;
- public static String SpellingPreferencePage_ignore_single_letters_label;
- public static String SpellingPreferencePage_ignore_java_strings_label;
- public static String SpellingPreferencePage_ignore_ampersand_in_properties_label;
- public static String SpellingPreferencePage_proposals_threshold;
- public static String SpellingPreferencePage_dictionary_label;
- public static String SpellingPreferencePage_encoding_label;
- public static String SpellingPreferencePage_workspace_dictionary_label;
- public static String SpellingPreferencePage_browse_label;
- public static String SpellingPreferencePage_dictionary_error;
- public static String SpellingPreferencePage_dictionary_none;
- public static String SpellingPreferencePage_locale_error;
- public static String SpellingPreferencePage_filedialog_title;
- public static String SpellingPreferencePage_filter_dictionary_extension;
- public static String SpellingPreferencePage_filter_all_extension;
- public static String SpellingPreferencePage_filter_dictionary_label;
- public static String SpellingPreferencePage_filter_all_label;
- public static String SpellingPreferencePage_enable_contentassist_label;
- public static String SpellingPreferencePage_group_user;
- public static String SpellingPreferencePage_group_dictionary;
- public static String SpellingPreferencePage_group_dictionaries;
- public static String SpellingPreferencePage_group_advanced;
- public static String SpellingPreferencePage_user_dictionary_description;
- public static String BuildPathPreferencePage_title;
- public static String BuildPathPreferencePage_description;
- public static String UserLibraryPreferencePage_title;
- public static String UserLibraryPreferencePage_description;
- public static String UserLibraryPreferencePage_libraries_label;
- public static String UserLibraryPreferencePage_libraries_new_button;
- public static String UserLibraryPreferencePage_libraries_edit_button;
- public static String UserLibraryPreferencePage_libraries_addjar_button;
- public static String UserLibraryPreferencePage_libraries_remove_button;
- public static String UserLibraryPreferencePage_libraries_load_button;
- public static String UserLibraryPreferencePage_libraries_save_button;
- public static String UserLibraryPreferencePage_operation;
- public static String UserLibraryPreferencePage_operation_error;
- public static String UserLibraryPreferencePage_config_error_title;
- public static String UserLibraryPreferencePage_config_error_message;
- public static String UserLibraryPreferencePage_browsejar_new_title;
- public static String UserLibraryPreferencePage_browsejar_edit_title;
- public static String UserLibraryPreferencePage_LibraryNameDialog_new_title;
- public static String UserLibraryPreferencePage_LibraryNameDialog_edit_title;
- public static String UserLibraryPreferencePage_LibraryNameDialog_name_label;
- public static String UserLibraryPreferencePage_LibraryNameDialog_issystem_label;
- public static String UserLibraryPreferencePage_LibraryNameDialog_name_error_entername;
- public static String UserLibraryPreferencePage_LibraryNameDialog_name_error_exists;
- public static String UserLibraryPreferencePage_LoadSaveDialog_save_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_save_ok_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_load_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_label;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_button;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_selectall_button;
- public static String UserLibraryPreferencePage_LoadSaveDialog_load_replace_message;
- public static String UserLibraryPreferencePage_LoadSaveDialog_load_replace_multiple_message;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_deselectall_button;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_save_label;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_load_label;
- public static String UserLibraryPreferencePage_LoadSaveDialog_filedialog_save_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_filedialog_load_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_error_empty;
- public static String UserLibraryPreferencePage_LoadSaveDialog_error_invalidfile;
- public static String UserLibraryPreferencePage_LoadSaveDialog_overwrite_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_save_ok_message;
- public static String UserLibraryPreferencePage_LoadSaveDialog_overwrite_message;
- public static String UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_title;
- public static String UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_message;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_error_save_enterlocation;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_error_save_invalid;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_error_save_nothingselected;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_error_load_enterlocation;
- public static String UserLibraryPreferencePage_LoadSaveDialog_location_error_load_invalid;
- public static String UserLibraryPreferencePage_LoadSaveDialog_list_error_load_nothingselected;
- public static String UserLibraryPreferencePage_LoadSaveDialog_load_badformat;
- public static String UserLibraryPreferencePage_LoadSaveDialog_load_replace_title;
- public static String EditTemplateDialog_error_noname;
- public static String EditTemplateDialog_error_spaces;
- public static String EditTemplateDialog_title_new;
- public static String EditTemplateDialog_title_edit;
- public static String EditTemplateDialog_name;
- public static String EditTemplateDialog_description;
- public static String EditTemplateDialog_context;
- public static String EditTemplateDialog_pattern;
- public static String EditTemplateDialog_insert_variable;
- public static String EditTemplateDialog_undo;
- public static String EditTemplateDialog_cut;
- public static String EditTemplateDialog_copy;
- public static String EditTemplateDialog_paste;
- public static String EditTemplateDialog_select_all;
- public static String EditTemplateDialog_content_assist;
- public static String JavaEditorPreferencePage_folding_title;
- public static String FoldingConfigurationBlock_enable;
- public static String FoldingConfigurationBlock_combo_caption;
- public static String FoldingConfigurationBlock_info_no_preferences;
- public static String FoldingConfigurationBlock_error_not_exist;
- public static String FoldingConfigurationBlock_warning_providerNotFound_resetToDefault;
- public static String SmartTypingConfigurationBlock_autoclose_title;
- public static String SmartTypingConfigurationBlock_automove_title;
- public static String SmartTypingConfigurationBlock_tabs_title;
- public static String SmartTypingConfigurationBlock_tabs_message_tab_text;
- public static String SmartTypingConfigurationBlock_tabs_message_others_text;
- public static String SmartTypingConfigurationBlock_tabs_message_tooltip;
- public static String SmartTypingConfigurationBlock_tabs_message_spaces;
- public static String SmartTypingConfigurationBlock_tabs_message_tabs;
- public static String SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
- public static String SmartTypingConfigurationBlock_pasting_title;
- public static String SmartTypingConfigurationBlock_strings_title;
- public static String CodeAssistConfigurationBlock_sortingSection_title;
- public static String CodeAssistConfigurationBlock_autoactivationSection_title;
- public static String CodeAssistConfigurationBlock_insertionSection_title;
- public static String JavaEditorPreferencePage_coloring_category_java;
- public static String JavaEditorPreferencePage_coloring_category_javadoc;
- public static String JavaEditorPreferencePage_coloring_category_comments;
- public static String ProjectSelectionDialog_title;
- public static String ProjectSelectionDialog_desciption;
- public static String ProjectSelectionDialog_filter;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
- }
-
- public static String NameConventionConfigurationBlock_use_override_annotation_label;
- public static String ProblemSeveritiesConfigurationBlock_pb_unhandled_surpresswarning_tokens;
- public static String ProblemSeveritiesConfigurationBlock_pb_enable_surpresswarning_annotation;
- public static String SmartTypingConfigurationBlock_annotationReporting_link;
- public static String CodeAssistConfigurationBlock_restricted_link;
- public static String CodeAssistConfigurationBlock_hideDiscouraged_label;
- public static String CodeAssistConfigurationBlock_hideForbidden_label;
- public static String UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_up_button;
- public static String UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_down_button;
- public static String EditTemplateDialog_autoinsert;
- public static String ComplianceConfigurationBlock_jrecompliance_info;
- public static String ComplianceConfigurationBlock_jrecompliance_info_project;
- public static String ProblemSeveritiesConfigurationBlock_section_generics;
- public static String JavaBasePreferencePage_dialogs;
- public static String JavaBasePreferencePage_do_not_hide_description;
- public static String JavaBasePreferencePage_do_not_hide_button;
- public static String JavaBasePreferencePage_do_not_hide_dialog_title;
- public static String JavaBasePreferencePage_do_not_hide_dialog_message;
- public static String CodeAssistConfigurationBlock_matchCamelCase_label;
- public static String ComplianceConfigurationBlock_version16;
- public static String ComplianceConfigurationBlock_src_greater_compliance;
- public static String ComplianceConfigurationBlock_classfile_greater_compliance;
- public static String ComplianceConfigurationBlock_classfile_greater_source;
- public static String ProblemSeveritiesConfigurationBlock_pb_parameter_assignment;
- public static String ProblemSeveritiesConfigurationBlock_pb_null_reference;
- public static String ProblemSeveritiesConfigurationBlock_pb_potential_null_reference;
- public static String ProblemSeveritiesConfigurationBlock_pb_fall_through_case;
- public static String CodeAssistConfigurationBlock_hideDeprecated_label;
-
- public static String CodeAssistStaticMembersConfigurationBlock_description;
- public static String CodeAssistStaticMembersConfigurationBlock_newType_button;
- public static String CodeAssistStaticMembersConfigurationBlock_newMember_button;
- public static String CodeAssistStaticMembersConfigurationBlock_edit_button;
- public static String CodeAssistStaticMembersConfigurationBlock_remove_button;
-
- public static String FavoriteStaticMemberInputDialog_member_title;
- public static String FavoriteStaticMemberInputDialog_member_labelText;
- public static String FavoriteStaticMemberInputDialog_type_title;
- public static String FavoriteStaticMemberInputDialog_type_labelText;
- public static String FavoriteStaticMemberInputDialog_browse_button;
- public static String FavoriteStaticMemberInputDialog_ChooseTypeDialog_title;
- public static String FavoriteStaticMemberInputDialog_ChooseTypeDialog_description;
- public static String FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message;
- public static String FavoriteStaticMemberInputDialog_error_enterName;
- public static String FavoriteStaticMemberInputDialog_error_invalidMemberName;
- public static String FavoriteStaticMemberInputDialog_error_invalidTypeName;
- public static String FavoriteStaticMemberInputDialog_error_entryExists;
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.properties
deleted file mode 100644
index 2b9d3a19..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PreferencesMessages.properties
+++ /dev/null
@@ -1,906 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
-# Sebastian Davids, sdavids@gmx.de - 187316 [preferences] Mark Occurences Pref Page; Link to
-###############################################################################
-
-
-BuildPathsPropertyPage_error_message=An error occurred while setting the include path
-BuildPathsPropertyPage_error_title=Error Setting Include Path
-BuildPathsPropertyPage_job_title=Setting include path
-BuildPathsPropertyPage_no_java_project_message=Not a JavaScript project.
-BuildPathsPropertyPage_closed_project_message=JavaScript information is not available for a closed project.
-
-BuildPathsPropertyPage_unsavedchanges_title=Setting JavaScript Include Path
-BuildPathsPropertyPage_unsavedchanges_message=The JavaScript Include path property page contains unsaved modifications. Do you want to save changes so that other build path related property pages can be updated?
-BuildPathsPropertyPage_unsavedchanges_button_save=Apply
-BuildPathsPropertyPage_unsavedchanges_button_discard=Discard
-BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later
-
-ClasspathVariablesPreferencePage_title=Include Path Variables
-ClasspathVariablesPreferencePage_description=A include path variable can be added to a project's include path.
-
-ClasspathVariablesPreferencePage_savechanges_title=Includepath Variables
-ClasspathVariablesPreferencePage_savechanges_message=Do you want to apply the changes to the include path variables now? Your changes will be lost if another page modifies the include variables as well.
-
-ImportOrganizePreferencePage_description=Preferences used by the Organize Imports action:
-ImportOrganizePreferencePage_title=Organize Imports
-
-ImportOrganizeConfigurationBlock_order_label=Define the &sorting order of import statements. A package or type name prefix (e.g. org.eclipse) is a valid entry. An import is always added to the most specific group.
-ImportOrganizeConfigurationBlock_other_static=* - all unmatched static imports
-ImportOrganizeConfigurationBlock_other_normal=* - all unmatched type imports
-ImportOrganizeConfigurationBlock_other_normal_label=Enable 'Other' group
-ImportOrganizeConfigurationBlock_order_add_button=&New...
-ImportOrganizeConfigurationBlock_order_edit_button=&Edit...
-ImportOrganizeConfigurationBlock_order_up_button=&Up
-ImportOrganizeConfigurationBlock_order_down_button=Do&wn
-ImportOrganizeConfigurationBlock_order_remove_button=&Remove
-ImportOrganizeConfigurationBlock_order_add_static_button=New Stati&c...
-ImportOrganizeConfigurationBlock_order_load_button=I&mport...
-ImportOrganizeConfigurationBlock_order_save_button=E&xport...
-ImportOrganizeConfigurationBlock_other_description=Group all import not covered by all other groups:
-ImportOrganizeConfigurationBlock_ignoreLowerCase_label=Do not create imports for &types starting with a lowercase letter
-ImportOrganizeConfigurationBlock_threshold_label=Number of &imports needed for .* (e.g. 'org.eclipse.*'):
-ImportOrganizeConfigurationBlock_error_invalidthreshold=Invalid import number.
-ImportOrganizeConfigurationBlock_error_invalidnumberofemptylines=Invalid number of empty lines between groups
-ImportOrganizeConfigurationBlock_loadDialog_title=Load Import Order from File
-ImportOrganizeConfigurationBlock_loadDialog_error_title=Load Import Order
-ImportOrganizeConfigurationBlock_loadDialog_error_message=Importing failed. Not a valid import order file.
-ImportOrganizeConfigurationBlock_saveDialog_title=Save Import Order to File
-ImportOrganizeConfigurationBlock_saveDialog_error_title=Save Import Order
-ImportOrganizeConfigurationBlock_staticthreshold_label=Number of &static imports needed for .* (e.g. 'java.lang.Math.*'):
-ImportOrganizeConfigurationBlock_saveDialog_error_message=Exporting import order file failed.
-ImportOrganizeConfigurationBlock_emptylines_between_groups_label=Empt&y lines between import groups:
-ImportOrganizeInputDialog_title=Import Group
-ImportOrganizeInputDialog_browse_packages_button=&Packages...
-ImportOrganizeInputDialog_browse_types_label=&Types...
-ImportOrganizeInputDialog_title_static=Static Import Group
-ImportOrganizeInputDialog_ChoosePackageDialog_title=Package Selection
-ImportOrganizeInputDialog_ChoosePackageDialog_description=Choose package name or package prefix:
-ImportOrganizeInputDialog_ChoosePackageDialog_empty=No packages available.
-ImportOrganizeInputDialog_ChooseTypeDialog_title=Type Selection
-ImportOrganizeInputDialog_ChooseTypeDialog_description=Choose type name:
-ImportOrganizeInputDialog_ChooseTypeDialog_error_message=A problem occurred while collecting types. Check log for more details.
-
-ImportOrganizeInputDialog_error_enterName=Enter a name or prefix.
-ImportOrganizeInputDialog_error_invalidName=Not a valid type or package name.
-ImportOrganizeInputDialog_error_entryExists=Entry already exists in list.
-ImportOrganizeInputDialog_name_group_label=Enter a prefix (e.g. 'org.eclipse') or '*' to match all imports:
-ImportOrganizeInputDialog_name_group_static_label=Enter a prefix (e.g. 'org.eclipse') or '*' to match all imports:
-JavaBasePreferencePage_description=General settings for JavaScript development:
-
-JavaBasePreferencePage_doubleclick_action=Action on double click in the Script Explorer
-JavaBasePreferencePage_doubleclick_gointo=&Go into the selected element
-JavaBasePreferencePage_doubleclick_expand=E&xpand the selected element
-JavaBasePreferencePage_do_not_hide_button=&Clear
-
-JavaBasePreferencePage_refactoring_title= Refactoring JavaScript code
-JavaBasePreferencePage_refactoring_auto_save= &Save all modified resources automatically prior to refactoring
-JavaBasePreferencePage_refactoring_lightweight=Rename in editor &without dialog
-JavaBasePreferencePage_do_not_hide_description=Clear all 'do not show again' settings and show all hidden dialogs again
-JavaBasePreferencePage_do_not_hide_dialog_title=Hidden Dialogs
-JavaBasePreferencePage_do_not_hide_dialog_message=All 'do not ask again' settings for JavaScript dialogs cleared. Hidden dialogs will be shown again.
-
-JavaBasePreferencePage_search= Search
-JavaBasePreferencePage_search_small_menu=Use &reduced search menu
-
-NewJavaProjectPreferencePage_title=New Project
-NewJavaProjectPreferencePage_description=Specify the build path entries used as default by the New JavaScript Project creation wizard:
-
-NewJavaProjectPreferencePage_sourcefolder_label=Source and output folder
-NewJavaProjectPreferencePage_sourcefolder_project=&Project
-NewJavaProjectPreferencePage_sourcefolder_folder=&Folders
-NewJavaProjectPreferencePage_folders_src=&Source folder name:
-
-
-NewJavaProjectPreferencePage_folders_error_namesempty=Enter folder names.
-NewJavaProjectPreferencePage_folders_error_invalidsrcname=Invalid source folder name: {0}
-NewJavaProjectPreferencePage_folders_error_invalidcp=Settings will result in an invalid include path. Check for nested folders.
-
-NewJavaProjectPreferencePage_error_decode=Error while decoding JRE entry
-
-JavaEditorPreferencePage_showQuickFixables= Indicate annotations solvable with &Quick Fix in vertical ruler
-JavaEditorPreferencePage_analyseAnnotationsWhileTyping= Report &problems as you type
-
-JavaEditorPreferencePage_multiLineComment=Multi-line comment
-JavaEditorPreferencePage_singleLineComment=Single-line comment
-JavaEditorPreferencePage_returnKeyword= Keyword 'return'
-JavaEditorPreferencePage_keywords=Keywords excluding 'return'
-JavaEditorPreferencePage_strings=Strings
-JavaEditorPreferencePage_others=Others
-JavaEditorPreferencePage_operators=Operators
-JavaEditorPreferencePage_brackets=Brackets
-JavaEditorPreferencePage_javaCommentTaskTags=Task Tags
-JavaEditorPreferencePage_javaDocKeywords=Tags
-JavaEditorPreferencePage_javaDocHtmlTags=HTML markup
-JavaEditorPreferencePage_javaDocLinks=Links
-JavaEditorPreferencePage_javaDocOthers=Others
-JavaEditorPreferencePage_backgroundColor=Background color
-JavaEditorPreferencePage_systemDefault=&System Default
-JavaEditorPreferencePage_custom=C&ustom:
-JavaEditorPreferencePage_semanticHighlighting_option= &Enable advanced coloring
-JavaEditorPreferencePage_foreground=Ele&ment:
-JavaEditorPreferencePage_color=C&olor:
-JavaEditorPreferencePage_bold=&Bold
-JavaEditorPreferencePage_italic=&Italic
-JavaEditorPreferencePage_strikethrough=&Strikethrough
-JavaEditorPreferencePage_underline=&Underline
-JavaEditorPreferencePage_enable=Enab&le
-JavaEditorPreferencePage_preview=Previe&w:
-JavaEditorPreferencePage_displayedTabWidth=Displayed &tab width:
-JavaEditorPreferencePage_insertSpaceForTabs=Ins&ert spaces for tab (see Code Formatter preference page)
-JavaEditorPreferencePage_showOverviewRuler=Show overview &ruler
-JavaEditorPreferencePage_highlightMatchingBrackets=Highlight &matching brackets
-JavaEditorPreferencePage_highlightCurrentLine=Highlight &current line
-JavaEditorPreferencePage_showPrintMargin=Sho&w print margin
-JavaEditorPreferencePage_printMarginColumn=&Print margin column:
-JavaEditorPreferencePage_insertSingleProposalsAutomatically=Insert single &proposals automatically
-JavaEditorPreferencePage_showOnlyProposalsVisibleInTheInvocationContext=Hide proposals &not visible in the invocation context
-JavaEditorPreferencePage_presentProposalsInAlphabeticalOrder=&Sort proposals
-JavaEditorPreferencePage_coloring_element=&Element:
-JavaEditorPreferencePage_enableAutoActivation=&Enable auto activation
-#JavaEditorPreferencePage_automaticallyAddImportInsteadOfQualifiedName=Add import instead of qua&lified name
-#JavaEditorPreferencePage_suggestStaticImports=&Use static imports (only 5.0 or higher)
-JavaEditorPreferencePage_completionInserts=Completion inser&ts
-JavaEditorPreferencePage_completionOverwrites=Completion over&writes
-JavaEditorPreferencePage_completionToggleHint=Press 'Ctrl' to toggle while content assist is active
-JavaEditorPreferencePage_fillArgumentNamesOnMethodCompletion=&Fill argument names on completion
-JavaEditorPreferencePage_guessArgumentNamesOnMethodCompletion=&Guess filled function arguments
-JavaEditorPreferencePage_autoActivationDelay=A&uto activation delay:
-JavaEditorPreferencePage_autoActivationTriggersForJava=Auto activation triggers for &JavaScript:
-JavaEditorPreferencePage_autoActivationTriggersForJavaDoc=Auto activation triggers for Jsd&oc:
-JavaEditorPreferencePage_completePrefixes= &Insert common prefixes automatically
-
-JavaEditorPreferencePage_backgroundForCompletionProposals= Completion proposal background
-JavaEditorPreferencePage_foregroundForCompletionProposals= Completion proposal foreground
-JavaEditorPreferencePage_backgroundForMethodParameters= Parameter hints background
-JavaEditorPreferencePage_foregroundForMethodParameters= Parameter hints foreground
-JavaEditorPreferencePage_backgroundForCompletionReplacement= Completion overwrite background
-JavaEditorPreferencePage_foregroundForCompletionReplacement= Completion overwrite foreground
-JavaEditorPreferencePage_sourceHoverBackgroundColor= Source hover background
-
-JavaEditorPreferencePage_general=Appeara&nce
-JavaEditorPreferencePage_colors=Synta&x
-JavaEditorPreferencePage_empty_input=Empty input
-JavaEditorPreferencePage_invalid_input=''{0}'' is not a valid input.
-JavaEditorPreferencePage_showLineNumbers=Show lin&e numbers
-JavaEditorPreferencePage_lineNumberForegroundColor=Line number foreground
-JavaEditorPreferencePage_matchingBracketsHighlightColor2=Matching brackets highlight
-JavaEditorPreferencePage_currentLineHighlighColor=Current line highlight
-JavaEditorPreferencePage_printMarginColor2=Print margin
-JavaEditorPreferencePage_appearanceOptions=Appearance co&lor options:
-
-JavaEditorPreferencePage_typing_tabTitle=T&yping
-JavaEditorPreferencePage_typing_description= Enable these typing aids in Smart Insert mode:
-JavaEditorPreferencePage_closeStrings= "&Strings"
-JavaEditorPreferencePage_closeBrackets= (Parentheses), [square] and <angle> brac&kets
-JavaEditorPreferencePage_closeBraces= {B&races}
-JavaEditorPreferencePage_closeJavaDocs= Ja&vadoc and comment regions
-JavaEditorPreferencePage_wrapStrings= &Wrap automatically
-JavaEditorPreferencePage_escapeStrings= Escape text w&hen pasting into a string literal
-JavaEditorPreferencePage_addJavaDocTags= Add &Jsdoc tags
-JavaEditorPreferencePage_smartPaste= Adjust &indentation
-JavaEditorPreferencePage_link=JavaScript editor preferences. Note that some preferences may be set on the <a>Text Editors</a> preference page.
-JavaEditorPreferencePage_link_tooltip=Show the shared text editor preferences
-JavaEditorPreferencePage_importsOnPaste=&Update imports
-JavaEditorPreferencePage_subWordNavigation= Smart &caret positioning in JavaScript names (overrides platform behavior)
-JavaEditorPreferencePage_typing_smartSemicolon= Se&micolons
-JavaEditorPreferencePage_typing_smartOpeningBrace= &Braces
-JavaEditorPreferencePage_typing_smartTab= &Tab key adjusts the indentation of the current line
-JavaEditorPropertyPage_SaveActionLink_Text=The actions to execute when the JavaScript Editor is saved can be configured on to the <a>Save Action</a> property page.
-
-# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts"
-JavaEditorColoringConfigurationBlock_link= Default colors and font can be configured on the <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">Text Editors</a> and on the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">Colors and Fonts</a> preference page.
-
-JavaEditorPreferencePage_hoverTab_title= Ho&vers
-
-JavaBasePreferencePage_openTypeHierarchy=When opening a Type Hierarchy
-JavaBasePreferencePage_inView=Show the &Type Hierarchy View in the current perspective
-JavaBasePreferencePage_dialogs=JavaScript dialogs
-JavaBasePreferencePage_inPerspective=Open a new Type Hierarchy &Perspective
-
-JavaEditorPreferencePage_quickassist_lightbulb=L&ight bulb for quick assists
-JavaEditorPreferencePage_showJavaElementOnly= O&nly show the selected JavaScript element
-
-JavaEditorPreferencePage_accessibility_disableCustomCarets= &Use custom caret
-JavaEditorPreferencePage_accessibility_wideCaret= Enable thic&k caret
-
-JavaEditorHoverConfigurationBlock_annotationRollover= &Expand vertical ruler icons upon hovering (does not affect open editors)
-JavaEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences:
-JavaEditorHoverConfigurationBlock_enabled= &Enabled
-JavaEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering:
-JavaEditorHoverConfigurationBlock_description= Descriptio&n:
-JavaEditorHoverConfigurationBlock_modifierIsNotValid= Modifier ''{0}'' is not valid.
-JavaEditorHoverConfigurationBlock_modifierIsNotValidForHover= Modifier ''{0}'' for ''{1}'' hover is not valid.
-JavaEditorHoverConfigurationBlock_duplicateModifier= ''{0}'' hover uses the same modifier as ''{1}'' hover.
-JavaEditorHoverConfigurationBlock_nameColumnTitle= Text Hover Name
-JavaEditorHoverConfigurationBlock_modifierColumnTitle= Pressed Key Modifier While Hovering
-
-JavaEditorHoverConfigurationBlock_delimiter= +
-JavaEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter= \ + {0} +
-JavaEditorHoverConfigurationBlock_insertModifierAndDelimiter= \ {0} +
-JavaEditorHoverConfigurationBlock_insertDelimiterAndModifier= \ + {0}
-
-MarkOccurrencesConfigurationBlock_title= &Mark Occurrences
-
-# DO NOT TRANSLATE "org.eclipse.ui.editors.preferencePages.Annotations"
-MarkOccurrencesConfigurationBlock_link= The appearance can be configured on the <a href=\"org.eclipse.ui.editors.preferencePages.Annotations\">Annotations</a> preference page.
-
-MarkOccurrencesConfigurationBlock_link_tooltip=Show the annotations preferences
-MarkOccurrencesConfigurationBlock_markOccurrences= Mark &occurrences of the selected element in the current file.
-#MarkOccurrencesConfigurationBlock_markTypeOccurrences= &Types
-MarkOccurrencesConfigurationBlock_markMethodOccurrences= &Functions
-MarkOccurrencesConfigurationBlock_markConstantOccurrences= &Constants
-#MarkOccurrencesConfigurationBlock_markFieldOccurrences= &Non-constant fields
-MarkOccurrencesConfigurationBlock_markLocalVariableOccurrences= &Local variables
-#MarkOccurrencesConfigurationBlock_markExceptionOccurrences= E&xpressions throwing a declared exception
-MarkOccurrencesConfigurationBlock_markMethodExitPoints= Function &exits
-#MarkOccurrencesConfigurationBlock_markImplementors= Functions implementing an &interface
-MarkOccurrencesConfigurationBlock_markBreakContinueTargets= Targets of &break and continue statements
-MarkOccurrencesConfigurationBlock_stickyOccurrences= &Keep marks when the selection changes
-
-JavaElementInfoPage_binary=binary
-JavaElementInfoPage_classpath_entry_kind=Classpath entry kind:
-JavaElementInfoPage_library=library
-JavaElementInfoPage_nameLabel=Name:
-JavaElementInfoPage_not_present=not present
-JavaElementInfoPage_package=Package:
-JavaElementInfoPage_package_contents=Package contents:
-JavaElementInfoPage_project=project
-JavaElementInfoPage_resource_path=Resource path:
-JavaElementInfoPage_source=source
-JavaElementInfoPage_variable=variable
-JavaElementInfoPage_variable_path=Variable path:
-JavaElementInfoPage_location=Location:
-
-JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description=Specify the location (URL) of the documentation generated by Jsdoc. The Jsdoc location will contain a file called 'package-list'.
-JavadocConfigurationBlock_workspace_archive_selection_dialog_title=Jsdoc Archive Selection Dialog
-JavadocConfigurationBlock_workspace_archive_selection_dialog_description=&Choose the archive containing the documentation
-JavadocConfigurationPropertyPage_IsIncorrectElement_description=Jsdoc location can only be attached to JavaScript projects or archives and class folders in JavaScript projects. Source folders use the location specified at their project.
-JavadocConfigurationPropertyPage_IsJavaProject_description=Specify the location of the project\'s Jsdoc documentation. This location is used by the Jsdoc export wizard as the default value and by the \'Open External Jsdoc\' action. For example: \'file:/c:/myworkspace/myproject/doc\'.
-JavadocConfigurationPropertyPage_invalid_container=The current class path entry belongs to container ''{0}'' which can not be configured.
-JavadocConfigurationPropertyPage_not_supported=The current class path entry belongs to container ''{0}'' which does not support the attachment of Javadoc to its entries.
-
-JavadocConfigurationBlock_browse_archive_button=&Browse...
-JavadocConfigurationBlock_error_notafolder=Location does not exist.
-JavadocConfigurationPropertyPage_read_only=The current class path entry belongs to container ''{0}'' which does not allow user modifications to Javadoc locations on its entries.
-JavadocConfigurationBlock_javadocFolderDialog_label=Jsdoc Location Selection
-JavadocConfigurationBlock_javadocFolderDialog_message=Select Jsdoc location:
-JavadocConfigurationBlock_MalformedURL_error=Invalid URL
-JavadocConfigurationBlock_validate_button=&Validate...
-JavadocConfigurationBlock_workspace_radio=Wor&kspace file
-JavadocConfigurationBlock_InvalidLocation_message=Location might be invalid. Files 'package-list' and 'index.html' that are typically available at the root of documentation created by the Jsdoc tool have not been found.
-JavadocConfigurationBlock_ValidLocation_message=Location is likely valid. Files 'package-list' and 'index.html' have been found. Open the location in your browser?
-JavadocConfigurationBlock_UnableToValidateLocation_message=Cannot validate Jsdoc location.
-JavadocConfigurationBlock_MessageDialog_title=Validating Jsdoc Location
-JavadocConfigurationBlock_location_type_path_label=Jsdoc &URL (e.g. 'http://www.sample-url.org/doc/' or 'file:/c:/myworkspace/myproject/doc')
-JavadocConfigurationBlock_location_type_jar_label=Jsdoc in ar&chive
-JavadocConfigurationBlock_location_path_label=&Jsdoc location path:
-JavadocConfigurationBlock_location_jar_label=Archive &path:
-JavadocConfigurationBlock_jar_path_label=Path &within archive:
-JavadocConfigurationBlock_zipImportSource_title=Jsdoc Archive Selection
-JavadocConfigurationBlock_location_in_jarorzip_message=&Select the folder that is the root of the Jsdoc documentation:
-JavadocConfigurationBlock_browse_jarorzip_path_title=Jsdoc Root Location
-JavadocConfigurationBlock_browse_archive_path_button=Br&owse...
-JavadocConfigurationBlock_browse_folder_button=&Browse...
-JavadocConfigurationBlock_error_notafile=Archive can not be found in file system
-JavadocConfigurationBlock_external_radio=E&xternal file
-JavadocConfigurationBlock_error_invalidarchivepath=Archive path is not a valid path.
-JavadocConfigurationBlock_error_archivepathnotabsolute=Archive path must be an absolute path.
-JavadocConfigurationBlock_error_archive_not_found_in_workspace=Archive can not be found in workspace
-
-SourceAttachmentPropertyPage_error_title=Error Attaching Source
-SourceAttachmentPropertyPage_read_only=The current class path entry belongs to container ''{0}'' which does not allow user modifications to source attachments on its entries.
-SourceAttachmentPropertyPage_error_message=An error occurred while associating the source
-SourceAttachmentPropertyPage_not_supported=The current class path entry belongs to container ''{0}'' which does not support the attachment of sources to its entries.
-SourceAttachmentPropertyPage_noarchive_message=Source can only be attached to archive and class folders in JavaScript projects.
-SourceAttachmentPropertyPage_invalid_container=The current class path entry belongs to container ''{0}'' which can not be configured.
-SourceAttachmentPropertyPage_containerentry_message=JAR belongs to the container ''{0}''.\nTo configure the source attachment, go directly to the corresponding configuration page (For example for JREs go to ''Installed JREs'' page in the preferences).
-
-
-AppearancePreferencePage_description= Appearance of JavaScript elements in viewers:
-#AppearancePreferencePage_methodreturntype_label= Show &function return types
-AppearancePreferencePage_inferredmethodreturntype_label= Show inferred &function return types
-#AppearancePreferencePage_methodtypeparams_label=Show function type pa&rameters
-AppearancePreferencePage_showCategory_label=Show categ&ories
-#AppearancePreferencePage_pkgNamePatternEnable_label= &Compress all package name segments, except the final segment
-#AppearancePreferencePage_pkgNamePattern_label= Com&pression pattern (e.g. given package name 'org.eclipse.wst.jsdt' pattern '.' will compress it to '..jdt', '0' to 'jdt', '1~.' to 'o~.e~.jdt'):
-AppearancePreferencePage_coloredlabels_label=Sho&w colored labels
-AppearancePreferencePage_showMembersInPackagesView=S&how members in Script Explorer
-AppearancePreferencePage_stackViewsVerticallyInTheJavaBrowsingPerspective=&Stack views vertically in the JavaScript Browsing perspective
-#AppearancePreferencePage_note=Note:
-#AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives=This preference will only take effect on new perspectives
-AppearancePreferencePage_packageNameCompressionPattern_error_isEmpty=Enter a package name compression pattern
-#AppearancePreferencePage_foldEmptyPackages= &Fold empty packages in hierarchical Script Explorer layout
-AppearancePreferencePage_foldEmptySourceFolders= &Fold empty source folders in hierarchical Script Explorer layout
-
-CodeFormatterPreferencePage_title=Code Formatter
-CodeFormatterPreferencePage_description=Sele&ct a profile:
-
-
-TodoTaskPreferencePage_title=Task Tags
-TodoTaskPreferencePage_description=&Strings indicating tasks in JavaScript comments. The entry marked as default will be used in the code templates.
-
-TodoTaskConfigurationBlock_markers_tasks_high_priority=High
-TodoTaskConfigurationBlock_markers_tasks_normal_priority=Normal
-TodoTaskConfigurationBlock_markers_tasks_low_priority=Low
-TodoTaskConfigurationBlock_markers_tasks_add_button=&New...
-TodoTaskConfigurationBlock_markers_tasks_remove_button=&Remove
-TodoTaskConfigurationBlock_markers_tasks_edit_button=&Edit...
-TodoTaskConfigurationBlock_markers_tasks_name_column=Tag
-TodoTaskConfigurationBlock_markers_tasks_priority_column=Priority
-TodoTaskConfigurationBlock_markers_tasks_setdefault_button=Defa&ult
-TodoTaskConfigurationBlock_casesensitive_label=&Case sensitive task tag names
-
-TodoTaskConfigurationBlock_needsbuild_title=Task Tags Settings Changed
-TodoTaskConfigurationBlock_tasks_default={0} (default)
-TodoTaskConfigurationBlock_needsfullbuild_message=The task tags settings have changed. A full rebuild is required to for changes to take effect. Do the full build now?
-TodoTaskConfigurationBlock_needsprojectbuild_message=The task tags settings have changed. A rebuild of the project is required for changes to take effect. Build the project 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=An entry with the same name already exists.
-TodoTaskInputDialog_error_noSpace=Name cannot begin or end with a whitespace.
-
-PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings...
-PropertyAndPreferencePage_showprojectspecificsettings_label=Configure Project Specific Settings...
-PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings
-
-JavaBuildPreferencePage_title=Builder
-JavaBuildPreferencePage_description=Options for the JavaScript compiler:\nNote that a full rebuild is required for changes to take effect.
-
-JavaBuildConfigurationBlock_section_general=&General
-JavaBuildConfigurationBlock_section_output_folder=Out&put folder
-JavaBuildConfigurationBlock_section_access_rules=A&ccess rule severities
-JavaBuildConfigurationBlock_section_build_path_problems=&Build path problems
-
-
-JavaBuildConfigurationBlock_error=Error
-JavaBuildConfigurationBlock_warning=Warning
-JavaBuildConfigurationBlock_ignore=Ignore
-
-JavaBuildConfigurationBlock_needsbuild_title=Building Settings Changed
-JavaBuildConfigurationBlock_needsfullbuild_message=The Building settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
-ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal=Treat errors like &fatal compiler errors (make compiled code not executable)
-JavaBuildConfigurationBlock_needsprojectbuild_message=The Building settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
-
-JavaBuildConfigurationBlock_resource_filter_description=Filtered resources are not be copied to the output folder during a build. List is comma separated (e.g. '*.doc, plugin.xml, scripts/')
-JavaBuildConfigurationBlock_resource_filter_label=Fi&ltered Resources:
-JavaBuildConfigurationBlock_build_invalid_classpath_label=Abo&rt build when include path errors occur
-JavaBuildConfigurationBlock_build_recreate_modified=Rebuild class files modified by others
-
-JavaBuildConfigurationBlock_build_clean_outputfolder_label=Scrub output folders &when cleaning projects
-JavaBuildConfigurationBlock_enable_exclusion_patterns_label=Enable use of e&xclusion patterns in source folders
-JavaBuildConfigurationBlock_enable_multiple_outputlocations_label=Enable use of m&ultiple output locations for source folders
-
-JavaBuildConfigurationBlock_pb_incomplete_build_path_label=I&ncomplete build path:
-ProblemSeveritiesConfigurationBlock_pb_discourraged_reference_label=Di&scouraged reference (access rules):
-JavaBuildConfigurationBlock_pb_build_path_cycles_label=Circular d&ependencies:
-JavaBuildConfigurationBlock_pb_duplicate_resources_label=Duplica&ted resources:
-ProblemSeveritiesConfigurationBlock_pb_forbidden_reference_label=&Forbidden reference (access rules):
-JavaBuildConfigurationBlock_pb_max_per_unit_label=&Maximum number of problems reported per JavaScript file:
-
-JavaBuildConfigurationBlock_pb_check_prereq_binary_level_label=In&compatible required binaries:
-
-JavaBuildConfigurationBlock_empty_input=Number of problems cannot be empty.
-JavaBuildConfigurationBlock_invalid_input={0} is not a valid number of problems.
-JavaBuildConfigurationBlock_filter_invalidsegment_error=Filter is invalid: {0}
-
-ProblemSeveritiesPreferencePage_title=Problem Severities
-
-ProblemSeveritiesConfigurationBlock_error=Error
-ProblemSeveritiesConfigurationBlock_warning=Warning
-ProblemSeveritiesConfigurationBlock_ignore=Ignore
-
-ProblemSeveritiesConfigurationBlock_section_potential_programming_problems=&Potential programming problems
-ProblemSeveritiesConfigurationBlock_section_unnecessary_code=&Unnecessary code
-ProblemSeveritiesConfigurationBlock_section_nls=String e&xternalization
-ProblemSeveritiesConfigurationBlock_Resolution=&Resolution
-ProblemSeveritiesConfigurationBlock_section_code_style=&Code style
-ProblemSeveritiesConfigurationBlock_section_generics=&Generic types
-ProblemSeveritiesConfigurationBlock_section_deprecations=D&eprecated and restricted API
-ProblemSeveritiesConfigurationBlock_section_name_shadowing=Name shadowing and conflicts
-ProblemSeveritiesConfigurationBlock_section_annotations=A&nnotations
-ProblemSeveritiesConfigurationBlock_needsbuild_title=Error/Warning Settings Changed
-ProblemSeveritiesConfigurationBlock_UnresolvedTypes=Unresolved Types
-ProblemSeveritiesConfigurationBlock_UnresolvedFields=Unresolved Fields
-ProblemSeveritiesConfigurationBlock_needsfullbuild_message=The Error/Warning settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
-ProblemSeveritiesConfigurationBlock_needsprojectbuild_message=The Error/Warning settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
-
-ProblemSeveritiesConfigurationBlock_common_description=Select the severity level for the following optional JavaScript validator problems:
-ProblemSeveritiesConfigurationBlock_pb_unsafe_type_op_label=Unchecked generic type operation:
-ProblemSeveritiesConfigurationBlock_pb_raw_type_reference=Usage of a raw type:
-ProblemSeveritiesConfigurationBlock_pb_final_param_bound_label=Generic t&ype parameter declared with a final type bound:
-ProblemSeveritiesConfigurationBlock_pb_inexact_vararg_label=Inexact type &match for vararg arguments:
-
-ProblemSeveritiesConfigurationBlock_pb_accidential_assignement_label=Po&ssible accidental boolean assignment (e.g. 'if (a = b)'):
-ProblemSeveritiesConfigurationBlock_pb_local_variable_hiding_label=Local &variable declaration hides another field or variable:
-ProblemSeveritiesConfigurationBlock_pb_field_hiding_label=Field declaration &hides another field or variable:
-ProblemSeveritiesConfigurationBlock_pb_special_param_hiding_label=Include constructor or setter function parameters
-ProblemSeveritiesConfigurationBlock_pb_unqualified_field_access_label=Un&qualified access to instance field:
-ProblemSeveritiesConfigurationBlock_pb_finally_block_not_completing_label='&finally' does not complete normally:
-ProblemSeveritiesConfigurationBlock_pb_undocumented_empty_block_label=Undocumented empty &block:
-ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_label=Unnecessary declaration of thrown checked exception:
-ProblemSeveritiesConfigurationBlock_pb_unhandled_surpresswarning_tokens=Unhandled warning token in '@SuppressWarnings':
-ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_when_overriding_label=Check overriding and implementing functions
-ProblemSeveritiesConfigurationBlock_pb_missing_serial_version_label=Seriali&zable class without serialVersionUID:
-
-ProblemSeveritiesConfigurationBlock_pb_undefined_field_label=Undefined Field:
-ProblemSeveritiesConfigurationBlock_pb_method_naming_label=&Function with a constructor name:
-ProblemSeveritiesConfigurationBlock_pb_no_effect_assignment_label=Assignmen&t has no effect (e.g. 'x = x'):
-ProblemSeveritiesConfigurationBlock_pb_incompatible_interface_method_label=Interface function conflicts &with protected 'Object' function:
-ProblemSeveritiesConfigurationBlock_pb_indirect_access_to_static_label=&Indirect access to static member:
-ProblemSeveritiesConfigurationBlock_pb_hidden_catchblock_label=Hidden catch bloc&k:
-ProblemSeveritiesConfigurationBlock_pb_static_access_receiver_label=&Non-static access to static member:
-ProblemSeveritiesConfigurationBlock_pb_unused_imports_label=Unused &import:
-ProblemSeveritiesConfigurationBlock_pb_unused_local_label=&Local variable is never read:
-ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label=Parameter is never read:
-ProblemSeveritiesConfigurationBlock_pb_signal_param_in_overriding_label=Check overriding and implementing functions
-ProblemSeveritiesConfigurationBlock_pb_unused_private_label=Unused local or private member:
-ProblemSeveritiesConfigurationBlock_pb_parameter_assignment=Parameter assignment:
-ProblemSeveritiesConfigurationBlock_pb_redundant_null_check=Redundant null check:
-ProblemSeveritiesConfigurationBlock_pb_non_externalized_strings_label=Non-externalized strings (missing/unused $NON-NLS$ tag):
-ProblemSeveritiesConfigurationBlock_pb_deprecation_label=Deprecated API:
-ProblemSeveritiesConfigurationBlock_pb_deprecation_in_deprecation_label=Signal use of deprecated API inside deprecated code
-ProblemSeveritiesConfigurationBlock_pb_deprecation_when_overriding_label=Signal overriding or implementing deprecated function
-ProblemSeveritiesConfigurationBlock_pb_empty_statement_label=Empty statement:
-ProblemSeveritiesConfigurationBlock_LooselyDeclaredGlobalVar=Loosely Declared, Globaly Scoped Variable Usage
-ProblemSeveritiesConfigurationBlock_pb_unnecessary_type_check_label=Unnecessary cast or 'instanceof' operation:
-ProblemSeveritiesConfigurationBlock_pb_incomplete_enum_switch_label=Enum type constant not covered on 'switch':
-ProblemSeveritiesConfigurationBlock_pb_null_reference=Null reference:
-ProblemSeveritiesConfigurationBlock_UnresolvedMethods=Unresolved Methods
-ProblemSeveritiesConfigurationBlock_Optionalsemicolon=Optional Semi-Colon
-ProblemSeveritiesConfigurationBlock_pb_potential_null_reference=Potential null pointer access:
-ProblemSeveritiesConfigurationBlock_pb_fall_through_case='switch' case fall-through:
-ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label=Unnecessary 'else' statement:
-ProblemSeveritiesConfigurationBlock_pb_synth_access_emul_label=Access to a non-accessible member of an enclosing type:
-ProblemSeveritiesConfigurationBlock_pb_autoboxing_problem_label=Boxing and unboxing conversions:
-ProblemSeveritiesConfigurationBlock_pb_char_array_in_concat_label=Using a char array in string concatenation:
-ProblemSeveritiesConfigurationBlock_pb_missing_override_annotation_label=Missing '@Override' annotation:
-ProblemSeveritiesConfigurationBlock_pb_enable_surpresswarning_annotation=Enable '@SuppressWarnings' annotations
-ProblemSeveritiesConfigurationBlock_pb_missing_deprecated_annotation_label=Missing '@Deprecated' annotation:
-ProblemSeveritiesConfigurationBlock_pb_annotation_super_interface_label=Annotation is used as super interface:
-ProblemSeveritiesConfigurationBlock_ignore_documented_unused_parameters=Ignore parameters documented with '&@param' tag
-ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label=Type parameter hides another type:
-ProblemSeveritiesConfigurationBlock_pb_unused_label_label=Unused 'break' or 'continue' label:
-JavadocProblemsPreferencePage_title=Jsdoc Comments
-
-JavadocProblemsConfigurationBlock_public=Public
-JavadocProblemsConfigurationBlock_protected=Protected
-JavadocProblemsConfigurationBlock_default=Default
-JavadocProblemsConfigurationBlock_private=Private
-
-JavadocProblemsConfigurationBlock_error=Error
-JavadocProblemsConfigurationBlock_warning=Warning
-JavadocProblemsConfigurationBlock_ignore=Ignore
-
-JavadocProblemsConfigurationBlock_needsbuild_title=Jsdoc Settings Changed
-JavadocProblemsConfigurationBlock_needsfullbuild_message=The Jsdoc settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
-JavadocProblemsConfigurationBlock_needsprojectbuild_message=The Jsdoc settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
-
-JavadocProblemsConfigurationBlock_javadoc_description=Severity level for problems in Jsdoc comments:
-
-JavadocProblemsConfigurationBlock_pb_javadoc_support_label=Proc&ess Jsdoc comments (includes search and refactoring)
-JavadocProblemsConfigurationBlock_pb_invalid_javadoc_label=Mal&formed Jsdoc comments:
-JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_label=Report e&rrors in tags
-JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_visibility_label=On&ly consider members as visible as:
-JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_not_visible_ref_label=Report non &visible references
-JavadocProblemsConfigurationBlock_pb_invalid_javadoc_tags_deprecated_label=Report de&precated references
-JavadocProblemsConfigurationBlock_pb_missing_javadoc_label=Missing Jsdoc &tags:
-JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_visibility_label=O&nly consider members as visible as:
-JavadocProblemsConfigurationBlock_pb_missing_javadoc_tags_overriding_label=C&heck overriding and implementing functions
-JavadocProblemsConfigurationBlock_pb_missing_comments_label=&Missing Jsdoc comments:
-JavadocProblemsConfigurationBlock_pb_missing_comments_visibility_label=&Only consider members as visible as:
-JavadocProblemsConfigurationBlock_pb_missing_comments_overriding_label=Chec&k overriding and implementing functions
-
-
-CompliancePreferencePage_title=Compiler
-CompliancePreferencePage_description=Options for the JavaScript validator:\nNote that a full rebuild is required for changes to take effect.
-
-ComplianceConfigurationBlock_error=Error
-ComplianceConfigurationBlock_warning=Warning
-ComplianceConfigurationBlock_ignore=Ignore
-
-ComplianceConfigurationBlock_version11=1.1
-ComplianceConfigurationBlock_version12=1.2
-ComplianceConfigurationBlock_version13=1.3
-ComplianceConfigurationBlock_version14=ECMAScript 3
-ComplianceConfigurationBlock_version15=ECMAScript 4
-ComplianceConfigurationBlock_version16=6.0
-
-ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed
-ComplianceConfigurationBlock_needsfullbuild_message=The compiler settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
-ComplianceConfigurationBlock_needsprojectbuild_message=The compiler settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
-
-ComplianceConfigurationBlock_variable_attr_label=Add varia&ble attributes to generated class files (used by the debugger)
-ComplianceConfigurationBlock_line_number_attr_label=Add &line number attributes to generated class files (used by the debugger)
-ComplianceConfigurationBlock_source_file_attr_label=Add source &file name to generated class file (used by the debugger)
-ComplianceConfigurationBlock_src_greater_compliance=Source compatibility must be equal or less than compliance level.
-ComplianceConfigurationBlock_codegen_unused_local_label=Pr&eserve unused (never read) local variables
-ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label=Inline finally bl&ocks (larger class files, but improved performance)
-ComplianceConfigurationBlock_compiler_compliance_label=ECMAScript compliance level:
-ComplianceConfigurationBlock_default_settings_label=Use defaul&t compliance settings
-ComplianceConfigurationBlock_source_compatibility_label=Source co&mpatibility:
-ComplianceConfigurationBlock_codegen_targetplatform_label=Ge&nerated .class files compatibility:
-ComplianceConfigurationBlock_pb_assert_as_identifier_label=Disallow identifie&rs called 'assert':
-ComplianceConfigurationBlock_pb_enum_as_identifier_label=Disallo&w identifiers called 'enum':
-ComplianceConfigurationBlock_compliance_group_label=ECMAScript Compliance
-ComplianceConfigurationBlock_classfiles_group_label=Classfile Generation
-ComplianceConfigurationBlock_classfile_greater_compliance=Classfile compatibility must be equal or less than compliance level.
-ComplianceConfigurationBlock_classfile_greater_source=Classfile compatibility must be greater or equal than source compatibility.
-
-ComplianceConfigurationBlock_jrecompliance_info=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (Currently {1}). <a href="1" >Configure...</a>
-ComplianceConfigurationBlock_jrecompliance_info_project=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (Currently {1}). Configure the <a href="1" >Installed JREs</a> or change the JRE on the <a href="2" >Java build path</a>.
-
-OptionsConfigurationBlock_job_title=Rebuilding
-
-OptionsConfigurationBlock_buildall_taskname=Build all...
-OptionsConfigurationBlock_buildproject_taskname=Build project ''{0}''...
-
-CodeStylePreferencePage_title=Code Style
-CodeTemplatesPreferencePage_title=Code Templates
-
-JavaCategoryPropertyPage_text=<form>\
-Project specific settings for project ''{0}''. If specified, they override settings defined in the global workspace preferences.\
-<li><a href=''{1}''>Build path</a>: Configures the paths used to find source files and classes and defines the output locations for the generated class files.</li>\
-<li><a href=''{2}''>Compiler</a>: Specifies the used compiler compliance and various options for the JavaScript validator like <a href=''{3}''>Todo</a> tasks, problem <a href=''{4}''>severities</a>, <a href=''{5}''>Jsdoc</a> processing and <a href=''{6}''>build</a> options</li>\
-<li><a href=''{7}''>Code Style</a>: Defines the rules used when creating code, including your preferred code <a href=''{8}''>formatter</a> settings, used code <a href=''{9}''>templates</a> and <a href=''{10}''>import</a> order</li>\
-<li><a href=''{11}''>Jsdoc location</a>: Configures the location where you want to generate your documentation to.</li>\
-</form>
-
-
-NameConventionConfigurationBlock_field_label=Fields
-NameConventionConfigurationBlock_static_label=Static Fields
-NameConventionConfigurationBlock_arg_label=Parameters
-NameConventionConfigurationBlock_local_label=Local Variables
-#NameConventionConfigurationBlock_keywordthis_label=&Qualify all generated field accesses with 'this.'
-NameConventionConfigurationBlock_isforbooleangetters_label=&Use 'is' prefix for getters that return boolean
-NameConventionConfigurationBlock_use_override_annotation_label=Add '@O&verride' annotation for new overriding functions
-
-NameConventionConfigurationBlock_dialog_prefix=P&refix list:
-NameConventionConfigurationBlock_dialog_suffix=S&uffix list:
-
-NameConventionConfigurationBlock_exceptionname_label=E&xception variable name in catch blocks:
-
-NameConventionConfigurationBlock_error_emptyprefix=Prefix strings cannot contain an empty entry.
-NameConventionConfigurationBlock_error_emptysuffix=Suffix strings cannot contain an empty entry.
-NameConventionConfigurationBlock_error_invalidprefix={0} is not a valid prefix.
-NameConventionConfigurationBlock_error_invalidsuffix={0} is not a valid suffix.
-
-NameConventionConfigurationBlock_list_label=&Conventions for variable names:
-NameConventionConfigurationBlock_list_edit_button=&Edit...
-NameConventionConfigurationBlock_list_name_column=Variable type
-NameConventionConfigurationBlock_list_prefix_column=Prefix list
-NameConventionConfigurationBlock_list_suffix_column=Suffix list
-
-NameConventionConfigurationBlock_field_dialog_title=Field Name Conventions
-NameConventionConfigurationBlock_field_dialog_message=Specify prefix and suffix to be used for fields (comma separated):
-
-NameConventionConfigurationBlock_static_dialog_title=Static Field Name Conventions
-NameConventionConfigurationBlock_static_dialog_message=Specify prefix and suffix to be used for static fields (comma separated):
-
-NameConventionConfigurationBlock_arg_dialog_title=Parameter Name Conventions
-NameConventionConfigurationBlock_arg_dialog_message=Specify prefix and suffix to be used for parameters (comma separated):
-
-NameConventionConfigurationBlock_local_dialog_title=Local Variable Name Conventions
-NameConventionConfigurationBlock_local_dialog_message=Specify prefix and suffix to be used for local variables (comma separated):
-
-MembersOrderPreferencePage_category_button_up=&Up
-MembersOrderPreferencePage_category_button_down=D&own
-
-MembersOrderPreferencePage_visibility_button_up=U&p
-MembersOrderPreferencePage_visibility_button_down=Do&wn
-
-MembersOrderPreferencePage_label_description=&Choose the order in which members will be displayed. The order is also used by the 'Sort Members' action.
-
-
-#MembersOrderPreferencePage_fields_label=Fields
-MembersOrderPreferencePage_vars_label=Vars
-MembersOrderPreferencePage_constructors_label=Constructors
-MembersOrderPreferencePage_methods_label=Functions
-MembersOrderPreferencePage_staticfields_label=Static Fields
-MembersOrderPreferencePage_staticmethods_label=Static Functions
-MembersOrderPreferencePage_initialisers_label=Initializers
-MembersOrderPreferencePage_staticinitialisers_label=Static Initializers
-MembersOrderPreferencePage_types_label=Types
-MembersOrderPreferencePage_public_label=Public
-MembersOrderPreferencePage_private_label=Private
-MembersOrderPreferencePage_protected_label=Protected
-MembersOrderPreferencePage_default_label=Default
-MembersOrderPreferencePage_usevisibilitysort_label=&Sort members in same category by visibility
-CodeTemplateBlock_templates_comment_node=Comments
-CodeTemplateBlock_templates_code_node=Code
-
-CodeTemplateBlock_catchblock_label=Catch block body
-CodeTemplateBlock_methodstub_label=Function body
-CodeTemplateBlock_constructorstub_label=Constructor body
-CodeTemplateBlock_newtype_label=New JavaScript files
-CodeTemplateBlock_classbody_label=Class body
-CodeTemplateBlock_interfacebody_label=Interface body
-CodeTemplateBlock_enumbody_label=Enum body
-CodeTemplateBlock_annotationbody_label=Annotation body
-CodeTemplateBlock_typecomment_label=Types
-CodeTemplateBlock_fieldcomment_label=Fields
-CodeTemplateBlock_filecomment_label=Files
-CodeTemplateBlock_methodcomment_label=Functions
-CodeTemplateBlock_overridecomment_label=Overriding functions
-CodeTemplateBlock_delegatecomment_label=Delegate functions
-CodeTemplateBlock_constructorcomment_label=Constructors
-CodeTemplateBlock_gettercomment_label=Getters
-CodeTemplateBlock_settercomment_label=Setters
-CodeTemplateBlock_getterstub_label=Getter body
-CodeTemplateBlock_setterstub_label=Setter body
-
-CodeTemplateBlock_templates_edit_button=&Edit...
-CodeTemplateBlock_templates_import_button=I&mport...
-CodeTemplateBlock_templates_export_button=E&xport...
-CodeTemplateBlock_templates_exportall_button=Ex&port All...
-
-CodeTemplateBlock_link_tooltip=Show code style settings
-CodeTemplateBlock_createcomment_label=A&utomatically add comments for new functions and types
-CodeTemplateBlock_templates_label=C&onfigure generated code and comments:
-CodeTemplateBlock_preview=Pa&ttern:
-
-CodeTemplateBlock_import_title=Import Templates
-CodeTemplateBlock_import_extension=*.xml
-
-CodeTemplateBlock_export_title=Export {0} Code Template(s)
-CodeTemplateBlock_export_filename=codetemplates.xml
-CodeTemplateBlock_export_extension=*.xml
-
-CodeTemplateBlock_export_exists_title=Export Code Templates
-CodeTemplateBlock_export_exists_message={0} already exists.\nDo you want to replace it?
-
-CodeTemplateBlock_error_read_title= Code Templates
-CodeTemplateBlock_error_read_message= Failed to read templates.
-
-CodeTemplateBlock_error_parse_message= Failed to parse templates:\n{0}
-
-CodeTemplateBlock_error_write_title=Code Templates
-CodeTemplateBlock_error_write_message=Failed to write templates.
-
-CodeTemplateBlock_export_error_title= Export Templates
-CodeTemplateBlock_export_error_hidden= Export failed.\n{0} is a hidden file.
-CodeTemplateBlock_export_error_canNotWrite= Export failed.\n{0} cannot be modified.
-
-TypeFilterPreferencePage_description=All types in packages that match the selected filter strings will not be shown in the 'Open Type' dialog. They will also be ignored in content assist or quick fix proposals. For example 'java.awt.*' will hide all types from the awt packages.
-TypeFilterPreferencePage_list_label=&Filter list:
-TypeFilterPreferencePage_add_button=&New...
-TypeFilterPreferencePage_addpackage_button=Add &Packages...
-TypeFilterPreferencePage_edit_button=&Edit...
-TypeFilterPreferencePage_remove_button=&Remove
-TypeFilterPreferencePage_selectall_button=Ena&ble All
-TypeFilterPreferencePage_deselectall_button=Di&sable All
-
-TypeFilterPreferencePage_choosepackage_label=Package Selection
-TypeFilterPreferencePage_choosepackage_description=&Choose packages to filter:
-
-TypeFilterInputDialog_title=Type Filter
-TypeFilterInputDialog_message=&Type filter name ('*' and '?' are valid wildcards):
-TypeFilterInputDialog_browse_button=&Browse...
-TypeFilterInputDialog_error_enterName=Enter a qualified type name.
-TypeFilterInputDialog_error_invalidName=Invalid name: {0}.
-TypeFilterInputDialog_error_entryExists=Entry already exists.
-TypeFilterInputDialog_choosepackage_label=Package Selection
-TypeFilterInputDialog_choosepackage_description=&Choose packages to filter:
-
-JavaEditorPreferencePage_selectionBackgroundColor= Selection background color
-JavaEditorPreferencePage_selectionForegroundColor= Selection foreground color
-
-SpellingPreferencePage_empty_threshold= A maximum number of correction proposals must be specified.
-SpellingPreferencePage_invalid_threshold=''{0}'' is not a valid maximum number of correction proposals.
-SpellingPreferencePage_ignore_digits_label=Ignore &words with digits
-SpellingPreferencePage_ignore_mixed_label=Ignore &mixed case words
-SpellingPreferencePage_ignore_sentence_label=Ignore &sentence capitalization
-SpellingPreferencePage_ignore_upper_label=Ignore u&pper case words
-SpellingPreferencePage_ignore_url_label=Ignore &internet addresses
-SpellingPreferencePage_ignore_single_letters_label=I&gnore single letters
-SpellingPreferencePage_ignore_java_strings_label=Ignore Ja&va string literals
-SpellingPreferencePage_ignore_ampersand_in_properties_label=Ignore '&&' in &JavaScript properties files
-SpellingPreferencePage_ignore_non_letters_label=Ignore &non-letters at word boundaries
-SpellingPreferencePage_proposals_threshold= Ma&ximum number of correction proposals:
-SpellingPreferencePage_dictionary_label=Plat&form dictionary:
-SpellingPreferencePage_workspace_dictionary_label=&User defined dictionary:
-SpellingPreferencePage_browse_label=&Browse...
-SpellingPreferencePage_dictionary_error=The dictionary file must be read/write accessible.
-SpellingPreferencePage_dictionary_none=none
-SpellingPreferencePage_encoding_label=En&coding:
-SpellingPreferencePage_locale_error=There is no dictionary available for this language.
-SpellingPreferencePage_filedialog_title=Select User Dictionary
-SpellingPreferencePage_filter_dictionary_extension=*.dictionary
-SpellingPreferencePage_filter_all_extension=*.*
-SpellingPreferencePage_filter_dictionary_label=Dictionary Files
-SpellingPreferencePage_filter_all_label=All Files
-SpellingPreferencePage_enable_contentassist_label=Ma&ke dictionary available to content assist
-SpellingPreferencePage_group_user=Options
-SpellingPreferencePage_group_dictionary=Dictionary
-SpellingPreferencePage_group_dictionaries=Dictionaries
-SpellingPreferencePage_group_advanced=Advanced
-SpellingPreferencePage_user_dictionary_description=The user dictionary is a text file with one word on each line
-
-BuildPathPreferencePage_title=Build Path
-BuildPathPreferencePage_description=Build path settings:
-
-UserLibraryPreferencePage_title=User Libraries
-UserLibraryPreferencePage_description=User libraries can be added to a JavaScript Include path and bundle a number of external JavaScript source files.
-
-UserLibraryPreferencePage_libraries_label=&Defined user libraries:
-UserLibraryPreferencePage_libraries_new_button=&New...
-UserLibraryPreferencePage_libraries_edit_button=&Edit...
-UserLibraryPreferencePage_libraries_addjar_button=Add &.js...
-UserLibraryPreferencePage_libraries_remove_button=&Remove
-UserLibraryPreferencePage_libraries_load_button=I&mport...
-UserLibraryPreferencePage_libraries_save_button=E&xport...
-
-UserLibraryPreferencePage_operation=Updating classpath containers...
-UserLibraryPreferencePage_operation_error=Error while updating classpath containers
-
-UserLibraryPreferencePage_config_error_title=User Libraries
-UserLibraryPreferencePage_config_error_message=Configuration of user libraries failed.
-UserLibraryPreferencePage_browsejar_new_title=.js File Selection
-UserLibraryPreferencePage_browsejar_edit_title=Edit JAR
-
-UserLibraryPreferencePage_LibraryNameDialog_new_title=New User Library
-UserLibraryPreferencePage_LibraryNameDialog_edit_title=Edit User Library
-UserLibraryPreferencePage_LibraryNameDialog_name_label=&User library name:
-UserLibraryPreferencePage_LibraryNameDialog_issystem_label=&System library (added to the boot class path)
-UserLibraryPreferencePage_LibraryNameDialog_name_error_entername=Enter a library name.
-UserLibraryPreferencePage_LibraryNameDialog_name_error_exists=Library {0} already exists.
-
-UserLibraryPreferencePage_LoadSaveDialog_save_title=Export User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_save_ok_title=Export User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_load_title=Import User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_location_label=&File location:
-UserLibraryPreferencePage_LoadSaveDialog_location_button=&Browse...
-UserLibraryPreferencePage_LoadSaveDialog_list_selectall_button=&Select All
-UserLibraryPreferencePage_LoadSaveDialog_load_replace_message=An existing library will be replaced. Do you want to continue?
-UserLibraryPreferencePage_LoadSaveDialog_load_replace_multiple_message={0} libraries will be replaced. Do you want to continue?
-UserLibraryPreferencePage_LoadSaveDialog_list_deselectall_button=&Deselect All
-UserLibraryPreferencePage_LoadSaveDialog_list_save_label=S&elect libraries to export:
-UserLibraryPreferencePage_LoadSaveDialog_list_load_label=Libraries contained in the s&elected file:
-UserLibraryPreferencePage_LoadSaveDialog_filedialog_save_title=Export User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_filedialog_load_title=Import User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_error_empty=The selected file contains no user libraries
-UserLibraryPreferencePage_LoadSaveDialog_error_invalidfile=The selected file is not a valid user library data file
-UserLibraryPreferencePage_LoadSaveDialog_overwrite_title=Export User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_save_ok_message=Libraries successfully exported.
-UserLibraryPreferencePage_LoadSaveDialog_overwrite_message=The file already exists. Do you want to overwrite the existing file?
-UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_title=Export User Libraries
-UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_message=Could not export file. {0}.
-UserLibraryPreferencePage_LoadSaveDialog_location_error_save_enterlocation=A location must be specified for the export.
-UserLibraryPreferencePage_LoadSaveDialog_location_error_save_invalid=The export location is invalid.
-UserLibraryPreferencePage_LoadSaveDialog_list_error_save_nothingselected=Select the libraries to export.
-UserLibraryPreferencePage_LoadSaveDialog_location_error_load_enterlocation=A location must be specified for the import target.
-UserLibraryPreferencePage_LoadSaveDialog_location_error_load_invalid=The location path does not point to a file.
-UserLibraryPreferencePage_LoadSaveDialog_list_error_load_nothingselected=Select the libraries to import.
-UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_up_button=&Up
-UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_down_button=D&own
-UserLibraryPreferencePage_LoadSaveDialog_load_badformat=bad format
-UserLibraryPreferencePage_LoadSaveDialog_load_replace_title=Import User Libraries
-
-
-# template stuff
-
-# edit template dialog
-EditTemplateDialog_error_noname=Template name cannot be empty.
-EditTemplateDialog_error_spaces=Template name cannot contain spaces.
-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
-EditTemplateDialog_cut=Cu&t
-EditTemplateDialog_copy=&Copy
-EditTemplateDialog_paste=&Paste
-EditTemplateDialog_select_all=Select &All
-EditTemplateDialog_autoinsert=Auto&matically insert
-EditTemplateDialog_content_assist=Insert &Variable...
-
-JavaEditorPreferencePage_folding_title= &Folding
-
-FoldingConfigurationBlock_enable= Enable f&olding
-FoldingConfigurationBlock_combo_caption= Select folding to &use:
-FoldingConfigurationBlock_info_no_preferences= The selected folding provider did not provide a preference control
-FoldingConfigurationBlock_error_not_exist= The ''{0}'' folding provider does not exist.
-FoldingConfigurationBlock_warning_providerNotFound_resetToDefault= The ''{0}'' folding provider could not be found. Resetting to the default folding provider.
-
-
-# smart typing block
-SmartTypingConfigurationBlock_autoclose_title=Automatically close
-SmartTypingConfigurationBlock_automove_title=Automatically insert at correct position
-SmartTypingConfigurationBlock_tabs_title=Tabulators
-# The argument will be replaced by the tab display size
-SmartTypingConfigurationBlock_tabs_message_tab_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>formatter preference page</a>. The current indentation mode uses tabs.
-# The first argument will be replaced by the tab display size, the second by the indent size and the third by the NLSed string of 'SmartTypingConfigurationBlock_tabs_message_spaces' or 'SmartTypingConfigurationBlock_tabs_message_tabs' (see below)
-SmartTypingConfigurationBlock_tabs_message_others_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>formatter preference page</a>. The current indentation size is {1}, using {2}.
-SmartTypingConfigurationBlock_tabs_message_tooltip=Go to the formatter preference page
-SmartTypingConfigurationBlock_tabs_message_spaces=spaces
-SmartTypingConfigurationBlock_tabs_message_tabs=tabs
-SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces=tabs and spaces
-SmartTypingConfigurationBlock_pasting_title=When pasting
-SmartTypingConfigurationBlock_strings_title=In string literals
-# do not translate the href arguments (org.eclipse.wst.jsdt.ui.preferences.ProblemSeveritiesPreferencePage and org.eclipse.ui.editors.preferencePages.Spelling)
-SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org.eclipse.wst.jsdt.ui.preferences.ProblemSeveritiesPreferencePage">compiler warnings</a> and <a href="org.eclipse.ui.editors.preferencePages.Spelling">spell checking</a> preferences.
-
-# code assist block
-CodeAssistConfigurationBlock_insertionSection_title=Insertion
-CodeAssistConfigurationBlock_sortingSection_title=Sorting and Filtering
-CodeAssistConfigurationBlock_matchCamelCase_label=Show ca&mel case matches
-CodeAssistConfigurationBlock_autoactivationSection_title=Auto-Activation
-# do not translate the href arguments (org.eclipse.wst.jsdt.ui.preferences.ProblemSeveritiesPreferencePage)
-CodeAssistConfigurationBlock_restricted_link=Proposals with <a href="org.eclipse.wst.jsdt.ui.preferences.ProblemSeveritiesPreferencePage">access restrictions</a>:
-CodeAssistConfigurationBlock_hideForbidden_label=Hide fo&rbidden references
-CodeAssistConfigurationBlock_hideDiscouraged_label=Hide dis&couraged references
-CodeAssistConfigurationBlock_hideDeprecated_label=&Hide deprecated references
-
-# {0} will be replaced by the keyboard shortcut for the command (e.g. "Ctrl+Space", or "no shortcut")
-CodeAssistAdvancedConfigurationBlock_page_description=Configure the behavior of the content assist ({0}) command.
-# stand-in text if there is no keyboard shortcut in above statement
-CodeAssistAdvancedConfigurationBlock_no_shortcut=no shortcut
-CodeAssistAdvancedConfigurationBlock_default_table_description=Select the proposal kinds contained in the 'default' content assist list:
-CodeAssistAdvancedConfigurationBlock_default_table_category_column_title=Default Proposal Kinds
-CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title=Key Binding
-# do not translate the href argument (org.eclipse.ui.preferencePages.Keys)
-CodeAssistAdvancedConfigurationBlock_key_binding_hint=Individual key bindings can be assigned to each proposal kind on the <a href="org.eclipse.ui.preferencePages.Keys">Keys</a> preference page.
-CodeAssistAdvancedConfigurationBlock_separate_table_description=Content assist cycling: Select the proposal kinds that are cycled through when repeatedly invoking content assist:
-CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title=Separate Proposal Kinds
-CodeAssistAdvancedConfigurationBlock_Up=&Up
-CodeAssistAdvancedConfigurationBlock_Down=D&own
-CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout=Timeout for fetching a parameter name from attached Jsdoc:
-
-# Abbreviation for milliseconds
-CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_ms=ms
-
-CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_emptyInput=Empty input.
-CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidInput=''{0}'' is not a valid input.
-CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidRange=Value must be between {0} and {1}.
-
-CodeAssistStaticMembersConfigurationBlock_description= Define a list of static members or types with static members. Content assist will propose those static members even if the import is missing.
-CodeAssistStaticMembersConfigurationBlock_newType_button= New &Type...
-CodeAssistStaticMembersConfigurationBlock_newMember_button= New &Member...
-CodeAssistStaticMembersConfigurationBlock_edit_button= &Edit
-CodeAssistStaticMembersConfigurationBlock_remove_button= &Remove
-
-FavoriteStaticMemberInputDialog_member_title= New Member Favorite
-FavoriteStaticMemberInputDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'):
-FavoriteStaticMemberInputDialog_type_title= New Type Favorite
-FavoriteStaticMemberInputDialog_type_labelText= Enter a fully qualified type (e.g. \'java.lang.Math\'):
-FavoriteStaticMemberInputDialog_browse_button= &Browse...
-FavoriteStaticMemberInputDialog_ChooseTypeDialog_title= Type Selection
-FavoriteStaticMemberInputDialog_ChooseTypeDialog_description= Choose type name:
-FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message= A problem occurred while collecting types. See the error Log for details.
-FavoriteStaticMemberInputDialog_error_enterName=Enter a name or prefix.
-FavoriteStaticMemberInputDialog_error_invalidTypeName=Not a valid type name.
-FavoriteStaticMemberInputDialog_error_invalidMemberName=Not a valid member name.
-FavoriteStaticMemberInputDialog_error_entryExists=Entry already exists in list.
-
-# coloring
-JavaEditorPreferencePage_coloring_category_java=JavaScript
-JavaEditorPreferencePage_coloring_category_javadoc=Jsdoc
-JavaEditorPreferencePage_coloring_category_comments=Comments
-
-ProjectSelectionDialog_title=Project Specific Configuration
-ProjectSelectionDialog_desciption=&Select the project to configure:
-ProjectSelectionDialog_filter=Show only &projects with project specific settings
-
-CleanUpPreferencePage_Description=A&ctive profile:
-CleanUpPreferencePage_Title=Code Clean Up
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
deleted file mode 100644
index f8f7a53a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
+++ /dev/null
@@ -1,546 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.IDialogSettings;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-
-/**
- */
-public class ProblemSeveritiesConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final String SETTINGS_SECTION_NAME= "ProblemSeveritiesConfigurationBlock"; //$NON-NLS-1$
-
- // Preference store keys, see JavaScriptCore.getOptions
- private static final Key PREF_PB_UNDEFINED_FIELD= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNDEFINED_FIELD);
-// private static final Key PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= getJDTCoreKey(JavaScriptCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
- private static final Key PREF_PB_DEPRECATION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_DEPRECATION);
- private static final Key PREF_PB_DEPRECATION_IN_DEPRECATED_CODE=getJDTCoreKey(JavaScriptCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
- private static final Key PREF_PB_DEPRECATION_WHEN_OVERRIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD);
-
- private static final Key PREF_PB_HIDDEN_CATCH_BLOCK= getJDTCoreKey(JavaScriptCore.COMPILER_PB_HIDDEN_CATCH_BLOCK);
- private static final Key PREF_PB_UNUSED_LOCAL= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_LOCAL);
- private static final Key PREF_PB_UNUSED_PARAMETER= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_PARAMETER);
-// private static final Key PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
- private static final Key PREF_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE);
- private static final Key PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
-// private static final Key PREF_PB_SYNTHETIC_ACCESS_EMULATION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
- private static final Key PREF_PB_NON_EXTERNALIZED_STRINGS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_NON_NLS_STRING_LITERAL);
-// private static final Key PREF_PB_UNUSED_IMPORT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_IMPORT);
- private static final Key PREF_PB_UNUSED_PRIVATE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER);
-// private static final Key PREF_PB_STATIC_ACCESS_RECEIVER= getJDTCoreKey(JavaScriptCore.COMPILER_PB_STATIC_ACCESS_RECEIVER);
- private static final Key PREF_PB_NO_EFFECT_ASSIGNMENT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT);
-// private static final Key PREF_PB_CHAR_ARRAY_IN_CONCAT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
- private static final Key PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT);
- private static final Key PREF_PB_LOCAL_VARIABLE_HIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_LOCAL_VARIABLE_HIDING);
- private static final Key PREF_PB_FIELD_HIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FIELD_HIDING);
-// private static final Key PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= getJDTCoreKey(JavaScriptCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD);
- private static final Key PREF_PB_INDIRECT_STATIC_ACCESS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INDIRECT_STATIC_ACCESS);
- private static final Key PREF_PB_EMPTY_STATEMENT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_EMPTY_STATEMENT);
- private static final Key PREF_PB_UNNECESSARY_ELSE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNNECESSARY_ELSE);
-// private static final Key PREF_PB_UNNECESSARY_TYPE_CHECK= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK);
-// private static final Key PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
-// private static final Key PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION);
-// private static final Key PREF_PB_MISSING_SERIAL_VERSION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_SERIAL_VERSION);
- private static final Key PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK);
- private static final Key PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING);
- private static final Key PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING);
-// private static final Key PREF_PB_UNQUALIFIED_FIELD_ACCESS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS);
- private static final Key PREF_PB_MISSING_DEPRECATED_ANNOTATION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION);
- private static final Key PREF_PB_FORBIDDEN_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE);
- private static final Key PREF_PB_DISCOURRAGED_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE);
- private static final Key PREF_PB_UNUSED_LABEL= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNUSED_LABEL);
- private static final Key PREF_PB_PARAMETER_ASSIGNMENT= getJDTCoreKey(JavaScriptCore.COMPILER_PB_PARAMETER_ASSIGNMENT);
- private static final Key PREF_PB_FALLTHROUGH_CASE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FALLTHROUGH_CASE);
-
- private static final Key PREF_PB_NULL_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_NULL_REFERENCE);
- private static final Key PREF_PB_POTENTIAL_NULL_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE);
- private static final Key PREF_PB_REDUNDANT_NULL_CHECK= getJDTCoreKey(JavaScriptCore.COMPILER_PB_REDUNDANT_NULL_CHECK);
-
-// private static final Key PREF_15_PB_UNCHECKED_TYPE_OPERATION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION);
-// private static final Key PREF_15_PB_FINAL_PARAM_BOUND= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FINAL_PARAMETER_BOUND);
-// private static final Key PREF_15_PB_VARARGS_ARGUMENT_NEED_CAST= getJDTCoreKey(JavaScriptCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST);
-// private static final Key PREF_15_PB_AUTOBOXING_PROBLEM= getJDTCoreKey(JavaScriptCore.COMPILER_PB_AUTOBOXING);
-
-// private static final Key PREF_15_PB_MISSING_OVERRIDE_ANNOTATION= getJDTCoreKey(JavaScriptCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION);
-// private static final Key PREF_15_PB_ANNOTATION_SUPER_INTERFACE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_ANNOTATION_SUPER_INTERFACE);
-// private static final Key PREF_15_PB_TYPE_PARAMETER_HIDING= getJDTCoreKey(JavaScriptCore.COMPILER_PB_TYPE_PARAMETER_HIDING);
-// private static final Key PREF_15_PB_INCOMPLETE_ENUM_SWITCH= getJDTCoreKey(JavaScriptCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH);
-// private static final Key PREF_15_PB_RAW_TYPE_REFERENCE= getJDTCoreKey(JavaScriptCore.COMPILER_PB_RAW_TYPE_REFERENCE);
-
-// private static final Key PREF_PB_SUPPRESS_WARNINGS= getJDTCoreKey(JavaScriptCore.COMPILER_PB_SUPPRESS_WARNINGS);
-// private static final Key PREF_PB_UNHANDLED_WARNING_TOKEN= getJDTCoreKey(JavaScriptCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN);
- //private static final Key PREF_PB_FATAL_OPTIONAL_ERROR= getJDTCoreKey(JavaScriptCore.COMPILER_PB_FATAL_OPTIONAL_ERROR);
-
- /* START -------------------------------- Bug 203292 Type/Method/Filed resolution error configuration --------------------- */
- private static final Key PREF_UNRESOLVED_TYPE_OPTIONAL_ERROR = getJDTCoreKey(JavaScriptCore.UNRESOLVED_TYPE_REFERENCE);
- private static final Key PREF_UNRESOLVED_FIELD_OPTIONAL_ERROR = getJDTCoreKey(JavaScriptCore.UNRESOLVED_FIELD_REFERENCE);
- private static final Key PREF_UNRESOLVED_METHOD_OPTIONAL_ERROR = getJDTCoreKey(JavaScriptCore.UNRESOLVED_METHOD_REFERENCE);
- /* END -------------------------------- Bug 203292 Type/Method/Filed resolution error configuration --------------------- */
-
-
- /* START -------------------------------- Bug 197884 Loosly defined var (for statement) and optional semi-colon --------------------- */
- private static final Key PREF_LOOSE_VAR = getJDTCoreKey(JavaScriptCore.LOOSE_VAR_DECL);
- private static final Key PREF_OPTIONAL_SEMICOLON = getJDTCoreKey(JavaScriptCore.OPTIONAL_SEMICOLON);
-
-
- /* END -------------------------------- Bug 197884 Loosly defined var (for statement) and optional semi-colon --------------------- */
-
- // values
- private static final String ERROR= JavaScriptCore.ERROR;
- private static final String WARNING= JavaScriptCore.WARNING;
- private static final String IGNORE= JavaScriptCore.IGNORE;
-
- private static final String ENABLED= JavaScriptCore.ENABLED;
- private static final String DISABLED= JavaScriptCore.DISABLED;
-
-
- private PixelConverter fPixelConverter;
-
- public ProblemSeveritiesConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getKeys(), container);
-
- // compatibilty code for the merge of the two option PB_SIGNAL_PARAMETER:
- if (ENABLED.equals(getValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT))) {
-// setValue(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, ENABLED);
- }
- }
-
- private static Key[] getKeys() {
- return new Key[] {
- PREF_PB_UNDEFINED_FIELD,
- /*PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME,*/ PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
- PREF_PB_UNUSED_PARAMETER, PREF_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE,
- /*PREF_PB_SYNTHETIC_ACCESS_EMULATION,*/ PREF_PB_NON_EXTERNALIZED_STRINGS,
- /*PREF_PB_UNUSED_IMPORT,*/ PREF_PB_UNUSED_LABEL,
- /*PREF_PB_STATIC_ACCESS_RECEIVER, */PREF_PB_DEPRECATION_IN_DEPRECATED_CODE,
- PREF_PB_NO_EFFECT_ASSIGNMENT, /*PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,*/
- PREF_PB_UNUSED_PRIVATE,/* PREF_PB_CHAR_ARRAY_IN_CONCAT,*/ PREF_PB_UNNECESSARY_ELSE,
- PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, PREF_PB_LOCAL_VARIABLE_HIDING, PREF_PB_FIELD_HIDING,
- /*PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD,*/ PREF_PB_INDIRECT_STATIC_ACCESS,
- PREF_PB_EMPTY_STATEMENT, /*PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, */PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
-// PREF_PB_UNNECESSARY_TYPE_CHECK, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, PREF_PB_UNQUALIFIED_FIELD_ACCESS,
- PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, PREF_PB_DEPRECATION_WHEN_OVERRIDING,
- PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, /*PREF_PB_MISSING_SERIAL_VERSION, */
- PREF_PB_PARAMETER_ASSIGNMENT, PREF_PB_NULL_REFERENCE, PREF_PB_POTENTIAL_NULL_REFERENCE,
- PREF_PB_REDUNDANT_NULL_CHECK, PREF_PB_FALLTHROUGH_CASE,
-// PREF_15_PB_UNCHECKED_TYPE_OPERATION, PREF_15_PB_FINAL_PARAM_BOUND, PREF_15_PB_VARARGS_ARGUMENT_NEED_CAST,
-// PREF_15_PB_AUTOBOXING_PROBLEM, PREF_15_PB_MISSING_OVERRIDE_ANNOTATION, PREF_15_PB_ANNOTATION_SUPER_INTERFACE,
- /*PREF_15_PB_TYPE_PARAMETER_HIDING, PREF_15_PB_INCOMPLETE_ENUM_SWITCH,*/ PREF_PB_MISSING_DEPRECATED_ANNOTATION,
- /*PREF_15_PB_RAW_TYPE_REFERENCE,*/ /*PREF_PB_FATAL_OPTIONAL_ERROR,*/
- PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE/*, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN*/,PREF_UNRESOLVED_TYPE_OPTIONAL_ERROR,PREF_UNRESOLVED_FIELD_OPTIONAL_ERROR,PREF_UNRESOLVED_METHOD_OPTIONAL_ERROR,PREF_LOOSE_VAR,PREF_OPTIONAL_SEMICOLON
- };
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
- setShell(parent.getShell());
-
- Composite mainComp= new Composite(parent, SWT.NONE);
- mainComp.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- mainComp.setLayout(layout);
-
- Composite commonComposite= createStyleTabContent(mainComp);
- GridData gridData= new GridData(GridData.FILL, GridData.FILL, true, true);
- gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(20);
- commonComposite.setLayoutData(gridData);
-
- validateSettings(null, null, null);
-
- return mainComp;
- }
-
- private Composite createStyleTabContent(Composite folder) {
- String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
-
- String[] errorWarningIgnoreLabels= new String[] {
- PreferencesMessages.ProblemSeveritiesConfigurationBlock_error,
- PreferencesMessages.ProblemSeveritiesConfigurationBlock_warning,
- PreferencesMessages.ProblemSeveritiesConfigurationBlock_ignore
- };
-
- String[] enabledDisabled= new String[] { ENABLED, DISABLED };
-
- int nColumns= 3;
-
- final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
-
- Composite composite= sc1.getBody();
- GridLayout layout= new GridLayout(nColumns, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- Label description= new Label(composite, SWT.LEFT | SWT.WRAP);
- description.setFont(description.getFont());
- description.setText(PreferencesMessages.ProblemSeveritiesConfigurationBlock_common_description);
- description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false, nColumns - 1, 1));
-
- int indentStep= fPixelConverter.convertWidthInCharsToPixels(1);
-
- int defaultIndent= indentStep * 0;
- int extraIndent= indentStep * 2;
- String label;
- ExpandableComposite excomposite;
- Composite inner;
- /* START -------------------------------- Bug 203292 Type/Method/Filed resolution error configuration --------------------- */
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_Resolution;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_UnresolvedTypes;
- addComboBox(inner, label, PREF_UNRESOLVED_TYPE_OPTIONAL_ERROR, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_UnresolvedFields;
- addComboBox(inner, label, PREF_UNRESOLVED_FIELD_OPTIONAL_ERROR, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_UnresolvedMethods;
- addComboBox(inner, label, PREF_UNRESOLVED_METHOD_OPTIONAL_ERROR, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
- /* END -------------------------------- Bug 203292 Type/Method/Filed resolution error configuration --------------------- */
- // --- style
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_code_style;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_static_access_receiver_label;
-// addComboBox(inner, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_indirect_access_to_static_label;
-// addComboBox(inner, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unqualified_field_access_label;
-// addComboBox(inner, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_undocumented_empty_block_label;
- addComboBox(inner, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_synth_access_emul_label;
-// addComboBox(inner, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_method_naming_label;
-// addComboBox(inner, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_parameter_assignment;
- addComboBox(inner, label, PREF_PB_PARAMETER_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_non_externalized_strings_label;
- addComboBox(inner, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- // --- potential_programming_problems
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_potential_programming_problems;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
- /* START -------------------------------- Bug 197884 Loosly defined var (for statement) and optional semi-colon --------------------- */
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_LooselyDeclaredGlobalVar;
- addComboBox(inner, label, PREF_LOOSE_VAR, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_Optionalsemicolon;
- addComboBox(inner, label, PREF_OPTIONAL_SEMICOLON, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- /* END -------------------------------- Bug 197884 Loosly defined var (for statement) and optional semi-colon --------------------- */
-
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_undefined_field_label;
- addComboBox(inner, label, PREF_PB_UNDEFINED_FIELD, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_missing_serial_version_label;
-// addComboBox(inner, label, PREF_PB_MISSING_SERIAL_VERSION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_no_effect_assignment_label;
- addComboBox(inner, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_accidential_assignement_label;
- addComboBox(inner, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_finally_block_not_completing_label;
- addComboBox(inner, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_empty_statement_label;
- addComboBox(inner, label, PREF_PB_EMPTY_STATEMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_char_array_in_concat_label;
-// addComboBox(inner, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_hidden_catchblock_label;
- addComboBox(inner, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_inexact_vararg_label;
-// addComboBox(inner, label, PREF_15_PB_VARARGS_ARGUMENT_NEED_CAST, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_autoboxing_problem_label;
-// addComboBox(inner, label, PREF_15_PB_AUTOBOXING_PROBLEM, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_incomplete_enum_switch_label;
-// addComboBox(inner, label, PREF_15_PB_INCOMPLETE_ENUM_SWITCH, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_fall_through_case;
- addComboBox(inner, label, PREF_PB_FALLTHROUGH_CASE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_null_reference;
- addComboBox(inner, label, PREF_PB_NULL_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_potential_null_reference;
- addComboBox(inner, label, PREF_PB_POTENTIAL_NULL_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- // --- name_shadowing
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_name_shadowing;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_field_hiding_label;
- addComboBox(inner, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_local_variable_hiding_label;
- addComboBox(inner, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_special_param_hiding_label;
-// addCheckBox(inner, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, extraIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label;
-// addComboBox(inner, label, PREF_15_PB_TYPE_PARAMETER_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_incompatible_interface_method_label;
-// addComboBox(inner, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
- // --- API access rules
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_deprecations;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_deprecation_label;
- addComboBox(inner, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_deprecation_in_deprecation_label;
- addCheckBox(inner, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, extraIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_deprecation_when_overriding_label;
- addCheckBox(inner, label, PREF_PB_DEPRECATION_WHEN_OVERRIDING, enabledDisabled, extraIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_forbidden_reference_label;
- addComboBox(inner, label, PREF_PB_FORBIDDEN_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_discourraged_reference_label;
- addComboBox(inner, label, PREF_PB_DISCOURRAGED_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
-
-
- // --- unnecessary_code
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_unnecessary_code;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_local_label;
- addComboBox(inner, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label;
- addComboBox(inner, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_signal_param_in_overriding_label;
-// addCheckBox(inner, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, extraIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_ignore_documented_unused_parameters;
- addCheckBox(inner, label, PREF_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, enabledDisabled, extraIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_imports_label;
-// addComboBox(inner, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_private_label;
- addComboBox(inner, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_redundant_null_check;
- addComboBox(inner, label, PREF_PB_REDUNDANT_NULL_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label;
- addComboBox(inner, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unnecessary_type_check_label;
-// addComboBox(inner, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_label;
-// addComboBox(inner, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_throwing_exception_when_overriding_label;
-// addCheckBox(inner, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, enabledDisabled, extraIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_label_label;
- addComboBox(inner, label, PREF_PB_UNUSED_LABEL, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
-
- // --- generics
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_generics;
-// excomposite= createStyleSection(composite, label, nColumns);
-//
-//
-// inner= new Composite(excomposite, SWT.NONE);
-// inner.setFont(composite.getFont());
-// inner.setLayout(new GridLayout(nColumns, false));
-// excomposite.setClient(inner);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unsafe_type_op_label;
-// addComboBox(inner, label, PREF_15_PB_UNCHECKED_TYPE_OPERATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_raw_type_reference;
-// addComboBox(inner, label, PREF_15_PB_RAW_TYPE_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_final_param_bound_label;
-// addComboBox(inner, label, PREF_15_PB_FINAL_PARAM_BOUND, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-//
-// // --- annotations
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_annotations;
-// excomposite= createStyleSection(composite, label, nColumns);
-//
-//
-// inner= new Composite(excomposite, SWT.NONE);
-// inner.setFont(composite.getFont());
-// inner.setLayout(new GridLayout(nColumns, false));
-// excomposite.setClient(inner);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_missing_override_annotation_label;
-// addComboBox(inner, label, PREF_15_PB_MISSING_OVERRIDE_ANNOTATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_missing_deprecated_annotation_label;
-// addComboBox(inner, label, PREF_PB_MISSING_DEPRECATED_ANNOTATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_annotation_super_interface_label;
-// addComboBox(inner, label, PREF_15_PB_ANNOTATION_SUPER_INTERFACE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unhandled_surpresswarning_tokens;
-// addComboBox(inner, label, PREF_PB_UNHANDLED_WARNING_TOKEN, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-//
-// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_enable_surpresswarning_annotation;
-// addCheckBox(inner, label, PREF_PB_SUPPRESS_WARNINGS, enabledDisabled, 0);
-
- //new Label(composite, SWT.NONE);
-
- //String[] enableDisableValues= new String[] { ENABLED, DISABLED };
- //label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
- //addCheckBox(composite, label, PREF_PB_FATAL_OPTIONAL_ERROR, enableDisableValues, 0);
-
-
- IDialogSettings section= JavaScriptPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
- restoreSectionExpansionStates(section);
-
- return sc1;
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (!areSettingsEnabled()) {
- return;
- }
-
- if (changedKey != null) {
- if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) )
-// PREF_PB_DEPRECATION.equals(changedKey) ||
-// PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) ||
-// PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey))
- {
- updateEnableStates();
-// } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) {
-// // merging the two options
-// setValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue);
- } else {
- return;
- }
- } else {
- updateEnableStates();
- }
- fContext.statusChanged(new StatusInfo());
- }
-
- private void updateEnableStates() {
- boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE);
-// getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams);
- getCheckBox(PREF_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE).setEnabled(enableUnusedParams);
-
- boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE);
- getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation);
- getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation);
-
-// boolean enableThrownExceptions= !checkValue(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, IGNORE);
-// getCheckBox(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING).setEnabled(enableThrownExceptions);
-
-// boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE);
-// getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding);
- }
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsbuild_title;
- String message;
- if (workspaceSettings) {
- message= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsfullbuild_message;
- } else {
- message= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsprojectbuild_message;
- }
- return new String[] { title, message };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#dispose()
- */
- public void dispose() {
- IDialogSettings section= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION_NAME);
- storeSectionExpansionStates(section);
- super.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesPreferencePage.java
deleted file mode 100644
index ec9c10cb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProblemSeveritiesPreferencePage.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Page used to configure both workspace and project specific compiler settings
- */
-public class ProblemSeveritiesPreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
-
- public static final String DATA_SELECT_OPTION_KEY= "select_option_key"; //$NON-NLS-1$
- public static final String DATA_SELECT_OPTION_QUALIFIER= "select_option_qualifier"; //$NON-NLS-1$
-
- private ProblemSeveritiesConfigurationBlock fConfigurationBlock;
-
- public ProblemSeveritiesPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- //setDescription(PreferencesMessages.getString("ProblemSeveritiesPreferencePage.description")); //$NON-NLS-1$
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.ProblemSeveritiesPreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new ProblemSeveritiesConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
- if (isProjectPreferencePage()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PROPERTY_PAGE);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PREFERENCE_PAGE);
- }
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- super.applyData(data);
- if (data instanceof Map && fConfigurationBlock != null) {
- Map map= (Map) data;
- Object key= map.get(DATA_SELECT_OPTION_KEY);
- Object qualifier= map.get(DATA_SELECT_OPTION_QUALIFIER);
- if (key instanceof String && qualifier instanceof String) {
- fConfigurationBlock.selectOption((String) key, (String) qualifier);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProfilePreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProfilePreferencePage.java
deleted file mode 100644
index 18631ee1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProfilePreferencePage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.ui.preferences.IWorkingCopyManager;
-import org.eclipse.ui.preferences.WorkingCopyManager;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileConfigurationBlock;
-
-public abstract class ProfilePreferencePage extends PropertyAndPreferencePage {
-
- private ProfileConfigurationBlock fConfigurationBlock;
-
- public ProfilePreferencePage() {
- super();
- }
-
- protected abstract ProfileConfigurationBlock createConfigurationBlock(PreferencesAccess access);
-
- public void createControl(Composite parent) {
- IPreferencePageContainer container= getContainer();
- IWorkingCopyManager workingCopyManager;
- if (container instanceof IWorkbenchPreferenceContainer) {
- workingCopyManager= ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager();
- } else {
- workingCopyManager= new WorkingCopyManager(); // non shared
- }
- PreferencesAccess access= PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
- fConfigurationBlock= createConfigurationBlock(access);
-
- super.createControl(parent);
- }
-
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.enableProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- protected void performDefaults() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- super.performDefaults();
- }
-
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- super.performApply();
- }
-
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProjectSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProjectSelectionDialog.java
deleted file mode 100644
index 494c5250..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ProjectSelectionDialog.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.Set;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-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.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-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.Shell;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-public class ProjectSelectionDialog extends SelectionStatusDialog {
-
- // the visual selection widget group
- private TableViewer fTableViewer;
- private Set fProjectsWithSpecifics;
-
- // sizing constants
- private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
- private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
-
- private final static String DIALOG_SETTINGS_SHOW_ALL= "ProjectSelectionDialog.show_all"; //$NON-NLS-1$
-
- private ViewerFilter fFilter;
-
- public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) {
- super(parentShell);
- setTitle(PreferencesMessages.ProjectSelectionDialog_title);
- setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
- fProjectsWithSpecifics= projectsWithSpecifics;
-
- int shellStyle = getShellStyle();
- setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
-
- fFilter= new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- return fProjectsWithSpecifics.contains(element);
- }
- };
-
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected Control createDialogArea(Composite parent) {
- // page group
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Font font= parent.getFont();
- composite.setFont(font);
-
- createMessageArea(composite);
-
- fTableViewer= new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
- }
- });
- fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- okPressed();
- }
- });
- GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
- data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
- data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
- fTableViewer.getTable().setLayoutData(data);
-
- fTableViewer.setLabelProvider(new JavaScriptElementLabelProvider());
- fTableViewer.setContentProvider(new StandardJavaScriptElementContentProvider());
- fTableViewer.setComparator(new JavaScriptElementComparator());
- fTableViewer.getControl().setFont(font);
-
- Button checkbox= new Button(composite, SWT.CHECK);
- checkbox.setText(PreferencesMessages.ProjectSelectionDialog_filter);
- checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
- checkbox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateFilter(((Button) e.widget).getSelection());
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- updateFilter(((Button) e.widget).getSelection());
- }
- });
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- boolean doFilter= !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty();
- checkbox.setSelection(doFilter);
- updateFilter(doFilter);
-
- IJavaScriptModel input= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- fTableViewer.setInput(input);
-
- doSelectionChanged(new Object[0]);
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- protected void updateFilter(boolean selected) {
- if (selected) {
- fTableViewer.addFilter(fFilter);
- } else {
- fTableViewer.removeFilter(fFilter);
- }
- JavaScriptPlugin.getDefault().getDialogSettings().put(DIALOG_SETTINGS_SHOW_ALL, !selected);
- }
-
- private void doSelectionChanged(Object[] objects) {
- if (objects.length != 1) {
- updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
- setSelectionResult(null);
- } else {
- updateStatus(new StatusInfo());
- setSelectionResult(objects);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
- */
- protected void computeResult() {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertiesFileEditorColorSettingPreviewCode.txt b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertiesFileEditorColorSettingPreviewCode.txt
deleted file mode 100644
index 3f2a5c3a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertiesFileEditorColorSettingPreviewCode.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Properties
-#
-JavaElementProperties.name Name
-JavaElementProperties.name2= Name is {0}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertyAndPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertyAndPreferencePage.java
deleted file mode 100644
index 1ef90644..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/PropertyAndPreferencePage.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.window.Window;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-
-/**
- * Base for project property and preference pages
- */
-public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
-
- private Control fConfigurationBlockControl;
- private ControlEnableState fBlockEnableState;
- private Link fChangeWorkspaceSettings;
- private SelectionButtonDialogField fUseProjectSettings;
- private IStatus fBlockStatus;
- private Composite fParentComposite;
-
- private IProject fProject; // project or null
- private Map fData; // page data
-
- public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
-
- public PropertyAndPreferencePage() {
- fBlockStatus= new StatusInfo();
- fBlockEnableState= null;
- fProject= null;
- fData= null;
- }
-
- protected abstract Control createPreferenceContent(Composite composite);
- protected abstract boolean hasProjectSpecificOptions(IProject project);
-
- protected abstract String getPreferencePageID();
- protected abstract String getPropertyPageID();
-
- protected boolean supportsProjectSpecificOptions() {
- return getPropertyPageID() != null;
- }
-
- protected boolean offerLink() {
- return fData == null || !Boolean.TRUE.equals(fData.get(DATA_NO_LINK));
- }
-
- protected Label createDescriptionLabel(Composite parent) {
- fParentComposite= parent;
- if (isProjectPreferencePage()) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- IDialogFieldListener listener= new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
- }
- };
-
- fUseProjectSettings= new SelectionButtonDialogField(SWT.CHECK);
- fUseProjectSettings.setDialogFieldListener(listener);
- fUseProjectSettings.setLabelText(PreferencesMessages.PropertyAndPreferencePage_useprojectsettings_label);
- fUseProjectSettings.doFillIntoGrid(composite, 1);
- LayoutUtil.setHorizontalGrabbing(fUseProjectSettings.getSelectionButton(null));
-
- if (offerLink()) {
- fChangeWorkspaceSettings= createLink(composite, PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
- fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
- } else {
- LayoutUtil.setHorizontalSpan(fUseProjectSettings.getSelectionButton(null), 2);
- }
-
- Label horizontalLine= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
- horizontalLine.setFont(composite.getFont());
- } else if (supportsProjectSpecificOptions() && offerLink()) {
- fChangeWorkspaceSettings= createLink(parent, PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
- fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
- }
-
- return super.createDescriptionLabel(parent);
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setFont(parent.getFont());
-
- GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
-
- fConfigurationBlockControl= createPreferenceContent(composite);
- fConfigurationBlockControl.setLayoutData(data);
-
- if (isProjectPreferencePage()) {
- boolean useProjectSettings= hasProjectSpecificOptions(getProject());
- enableProjectSpecificSettings(useProjectSettings);
- }
-
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- private Link createLink(Composite composite, String text) {
- Link link= new Link(composite, SWT.NONE);
- link.setFont(composite.getFont());
- link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
- link.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- doLinkActivated((Link) e.widget);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- doLinkActivated((Link) e.widget);
- }
- });
- return link;
- }
-
- protected boolean useProjectSettings() {
- return isProjectPreferencePage() && fUseProjectSettings != null && fUseProjectSettings.isSelected();
- }
-
- protected boolean isProjectPreferencePage() {
- return fProject != null;
- }
-
- protected IProject getProject() {
- return fProject;
- }
-
- final void doLinkActivated(Link link) {
- Map data= new HashMap();
- data.put(DATA_NO_LINK, Boolean.TRUE);
-
- if (isProjectPreferencePage()) {
- openWorkspacePreferences(data);
- } else {
- HashSet projectsWithSpecifics= new HashSet();
- try {
- IJavaScriptProject[] projects= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaScriptProjects();
- for (int i= 0; i < projects.length; i++) {
- IJavaScriptProject curr= projects[i];
- if (hasProjectSpecificOptions(curr.getProject())) {
- projectsWithSpecifics.add(curr);
- }
- }
- } catch (JavaScriptModelException e) {
- // ignore
- }
- ProjectSelectionDialog dialog= new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
- if (dialog.open() == Window.OK) {
- IJavaScriptProject res= (IJavaScriptProject) dialog.getFirstResult();
- openProjectProperties(res.getProject(), data);
- }
- }
- }
-
- protected final void openWorkspacePreferences(Object data) {
- String id= getPreferencePageID();
- PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
- }
-
- protected final void openProjectProperties(IProject project, Object data) {
- String id= getPropertyPageID();
- if (id != null) {
- PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
- }
- }
-
-
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- fUseProjectSettings.setSelection(useProjectSpecificSettings);
- enablePreferenceContent(useProjectSpecificSettings);
- updateLinkVisibility();
- doStatusChanged();
- }
-
- private void updateLinkVisibility() {
- if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
- return;
- }
-
- if (isProjectPreferencePage()) {
- fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
- }
- }
-
-
- protected void setPreferenceContentStatus(IStatus status) {
- fBlockStatus= status;
- doStatusChanged();
- }
-
- /**
- * Returns a new status change listener that calls {@link #setPreferenceContentStatus(IStatus)}
- * when the status has changed
- * @return The new listener
- */
- protected IStatusChangeListener getNewStatusChangedListener() {
- return new IStatusChangeListener() {
- public void statusChanged(IStatus status) {
- setPreferenceContentStatus(status);
- }
- };
- }
-
- protected IStatus getPreferenceContentStatus() {
- return fBlockStatus;
- }
-
- protected void doStatusChanged() {
- if (!isProjectPreferencePage() || useProjectSettings()) {
- updateStatus(fBlockStatus);
- } else {
- updateStatus(new StatusInfo());
- }
- }
-
- protected void enablePreferenceContent(boolean enable) {
- if (enable) {
- 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()) {
- enableProjectSpecificSettings(false);
- }
- super.performDefaults();
- }
-
- private void updateStatus(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
- */
- public IAdaptable getElement() {
- return fProject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- fProject= (IProject) element.getAdapter(IResource.class);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- if (data instanceof Map) {
- fData= (Map) data;
- }
- if (fChangeWorkspaceSettings != null) {
- if (!offerLink()) {
- fChangeWorkspaceSettings.dispose();
- fParentComposite.layout(true, true);
- }
- }
- }
-
- protected Map getData() {
- return fData;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantConfigurationBlock.java
deleted file mode 100644
index e84e26a5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantConfigurationBlock.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.jface.preference.PreferencePage;
-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;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.ISaveParticipantPreferenceConfiguration;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.SaveParticipantDescriptor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.saveparticipant.SaveParticipantRegistry;
-
-import com.ibm.icu.text.Collator;
-
-/**
- * Configures Java Editor save participants.
- *
- *
- */
-class SaveParticipantConfigurationBlock implements IPreferenceAndPropertyConfigurationBlock {
-
- private interface IDelegateOperation {
- public void run(ISaveParticipantPreferenceConfiguration block);
- }
-
- private final PreferencePage fPreferencePage;
- private final IScopeContext fContext;
- private final ArrayList fConfigurations;
-
- public SaveParticipantConfigurationBlock(IScopeContext context, PreferencePage preferencePage) {
- Assert.isNotNull(context);
- Assert.isNotNull(preferencePage);
-
- fContext= context;
- fPreferencePage= preferencePage;
- fConfigurations= new ArrayList();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite)
- *
- */
- public Control createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- GridLayout gridLayout= new GridLayout(2, false);
- gridLayout.marginHeight= 0;
- gridLayout.marginWidth= 0;
- composite.setLayout(gridLayout);
-
- SaveParticipantRegistry registry= JavaScriptPlugin.getDefault().getSaveParticipantRegistry();
- SaveParticipantDescriptor[] descriptors= registry.getSaveParticipantDescriptors();
-
- if (descriptors.length == 0)
- return composite;
-
- Arrays.sort(descriptors, new Comparator() {
- public int compare(Object o1, Object o2) {
- SaveParticipantDescriptor d1= (SaveParticipantDescriptor)o1;
- SaveParticipantDescriptor d2= (SaveParticipantDescriptor)o2;
- return Collator.getInstance().compare(d1.getPostSaveListener().getName(), d2.getPostSaveListener().getName());
- }
- });
-
- IPreferencePageContainer container= fPreferencePage.getContainer();
- for (int i= 0; i < descriptors.length; i++) {
- final SaveParticipantDescriptor descriptor= descriptors[i];
- ISaveParticipantPreferenceConfiguration configuration= descriptor.createPreferenceConfiguration();
- configuration.createControl(composite, container);
- fConfigurations.add(configuration);
- }
-
- return composite;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
- */
- public void dispose() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- block.dispose();
- }
- });
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
- */
- public void initialize() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- IAdaptable element= null;
- if (fPreferencePage instanceof PropertyAndPreferencePage) {
- element= ((PropertyAndPreferencePage)fPreferencePage).getElement();
- }
- block.initialize(fContext, element);
- }
- });
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
- */
- public void performDefaults() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- block.performDefaults();
- }
- });
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
- */
- public void performOk() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- block.performOk();
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public void enableProjectSettings() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- block.enableProjectSettings();
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public void disableProjectSettings() {
- delegateToPreferenceConfiguration(new IDelegateOperation() {
- public void run(ISaveParticipantPreferenceConfiguration block) {
- block.disableProjectSettings();
- }
- });
- }
-
- private void delegateToPreferenceConfiguration(IDelegateOperation op) {
- for (int i= 0; i < fConfigurations.size(); i++) {
- ISaveParticipantPreferenceConfiguration block= (ISaveParticipantPreferenceConfiguration)fConfigurations.get(i);
- op.run(block);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantPreferencePage.java
deleted file mode 100644
index 89608b6c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SaveParticipantPreferencePage.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Configures Java Editor save participant preferences.
- *
- *
- */
-public final class SaveParticipantPreferencePage extends AbstractConfigurationBlockPreferenceAndPropertyPage {
-
- public static final String PROPERTY_PAGE_ID= "org.eclipse.wst.jsdt.ui.propertyPages.SaveParticipantPreferencePage"; //$NON-NLS-1$
- public static final String PREFERENCE_PAGE_ID= "org.eclipse.wst.jsdt.ui.preferences.SaveParticipantPreferencePage"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- protected IPreferenceAndPropertyConfigurationBlock createConfigurationBlock(IScopeContext context) {
- return new SaveParticipantConfigurationBlock(context, this);
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getPreferencePageID() {
- return PREFERENCE_PAGE_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getPropertyPageID() {
- return PROPERTY_PAGE_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean hasProjectSpecificOptions(IProject project) {
- return JavaScriptPlugin.getDefault().getSaveParticipantRegistry().hasSettingsInScope(new ProjectScope(project));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ScrolledPageContent.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ScrolledPageContent.java
deleted file mode 100644
index e3dbf0ed..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/ScrolledPageContent.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-public class ScrolledPageContent extends SharedScrolledComposite {
-
- private FormToolkit fToolkit;
-
- public ScrolledPageContent(Composite parent) {
- this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- }
-
- public ScrolledPageContent(Composite parent, int style) {
- super(parent, style);
-
- setFont(parent.getFont());
-
- fToolkit= JavaScriptPlugin.getDefault().getDialogsFormToolkit();
-
- setExpandHorizontal(true);
- setExpandVertical(true);
-
- Composite body= new Composite(this, SWT.NONE);
- body.setFont(parent.getFont());
- setContent(body);
- }
-
-
- public void adaptChild(Control childControl) {
- fToolkit.adapt(childControl, true, true);
- }
-
- public Composite getBody() {
- return (Composite) getContent();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
deleted file mode 100644
index 7dcb40d1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-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.Link;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Configures Java Editor typing preferences.
- *
- *
- */
-class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
-
- public SmartTypingConfigurationBlock(OverlayPreferenceStore store) {
- super(store);
-
- store.addKeys(createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- return new OverlayPreferenceStore.OverlayKey[] {
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_IMPORTS_ON_PASTE),
-
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
-
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_TAB),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE),
- };
- }
-
- /**
- * Creates page for mark occurrences preferences.
- *
- * @param parent the parent composite
- * @return the control for the preference page
- */
- public Control createControl(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- scrolled.setExpandHorizontal(true);
- scrolled.setExpandVertical(true);
-
- Composite control= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- control.setLayout(layout);
-
- Composite composite;
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title);
- addAutoclosingSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title);
- addAutopositionSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_tabs_title);
- addTabSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title);
- addPasteSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title);
- addStringsSection(composite);
-
- scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrolled.setMinSize(size.x, size.y);
- return scrolled;
- }
-
- private void addStringsSection(Composite composite) {
- GridLayout layout= new GridLayout();
- composite.setLayout(layout);
-
- String label;
- Button master, slave;
- label= PreferencesMessages.JavaEditorPreferencePage_wrapStrings;
- master= addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_escapeStrings;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
- createDependency(master, slave);
- }
-
- private void addPasteSection(Composite composite) {
- GridLayout layout= new GridLayout();
- composite.setLayout(layout);
-
- String label;
- label= PreferencesMessages.JavaEditorPreferencePage_smartPaste;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_importsOnPaste;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_IMPORTS_ON_PASTE, 0);
- }
-
- private void addTabSection(Composite composite) {
- GridLayout layout= new GridLayout();
- composite.setLayout(layout);
-
- String label;
- label= PreferencesMessages.JavaEditorPreferencePage_typing_smartTab;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_TAB, 0);
-
- createMessage(composite);
- }
-
- private void addAutopositionSection(Composite composite) {
-
- GridLayout layout= new GridLayout();
- composite.setLayout(layout);
-
- String label;
-
- label= PreferencesMessages.JavaEditorPreferencePage_typing_smartSemicolon;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_typing_smartOpeningBrace;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 0);
- }
-
- private void addAutoclosingSection(Composite composite) {
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- composite.setLayout(layout);
-
- String label;
- Button master, slave;
-
- label= PreferencesMessages.JavaEditorPreferencePage_closeStrings;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_closeBrackets;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_closeBraces;
- addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_closeJavaDocs;
- master= addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 0);
-
- label= PreferencesMessages.JavaEditorPreferencePage_addJavaDocTags;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 0);
- createDependency(master, slave);
- }
-
- private void createMessage(final Composite composite) {
- // TODO create a link with an argument, so the formatter preference page can open the
- // current profile automatically.
- String linkTooltip= PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tooltip;
- String text;
- String indentMode= JavaScriptPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- if (JavaScriptCore.TAB.equals(indentMode))
- text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tab_text, new String[] {Integer.toString(getTabDisplaySize())});
- else
- text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_others_text, new String[] {Integer.toString(getTabDisplaySize()), Integer.toString(getIndentSize()), getIndentMode()});
-
- final Link link= new Link(composite, SWT.NONE);
- link.setText(text);
- link.setToolTipText(linkTooltip);
- GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gd.widthHint= 300; // don't get wider initially
- link.setLayoutData(gd);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.wst.jsdt.ui.preferences.CodeFormatterPreferencePage", null, null); //$NON-NLS-1$
- }
- });
-
- final IPreferenceStore combinedStore= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
- private boolean fHasRun= false;
- public void propertyChange(PropertyChangeEvent event) {
- if (fHasRun)
- return;
- if (composite.isDisposed())
- return;
- String property= event.getProperty();
- if (DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)
- || DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)) {
- fHasRun= true;
- link.dispose();
- createMessage(composite);
- Dialog.applyDialogFont(composite);
- composite.redraw();
- composite.layout();
- }
- }
- };
- combinedStore.addPropertyChangeListener(propertyChangeListener);
- link.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
- combinedStore.removePropertyChangeListener(propertyChangeListener);
- }
- });
- }
-
- private String getIndentMode() {
- String indentMode= JavaScriptPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
-
- if (JavaScriptCore.SPACE.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces;
-
- if (JavaScriptCore.TAB.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
-
- if (DefaultCodeFormatterConstants.MIXED.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
-
- Assert.isTrue(false, "Illegal indent mode - must not happen"); //$NON-NLS-1$
- return null;
- }
-
- private int getIndentSize() {
- return CodeFormatterUtil.getIndentWidth(null);
- }
-
- private int getTabDisplaySize() {
- return CodeFormatterUtil.getTabWidth(null);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingPreferencePage.java
deleted file mode 100644
index 5e90154f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SmartTypingPreferencePage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * The page for setting the editor options.
- */
-public final class SmartTypingPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= PreferencesMessages.JavaEditorPreferencePage_typing_tabTitle;
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- }
-
-
- protected Label createDescriptionLabel(Composite parent) {
- return null; // no description for new look.
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new SmartTypingConfigurationBlock(overlayPreferenceStore);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SourceAttachmentPropertyPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SourceAttachmentPropertyPage.java
deleted file mode 100644
index afb0b259..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SourceAttachmentPropertyPage.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
-import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock;
-
-/**
- * Property page to configure a archive's JARs source attachment
- */
-public class SourceAttachmentPropertyPage extends PropertyPage implements IStatusChangeListener {
-
- private SourceAttachmentBlock fSourceAttachmentBlock;
- private IPackageFragmentRoot fRoot;
- private IPath fContainerPath;
- private IIncludePathEntry fEntry;
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.SourceAttachmentPage" ; //$NON-NLS-1$
-
- public SourceAttachmentPropertyPage() {
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.SOURCE_ATTACHMENT_PROPERTY_PAGE);
- }
-
- /*
- * @see PreferencePage#createContents
- */
- protected Control createContents(Composite composite) {
- initializeDialogUnits(composite);
- Control result= createPageContent(composite);
- Dialog.applyDialogFont(result);
- return result;
- }
-
- private Control createPageContent(Composite composite) {
- try {
- fContainerPath= null;
- fEntry= null;
- fRoot= getJARPackageFragmentRoot();
- if (fRoot == null || fRoot.getKind() != IPackageFragmentRoot.K_BINARY) {
- return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message);
- }
-
- IPath containerPath= null;
- IJavaScriptProject jproject= fRoot.getJavaScriptProject();
- IIncludePathEntry entry= fRoot.getRawIncludepathEntry();
- if (entry == null) {
- // use a dummy entry to use for initialization
- entry= JavaScriptCore.newLibraryEntry(fRoot.getPath(), null, null);
- } else {
- if (entry.getEntryKind() == IIncludePathEntry.CPE_CONTAINER) {
- containerPath= entry.getPath();
- JsGlobalScopeContainerInitializer initializer= JavaScriptCore.getJsGlobalScopeContainerInitializer(containerPath.segment(0));
- IJsGlobalScopeContainer container= JavaScriptCore.getJsGlobalScopeContainer(containerPath, jproject);
- if (initializer == null || container == null) {
- return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, containerPath.toString()));
- }
- String containerName= container.getDescription();
-
- IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject);
- if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
- return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName));
- }
- if (status.getCode() == JsGlobalScopeContainerInitializer.ATTRIBUTE_READ_ONLY) {
- return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName));
- }
- entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath());
- Assert.isNotNull(entry);
- }
- }
- fContainerPath= containerPath;
- fEntry= entry;
-
- fSourceAttachmentBlock= new SourceAttachmentBlock(this, entry);
- return fSourceAttachmentBlock.createControl(composite);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message);
- }
- }
-
-
- private Control createMessageContent(Composite composite, String message) {
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- inner.setLayout(layout);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.widthHint= convertWidthInCharsToPixels(80);
-
- Label label= new Label(inner, SWT.LEFT + SWT.WRAP);
- label.setText(message);
- label.setLayoutData(gd);
- return inner;
- }
-
-
- /*
- * @see IPreferencePage#performOk
- */
- public boolean performOk() {
- if (fSourceAttachmentBlock != null) {
- try {
- IIncludePathEntry entry= fSourceAttachmentBlock.getNewEntry();
- if (entry.equals(fEntry)) {
- return true; // no change
- }
-
- IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(getShell(), entry, fRoot.getJavaScriptProject(), fContainerPath);
- PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
- } catch (InvocationTargetException e) {
- String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title;
- String message= PreferencesMessages.SourceAttachmentPropertyPage_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
- }
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- if (fSourceAttachmentBlock != null) {
- fSourceAttachmentBlock.setDefaults();
- }
- super.performDefaults();
- }
-
- private IPackageFragmentRoot getJARPackageFragmentRoot() throws CoreException {
- // try to find it as Java element (needed for external jars)
- IAdaptable adaptable= getElement();
- IJavaScriptElement elem= (IJavaScriptElement) adaptable.getAdapter(IJavaScriptElement.class);
- if (elem instanceof IPackageFragmentRoot) {
- return (IPackageFragmentRoot) elem;
- }
- // not on classpath or not in a java project
- IResource resource= (IResource) adaptable.getAdapter(IResource.class);
- if (resource instanceof IFile) {
- IProject proj= resource.getProject();
- if (proj.hasNature(JavaScriptCore.NATURE_ID)) {
- IJavaScriptProject jproject= JavaScriptCore.create(proj);
- return jproject.getPackageFragmentRoot(resource);
- }
- }
- return null;
- }
-
-
- /*
- * @see IStatusChangeListener#statusChanged
- */
- public void statusChanged(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingConfigurationBlock.java
deleted file mode 100644
index 908356a8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingConfigurationBlock.java
+++ /dev/null
@@ -1,629 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.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.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.text.spelling.JavaSpellingEngine;
-import org.eclipse.wst.jsdt.internal.ui.text.spelling.SpellCheckEngine;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/**
- * Options configuration block for spell check related settings.
- *
- *
- */
-public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
-
- /**
- * Tells whether content assist proposal block should be shown.
- * Currently the spelling engine cannot return word proposals but
- * only correction proposals and hence this is disabled.
- *
- *
- */
- private static final boolean SUPPORT_CONTENT_ASSIST_PROPOSALS= false;
-
-
- /** Preference keys for the preferences in this block */
- private static final Key PREF_SPELLING_IGNORE_DIGITS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
- private static final Key PREF_SPELLING_IGNORE_MIXED= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
- private static final Key PREF_SPELLING_IGNORE_SENTENCE= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
- private static final Key PREF_SPELLING_IGNORE_UPPER= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
- private static final Key PREF_SPELLING_IGNORE_JAVA_STRINGS= getJDTUIKey(JavaSpellingEngine.SPELLING_IGNORE_JAVA_STRINGS);
- private static final Key PREF_SPELLING_IGNORE_SINGLE_LETTERS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS);
- private static final Key PREF_SPELLING_IGNORE_NON_LETTERS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS);
- private static final Key PREF_SPELLING_IGNORE_URLS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
- private static final Key PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES);
- private static final Key PREF_SPELLING_LOCALE= getJDTUIKey(PreferenceConstants.SPELLING_LOCALE);
- private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getJDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
- private static final Key PREF_SPELLING_USER_DICTIONARY= getJDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
- private static final Key PREF_SPELLING_USER_DICTIONARY_ENCODING= getJDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING);
- private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getJDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
-
- /**
- * The value for no platform dictionary.
- *
- */
- private static final String PREF_VALUE_NO_LOCALE= ""; //$NON-NLS-1$
-
-
- /**
- * Creates a selection dependency between a master and a slave control.
- *
- * @param master
- * The master button that controls the state of the slave
- * @param slave
- * The slave control that is enabled only if the master is
- * selected
- */
- protected static void createSelectionDependency(final Button master, final Control slave) {
-
- master.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent event) {
- // Do nothing
- }
-
- public void widgetSelected(SelectionEvent event) {
- slave.setEnabled(master.getSelection());
- }
- });
- slave.setEnabled(master.getSelection());
- }
-
- /**
- * Returns the locale codes for the locale list.
- *
- * @param locales
- * The list of locales
- * @return Array of locale codes for the list
- */
- protected static String[] getDictionaryCodes(final Set locales) {
-
- int index= 0;
- Locale locale= null;
-
- final String[] codes= new String[locales.size() + 1];
- for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
- locale= (Locale)iterator.next();
- codes[index++]= locale.toString();
- }
- codes[index++]= PREF_VALUE_NO_LOCALE;
- return codes;
- }
-
- /**
- * Returns the display labels for the locale list.
- *
- * @param locales
- * The list of locales
- * @return Array of display labels for the list
- */
- protected static String[] getDictionaryLabels(final Set locales) {
-
- int index= 0;
- Locale locale= null;
-
- final String[] labels= new String[locales.size() + 1];
- for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
-
- locale= (Locale)iterator.next();
- labels[index++]= locale.getDisplayName();
- }
- labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none;
- return labels;
- }
-
- /**
- * Validates that the file with the specified absolute path exists and can
- * be opened.
- *
- * @param path
- * The path of the file to validate
- * @return <code>true</code> iff the file exists and can be opened,
- * <code>false</code> otherwise
- */
- protected static IStatus validateAbsoluteFilePath(final String path) {
-
- final StatusInfo status= new StatusInfo();
- if (path.length() > 0) {
-
- final File file= new File(path);
- if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
- status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
- else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
- status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
-
- }
- return status;
- }
-
- /**
- * Validates that the specified locale is available.
- *
- * @param localeString the locale to validate
- * @return The status of the validation
- */
- private static IStatus validateLocale(final String localeString) {
- if (PREF_VALUE_NO_LOCALE.equals(localeString))
- return new StatusInfo();
-
- Locale locale= SpellCheckEngine.convertToLocale(localeString);
-
- if (SpellCheckEngine.findClosestLocale(locale) != null)
- return new StatusInfo();
-
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error);
- }
-
- /**
- * Validates that the specified number is positive.
- *
- * @param number
- * The number to validate
- * @return The status of the validation
- */
- protected static IStatus validatePositiveNumber(final String number) {
-
- final StatusInfo status= new StatusInfo();
- if (number.length() == 0) {
- status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
- } else {
- try {
- final int value= Integer.parseInt(number);
- if (value < 0) {
- status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
- }
- } catch (NumberFormatException exception) {
- status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
- }
- }
- return status;
- }
-
- /** The dictionary path field */
- private Text fDictionaryPath= null;
-
- /** The status for the workspace dictionary file */
- private IStatus fFileStatus= new StatusInfo();
-
- /** The status for the proposal threshold */
- private IStatus fThresholdStatus= new StatusInfo();
-
- /** The status for the encoding field editor */
- private IStatus fEncodingFieldEditorStatus= new StatusInfo();
-
- /** The encoding field editor. */
- private EncodingFieldEditor fEncodingEditor;
- /** The encoding field editor's parent. */
- private Composite fEncodingEditorParent;
-
- /**
- * All controls
- *
- */
- private Control[] fAllControls;
-
- /**
- * All previously enabled controls
- *
- */
- private Control[] fEnabledControls;
-
- /**
- * Creates a new spelling configuration block.
- *
- * @param context the status change listener
- * @param project the Java project
- * @param container the preference container
- */
- public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getAllKeys(), container);
-
- IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
- if (status.getSeverity() != IStatus.OK)
- setValue(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
-
- status= validateLocale(getValue(PREF_SPELLING_LOCALE));
- if (status.getSeverity() != IStatus.OK)
- setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString());
- }
-
- protected Combo addComboBox(Composite parent, String label, Key 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);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- comboBox.setLayoutData(gd);
- comboBox.addSelectionListener(getSelectionListener());
-
- fLabels.put(comboBox, labelControl);
-
- String currValue= getValue(key);
-
- Locale locale= SpellCheckEngine.convertToLocale(currValue);
- locale= SpellCheckEngine.findClosestLocale(locale);
- if (locale != null)
- currValue= locale.toString();
-
- comboBox.select(data.getSelection(currValue));
-
- fComboBoxes.add(comboBox);
- return comboBox;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(final Composite parent) {
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
-
- List allControls= new ArrayList();
- final PixelConverter converter= new PixelConverter(parent);
-
- final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
-
- Group user= new Group(composite, SWT.NONE);
- user.setText(PreferencesMessages.SpellingPreferencePage_group_user);
- user.setLayout(new GridLayout());
- user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- allControls.add(user);
-
- String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label;
- Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_url_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_non_letters_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_NON_LETTERS, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_single_letters_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SINGLE_LETTERS, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_java_strings_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_JAVA_STRINGS, trueFalse, 0);
- allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_ampersand_in_properties_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, trueFalse, 0);
- allControls.add(slave);
-
- final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries();
- boolean hasPlaformDictionaries= locales.size() > 0;
-
- final Group engine= new Group(composite, SWT.NONE);
- if (hasPlaformDictionaries)
- engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionaries);
- else
- engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionary);
- engine.setLayout(new GridLayout(4, false));
- engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- allControls.add(engine);
-
- if (hasPlaformDictionaries) {
- label= PreferencesMessages.SpellingPreferencePage_dictionary_label;
- Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0);
- combo.setEnabled(locales.size() > 0);
- allControls.add(combo);
- allControls.add(fLabels.get(combo));
-
- new Label(engine, SWT.NONE); // placeholder
- }
-
- label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label;
- fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
- GridData gd= (GridData) fDictionaryPath.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.widthHint= converter.convertWidthInCharsToPixels(40);
- allControls.add(fDictionaryPath);
- allControls.add(fLabels.get(fDictionaryPath));
-
-
- Button button= new Button(engine, SWT.PUSH);
- button.setText(PreferencesMessages.SpellingPreferencePage_browse_label);
- button.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- handleBrowseButtonSelected();
- }
- });
- button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- SWTUtil.setButtonDimensionHint(button);
- allControls.add(button);
-
- // Description for user dictionary
- new Label(engine, SWT.NONE); // filler
- Label description= new Label(engine, SWT.NONE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- description.setLayoutData(gd);
- description.setText(PreferencesMessages.SpellingPreferencePage_user_dictionary_description);
- allControls.add(description);
-
- createEncodingFieldEditor(engine, allControls);
-
- Group advanced= new Group(composite, SWT.NONE);
- advanced.setText(PreferencesMessages.SpellingPreferencePage_group_advanced);
- advanced.setLayout(new GridLayout(3, false));
- advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- allControls.add(advanced);
-
- label= PreferencesMessages.SpellingPreferencePage_proposals_threshold;
- Text text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, 0);
- text.setTextLimit(3);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint= converter.convertWidthInCharsToPixels(4);
- text.setLayoutData(gd);
- allControls.add(text);
- allControls.add(fLabels.get(text));
-
- if (SUPPORT_CONTENT_ASSIST_PROPOSALS) {
- label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label;
- button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
- allControls.add(button);
- }
-
- fAllControls= (Control[]) allControls.toArray(new Control[allControls.size()]);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.SPELLING_CONFIGURATION_BLOCK);
- return composite;
- }
-
- /**
- * Creates the encoding field editor.
- *
- * @param composite the parent composite
- * @param allControls list with all controls
- *
- */
- private void createEncodingFieldEditor(Composite composite, List allControls) {
- Label filler= new Label(composite, SWT.NONE);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 4;
- filler.setLayoutData(gd);
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label);
- label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- allControls.add(label);
-
- fEncodingEditorParent= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- fEncodingEditorParent.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- fEncodingEditorParent.setLayoutData(gd);
-
- fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); //$NON-NLS-1$
-
- PreferenceStore store= new PreferenceStore();
- String defaultEncoding= ResourcesPlugin.getEncoding();
- store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding);
- String encoding= getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING);
- if (encoding != null && encoding.length() > 0)
- store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding);
-
- fEncodingEditor.setPreferenceStore(store);
-
- // Redirect status messages from the field editor to the status change listener
- DialogPage fakePage= new DialogPage() {
- public void createControl(Composite c) {
- }
- public void setErrorMessage(String newMessage) {
- StatusInfo status= new StatusInfo();
- if (newMessage != null)
- status.setError(newMessage);
- fEncodingFieldEditorStatus= status;
- fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
- }
- };
- fEncodingEditor.setPage(fakePage);
-
- fEncodingEditor.load();
-
- if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
- fEncodingEditor.loadDefault();
-
- }
-
- private static Key[] getAllKeys() {
- if (SUPPORT_CONTENT_ASSIST_PROPOSALS)
- return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_JAVA_STRINGS };
- else
- return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_IGNORE_JAVA_STRINGS };
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
- */
- protected final String[] getFullBuildDialogStrings(final boolean workspace) {
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#performOk()
- *
- */
- public boolean performOk() {
- fEncodingEditor.store();
- if (fEncodingEditor.presentsDefaultValue())
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
- else
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#performApply()
- *
- */
- public boolean performApply() {
- fEncodingEditor.store();
- if (fEncodingEditor.presentsDefaultValue())
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
- else
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
- return super.performApply();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults()
- *
- */
- public void performDefaults() {
- super.performDefaults();
-
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
-
- fEncodingEditor.getPreferenceStore().setValue(fEncodingEditor.getPreferenceName(), ResourcesPlugin.getEncoding());
- fEncodingEditor.load();
-
- fEncodingEditor.loadDefault();
- }
-
- /**
- * Handles selections of the browse button.
- */
- protected void handleBrowseButtonSelected() {
- final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
- dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title);
- dialog.setFilterPath(fDictionaryPath.getText());
-
- final String path= dialog.open();
- if (path != null)
- fDictionaryPath.setText(path);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
- */
- protected void validateSettings(final Key key, final String oldValue, final String newValue) {
-
- if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key))
- fThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
-
- if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key))
- fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
-
- fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateCheckBox(org.eclipse.swt.widgets.Button)
- *
- */
- protected void updateCheckBox(Button curr) {
- super.updateCheckBox(curr);
- Event event= new Event();
- event.type= SWT.Selection;
- event.display= curr.getDisplay();
- event.widget= curr;
- curr.notifyListeners(SWT.Selection, event);
- }
-
- /**
- * Sets the enabled state.
- *
- * @param enabled the new state
- *
- */
- protected void setEnabled(boolean enabled) {
- fEncodingEditor.setEnabled(enabled, fEncodingEditorParent);
-
- if (enabled && fEnabledControls != null) {
- for (int i= fEnabledControls.length - 1; i >= 0; i--)
- fEnabledControls[i].setEnabled(true);
- fEnabledControls= null;
- }
- if (!enabled && fEnabledControls == null) {
- List enabledControls= new ArrayList();
- for (int i= fAllControls.length - 1; i >= 0; i--) {
- Control control= fAllControls[i];
- if (control.isEnabled()) {
- enabledControls.add(control);
- control.setEnabled(false);
- }
- }
- fEnabledControls= (Control[]) enabledControls.toArray(new Control[enabledControls.size()]);
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingPreferenceBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingPreferenceBlock.java
deleted file mode 100644
index 390a8bf5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/SpellingPreferenceBlock.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
-import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-
-/**
- * Spelling preference block
- *
- *
- */
-public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
-
- private class NullStatusChangeListener implements IStatusChangeListener {
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
- */
- public void statusChanged(IStatus status) {
- }
- }
-
- private class StatusChangeListenerAdapter implements IStatusChangeListener {
-
- private IPreferenceStatusMonitor fMonitor;
-
- private IStatus fStatus;
-
- public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
- super();
- fMonitor= monitor;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
- */
- public void statusChanged(IStatus status) {
- fStatus= status;
- fMonitor.statusChanged(status);
- }
-
- public IStatus getStatus() {
- return fStatus;
- }
- }
-
- private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
-
- private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
- */
- public Control createControl(Composite parent) {
- return fBlock.createContents(parent);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#initialize(org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor)
- */
- public void initialize(IPreferenceStatusMonitor statusMonitor) {
- fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
- fBlock.fContext= fStatusMonitor;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#canPerformOk()
- */
- public boolean canPerformOk() {
- return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performOk()
- */
- public void performOk() {
- fBlock.performOk();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performDefaults()
- */
- public void performDefaults() {
- fBlock.performDefaults();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
- */
- public void performRevert() {
- fBlock.performRevert();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#dispose()
- */
- public void dispose() {
- fBlock.dispose();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
- fBlock.setEnabled(enabled);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
deleted file mode 100644
index b5082608..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-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.Control;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-
-/**
- */
-public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_COMPILER_TASK_TAGS= getJDTCoreKey(JavaScriptCore.COMPILER_TASK_TAGS);
- private static final Key PREF_COMPILER_TASK_PRIORITIES= getJDTCoreKey(JavaScriptCore.COMPILER_TASK_PRIORITIES);
-
- private static final Key PREF_COMPILER_TASK_CASE_SENSITIVE= getJDTCoreKey(JavaScriptCore.COMPILER_TASK_CASE_SENSITIVE);
-
- private static final String PRIORITY_HIGH= JavaScriptCore.COMPILER_TASK_PRIORITY_HIGH;
- private static final String PRIORITY_NORMAL= JavaScriptCore.COMPILER_TASK_PRIORITY_NORMAL;
- private static final String PRIORITY_LOW= JavaScriptCore.COMPILER_TASK_PRIORITY_LOW;
-
- private static final String ENABLED= JavaScriptCore.ENABLED;
- private static final String DISABLED= JavaScriptCore.DISABLED;
-
- public static class TodoTask {
- public String name;
- public String priority;
- }
-
- private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
-
- public TodoTaskLabelProvider() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
- }
-
- /* (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) {
- String name= task.name;
- if (isDefaultTask(task)) {
- name=Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
- }
- return name;
- } else {
- if (PRIORITY_HIGH.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
- } else if (PRIORITY_NORMAL.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
- } else if (PRIORITY_LOW.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
- }
- return ""; //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
- public Font getFont(Object element) {
- if (isDefaultTask((TodoTask) element)) {
- return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
- }
- return null;
- }
- }
-
- private static class TodoTaskSorter extends ViewerComparator {
- public int compare(Viewer viewer, Object e1, Object e2) {
- return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name);
- }
- }
-
- private static final int IDX_ADD= 0;
- private static final int IDX_EDIT= 1;
- private static final int IDX_REMOVE= 2;
- private static final int IDX_DEFAULT= 4;
-
- private IStatus fTaskTagsStatus;
- private ListDialogField fTodoTasksList;
- private SelectionButtonDialogField fCaseSensitiveCheckBox;
-
-
- public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getKeys(), container);
-
- TaskTagAdapter adapter= new TaskTagAdapter();
- String[] buttons= new String[] {
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button,
- null,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
- };
- fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider());
- fTodoTasksList.setDialogFieldListener(adapter);
- fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
-
- String[] columnsHeaders= new String[] {
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column,
- };
-
- fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
- fTodoTasksList.setViewerComparator(new TodoTaskSorter());
-
-
- fCaseSensitiveCheckBox= new SelectionButtonDialogField(SWT.CHECK);
- fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label);
- fCaseSensitiveCheckBox.setDialogFieldListener(adapter);
-
- unpackTodoTasks();
- if (fTodoTasksList.getSize() > 0) {
- fTodoTasksList.selectFirstElement();
- } else {
- fTodoTasksList.enableButton(IDX_EDIT, false);
- fTodoTasksList.enableButton(IDX_DEFAULT, false);
- }
-
- fTaskTagsStatus= new StatusInfo();
- }
-
- public void setEnabled(boolean isEnabled) {
- fTodoTasksList.setEnabled(isEnabled);
- fCaseSensitiveCheckBox.setEnabled(isEnabled);
- }
-
- final boolean isDefaultTask(TodoTask task) {
- return fTodoTasksList.getIndexOfElement(task) == 0;
- }
-
- private void setToDefaultTask(TodoTask task) {
- List elements= fTodoTasksList.getElements();
- elements.remove(task);
- elements.add(0, task);
- fTodoTasksList.setElements(elements);
- fTodoTasksList.enableButton(IDX_DEFAULT, false);
- }
-
- private static Key[] getKeys() {
- return new Key[] {
- PREF_COMPILER_TASK_TAGS, PREF_COMPILER_TASK_PRIORITIES, PREF_COMPILER_TASK_CASE_SENSITIVE
- };
- }
-
- public class TaskTagAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(List selectedElements) {
- return selectedElements.size() == 1;
- }
-
- private boolean canSetToDefault(List selectedElements) {
- return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0));
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doTodoButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- List selectedElements= field.getSelectedElements();
- field.enableButton(IDX_EDIT, canEdit(selectedElements));
- field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field.getSelectedElements())) {
- doTodoButtonPressed(IDX_EDIT);
- }
- }
-
- public void dialogFieldChanged(DialogField field) {
- updateModel(field);
- }
-
- }
-
- protected Control createContents(Composite parent) {
- setShell(parent.getShell());
-
- Composite markersComposite= createMarkersTabContent(parent);
-
- validateSettings(null, null, null);
-
- return markersComposite;
- }
-
- private Composite createMarkersTabContent(Composite folder) {
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
-
- PixelConverter conv= new PixelConverter(folder);
-
- Composite markersComposite= new Composite(folder, SWT.NULL);
- markersComposite.setLayout(layout);
- markersComposite.setFont(folder.getFont());
-
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= conv.convertWidthInCharsToPixels(50);
- Control listControl= fTodoTasksList.getListControl(markersComposite);
- listControl.setLayoutData(data);
-
- Control buttonsControl= fTodoTasksList.getButtonBox(markersComposite);
- buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
-
- fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2);
-
- return markersComposite;
- }
-
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- if (!areSettingsEnabled()) {
- return;
- }
-
- if (changedKey != null) {
- if (PREF_COMPILER_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();
- }
-
- protected final void updateModel(DialogField field) {
- if (field == fTodoTasksList) {
- 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);
- }
- setValue(PREF_COMPILER_TASK_TAGS, tags.toString());
- setValue(PREF_COMPILER_TASK_PRIORITIES, prios.toString());
- validateSettings(PREF_COMPILER_TASK_TAGS, null, null);
- } else if (field == fCaseSensitiveCheckBox) {
- String state= fCaseSensitiveCheckBox.isSelected() ? ENABLED : DISABLED;
- setValue(PREF_COMPILER_TASK_CASE_SENSITIVE, state);
- }
- }
-
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String title= PreferencesMessages.TodoTaskConfigurationBlock_needsbuild_title;
- String message;
- if (fProject == null) {
- message= PreferencesMessages.TodoTaskConfigurationBlock_needsfullbuild_message;
- } else {
- message= PreferencesMessages.TodoTaskConfigurationBlock_needsprojectbuild_message;
- }
- return new String[] { title, message };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
- */
- protected void updateControls() {
- unpackTodoTasks();
- }
-
- private void unpackTodoTasks() {
- String currTags= getValue(PREF_COMPILER_TASK_TAGS);
- String currPrios= getValue(PREF_COMPILER_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);
-
- boolean isCaseSensitive= checkValue(PREF_COMPILER_TASK_CASE_SENSITIVE, ENABLED);
- fCaseSensitiveCheckBox.setSelection(isCaseSensitive);
- }
-
- private void doTodoButtonPressed(int index) {
- TodoTask edited= null;
- if (index != IDX_ADD) {
- edited= (TodoTask) fTodoTasksList.getSelectedElements().get(0);
- }
- if (index == IDX_ADD || index == IDX_EDIT) {
- TodoTaskInputDialog dialog= new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
- if (dialog.open() == Window.OK) {
- if (edited != null) {
- fTodoTasksList.replaceElement(edited, dialog.getResult());
- } else {
- fTodoTasksList.addElement(dialog.getResult());
- }
- }
- } else if (index == IDX_DEFAULT) {
- setToDefaultTask(edited);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskInputDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskInputDialog.java
deleted file mode 100644
index 6ec191cb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskInputDialog.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.StatusDialog;
-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.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.preferences.TodoTaskConfigurationBlock.TodoTask;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ComboDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.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.TodoTaskInputDialog_new_title);
- } else {
- setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title);
- }
-
- CompilerTodoTaskInputAdapter adapter= new CompilerTodoTaskInputAdapter();
-
- fNameDialogField= new StringDialogField();
- fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label);
- fNameDialogField.setDialogFieldListener(adapter);
-
- fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
-
- String[] items= new String[] {
- PreferencesMessages.TodoTaskInputDialog_priority_high,
- PreferencesMessages.TodoTaskInputDialog_priority_normal,
- PreferencesMessages.TodoTaskInputDialog_priority_low
- };
-
- fPriorityDialogField= new ComboDialogField(SWT.READ_ONLY);
- fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label);
- fPriorityDialogField.setItems(items);
- if (task != null) {
- if (JavaScriptCore.COMPILER_TASK_PRIORITY_HIGH.equals(task.priority)) {
- fPriorityDialogField.selectItem(0);
- } else if (JavaScriptCore.COMPILER_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= JavaScriptCore.COMPILER_TASK_PRIORITY_HIGH;
- break;
- case 1 :
- task.priority= JavaScriptCore.COMPILER_TASK_PRIORITY_NORMAL;
- break;
- default :
- task.priority= JavaScriptCore.COMPILER_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);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.TASK_TAG_INPUT_DIALOG);
-
- return composite;
- }
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fNameDialogField.getText();
- if (newText.length() == 0) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
- } else {
- if (newText.indexOf(',') != -1) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma);
- } else if (fExistingNames.contains(newText)) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists);
- } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace);
- }
- }
- updateStatus(status);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.TODO_TASK_INPUT_DIALOG);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskPreferencePage.java
deleted file mode 100644
index 1960c358..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TodoTaskPreferencePage.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/*
- * The page to configure the task tags
- */
-public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
-
- public static final String PREF_ID= "org.eclipse.wst.jsdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.wst.jsdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$
-
- private TodoTaskConfigurationBlock fConfigurationBlock;
-
- public TodoTaskPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.TodoTaskPreferencePage_description);
-
- // only used when page is shown programatically
- setTitle(PreferencesMessages.TodoTaskPreferencePage_title);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new TodoTaskConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
- super.createControl(parent);
-
- if (isProjectPreferencePage()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PROPERTY_PAGE);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PREFERENCE_PAGE);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
- */
- protected Control createPreferenceContent(Composite composite) {
- return fConfigurationBlock.createContents(composite);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
- */
- protected boolean hasProjectSpecificOptions(IProject project) {
- return fConfigurationBlock.hasProjectSpecificOptions(project);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- if (fConfigurationBlock != null) {
- fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.performApply();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterInputDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterInputDialog.java
deleted file mode 100644
index d8a4b165..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterInputDialog.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.PackageSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-
-/**
- * Dialog to enter a new entry in the type filter preference page.
- */
-public class TypeFilterInputDialog extends StatusDialog {
-
- private class TypeFilterInputAdapter implements IDialogFieldListener, IStringButtonAdapter {
- /*
- * @see IDialogFieldListener#dialogFieldChanged(DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- doValidation();
- }
- /*
- * @see IStringButtonAdapter#changeControlPressed(DialogField)
- */
- public void changeControlPressed(DialogField field) {
- doButtonPressed();
- }
- }
-
- private StringButtonDialogField fNameDialogField;
- private List fExistingEntries;
-
- public TypeFilterInputDialog(Shell parent, List existingEntries) {
- super(parent);
-
- fExistingEntries= existingEntries;
-
- setTitle(PreferencesMessages.TypeFilterInputDialog_title);
-
- TypeFilterInputAdapter adapter= new TypeFilterInputAdapter();
-
- fNameDialogField= new StringButtonDialogField(adapter);
- fNameDialogField.setLabelText(PreferencesMessages.TypeFilterInputDialog_message);
- fNameDialogField.setButtonLabel(PreferencesMessages.TypeFilterInputDialog_browse_button);
- fNameDialogField.setDialogFieldListener(adapter);
-
- fNameDialogField.setText(""); //$NON-NLS-1$
- }
-
- public void setInitialString(String input) {
- Assert.isNotNull(input);
- fNameDialogField.setText(input);
- }
-
- public Object getResult() {
- return fNameDialogField.getText();
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- LayoutUtil.doDefaultLayout(inner, new DialogField[] { fNameDialogField }, true, 0, 0);
-
- int fieldWidthHint= convertWidthInCharsToPixels(60);
- Text text= fNameDialogField.getTextControl(null);
- LayoutUtil.setWidthHint(text, fieldWidthHint);
- LayoutUtil.setHorizontalGrabbing(text);
- TextFieldNavigationHandler.install(text);
-
- fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
- return composite;
- }
-
- private void doButtonPressed() {
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
- int flags= PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE | PackageSelectionDialog.F_REMOVE_DUPLICATES;
- PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, flags , scope);
- dialog.setTitle(PreferencesMessages.TypeFilterInputDialog_choosepackage_label);
- dialog.setMessage(PreferencesMessages.TypeFilterInputDialog_choosepackage_description);
- dialog.setMultipleSelection(false);
- dialog.setFilter(fNameDialogField.getText());
- if (dialog.open() == IDialogConstants.OK_ID) {
- IPackageFragment res= (IPackageFragment) dialog.getFirstResult();
- fNameDialogField.setText(res.getElementName() + "*"); //$NON-NLS-1$
- }
- }
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fNameDialogField.getText();
- if (newText.length() == 0) {
- status.setError(PreferencesMessages.TypeFilterInputDialog_error_enterName);
- } else {
- newText= newText.replace('*', 'X').replace('?', 'Y');
- IStatus val= JavaScriptConventions.validatePackageName(newText, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3);
- if (val.matches(IStatus.ERROR)) {
- status.setError(Messages.format(PreferencesMessages.TypeFilterInputDialog_error_invalidName, val.getMessage()));
- } else {
- if (fExistingEntries.contains(newText)) {
- status.setError(PreferencesMessages.TypeFilterInputDialog_error_entryExists);
- }
- }
- }
- updateStatus(status);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.IMPORT_ORGANIZE_INPUT_DIALOG);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterPreferencePage.java
deleted file mode 100644
index 5f04d0a9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/TypeFilterPreferencePage.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-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.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.PackageSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-/*
- * The page for setting the type filters
- */
-public class TypeFilterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String TYPE_FILTER_PREF_PAGE_ID= "org.eclipse.wst.jsdt.ui.preferences.TypeFilterPreferencePage"; //$NON-NLS-1$
-
- private static final String PREF_FILTER_ENABLED= PreferenceConstants.TYPEFILTER_ENABLED;
- private static final String PREF_FILTER_DISABLED= PreferenceConstants.TYPEFILTER_DISABLED;
-
- private static String[] unpackOrderList(String str) {
- StringTokenizer tok= new StringTokenizer(str, ";"); //$NON-NLS-1$
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < nTokens; i++) {
- res[i]= tok.nextToken();
- }
- return res;
- }
-
- private static String packOrderList(List orderList) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < orderList.size(); i++) {
- buf.append((String) orderList.get(i));
- buf.append(';');
- }
- return buf.toString();
- }
-
- private class TypeFilterAdapter implements IListAdapter, IDialogFieldListener {
-
- private boolean canEdit(ListDialogField field) {
- return field.getSelectedElements().size() == 1;
- }
-
- public void customButtonPressed(ListDialogField field, int index) {
- doButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- fFilterListField.enableButton(IDX_EDIT, canEdit(field));
- }
-
- public void dialogFieldChanged(DialogField field) {
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit(field)) {
- doButtonPressed(IDX_EDIT);
- }
- }
- }
-
- private static final int IDX_ADD= 0;
- private static final int IDX_ADD_PACKAGE= 1;
- private static final int IDX_EDIT= 2;
- private static final int IDX_REMOVE= 3;
- private static final int IDX_SELECT= 5;
- private static final int IDX_DESELECT= 6;
-
- private CheckedListDialogField fFilterListField;
-
- public TypeFilterPreferencePage() {
- super();
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.TypeFilterPreferencePage_description);
-
- String[] buttonLabels= new String[] {
- PreferencesMessages.TypeFilterPreferencePage_add_button,
- PreferencesMessages.TypeFilterPreferencePage_addpackage_button,
- PreferencesMessages.TypeFilterPreferencePage_edit_button,
- PreferencesMessages.TypeFilterPreferencePage_remove_button,
- /* 4 */ null,
- PreferencesMessages.TypeFilterPreferencePage_selectall_button,
- PreferencesMessages.TypeFilterPreferencePage_deselectall_button,
- };
-
- TypeFilterAdapter adapter= new TypeFilterAdapter();
-
- fFilterListField= new CheckedListDialogField(adapter, buttonLabels, new LabelProvider());
- fFilterListField.setDialogFieldListener(adapter);
- fFilterListField.setLabelText(PreferencesMessages.TypeFilterPreferencePage_list_label);
- fFilterListField.setCheckAllButtonIndex(IDX_SELECT);
- fFilterListField.setUncheckAllButtonIndex(IDX_DESELECT);
- fFilterListField.setRemoveButtonIndex(IDX_REMOVE);
-
- fFilterListField.enableButton(IDX_EDIT, false);
-
- initialize(false);
- }
-
- /*
- * @see PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TYPE_FILTER_PREFERENCE_PAGE);
- }
-
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
-
- composite.setLayout(layout);
-
- fFilterListField.doFillIntoGrid(composite, 3);
- LayoutUtil.setHorizontalSpan(fFilterListField.getLabelControl(null), 2);
- LayoutUtil.setWidthHint(fFilterListField.getLabelControl(null), convertWidthInCharsToPixels(40));
- LayoutUtil.setHorizontalGrabbing(fFilterListField.getListControl(null));
-
- fFilterListField.getTableViewer().setComparator(new ViewerComparator());
-
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- private void initialize(boolean fromDefault) {
- IPreferenceStore store= getPreferenceStore();
-
- String enabled= fromDefault ? store.getDefaultString(PREF_FILTER_ENABLED) : store.getString(PREF_FILTER_ENABLED);
- String disabled= fromDefault ? store.getDefaultString(PREF_FILTER_DISABLED) : store.getString(PREF_FILTER_DISABLED);
-
- ArrayList res= new ArrayList();
-
- String[] enabledEntries= unpackOrderList(enabled);
- for (int i= 0; i < enabledEntries.length; i++) {
- res.add(enabledEntries[i]);
- }
- String[] disabledEntries= unpackOrderList(disabled);
- for (int i= 0; i < disabledEntries.length; i++) {
- res.add(disabledEntries[i]);
- }
-
- fFilterListField.setElements(res);
- fFilterListField.setCheckedElements(Arrays.asList(enabledEntries));
- }
-
-
- private void doButtonPressed(int index) {
- if (index == IDX_ADD) { // add new
- List existing= fFilterListField.getElements();
- TypeFilterInputDialog dialog= new TypeFilterInputDialog(getShell(), existing);
- if (dialog.open() == Window.OK) {
- Object res= dialog.getResult();
- fFilterListField.addElement(res);
- fFilterListField.setChecked(res, true);
- }
- } else if (index == IDX_ADD_PACKAGE) { // add packages
- String[] res= choosePackage();
- if (res != null) {
- fFilterListField.addElements(Arrays.asList(res));
- for (int i= 0; i < res.length; i++) {
- fFilterListField.setChecked(res[i], true);
- }
- }
-
- } else if (index == IDX_EDIT) { // edit
- List selected= fFilterListField.getSelectedElements();
- if (selected.isEmpty()) {
- return;
- }
- String editedEntry= (String) selected.get(0);
-
- List existing= fFilterListField.getElements();
- existing.remove(editedEntry);
-
- TypeFilterInputDialog dialog= new TypeFilterInputDialog(getShell(), existing);
- dialog.setInitialString(editedEntry);
- if (dialog.open() == Window.OK) {
- fFilterListField.replaceElement(editedEntry, dialog.getResult());
- }
- }
- }
-
- private String[] choosePackage() {
- IJavaScriptSearchScope scope= SearchEngine.createWorkspaceScope();
- BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
- int flags= PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE | PackageSelectionDialog.F_REMOVE_DUPLICATES;
- PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, flags , scope);
- dialog.setTitle(PreferencesMessages.TypeFilterPreferencePage_choosepackage_label);
- dialog.setMessage(PreferencesMessages.TypeFilterPreferencePage_choosepackage_description);
- dialog.setMultipleSelection(true);
- if (dialog.open() == IDialogConstants.OK_ID) {
- Object[] fragments= dialog.getResult();
- String[] res= new String[fragments.length];
- for (int i= 0; i < res.length; i++) {
- res[i]= ((IPackageFragment) fragments[i]).getElementName() + ".*"; //$NON-NLS-1$
- }
- return res;
- }
- return null;
- }
-
-
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- initialize(true);
-
- super.performDefaults();
- }
-
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore prefs= JavaScriptPlugin.getDefault().getPreferenceStore();
-
- List checked= fFilterListField.getCheckedElements();
- List unchecked= fFilterListField.getElements();
- unchecked.removeAll(checked);
-
- prefs.setValue(PREF_FILTER_ENABLED, packOrderList(checked));
- prefs.setValue(PREF_FILTER_DISABLED, packOrderList(unchecked));
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
-
-}
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/UserLibraryPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/UserLibraryPreferencePage.java
deleted file mode 100644
index 12964723..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/UserLibraryPreferencePage.java
+++ /dev/null
@@ -1,1381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-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.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.StringConverter;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-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.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
-import org.eclipse.wst.jsdt.core.IAccessRule;
-import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
-import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.IUIConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.AccessRulesDialog;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathSupport;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListElement;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListElementSorter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPListLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.CPUserLibraryElement;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.ClasspathAttributeConfigurationDescriptors;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField;
-//import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.TreeListDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.wst.jsdt.ui.wizards.ClasspathAttributeConfiguration;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class UserLibraryPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- public static final String ID= "org.eclipse.wst.jsdt.ui.preferences.UserLibraryPreferencePage"; //$NON-NLS-1$
- public static final String DATA_DO_CREATE= "do_create"; //$NON-NLS-1$
- public static final String DATA_LIBRARY_TO_SELECT= "select_library"; //$NON-NLS-1$
-
- public static class LibraryNameDialog extends StatusDialog implements IDialogFieldListener {
-
- private StringDialogField fNameField;
- //private SelectionButtonDialogField fIsSystemField;
-
- private CPUserLibraryElement fElementToEdit;
- private List fExistingLibraries;
-
- public LibraryNameDialog(Shell parent, CPUserLibraryElement elementToEdit, List existingLibraries) {
- super(parent);
- if (elementToEdit == null) {
- setTitle(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_new_title);
- } else {
- setTitle(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_edit_title);
- }
-
- fElementToEdit= elementToEdit;
- fExistingLibraries= existingLibraries;
-
- fNameField= new StringDialogField();
- fNameField.setDialogFieldListener(this);
- fNameField.setLabelText(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_name_label);
-
- //fIsSystemField= new SelectionButtonDialogField(SWT.CHECK);
- //fIsSystemField.setLabelText(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_issystem_label);
-
- if (elementToEdit != null) {
- fNameField.setText(elementToEdit.getName());
- // fIsSystemField.setSelection(elementToEdit.isSystemLibrary());
- } else {
- fNameField.setText(""); //$NON-NLS-1$
- //fIsSystemField.setSelection(false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- LayoutUtil.doDefaultLayout(composite, new DialogField[] { fNameField }, true, SWT.DEFAULT, SWT.DEFAULT);
- fNameField.postSetFocusOnDialogField(parent.getDisplay());
-
- Dialog.applyDialogFont(composite);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CP_EDIT_USER_LIBRARY);
-
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- if (field == fNameField) {
- updateStatus(validateSettings());
- }
- }
-
- private IStatus validateSettings() {
- String name= fNameField.getText();
- if (name.length() == 0) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_name_error_entername);
- }
- for (int i= 0; i < fExistingLibraries.size(); i++) {
- CPUserLibraryElement curr= (CPUserLibraryElement) fExistingLibraries.get(i);
- if (curr != fElementToEdit && name.equals(curr.getName())) {
- return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_name_error_exists, name));
- }
- }
- IStatus status= ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
- if (status.matches(IStatus.ERROR)) {
- return new StatusInfo(IStatus.ERROR, "Name contains invalid characters."); //$NON-NLS-1$
- }
- return StatusInfo.OK_STATUS;
- }
-
- public CPUserLibraryElement getNewLibrary() {
- CPListElement[] entries= null;
- if (fElementToEdit != null) {
- entries= fElementToEdit.getChildren();
- }
- return new CPUserLibraryElement(fNameField.getText(), false, entries);
- }
-
- }
-
- public static class LoadSaveDialog extends StatusDialog implements IStringButtonAdapter, IDialogFieldListener, IListAdapter {
-
-
- private static final String VERSION1= "1"; //$NON-NLS-1$ // using OS strings for archive path and source attachment
- private static final String CURRENT_VERSION= "2"; //$NON-NLS-1$
-
- private static final String TAG_ROOT= "eclipse-userlibraries"; //$NON-NLS-1$
- private static final String TAG_VERSION= "version"; //$NON-NLS-1$
- private static final String TAG_LIBRARY= "library"; //$NON-NLS-1$
- private static final String TAG_SOURCEATTACHMENT= "source"; //$NON-NLS-1$
- private static final String TAG_ARCHIVE_PATH= "path"; //$NON-NLS-1$
- private static final String TAG_ARCHIVE= "archive"; //$NON-NLS-1$
- private static final String TAG_SYSTEMLIBRARY= "systemlibrary"; //$NON-NLS-1$
- private static final String TAG_NAME= "name"; //$NON-NLS-1$
- private static final String TAG_JAVADOC= "javadoc"; //$NON-NLS-1$
- private static final String TAG_NATIVELIB_PATHS= "nativelibpaths"; //$NON-NLS-1$
- private static final String TAG_ACCESSRULES= "accessrules"; //$NON-NLS-1$
- private static final String TAG_ACCESSRULE= "accessrule"; //$NON-NLS-1$
- private static final String TAG_RULE_KIND= "kind"; //$NON-NLS-1$
- private static final String TAG_RULE_PATTERN= "pattern"; //$NON-NLS-1$
-
- private static final String PREF_LASTPATH= JavaScriptUI.ID_PLUGIN + ".lastuserlibrary"; //$NON-NLS-1$
- private static final String PREF_USER_LIBRARY_LOADSAVE_SIZE= "UserLibraryLoadSaveDialog.size"; //$NON-NLS-1$
-
- private List fExistingLibraries;
- private IDialogSettings fSettings;
-
- private File fLastFile;
-
- private StringButtonDialogField fLocationField;
- private CheckedListDialogField fExportImportList;
- private Point fInitialSize;
- private final boolean fIsSave;
-
- public LoadSaveDialog(Shell shell, boolean isSave, List existingLibraries, IDialogSettings dialogSettings) {
- super(shell);
- initializeDialogUnits(shell);
-
- setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
-
- fExistingLibraries= existingLibraries;
- fSettings= dialogSettings;
- fLastFile= null;
- fIsSave= isSave;
-
- int defaultWidth= convertWidthInCharsToPixels(80);
- int defaultHeigth= convertHeightInCharsToPixels(34);
- String lastSize= fSettings.get(PREF_USER_LIBRARY_LOADSAVE_SIZE);
- if (lastSize != null) {
- fInitialSize= StringConverter.asPoint(lastSize, new Point(defaultWidth, defaultHeigth));
- } else {
- fInitialSize= new Point(defaultWidth, defaultHeigth);
- }
-
- if (isSave()) {
- setTitle(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_save_title);
- } else {
- setTitle(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_title);
- }
-
- fLocationField= new StringButtonDialogField(this);
- fLocationField.setLabelText(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_label);
- fLocationField.setButtonLabel(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_button);
- fLocationField.setDialogFieldListener(this);
-
- String[] buttonNames= new String[] {
- PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_selectall_button,
- PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_deselectall_button
- };
- fExportImportList= new CheckedListDialogField(this, buttonNames, new CPListLabelProvider());
- fExportImportList.setCheckAllButtonIndex(0);
- fExportImportList.setUncheckAllButtonIndex(1);
- fExportImportList.setViewerComparator(new CPListElementSorter());
- fExportImportList.setDialogFieldListener(this);
- if (isSave()) {
- fExportImportList.setLabelText(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_save_label);
- fExportImportList.setElements(fExistingLibraries);
- fExportImportList.checkAll(true);
- } else {
- fExportImportList.setLabelText(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_load_label);
- }
- String lastPath= fSettings.get(PREF_LASTPATH);
- if (lastPath != null) {
- fLocationField.setText(lastPath);
- } else {
- fLocationField.setText(""); //$NON-NLS-1$
- }
- }
-
- protected Point getInitialSize() {
- return fInitialSize;
- }
-
- private boolean isSave() {
- return fIsSave;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
- DialogField[] fields;
- if (isSave()) {
- fields= new DialogField[] { fExportImportList, fLocationField };
- } else {
- fields= new DialogField[] { fLocationField, fExportImportList };
- }
- LayoutUtil.doDefaultLayout(composite, fields, true, SWT.DEFAULT, SWT.DEFAULT);
- fExportImportList.getListControl(null).setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fLocationField.postSetFocusOnDialogField(parent.getDisplay());
-
- Dialog.applyDialogFont(composite);
-
- if (isSave()) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CP_EXPORT_USER_LIBRARY);
- } else {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CP_IMPORT_USER_LIBRARY);
- }
-
- return composite;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter#changeControlPressed(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void changeControlPressed(DialogField field) {
- String label= isSave() ? PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_filedialog_save_title : PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_filedialog_load_title;
- FileDialog dialog= new FileDialog(getShell(), isSave() ? SWT.SAVE : SWT.OPEN);
- dialog.setText(label);
- dialog.setFilterExtensions(new String[] {"*.userlibraries", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- String lastPath= fLocationField.getText();
- if (lastPath.length() == 0 || !new File(lastPath).exists()) {
- lastPath= fSettings.get(PREF_LASTPATH);
- }
- if (lastPath != null) {
- dialog.setFileName(lastPath);
- }
- String fileName= dialog.open();
- if (fileName != null) {
- fSettings.put(PREF_LASTPATH, fileName);
- fLocationField.setText(fileName);
- }
- }
-
- private IStatus updateShownLibraries(IStatus status) {
- if (!status.isOK()) {
- fExportImportList.removeAllElements();
- fExportImportList.setEnabled(false);
- fLastFile= null;
- } else {
- File file= new File(fLocationField.getText());
- if (!file.equals(fLastFile)) {
- fLastFile= file;
- try {
- List elements= loadLibraries(file);
- fExportImportList.setElements(elements);
- fExportImportList.checkAll(true);
- fExportImportList.setEnabled(true);
- if (elements.isEmpty()) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_error_empty);
- }
- } catch (IOException e) {
- fExportImportList.removeAllElements();
- fExportImportList.setEnabled(false);
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_error_invalidfile);
- }
- }
- }
- return status;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- if (field == fLocationField) {
- IStatus status= validateSettings();
- if (!isSave()) {
- status= updateShownLibraries(status);
- }
- updateStatus(status);
- } else if (field == fExportImportList) {
- updateStatus(validateSettings());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField, int)
- */
- public void customButtonPressed(ListDialogField field, int index) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField)
- */
- public void selectionChanged(ListDialogField field) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.ListDialogField)
- */
- public void doubleClicked(ListDialogField field) {
- List selectedElements= fExportImportList.getSelectedElements();
- if (selectedElements.size() == 1) {
- Object elem= selectedElements.get(0);
- fExportImportList.setChecked(elem, !fExportImportList.isChecked(elem));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- if (isSave()) {
- final File file= new File(fLocationField.getText());
- if (file.exists()) {
- String title= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_overwrite_title;
- String message= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_overwrite_message;
- if (!MessageDialog.openQuestion(getShell(), title, message)) {
- return;
- }
- }
- try {
- String encoding= "UTF-8"; //$NON-NLS-1$
- IPath filePath= Path.fromOSString(file.getCanonicalPath());
- final IPath workspacePath= ResourcesPlugin.getWorkspace().getRoot().getLocation();
- if (filePath.matchingFirstSegments(workspacePath) == workspacePath.segmentCount()) {
- IPath path= filePath.removeFirstSegments(workspacePath.segmentCount());
- path= path.makeRelative();
- final IFile result= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- try {
- encoding= result.getCharset(true);
- } catch (CoreException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- final List elements= fExportImportList.getCheckedElements();
- final String charset= encoding;
- IRunnableContext context= PlatformUI.getWorkbench().getProgressService();
- try {
- context.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- saveLibraries(elements, file, charset, monitor);
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
- });
- fSettings.put(PREF_LASTPATH, file.getPath());
- } catch (InvocationTargetException e) {
- String errorTitle= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_title;
- String errorMessage= Messages.format(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_save_errordialog_message, e.getMessage());
- ExceptionHandler.handle(e, getShell(), errorTitle, errorMessage);
- return;
- } catch (InterruptedException e) {
- // cancelled
- return;
- }
- String savedTitle= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_save_ok_title;
- String savedMessage= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_save_ok_message;
- MessageDialog.openInformation(getShell(), savedTitle, savedMessage);
- } catch (IOException exception) {
- JavaScriptPlugin.log(exception);
- }
- } else {
- HashSet map= new HashSet(fExistingLibraries.size());
- for (int k= 0; k < fExistingLibraries.size(); k++) {
- CPUserLibraryElement elem= (CPUserLibraryElement) fExistingLibraries.get(k);
- map.add(elem.getName());
- }
- int nReplaced= 0;
- List elements= getLoadedLibraries();
- for (int i= 0; i < elements.size(); i++) {
- CPUserLibraryElement curr= (CPUserLibraryElement) elements.get(i);
- if (map.contains(curr.getName())) {
- nReplaced++;
- }
- }
- if (nReplaced > 0) {
- String replaceTitle= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_replace_title;
- String replaceMessage;
- if (nReplaced == 1) {
- replaceMessage= PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_replace_message;
- } else {
- replaceMessage= Messages.format(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_replace_multiple_message, String.valueOf(nReplaced));
- }
- if (!MessageDialog.openConfirm(getShell(), replaceTitle, replaceMessage)) {
- return;
- }
- }
- }
- super.okPressed();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#close()
- */
- public boolean close() {
- Point point= getShell().getSize();
- fSettings.put(PREF_USER_LIBRARY_LOADSAVE_SIZE, StringConverter.asString(point));
- return super.close();
- }
-
- private IStatus validateSettings() {
- String name= fLocationField.getText();
- fLastFile= null;
- if (isSave()) {
- if (name.length() == 0) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_error_save_enterlocation);
- }
- File file= new File(name);
- if (file.isDirectory()) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_error_save_invalid);
- }
- if (fExportImportList.getCheckedSize() == 0) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_error_save_nothingselected);
- }
- fLastFile= file;
- } else {
- if (name.length() == 0) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_error_load_enterlocation);
- }
- if (!new File(name).isFile()) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_location_error_load_invalid);
- }
- if (fExportImportList.getSize() > 0 && fExportImportList.getCheckedSize() == 0) {
- return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_list_error_load_nothingselected);
- }
- }
- return new StatusInfo();
- }
-
- protected static void saveLibraries(List libraries, File file, String encoding, IProgressMonitor monitor) throws IOException {
- OutputStream stream= new FileOutputStream(file);
- try {
- DocumentBuilder docBuilder= null;
- DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- docBuilder= factory.newDocumentBuilder();
- Document document= docBuilder.newDocument();
-
- // Create the document
- Element rootElement= document.createElement(TAG_ROOT);
- document.appendChild(rootElement);
-
- rootElement.setAttribute(TAG_VERSION, CURRENT_VERSION);
-
- for (int i= 0; i < libraries.size(); i++) {
- Element libraryElement= document.createElement(TAG_LIBRARY);
- rootElement.appendChild(libraryElement);
-
- CPUserLibraryElement curr= (CPUserLibraryElement) libraries.get(i);
- libraryElement.setAttribute(TAG_NAME, curr.getName());
- libraryElement.setAttribute(TAG_SYSTEMLIBRARY, String.valueOf(curr.isSystemLibrary()));
-
- CPListElement[] children= curr.getChildren();
- for (int k= 0; k < children.length; k++) {
- CPListElement child= children[k];
-
- Element childElement= document.createElement(TAG_ARCHIVE);
- libraryElement.appendChild(childElement);
-
- childElement.setAttribute(TAG_ARCHIVE_PATH, child.getPath().toPortableString());
- IPath sourceAttachment= (IPath) child.getAttribute(CPListElement.SOURCEATTACHMENT);
- if (sourceAttachment != null) {
- childElement.setAttribute(TAG_SOURCEATTACHMENT, sourceAttachment.toPortableString());
-
- }
- String javadocLocation= (String) child.getAttribute(CPListElement.JAVADOC);
- if (javadocLocation != null) {
- childElement.setAttribute(TAG_JAVADOC, javadocLocation);
- }
- String nativeLibPath= (String) child.getAttribute(CPListElement.NATIVE_LIB_PATH);
- if (nativeLibPath != null) {
- childElement.setAttribute(TAG_NATIVELIB_PATHS, nativeLibPath);
- }
- IAccessRule[] accessRules= (IAccessRule[]) child.getAttribute(CPListElement.ACCESSRULES);
- if (accessRules != null && accessRules.length > 0) {
- Element rulesElement= document.createElement(TAG_ACCESSRULES);
- childElement.appendChild(rulesElement);
- for (int n= 0; n < accessRules.length; n++) {
- IAccessRule rule= accessRules[n];
- Element ruleElement= document.createElement(TAG_ACCESSRULE);
- rulesElement.appendChild(ruleElement);
- ruleElement.setAttribute(TAG_RULE_KIND, String.valueOf(rule.getKind()));
- ruleElement.setAttribute(TAG_RULE_PATTERN, rule.getPattern().toPortableString());
- }
- }
- }
- }
-
- // Write the document to the stream
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$
-
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(stream);
- transformer.transform(source, result);
- } catch (ParserConfigurationException e) {
- throw new IOException(e.getMessage());
- } catch (TransformerException e) {
- throw new IOException(e.getMessage());
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // ignore
- }
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- private static List loadLibraries(File file) throws IOException {
- InputStream stream= new FileInputStream(file);
- Element cpElement;
- try {
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- cpElement = parser.parse(new InputSource(stream)).getDocumentElement();
- } catch (SAXException e) {
- throw new IOException(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_badformat);
- } catch (ParserConfigurationException e) {
- throw new IOException(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_badformat);
- } finally {
- stream.close();
- }
-
- if (!cpElement.getNodeName().equalsIgnoreCase(TAG_ROOT)) {
- throw new IOException(PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_load_badformat);
- }
-
- String version= cpElement.getAttribute(TAG_VERSION);
-
- NodeList libList= cpElement.getElementsByTagName(TAG_LIBRARY);
- int length = libList.getLength();
-
- ArrayList result= new ArrayList(length);
- for (int i= 0; i < length; i++) {
- Node lib= libList.item(i);
- if (!(lib instanceof Element)) {
- continue;
- }
- Element libElement= (Element) lib;
- String name= libElement.getAttribute(TAG_NAME);
- boolean isSystem= Boolean.valueOf(libElement.getAttribute(TAG_SYSTEMLIBRARY)).booleanValue();
-
- CPUserLibraryElement newLibrary= new CPUserLibraryElement(name, isSystem, null);
- result.add(newLibrary);
-
- NodeList archiveList= libElement.getElementsByTagName(TAG_ARCHIVE);
- for (int k= 0; k < archiveList.getLength(); k++) {
- Node archiveNode= archiveList.item(k);
- if (!(archiveNode instanceof Element)) {
- continue;
- }
- Element archiveElement= (Element) archiveNode;
-
- String pathString= archiveElement.getAttribute(TAG_ARCHIVE_PATH);
- IPath path= version.equals(VERSION1) ? Path.fromOSString(pathString) : Path.fromPortableString(pathString);
- CPListElement newArchive= new CPListElement(newLibrary, null, IIncludePathEntry.CPE_LIBRARY, path, null);
- newLibrary.add(newArchive);
-
- if (archiveElement.hasAttribute(TAG_SOURCEATTACHMENT)) {
- String sourceAttachString= archiveElement.getAttribute(TAG_SOURCEATTACHMENT);
- IPath sourceAttach= version.equals(VERSION1) ? Path.fromOSString(sourceAttachString) : Path.fromPortableString(sourceAttachString);
- newArchive.setAttribute(CPListElement.SOURCEATTACHMENT, sourceAttach);
- }
- if (archiveElement.hasAttribute(TAG_JAVADOC)) {
- String javadoc= archiveElement.getAttribute(TAG_JAVADOC);
- newArchive.setAttribute(CPListElement.JAVADOC, javadoc);
- }
- if (archiveElement.hasAttribute(TAG_NATIVELIB_PATHS)) {
- String nativeLibPath= archiveElement.getAttribute(TAG_NATIVELIB_PATHS);
- newArchive.setAttribute(CPListElement.NATIVE_LIB_PATH, nativeLibPath);
- }
- NodeList rulesParentNodes= archiveElement.getElementsByTagName(TAG_ACCESSRULES);
- if (rulesParentNodes.getLength() > 0 && rulesParentNodes.item(0) instanceof Element) {
- Element ruleParentElement= (Element) rulesParentNodes.item(0); // take first, ignore others
- NodeList ruleElements= ruleParentElement.getElementsByTagName(TAG_ACCESSRULE);
- int nRuleElements= ruleElements.getLength();
- if (nRuleElements > 0) {
- ArrayList resultingRules= new ArrayList(nRuleElements);
- for (int n= 0; n < nRuleElements; n++) {
- Node node= ruleElements.item(n);
- if (node instanceof Element) {
- Element ruleElement= (Element) node;
- try {
- int kind= Integer.parseInt(ruleElement.getAttribute(TAG_RULE_KIND));
- IPath pattern= Path.fromPortableString(ruleElement.getAttribute(TAG_RULE_PATTERN));
- resultingRules.add(JavaScriptCore.newAccessRule(pattern, kind));
- } catch (NumberFormatException e) {
- // ignore
- }
- }
- }
- newArchive.setAttribute(CPListElement.ACCESSRULES, resultingRules.toArray(new IAccessRule[resultingRules.size()]));
- }
- }
- }
- }
- return result;
- }
-
- public List getLoadedLibraries() {
- return fExportImportList.getCheckedElements();
- }
- }
-
- private IDialogSettings fDialogSettings;
- private TreeListDialogField fLibraryList;
- private IJavaScriptProject fDummyProject;
- private ClasspathAttributeConfigurationDescriptors fAttributeDescriptors;
-
- private static final int IDX_NEW= 0;
- private static final int IDX_EDIT= 1;
- private static final int IDX_ADD= 2;
- private static final int IDX_REMOVE= 3;
- private static final int IDX_UP= 5;
- private static final int IDX_DOWN= 6;
- private static final int IDX_LOAD= 8;
- private static final int IDX_SAVE= 9;
-
- /**
- * Constructor for ClasspathVariablesPreferencePage
- */
- public UserLibraryPreferencePage() {
- setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
- fDummyProject= createPlaceholderProject();
-
- fAttributeDescriptors= JavaScriptPlugin.getDefault().getClasspathAttributeConfigurationDescriptors();
-
- // title only used when page is shown programatically
- setTitle(PreferencesMessages.UserLibraryPreferencePage_title);
- setDescription(PreferencesMessages.UserLibraryPreferencePage_description);
- noDefaultAndApplyButton();
-
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
-
- UserLibraryAdapter adapter= new UserLibraryAdapter();
- String[] buttonLabels= new String[] {
- PreferencesMessages.UserLibraryPreferencePage_libraries_new_button,
- PreferencesMessages.UserLibraryPreferencePage_libraries_edit_button,
- PreferencesMessages.UserLibraryPreferencePage_libraries_addjar_button,
- PreferencesMessages.UserLibraryPreferencePage_libraries_remove_button,
- null,
- PreferencesMessages.UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_up_button,
- PreferencesMessages.UserLibraryPreferencePage_UserLibraryPreferencePage_libraries_down_button,
- null,
-
- PreferencesMessages.UserLibraryPreferencePage_libraries_load_button,
- PreferencesMessages.UserLibraryPreferencePage_libraries_save_button
- };
-
- fLibraryList= new TreeListDialogField(adapter, buttonLabels, new CPListLabelProvider());
- fLibraryList.setLabelText(PreferencesMessages.UserLibraryPreferencePage_libraries_label);
-
- String[] names= JavaScriptCore.getUserLibraryNames();
- ArrayList elements= new ArrayList();
-
- for (int i= 0; i < names.length; i++) {
- IPath path= new Path(JavaScriptCore.USER_LIBRARY_CONTAINER_ID).append(names[i]);
- try {
- IJsGlobalScopeContainer container= JavaScriptCore.getJsGlobalScopeContainer(path, fDummyProject);
- elements.add(new CPUserLibraryElement(names[i], container, fDummyProject));
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- // ignore
- }
- }
- fLibraryList.setElements(elements);
- fLibraryList.setViewerComparator(new CPListElementSorter());
-
- doSelectionChanged(fLibraryList); //update button enable state
- }
-
- private static IJavaScriptProject createPlaceholderProject() {
- String name= "####internal"; //$NON-NLS-1$
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- while (true) {
- IProject project= root.getProject(name);
- if (!project.exists()) {
- return JavaScriptCore.create(project);
- }
- name += '1';
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
- */
- public void applyData(Object data) {
- if (data instanceof Map) {
- Map map= (Map) data;
- Object selectedLibrary= map.get(DATA_LIBRARY_TO_SELECT);
- boolean createIfNotExists= Boolean.TRUE.equals(map.get(DATA_DO_CREATE));
- if (selectedLibrary instanceof String) {
- int nElements= fLibraryList.getSize();
- for (int i= 0; i < nElements; i++) {
- CPUserLibraryElement curr= (CPUserLibraryElement) fLibraryList.getElement(i);
- if (curr.getName().equals(selectedLibrary)) {
- fLibraryList.selectElements(new StructuredSelection(curr));
- fLibraryList.expandElement(curr, 1);
- break;
- }
- }
- if (createIfNotExists) {
- CPUserLibraryElement elem= new CPUserLibraryElement((String) selectedLibrary, null, createPlaceholderProject());
- fLibraryList.addElement(elem);
- fLibraryList.selectElements(new StructuredSelection(elem));
- }
- }
- }
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CP_USERLIBRARIES_PREFERENCE_PAGE);
- }
-
- /*
- * @see PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- LayoutUtil.doDefaultLayout(composite, new DialogField[] { fLibraryList }, true);
- LayoutUtil.setHorizontalGrabbing(fLibraryList.getTreeControl(null));
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- if (monitor != null) {
- monitor= new NullProgressMonitor();
- }
-
- updateUserLibararies(monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InterruptedException e) {
- // cancelled by user
- } catch (InvocationTargetException e) {
- String title= PreferencesMessages.UserLibraryPreferencePage_config_error_title;
- String message= PreferencesMessages.UserLibraryPreferencePage_config_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- return true;
- }
-
-
- private void updateUserLibararies(IProgressMonitor monitor) throws CoreException {
- List list= fLibraryList.getElements();
- HashSet oldNames= new HashSet(Arrays.asList(JavaScriptCore.getUserLibraryNames()));
- int nExisting= list.size();
-
- HashSet newEntries= new HashSet(list.size());
- for (int i= 0; i < nExisting; i++) {
- CPUserLibraryElement element= (CPUserLibraryElement) list.get(i);
- boolean contained= oldNames.remove(element.getName());
- if (!contained) {
- newEntries.add(element);
- }
- }
-
- int len= nExisting + oldNames.size();
- monitor.beginTask(PreferencesMessages.UserLibraryPreferencePage_operation, len);
- MultiStatus multiStatus= new MultiStatus(JavaScriptUI.ID_PLUGIN, IStatus.OK, PreferencesMessages.UserLibraryPreferencePage_operation_error, null);
-
- JsGlobalScopeContainerInitializer initializer= JavaScriptCore.getJsGlobalScopeContainerInitializer(JavaScriptCore.USER_LIBRARY_CONTAINER_ID);
- IJavaScriptProject jproject= fDummyProject;
-
- for (int i= 0; i < nExisting; i++) {
- CPUserLibraryElement element= (CPUserLibraryElement) list.get(i);
- IPath path= element.getPath();
- if (newEntries.contains(element) || element.hasChanges(JavaScriptCore.getJsGlobalScopeContainer(path, jproject))) {
- IJsGlobalScopeContainer updatedContainer= element.getUpdatedContainer();
- try {
- initializer.requestJsGlobalScopeContainerUpdate(path, jproject, updatedContainer);
- } catch (CoreException e) {
- multiStatus.add(e.getStatus());
- }
- }
- monitor.worked(1);
- }
-
- Iterator iter= oldNames.iterator();
- while (iter.hasNext()) {
- String name= (String) iter.next();
-
- IPath path= new Path(JavaScriptCore.USER_LIBRARY_CONTAINER_ID).append(name);
- try {
- initializer.requestJsGlobalScopeContainerUpdate(path, jproject, null);
- } catch (CoreException e) {
- multiStatus.add(e.getStatus());
- }
- monitor.worked(1);
- }
-
- if (!multiStatus.isOK()) {
- throw new CoreException(multiStatus);
- }
- }
-
- private CPUserLibraryElement getSingleSelectedLibrary(List selected) {
- if (selected.size() == 1 && selected.get(0) instanceof CPUserLibraryElement) {
- return (CPUserLibraryElement) selected.get(0);
- }
- return null;
- }
-
- private void editAttributeEntry(CPListElementAttribute elem) {
- String key= elem.getKey();
- CPListElement selElement= elem.getParent();
- if (key.equals(CPListElement.SOURCEATTACHMENT)) {
- IIncludePathEntry result= BuildPathDialogAccess.configureSourceAttachment(getShell(), selElement.getClasspathEntry());
- if (result != null) {
- selElement.setAttribute(CPListElement.SOURCEATTACHMENT, result.getSourceAttachmentPath());
- fLibraryList.refresh(elem);
- fLibraryList.update(selElement);
- }
- } else if (key.equals(CPListElement.ACCESSRULES)) {
- AccessRulesDialog dialog= new AccessRulesDialog(getShell(), selElement, null, false);
- if (dialog.open() == Window.OK) {
- selElement.setAttribute(CPListElement.ACCESSRULES, dialog.getAccessRules());
- fLibraryList.refresh(elem);
- fLibraryList.expandElement(elem, 2);
- }
- } else if (!elem.isBuiltIn()) {
- ClasspathAttributeConfiguration config= fAttributeDescriptors.get(key);
- if (config != null) {
- IIncludePathAttribute result= config.performEdit(getShell(), elem.getClasspathAttributeAccess());
- if (result != null) {
- elem.setValue(result.getValue());
- fLibraryList.refresh(elem);
- }
- }
- }
- }
-
- protected void doSelectionChanged(TreeListDialogField field) {
- List list= field.getSelectedElements();
- field.enableButton(IDX_REMOVE, canRemove(list));
- field.enableButton(IDX_EDIT, canEdit(list));
- field.enableButton(IDX_ADD, canAdd(list));
- field.enableButton(IDX_UP, canMoveUp(list));
- field.enableButton(IDX_DOWN, canMoveDown(list));
- field.enableButton(IDX_SAVE, field.getSize() > 0);
- }
-
- protected void doCustomButtonPressed(TreeListDialogField field, int index) {
- if (index == IDX_NEW) {
- editUserLibraryElement(null);
- } else if (index == IDX_ADD) {
- doAdd(field.getSelectedElements());
- } else if (index == IDX_REMOVE) {
- doRemove(field.getSelectedElements());
- } else if (index == IDX_EDIT) {
- doEdit(field.getSelectedElements());
- } else if (index == IDX_SAVE) {
- doSave();
- } else if (index == IDX_LOAD) {
- doLoad();
- } else if (index == IDX_UP) {
- doMoveUp(field.getSelectedElements());
- } else if (index == IDX_DOWN) {
- doMoveDown(field.getSelectedElements());
- }
- }
-
- protected void doDoubleClicked(TreeListDialogField field) {
- List selected= field.getSelectedElements();
- if (canEdit(selected)) {
- doEdit(field.getSelectedElements());
- }
- }
-
- protected void doKeyPressed(TreeListDialogField field, KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- List selection= field.getSelectedElements();
- if (canRemove(selection)) {
- doRemove(selection);
- }
- }
- }
-
- private void doEdit(List selected) {
- if (selected.size() == 1) {
- Object curr= selected.get(0);
- if (curr instanceof CPListElementAttribute) {
- editAttributeEntry((CPListElementAttribute) curr);
- } else if (curr instanceof CPUserLibraryElement) {
- editUserLibraryElement((CPUserLibraryElement) curr);
- } else if (curr instanceof CPListElement) {
- CPListElement elem= (CPListElement) curr;
- editArchiveElement(elem, (CPUserLibraryElement) elem.getParentContainer());
- }
- doSelectionChanged(fLibraryList);
- }
- }
-
- private void editUserLibraryElement(CPUserLibraryElement element) {
- LibraryNameDialog dialog= new LibraryNameDialog(getShell(), element, fLibraryList.getElements());
- if (dialog.open() == Window.OK) {
- CPUserLibraryElement newLibrary= dialog.getNewLibrary();
- if (element != null) {
- fLibraryList.replaceElement(element, newLibrary);
- } else {
- fLibraryList.addElement(newLibrary);
- }
- fLibraryList.expandElement(newLibrary, AbstractTreeViewer.ALL_LEVELS);
- fLibraryList.selectElements(new StructuredSelection(newLibrary));
- }
- }
-
- private void editArchiveElement(CPListElement existingElement, CPUserLibraryElement parent) {
- CPListElement[] elements= openExtJarFileDialog(existingElement, parent);
- if (elements != null) {
- for (int i= 0; i < elements.length; i++) {
- if (existingElement != null) {
- parent.replace(existingElement, elements[i]);
- } else {
- parent.add(elements[i]);
- }
- }
- fLibraryList.refresh(parent);
- fLibraryList.selectElements(new StructuredSelection(Arrays.asList(elements)));
- fLibraryList.expandElement(parent, 2);
- }
- }
-
-
- private void doRemove(List selected) {
- Object selectionAfter= null;
- for (int i= 0; i < selected.size(); i++) {
- Object curr= selected.get(i);
- if (curr instanceof CPUserLibraryElement) {
- fLibraryList.removeElement(curr);
- } else if (curr instanceof CPListElement) {
- Object parent= ((CPListElement) curr).getParentContainer();
- if (parent instanceof CPUserLibraryElement) {
- CPUserLibraryElement elem= (CPUserLibraryElement) parent;
- elem.remove((CPListElement) curr);
- fLibraryList.refresh(elem);
- selectionAfter= parent;
- }
- } else if (curr instanceof CPListElementAttribute) {
- CPListElementAttribute attrib= (CPListElementAttribute) curr;
- if (attrib.isBuiltIn()) {
- Object value= null;
- String key= attrib.getKey();
- if (key.equals(CPListElement.ACCESSRULES)) {
- value= new IAccessRule[0];
- }
- attrib.getParent().setAttribute(key, value);
- fLibraryList.refresh(attrib);
- } else {
- ClasspathAttributeConfiguration config= fAttributeDescriptors.get(attrib.getKey());
- if (config != null) {
- IIncludePathAttribute result= config.performRemove(attrib.getClasspathAttributeAccess());
- if (result != null) {
- attrib.setValue(result.getValue());
- fLibraryList.refresh(attrib);
- }
- }
- }
- }
- }
- if (fLibraryList.getSelectedElements().isEmpty()) {
- if (selectionAfter != null) {
- fLibraryList.selectElements(new StructuredSelection(selectionAfter));
- } else {
- fLibraryList.selectFirstElement();
- }
- } else {
- doSelectionChanged(fLibraryList);
- }
- }
-
- private void doAdd(List list) {
- if (canAdd(list)) {
- CPUserLibraryElement element= getSingleSelectedLibrary(list);
- editArchiveElement(null, element);
- }
- }
-
- private void doLoad() {
- List existing= fLibraryList.getElements();
- LoadSaveDialog dialog= new LoadSaveDialog(getShell(), false, existing, fDialogSettings);
- if (dialog.open() == Window.OK) {
- HashMap map= new HashMap(existing.size());
- for (int k= 0; k < existing.size(); k++) {
- CPUserLibraryElement elem= (CPUserLibraryElement) existing.get(k);
- map.put(elem.getName(), elem);
- }
-
- List list= dialog.getLoadedLibraries();
- for (int i= 0; i < list.size(); i++) {
- CPUserLibraryElement elem= (CPUserLibraryElement) list.get(i);
- CPUserLibraryElement found= (CPUserLibraryElement) map.get(elem.getName());
- if (found == null) {
- existing.add(elem);
- map.put(elem.getName(), elem);
- } else {
- existing.set(existing.indexOf(found), elem); // replace
- }
- }
- fLibraryList.setElements(existing);
- fLibraryList.selectElements(new StructuredSelection(list));
- }
- }
-
- private void doSave() {
- LoadSaveDialog dialog= new LoadSaveDialog(getShell(), true, fLibraryList.getElements(), fDialogSettings);
- dialog.open();
- }
-
- private boolean canAdd(List list) {
- return getSingleSelectedLibrary(list) != null;
- }
-
- private boolean canEdit(List list) {
- if (list.size() != 1)
- return false;
-
- Object firstElement= list.get(0);
- if (firstElement instanceof IAccessRule)
- return false;
- if (firstElement instanceof CPListElementAttribute) {
- CPListElementAttribute attrib= (CPListElementAttribute) firstElement;
- if (!attrib.isBuiltIn()) {
- ClasspathAttributeConfiguration config= fAttributeDescriptors.get(attrib.getKey());
- return config != null && config.canEdit(attrib.getClasspathAttributeAccess());
- }
- }
- return true;
- }
-
- private boolean canRemove(List list) {
- if (list.size() == 0) {
- return false;
- }
- for (int i= 0; i < list.size(); i++) {
- Object elem= list.get(i);
- if (elem instanceof CPListElementAttribute) {
- CPListElementAttribute attrib= (CPListElementAttribute) elem;
- if (attrib.isNonModifiable()) {
- return false;
- }
- if (attrib.isBuiltIn()) {
- if (attrib.getKey().equals(CPListElement.ACCESSRULES)) {
- return ((IAccessRule[]) attrib.getValue()).length > 0;
- }
- if (attrib.getValue() == null) {
- return false;
- }
- } else {
- ClasspathAttributeConfiguration config= fAttributeDescriptors.get(attrib.getKey());
- if (config == null || !config.canRemove(attrib.getClasspathAttributeAccess()) ) {
- return false;
- }
- }
- } else if (elem instanceof CPListElement) {
- // ok to remove
- } else if (elem instanceof CPUserLibraryElement) {
- // ok to remove
- } else { // unknown element
- return false;
- }
- }
- return true;
- }
-
- private CPUserLibraryElement getCommonParent(List list) {
- CPUserLibraryElement parent= null;
- for (int i= 0, len= list.size(); i < len; i++) {
- Object curr= list.get(i);
- if (curr instanceof CPListElement) {
- Object elemParent= ((CPListElement) curr).getParentContainer();
- if (parent == null) {
- if (elemParent instanceof CPUserLibraryElement) {
- parent= (CPUserLibraryElement) elemParent;
- } else {
- return null;
- }
- } else if (parent != elemParent) {
- return null;
- }
- } else {
- return null;
- }
- }
- return parent;
- }
-
- private void doMoveUp(List list) {
- CPUserLibraryElement parent= getCommonParent(list);
- if (parent != null) {
- parent.moveUp(list);
- fLibraryList.refresh(parent);
- doSelectionChanged(fLibraryList);
- }
- }
-
- private void doMoveDown(List list) {
- CPUserLibraryElement parent= getCommonParent(list);
- if (parent != null) {
- parent.moveDown(list);
- fLibraryList.refresh(parent);
- doSelectionChanged(fLibraryList);
- }
- }
-
-
- private boolean canMoveUp(List list) {
- CPUserLibraryElement parent= getCommonParent(list);
- if (parent != null) {
- CPListElement[] children= parent.getChildren();
- for (int i= 0, len= Math.min(list.size(), children.length); i < len ; i++) {
- if (!list.contains(children[i])) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean canMoveDown(List list) {
- CPUserLibraryElement parent= getCommonParent(list);
- if (parent != null) {
- CPListElement[] children= parent.getChildren();
- for (int i= children.length - 1, end= Math.max(0, children.length - list.size()); i >= end; i--) {
- if (!list.contains(children[i])) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- private CPListElement[] openExtJarFileDialog(CPListElement existing, Object parent) {
- String lastUsedPath;
- if (existing != null) {
- lastUsedPath= existing.getPath().removeLastSegments(1).toOSString();
- } else {
- lastUsedPath= fDialogSettings.get(IUIConstants.DIALOGSTORE_LASTEXTJAR);
- if (lastUsedPath == null) {
- lastUsedPath= ""; //$NON-NLS-1$
- }
- }
- String title= (existing == null) ? PreferencesMessages.UserLibraryPreferencePage_browsejar_new_title : PreferencesMessages.UserLibraryPreferencePage_browsejar_edit_title;
-
- FileDialog dialog= new FileDialog(getShell(), existing == null ? SWT.MULTI : SWT.SINGLE);
- dialog.setText(title);
- dialog.setFilterExtensions(new String[] {"*.js"}); //$NON-NLS-1$
- dialog.setFilterPath(lastUsedPath);
- if (existing != null) {
- dialog.setFileName(existing.getPath().lastSegment());
- }
-
- String res= dialog.open();
- if (res == null) {
- return null;
- }
- String[] fileNames= dialog.getFileNames();
- int nChosen= fileNames.length;
-
- IPath filterPath= Path.fromOSString(dialog.getFilterPath());
- CPListElement[] elems= new CPListElement[nChosen];
- for (int i= 0; i < nChosen; i++) {
- IPath path= filterPath.append(fileNames[i]).makeAbsolute();
- CPListElement curr= new CPListElement(parent, null, IIncludePathEntry.CPE_LIBRARY, path, null);
- curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
- curr.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(curr));
- elems[i]= curr;
- }
- fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());
-
- return elems;
- }
-
-
- private class UserLibraryAdapter implements ITreeListAdapter {
-
- private final Object[] EMPTY= new Object[0];
-
- public void customButtonPressed(TreeListDialogField field, int index) {
- doCustomButtonPressed(field, index);
- }
-
- public void selectionChanged(TreeListDialogField field) {
- doSelectionChanged(field);
- }
-
- public void doubleClicked(TreeListDialogField field) {
- doDoubleClicked(field);
- }
-
- public void keyPressed(TreeListDialogField field, KeyEvent event) {
- doKeyPressed(field, event);
- }
-
- public Object[] getChildren(TreeListDialogField field, Object element) {
- if (element instanceof CPUserLibraryElement) {
- CPUserLibraryElement elem= (CPUserLibraryElement) element;
- return elem.getChildren();
- } else if (element instanceof CPListElement) {
- return ((CPListElement)element).getChildren(false);
- } else if (element instanceof CPListElementAttribute) {
- CPListElementAttribute attribute= (CPListElementAttribute) element;
- if (CPListElement.ACCESSRULES.equals(attribute.getKey())) {
- return (IAccessRule[]) attribute.getValue();
- }
- }
- return EMPTY;
- }
-
- public Object getParent(TreeListDialogField field, Object element) {
- if (element instanceof CPListElementAttribute) {
- return ((CPListElementAttribute) element).getParent();
- } else if (element instanceof CPListElement) {
- return ((CPListElement) element).getParentContainer();
- }
- return null;
- }
-
- public boolean hasChildren(TreeListDialogField field, Object element) {
- return getChildren(field, element).length > 0;
- }
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/WorkInProgressPreferencePage.java
deleted file mode 100644
index bd76933b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/WorkInProgressPreferencePage.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-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.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Preference page for work in progress.
- */
-public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private List fCheckBoxes;
- private List fRadioButtons;
- private List fTextControls;
-
- /**
- * creates a new preference page.
- */
- public WorkInProgressPreferencePage() {
- setPreferenceStore(getPreferenceStore());
- fRadioButtons= new ArrayList();
- fCheckBoxes= new ArrayList();
- fTextControls= new ArrayList();
- }
-
- Button addCheckBox(Composite parent, String label, String key) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-
- Button button= new Button(parent, SWT.CHECK);
- button.setText(label);
- button.setData(key);
- button.setLayoutData(gd);
-
- button.setSelection(getPreferenceStore().getBoolean(key));
-
- fCheckBoxes.add(button);
- return button;
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "WORK_IN_PROGRESS_PREFERENCE_PAGE"); //$NON-NLS-1$
- }
-
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- result.setLayout(layout);
-
- // Add your controls here
-
- applyDialogFont(result);
- return result;
- }
-
-
- /*
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- protected void createSpacer(Composite composite, int columnSpan) {
- Label label= new Label(composite, SWT.NONE);
- GridData gd= new GridData();
- gd.horizontalSpan= columnSpan;
- label.setLayoutData(gd);
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
- */
- protected IPreferenceStore doGetPreferenceStore() {
- return JavaScriptPlugin.getDefault().getPreferenceStore();
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- button.setSelection(store.getDefaultBoolean(key));
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- String[] info= (String[]) button.getData();
- button.setSelection(info[1].equals(store.getDefaultString(info[0])));
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- text.setText(store.getDefaultString(key));
- }
-
- super.performDefaults();
- }
-
- /*
- * @see IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= (Button) fCheckBoxes.get(i);
- String key= (String) button.getData();
- store.setValue(key, button.getSelection());
- }
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= (Button) fRadioButtons.get(i);
- if (button.getSelection()) {
- String[] info= (String[]) button.getData();
- store.setValue(info[0], info[1]);
- }
- }
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= (Text) fTextControls.get(i);
- String key= (String) text.getData();
- store.setValue(key, text.getText());
- }
-
- JavaScriptPlugin.getDefault().savePluginPreferences();
- return super.performOk();
- }
-
- public static void initDefaults(IPreferenceStore store) {
- // Initialize your defaults here
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java
deleted file mode 100644
index 35153a64..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-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.Shell;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpPreferenceUtil;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.preferences.BulletListBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.IProfileVersioner;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialog;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileConfigurationBlock;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileStore;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-/**
- * The clean up configuration block for the clean up preference page.
- */
-public class CleanUpConfigurationBlock extends ProfileConfigurationBlock {
-
- private static final String CLEANUP_PAGE_SETTINGS_KEY= "cleanup_page"; //$NON-NLS-1$
- private static final String DIALOGSTORE_LASTSAVELOADPATH= JavaScriptUI.ID_PLUGIN + ".cleanup"; //$NON-NLS-1$
-
- private final IScopeContext fCurrContext;
- private SelectionButtonDialogField fShowCleanUpWizardDialogField;
- private CleanUpProfileManager fProfileManager;
- private ProfileStore fProfileStore;
- private BulletListBlock fBrowserBlock;
-
- public CleanUpConfigurationBlock(IProject project, PreferencesAccess access) {
- super(project, access, DIALOGSTORE_LASTSAVELOADPATH);
-
- if (project != null) {
- fCurrContext= null;
- } else {
- fCurrContext= access.getInstanceScope();
- }
- }
-
- protected IProfileVersioner createProfileVersioner() {
- return new CleanUpProfileVersioner();
- }
-
- protected ProfileStore createProfileStore(IProfileVersioner versioner) {
- fProfileStore= new ProfileStore(CleanUpConstants.CLEANUP_PROFILES, versioner);
- return fProfileStore;
- }
-
- protected ProfileManager createProfileManager(List profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) {
- profiles.addAll(CleanUpPreferenceUtil.getBuiltInProfiles());
- fProfileManager= new CleanUpProfileManager(profiles, context, access, profileVersioner);
- return fProfileManager;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void configurePreview(Composite composite, int numColumns, final ProfileManager profileManager) {
- Map settings= profileManager.getSelected().getSettings();
- final Map sharedSettings= new Hashtable();
- fill(settings, sharedSettings);
-
- final ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(sharedSettings);
-
- createLabel(composite, CleanUpMessages.CleanUpConfigurationBlock_SelectedCleanUps_label, numColumns);
-
- fBrowserBlock= new BulletListBlock();
- Control control= fBrowserBlock.createControl(composite);
- ((GridData)control.getLayoutData()).horizontalSpan= numColumns;
- fBrowserBlock.setText(getSelectedCleanUpsInfo(cleanUps));
-
- profileManager.addObserver(new Observer() {
-
- public void update(Observable o, Object arg) {
- final int value= ((Integer)arg).intValue();
- switch (value) {
- case ProfileManager.PROFILE_CREATED_EVENT:
- case ProfileManager.PROFILE_DELETED_EVENT:
- case ProfileManager.SELECTION_CHANGED_EVENT:
- case ProfileManager.SETTINGS_CHANGED_EVENT:
- fill(profileManager.getSelected().getSettings(), sharedSettings);
- fBrowserBlock.setText(getSelectedCleanUpsInfo(cleanUps));
- }
- }
-
- });
- }
-
- private String getSelectedCleanUpsInfo(ICleanUp[] cleanUps) {
- if (cleanUps.length == 0)
- return ""; //$NON-NLS-1$
-
- StringBuffer buf= new StringBuffer();
-
- boolean first= true;
- for (int i= 0; i < cleanUps.length; i++) {
- String[] descriptions= cleanUps[i].getDescriptions();
- if (descriptions != null) {
- for (int j= 0; j < descriptions.length; j++) {
- if (first) {
- first= false;
- } else {
- buf.append('\n');
- }
- buf.append(descriptions[j]);
- }
- }
- }
-
- return buf.toString();
- }
-
- private void fill(Map settings, Map sharedSettings) {
- sharedSettings.clear();
- for (Iterator iterator= settings.keySet().iterator(); iterator.hasNext();) {
- String key= (String)iterator.next();
- sharedSettings.put(key, settings.get(key));
- }
- }
-
- protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) {
- return new CleanUpModifyDialog(shell, profile, profileManager, profileStore, newProfile, CLEANUP_PAGE_SETTINGS_KEY, DIALOGSTORE_LASTSAVELOADPATH);
- }
-
- /**
- * {@inheritDoc}
- */
- public Composite createContents(Composite parent) {
- Composite composite= super.createContents(parent);
-
- if (fCurrContext == null)
- return composite;
-
- fShowCleanUpWizardDialogField= new SelectionButtonDialogField(SWT.CHECK);
- fShowCleanUpWizardDialogField.setLabelText(CleanUpMessages.CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel);
- fShowCleanUpWizardDialogField.doFillIntoGrid(composite, 5);
-
- IEclipsePreferences node= fCurrContext.getNode(JavaScriptUI.ID_PLUGIN);
- boolean showWizard;
- if (node.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null) {
- showWizard= node.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
- } else {
- showWizard= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN).getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
- }
- if (showWizard)
- fShowCleanUpWizardDialogField.setSelection(true);
-
- fShowCleanUpWizardDialogField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- doShowCleanUpWizard(fShowCleanUpWizardDialogField.isSelected());
- }
- });
-
- return composite;
- }
-
- private void doShowCleanUpWizard(boolean showWizard) {
- IEclipsePreferences preferences= fCurrContext.getNode(JavaScriptUI.ID_PLUGIN);
- if (preferences.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null &&
- preferences.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true) == showWizard)
- return;
-
- preferences.putBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, showWizard);
- }
-
- /**
- * {@inheritDoc}
- */
- public void performDefaults() {
- super.performDefaults();
- if (fCurrContext == null)
- return;
-
- fCurrContext.getNode(JavaScriptUI.ID_PLUGIN).remove(CleanUpConstants.SHOW_CLEAN_UP_WIZARD);
- boolean showWizard= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN).getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
- fShowCleanUpWizardDialogField.setDialogFieldListener(null);
- fShowCleanUpWizardDialogField.setSelection(showWizard);
- fShowCleanUpWizardDialogField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- doShowCleanUpWizard(fShowCleanUpWizardDialogField.isSelected());
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- protected void preferenceChanged(PreferenceChangeEvent event) {
- if (CleanUpConstants.CLEANUP_PROFILES.equals(event.getKey())) {
- try {
- String id= fCurrContext.getNode(JavaScriptUI.ID_PLUGIN).get(CleanUpConstants.CLEANUP_PROFILE, null);
- if (id == null)
- fProfileManager.getDefaultProfile().getID();
-
- List oldProfiles= fProfileManager.getSortedProfiles();
- Profile[] oldProfilesArray= (Profile[])oldProfiles.toArray(new Profile[oldProfiles.size()]);
- for (int i= 0; i < oldProfilesArray.length; i++) {
- if (oldProfilesArray[i] instanceof CustomProfile) {
- fProfileManager.deleteProfile((CustomProfile)oldProfilesArray[i]);
- }
- }
-
- List newProfiles= fProfileStore.readProfilesFromString((String)event.getNewValue());
- for (Iterator iterator= newProfiles.iterator(); iterator.hasNext();) {
- CustomProfile profile= (CustomProfile)iterator.next();
- fProfileManager.addProfile(profile);
- }
-
- Profile profile= fProfileManager.getProfile(id);
- if (profile != null) {
- fProfileManager.setSelected(profile);
- } else {
- fProfileManager.setSelected(fProfileManager.getDefaultProfile());
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- } else if (CleanUpConstants.CLEANUP_PROFILE.equals(event.getKey())) {
- if (event.getNewValue() == null) {
- fProfileManager.setSelected(fProfileManager.getDefaultProfile());
- } else {
- Profile profile= fProfileManager.getProfile((String)event.getNewValue());
- if (profile != null) {
- fProfileManager.setSelected(profile);
- }
- }
- }
- }
-
- public void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- fBrowserBlock.setEnabled(useProjectSpecificSettings);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.java
deleted file mode 100644
index 7b1bb799..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import org.eclipse.osgi.util.NLS;
-
-public class CleanUpMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.CleanUpMessages"; //$NON-NLS-1$
-
- public static String CleanUpConfigurationBlock_SelectedCleanUps_label;
- public static String CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel;
-
-
- public static String CleanUpModifyDialog_TabPageName_CodeFormating;
- public static String CleanUpModifyDialog_TabPageName_CodeStyle;
-
-
- public static String CleanUpProfileManager_ProfileName_EclipseBuildIn;
-
- public static String CodeFormatingTabPage_CheckboxName_FormatSourceCode;
- public static String CodeFormatingTabPage_FormatterSettings_Description;
- public static String CodeFormatingTabPage_GroupName_Formatter;
-// public static String CodeFormatingTabPage_Imports_GroupName;
-// public static String CodeFormatingTabPage_OrganizeImports_CheckBoxLable;
-// public static String CodeFormatingTabPage_OrganizeImportsSettings_Description;
- public static String CodeFormatingTabPage_SortMembers_GroupName;
- public static String CodeFormatingTabPage_SortMembers_Description;
-// public static String CodeFormatingTabPage_SortMembersFields_CheckBoxLabel;
-
- public static String CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio;
-
- public static String CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text;
-
- public static String CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio;
-
-
- public static String CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced;
- public static String CodeStyleTabPage_CheckboxName_UseBlocks;
-// public static String CodeStyleTabPage_CheckboxName_UseFinal;
-// public static String CodeStyleTabPage_CheckboxName_UseFinalForFields;
-// public static String CodeStyleTabPage_CheckboxName_UseFinalForLocals;
-// public static String CodeStyleTabPage_CheckboxName_UseFinalForParameters;
- public static String CodeStyleTabPage_CheckboxName_UseParentheses;
- public static String CodeStyleTabPage_GroupName_ControlStatments;
- public static String CodeStyleTabPage_GroupName_Expressions;
-// public static String CodeStyleTabPage_GroupName_VariableDeclarations;
- public static String CodeStyleTabPage_RadioName_AlwaysUseBlocks;
- public static String CodeStyleTabPage_RadioName_AlwaysUseParantheses;
- public static String CodeStyleTabPage_RadioName_NeverUseBlocks;
- public static String CodeStyleTabPage_RadioName_NeverUseParantheses;
- public static String CodeStyleTabPage_RadioName_UseBlocksSpecial;
-
-
-
- public static String UnnecessaryCodeTabPage_CheckboxName_UnnecessaryNLSTags;
- public static String UnnecessaryCodeTabPage_CheckboxName_UnusedFields;
- public static String UnnecessaryCodeTabPage_CheckboxName_UnusedLocalVariables;
- public static String UnnecessaryCodeTabPage_CheckboxName_UnusedMembers;
- public static String UnnecessaryCodeTabPage_CheckboxName_UnusedMethods;
- public static String UnnecessaryCodeTabPage_GroupName_UnnecessaryCode;
- public static String UnnecessaryCodeTabPage_GroupName_UnusedCode;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, CleanUpMessages.class);
- }
-
- private CleanUpMessages() {
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.properties
deleted file mode 100644
index b8e69565..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpMessages.properties
+++ /dev/null
@@ -1,55 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-CleanUpModifyDialog_TabPageName_CodeStyle=&Code Style
-CleanUpModifyDialog_TabPageName_CodeFormating=Code &Organizing
-
-CleanUpProfileManager_ProfileName_EclipseBuildIn=Eclipse [built-in]
-CleanUpConfigurationBlock_SelectedCleanUps_label=Details:
-CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel=&Show profile selection dialog for the 'Source > Clean Up' action
-
-CodeFormatingTabPage_GroupName_Formatter=Formatter
-#CodeFormatingTabPage_Imports_GroupName=Imports
-CodeFormatingTabPage_CheckboxName_FormatSourceCode=F&ormat source code
-CodeFormatingTabPage_FormatterSettings_Description=The settings for the Formatter can be changed on the Formatter preference page.
-#CodeFormatingTabPage_OrganizeImports_CheckBoxLable=Organize i&mports
-CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio=&All lines
-#CodeFormatingTabPage_OrganizeImportsSettings_Description=The settings for organizing imports can be changed on the Organize Imports preference page.
-CodeFormatingTabPage_SortMembers_GroupName=Members
-CodeFormatingTabPage_SortMembers_Description=The settings for sorting members can be changed on the Members Sort Order preference page.
-#CodeFormatingTabPage_SortMembersFields_CheckBoxLabel=Also sort vars, enum constants, and initializers
-CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text=Remove trailing &whitespace
-CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio=Ignore empty &lines
-
-CodeStyleTabPage_CheckboxName_UseBlocks=Use bloc&ks in if/while/for/do statements
-CodeStyleTabPage_RadioName_AlwaysUseBlocks=Al&ways
-CodeStyleTabPage_RadioName_NeverUseBlocks=No block for sin&gle statments
-CodeStyleTabPage_GroupName_Expressions=Expressions
-#CodeStyleTabPage_CheckboxName_UseFinal=U&se modifier 'final' where possible
-#CodeStyleTabPage_CheckboxName_UseFinalForParameters=&Parameter
-CodeStyleTabPage_RadioName_AlwaysUseParantheses=Alwa&ys
-CodeStyleTabPage_RadioName_NeverUseParantheses=Only &if necessary
-#CodeStyleTabPage_GroupName_VariableDeclarations=Var declarations
-#CodeStyleTabPage_CheckboxName_UseFinalForFields=Pr&ivate fields
-#CodeStyleTabPage_CheckboxName_UseFinalForLocals=&Local variables
-CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced=Conver&t for loops to enhanced
-CodeStyleTabPage_GroupName_ControlStatments=Control statements
-CodeStyleTabPage_RadioName_UseBlocksSpecial=No &block for single 'return' or 'throw' statments
-CodeStyleTabPage_CheckboxName_UseParentheses=Use parent&heses around conditions
-
-
-
-UnnecessaryCodeTabPage_GroupName_UnusedCode=Unused code
-UnnecessaryCodeTabPage_CheckboxName_UnusedMembers=Remove unuse&d private members
-UnnecessaryCodeTabPage_CheckboxName_UnusedFields=V&ars
-UnnecessaryCodeTabPage_CheckboxName_UnusedMethods=&Functions
-UnnecessaryCodeTabPage_CheckboxName_UnusedLocalVariables=Remove unused &local variables
-UnnecessaryCodeTabPage_GroupName_UnnecessaryCode=Unnecessary code
-UnnecessaryCodeTabPage_CheckboxName_UnnecessaryNLSTags=Remove unnecessary '$NON-NLS$' ta&gs \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpModifyDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpModifyDialog.java
deleted file mode 100644
index 2d9c8ddd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpModifyDialog.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialog;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileStore;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-
-public class CleanUpModifyDialog extends ModifyDialog {
-
- /**
- * Constant array for boolean selection
- */
- static String[] FALSE_TRUE = {
- CleanUpConstants.FALSE,
- CleanUpConstants.TRUE
- };
-
- public CleanUpModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
- super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void addPages(final Map values) {
- addTabPage(CleanUpMessages.CleanUpModifyDialog_TabPageName_CodeStyle, new CodeStyleTabPage(this, values));
-// addTabPage(CleanUpMessages.CleanUpModifyDialog_TabPageName_MemberAccesses, new MemberAccessesTabPage(this, values));
-// addTabPage(CleanUpMessages.CleanUpModifyDialog_TabPageName_UnnecessaryCode, new UnnecessaryCodeTabPage(this, values));
-// addTabPage(CleanUpMessages.CleanUpModifyDialog_TabPageName_MissingCode, new MissingCodeTabPage(this, values));
- addTabPage(CleanUpMessages.CleanUpModifyDialog_TabPageName_CodeFormating, new CodeFormatingTabPage(this, values));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpPreview.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpPreview.java
deleted file mode 100644
index 28bcb222..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpPreview.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.IContentFormatterExtension;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.MultiFixMessages;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.JavaPreview;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingContext;
-
-
-public class CleanUpPreview extends JavaPreview {
-
- private ICleanUp[] fPreviewCleanUps;
- private boolean fFormat;
- public CleanUpPreview(Composite parent, ICleanUp[] cleanUps) {
- super(JavaScriptCore.getDefaultOptions(), parent);
- fPreviewCleanUps= cleanUps;
- fFormat= false;
- }
-
- public void setCleanUps(ICleanUp[] fCleanUps) {
- fPreviewCleanUps= fCleanUps;
- }
-
- public void setFormat(boolean enable) {
- fFormat= enable;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void doFormatPreview() {
-
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < fPreviewCleanUps.length; i++) {
- buf.append(fPreviewCleanUps[i].getPreview());
- buf.append("\n"); //$NON-NLS-1$
- }
- format(buf.toString());
- }
-
- private void format(String text) {
- if (text == null) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
- fPreviewDocument.set(text);
-
- if (!fFormat)
- return;
-
- fSourceViewer.setRedraw(false);
- final IFormattingContext context = new CommentFormattingContext();
- try {
- final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
- if (formatter instanceof IContentFormatterExtension) {
- final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
- context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, JavaScriptCore.getOptions());
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
- extension.format(fPreviewDocument, context);
- } else
- formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
- } catch (Exception e) {
- final IStatus status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
- MultiFixMessages.CleanUpRefactoringWizard_formatterException_errorMessage, e);
- JavaScriptPlugin.log(status);
- } finally {
- context.dispose();
- fSourceViewer.setRedraw(true);
- }
- }
-
- public void setWorkingValues(Map workingValues) {
- //Don't change the formatter settings
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileManager.java
deleted file mode 100644
index 2febc5f8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileManager.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.IProfileVersioner;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class CleanUpProfileManager extends ProfileManager {
-
- public static KeySet[] KEY_SETS= {
- new KeySet(JavaScriptUI.ID_PLUGIN, new ArrayList(CleanUpConstants.getEclipseDefaultSettings().keySet()))
- };
-
- private final PreferencesAccess fPreferencesAccess;
-
- public CleanUpProfileManager(List profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
- super(profiles, context, preferencesAccess, profileVersioner, KEY_SETS, CleanUpConstants.CLEANUP_PROFILE, CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY);
- fPreferencesAccess= preferencesAccess;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.ProfileManager#getDefaultProfile()
- */
- public Profile getDefaultProfile() {
- return getProfile(CleanUpConstants.DEFAULT_PROFILE);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
- super.updateProfilesWithName(oldName, newProfile, applySettings);
-
- IEclipsePreferences node= fPreferencesAccess.getInstanceScope().getNode(JavaScriptUI.ID_PLUGIN);
- String name= node.get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null);
- if (name != null && name.equals(oldName)) {
- if (newProfile == null) {
- node.remove(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE);
- } else {
- node.put(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, newProfile.getID());
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java
deleted file mode 100644
index 57bb9ad4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.IProfileVersioner;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-
-
-public class CleanUpProfileVersioner implements IProfileVersioner {
-
- public static final String PROFILE_KIND= "CleanUpProfile"; //$NON-NLS-1$
-
- private static final int VERSION_1= 1; // 3.3M2
- private static final int VERSION_2= 2; // 3.3M3 Added ORGANIZE_IMPORTS
-
- public static final int CURRENT_VERSION= VERSION_2;
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion()
- */
- public int getFirstVersion() {
- return VERSION_1;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.IProfileVersioner#getCurrentVersion()
- */
- public int getCurrentVersion() {
- return CURRENT_VERSION;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.wst.jsdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile)
- */
- public void update(CustomProfile profile) {
- if (profile.getVersion() == VERSION_1)
- updateFrom1To2(profile);
-
- profile.setVersion(CURRENT_VERSION);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getProfileKind() {
- return PROFILE_KIND;
- }
-
- private static void updateFrom1To2(CustomProfile profile) {
- Map defaultSettings= CleanUpConstants.getEclipseDefaultSettings();
- profile.getSettings().put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.get(CleanUpConstants.ORGANIZE_IMPORTS));
- }
-
- }
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpTabPage.java
deleted file mode 100644
index 7a059a30..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CleanUpTabPage.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.JavaPreview;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage;
-
-public abstract class CleanUpTabPage extends ModifyDialogTabPage {
-
- private final Map fValues;
- private JavaPreview fCleanUpPreview;
- private final boolean fIsSaveAction;
- private int fCount;
- private int fSelectedCount;
-
- public CleanUpTabPage(IModificationListener listener, Map values, boolean isSaveAction) {
- super(listener, values);
- fValues= values;
- fIsSaveAction= isSaveAction;
- fCount= 0;
- fSelectedCount= 0;
- }
-
- /**
- * @return is this tab page shown in the save action dialog
- */
- public boolean isSaveAction() {
- return fIsSaveAction;
- }
-
- public int getCleanUpCount() {
- return fCount;
- }
-
- public int getSelectedCleanUpCount() {
- return fSelectedCount;
- }
-
- protected abstract ICleanUp[] createPreviewCleanUps(Map values);
-
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fCleanUpPreview= new CleanUpPreview(parent, createPreviewCleanUps(fValues));
- return fCleanUpPreview;
- }
-
- protected void doUpdatePreview() {
- fCleanUpPreview.setWorkingValues(fValues);
- fCleanUpPreview.update();
- }
-
- protected void initializePage() {
- fCleanUpPreview.update();
- }
-
- protected void registerPreference(final CheckboxPreference preference) {
- fCount++;
- preference.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- if (preference.getChecked()) {
- fSelectedCount++;
- } else {
- fSelectedCount--;
- }
- }
- });
- if (preference.getChecked()) {
- fSelectedCount++;
- }
- }
-
- protected void registerSlavePreference(final CheckboxPreference master, final RadioPreference[] slaves) {
- internalRegisterSlavePreference(master, slaves);
- registerPreference(master);
- }
-
- protected void registerSlavePreference(final CheckboxPreference master, final CheckboxPreference[] slaves) {
- internalRegisterSlavePreference(master, slaves);
- fCount+= slaves.length;
-
- master.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- if (master.getChecked()) {
- for (int i= 0; i < slaves.length; i++) {
- if (slaves[i].getChecked()) {
- fSelectedCount++;
- }
- }
- } else {
- for (int i= 0; i < slaves.length; i++) {
- if (slaves[i].getChecked()) {
- fSelectedCount--;
- }
- }
- }
- }
- });
-
- for (int i= 0; i < slaves.length; i++) {
- final CheckboxPreference slave= slaves[i];
- slave.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- if (slave.getChecked()) {
- fSelectedCount++;
- } else {
- fSelectedCount--;
- }
- }
- });
- }
-
- if (master.getChecked()) {
- for (int i= 0; i < slaves.length; i++) {
- if (slaves[i].getChecked()) {
- fSelectedCount++;
- }
- }
- }
- }
-
- private void internalRegisterSlavePreference(final CheckboxPreference master, final ButtonPreference[] slaves) {
- master.addObserver( new Observer() {
- public void update(Observable o, Object arg) {
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(master.getChecked());
- }
- }
- });
-
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(master.getChecked());
- }
- }
-
- protected void intent(Composite group) {
- Label l= new Label(group, SWT.NONE);
- GridData gd= new GridData();
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4);
- l.setLayoutData(gd);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java
deleted file mode 100644
index ba554b45..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Alex Blewitt - https://bugs.eclipse.org/bugs/show_bug.cgi?id=168954
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.fix.CodeFormatCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.CommentFormatCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.ImportsCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.SortMembersCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.JavaPreview;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialog;
-
-public final class CodeFormatingTabPage extends CleanUpTabPage {
-
- private final Map fValues;
- private CleanUpPreview fPreview;
-
- public CodeFormatingTabPage(ModifyDialog dialog, Map values) {
- this(dialog, values, false);
- }
-
- public CodeFormatingTabPage(IModificationListener listener, Map values, boolean isSaveParticipantConfiguration) {
- super(listener, values, isSaveParticipantConfiguration);
- fValues= values;
- }
-
- protected ICleanUp[] createPreviewCleanUps(Map values) {
- return new ICleanUp[] {
- new ImportsCleanUp(values),
- new CommentFormatCleanUp(values),
- new CodeFormatCleanUp(values),
- new SortMembersCleanUp(values)
- };
- }
-
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= (CleanUpPreview)super.doCreateJavaPreview(parent);
- fPreview.showInvisibleCharacters(true);
- fPreview.setFormat(CleanUpConstants.TRUE.equals(fValues.get(CleanUpConstants.FORMAT_SOURCE_CODE)));
- return fPreview;
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- Group group= createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_GroupName_Formatter);
-
- if (!isSaveAction()) {
- final CheckboxPreference format= createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatSourceCode, CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpModifyDialog.FALSE_TRUE);
- registerPreference(format);
- format.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- fPreview.setFormat(format.getChecked());
- fPreview.update();
- }
- });
- }
-
- final CheckboxPreference whiteSpace= createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES, CleanUpModifyDialog.FALSE_TRUE);
- intent(group);
- final RadioPreference allPref= createRadioPref(group, 1, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL, CleanUpModifyDialog.FALSE_TRUE);
- final RadioPreference ignoreEmptyPref= createRadioPref(group, 1, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, CleanUpModifyDialog.FALSE_TRUE);
- registerSlavePreference(whiteSpace, new RadioPreference[] {allPref, ignoreEmptyPref});
-
- if (!isSaveAction()) {
- createLabel(numColumns, group, CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description).setFont(composite.getFont());
-
-// Group importsGroup= createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_Imports_GroupName);
-// CheckboxPreference organizeImports= createCheckboxPref(importsGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_OrganizeImports_CheckBoxLable, CleanUpConstants.ORGANIZE_IMPORTS, CleanUpModifyDialog.FALSE_TRUE);
-// registerPreference(organizeImports);
-// createLabel(numColumns, importsGroup, CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description).setFont(composite.getFont());
- }
-
- Group sortMembersGroup= createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_SortMembers_GroupName);
-
-// final CheckboxPreference sortMembersPref= createCheckboxPref(sortMembersGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_SortMembers_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS, CleanUpModifyDialog.FALSE_TRUE);
-// intent(sortMembersGroup);
-// final RadioPreference sortAllPref= createRadioPref(sortMembersGroup, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_SortMembersFields_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS_ALL, CleanUpModifyDialog.FALSE_TRUE);
-// intent(sortMembersGroup);
-// final Button nullRadio= new Button(sortMembersGroup, SWT.RADIO);
-// nullRadio.setText(CleanUpMessages.CodeFormatingTabPage_SortMembersExclusive_radio0);
-// nullRadio.setLayoutData(createGridData(numColumns - 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
-// nullRadio.setFont(composite.getFont());
-// intent(sortMembersGroup);
-// final Label warningImage= new Label(sortMembersGroup, SWT.LEFT | SWT.WRAP);
-// warningImage.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
-// warningImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
-// final Label warningLabel= createLabel(numColumns - 2, sortMembersGroup, CleanUpMessages.CodeFormatingTabPage_SortMembersSemanticChange_warning);
-
-// registerSlavePreference(sortMembersPref, new RadioPreference[] {sortAllPref});
-// sortMembersPref.addObserver(new Observer() {
-// public void update(Observable o, Object arg) {
-// nullRadio.setEnabled(sortMembersPref.getChecked());
-//
-// boolean warningEnabled= sortMembersPref.getChecked() && sortAllPref.getChecked();
-// warningImage.setEnabled(warningEnabled);
-// warningLabel.setEnabled(warningEnabled);
-// }
-// });
-// sortAllPref.addObserver(new Observer() {
-// public void update(Observable o, Object arg) {
-// boolean warningEnabled= sortMembersPref.getChecked() && sortAllPref.getChecked();
-// warningImage.setEnabled(warningEnabled);
-// warningLabel.setEnabled(warningEnabled);
-// }
-// });
-// nullRadio.setEnabled(sortMembersPref.getChecked());
-// nullRadio.setSelection(CleanUpConstants.FALSE.equals(fValues.get(CleanUpConstants.SORT_MEMBERS_ALL)));
-// boolean warningEnabled= sortMembersPref.getChecked() && sortAllPref.getChecked();
-// warningImage.setEnabled(warningEnabled);
-// warningLabel.setEnabled(warningEnabled);
-
- createLabel(numColumns, sortMembersGroup, CleanUpMessages.CodeFormatingTabPage_SortMembers_Description);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java
deleted file mode 100644
index 0816e01d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.fix.ControlStatementsCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.ExpressionsCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.VariableDeclarationCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialog;
-
-public final class CodeStyleTabPage extends CleanUpTabPage {
-
- public CodeStyleTabPage(ModifyDialog dialog, Map values) {
- this(dialog, values, false);
- }
-
- public CodeStyleTabPage(IModificationListener listener, Map values, boolean isSaveParticipantConfiguration) {
- super(listener, values, isSaveParticipantConfiguration);
- }
-
- protected ICleanUp[] createPreviewCleanUps(Map values) {
- return new ICleanUp[] {
- new ControlStatementsCleanUp(values),
- new ExpressionsCleanUp(values),
- new VariableDeclarationCleanUp(values)
- };
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- Group controlGroup= createGroup(numColumns, composite, CleanUpMessages.CodeStyleTabPage_GroupName_ControlStatments);
-
- final CheckboxPreference useBlockPref= createCheckboxPref(controlGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseBlocks, CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpModifyDialog.FALSE_TRUE);
- intent(controlGroup);
- final RadioPreference useBlockAlwaysPref= createRadioPref(controlGroup, numColumns - 1, CleanUpMessages.CodeStyleTabPage_RadioName_AlwaysUseBlocks, CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpModifyDialog.FALSE_TRUE);
- intent(controlGroup);
- final RadioPreference useBlockJDTStylePref= createRadioPref(controlGroup, numColumns - 1, CleanUpMessages.CodeStyleTabPage_RadioName_UseBlocksSpecial, CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW, CleanUpModifyDialog.FALSE_TRUE);
- intent(controlGroup);
- final RadioPreference useBlockNeverPref= createRadioPref(controlGroup, numColumns - 1, CleanUpMessages.CodeStyleTabPage_RadioName_NeverUseBlocks, CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpModifyDialog.FALSE_TRUE);
- registerSlavePreference(useBlockPref, new RadioPreference[] {useBlockAlwaysPref, useBlockJDTStylePref, useBlockNeverPref});
-
-
- Group expressionsGroup= createGroup(numColumns, composite, CleanUpMessages.CodeStyleTabPage_GroupName_Expressions);
-
- final CheckboxPreference useParenthesesPref= createCheckboxPref(expressionsGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseParentheses, CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpModifyDialog.FALSE_TRUE);
- intent(expressionsGroup);
- final RadioPreference useParenthesesAlwaysPref= createRadioPref(expressionsGroup, 1, CleanUpMessages.CodeStyleTabPage_RadioName_AlwaysUseParantheses, CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpModifyDialog.FALSE_TRUE);
- final RadioPreference useParenthesesNeverPref= createRadioPref(expressionsGroup, 1, CleanUpMessages.CodeStyleTabPage_RadioName_NeverUseParantheses, CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpModifyDialog.FALSE_TRUE);
- registerSlavePreference(useParenthesesPref, new RadioPreference[] {useParenthesesAlwaysPref, useParenthesesNeverPref});
-
-// Group variableGroup= createGroup(numColumns, composite, CleanUpMessages.CodeStyleTabPage_GroupName_VariableDeclarations);
-
-// final CheckboxPreference useFinalPref= createCheckboxPref(variableGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinal, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL, CleanUpModifyDialog.FALSE_TRUE);
-// intent(variableGroup);
-// final CheckboxPreference useFinalFieldsPref= createCheckboxPref(variableGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinalForFields, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpModifyDialog.FALSE_TRUE);
-// final CheckboxPreference useFinalParametersPref= createCheckboxPref(variableGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinalForParameters, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpModifyDialog.FALSE_TRUE);
-// final CheckboxPreference useFinalVariablesPref= createCheckboxPref(variableGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinalForLocals, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpModifyDialog.FALSE_TRUE);
-// registerSlavePreference(useFinalPref, new CheckboxPreference[] {useFinalFieldsPref, useFinalParametersPref, useFinalVariablesPref});
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java
deleted file mode 100644
index c8e7afed..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.cleanup;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.wst.jsdt.internal.ui.fix.ICleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.StringCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.UnnecessaryCodeCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.fix.UnusedCodeCleanUp;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialog;
-
-public final class UnnecessaryCodeTabPage extends CleanUpTabPage {
-
- public UnnecessaryCodeTabPage(ModifyDialog dialog, Map values) {
- this(dialog, values, false);
- }
-
- public UnnecessaryCodeTabPage(IModificationListener listener, Map values, boolean isSaveParticipantConfiguration) {
- super(listener, values, isSaveParticipantConfiguration);
- }
-
- protected ICleanUp[] createPreviewCleanUps(Map values) {
- return new ICleanUp[] {
- new UnusedCodeCleanUp(values),
- new UnnecessaryCodeCleanUp(values),
- new StringCleanUp(values)
- };
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- Group unusedCodeGroup= createGroup(5, composite, CleanUpMessages.UnnecessaryCodeTabPage_GroupName_UnusedCode);
-
-// CheckboxPreference removeImports= createCheckboxPref(unusedCodeGroup, 5, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedImports, CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpModifyDialog.FALSE_TRUE);
-// registerPreference(removeImports);
-
- final CheckboxPreference unusedMembersPref= createCheckboxPref(unusedCodeGroup, 5, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedMembers, CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpModifyDialog.FALSE_TRUE);
- intent(unusedCodeGroup);
-// final CheckboxPreference typesPref= createCheckboxPref(unusedCodeGroup, 1, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedTypes, CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpModifyDialog.FALSE_TRUE);
-// final CheckboxPreference constructorPref= createCheckboxPref(unusedCodeGroup, 1, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedConstructors, CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpModifyDialog.FALSE_TRUE);
- final CheckboxPreference fieldsPref= createCheckboxPref(unusedCodeGroup, 1, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedFields, CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpModifyDialog.FALSE_TRUE);
- final CheckboxPreference methodsPref= createCheckboxPref(unusedCodeGroup, 1, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedMethods, CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpModifyDialog.FALSE_TRUE);
- registerSlavePreference(unusedMembersPref, new CheckboxPreference[] {/*typesPref, constructorPref, */fieldsPref, methodsPref});
-
- CheckboxPreference removeLocals= createCheckboxPref(unusedCodeGroup, numColumns, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnusedLocalVariables, CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpModifyDialog.FALSE_TRUE);
- registerPreference(removeLocals);
-
- Group unnecessaryGroup= createGroup(numColumns, composite, CleanUpMessages.UnnecessaryCodeTabPage_GroupName_UnnecessaryCode);
-//
-// CheckboxPreference casts= createCheckboxPref(unnecessaryGroup, numColumns, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnnecessaryCasts, CleanUpConstants.REMOVE_UNNECESSARY_CASTS, CleanUpModifyDialog.FALSE_TRUE);
-// registerPreference(casts);
-
- CheckboxPreference nls= createCheckboxPref(unnecessaryGroup, numColumns, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UnnecessaryNLSTags, CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS, CleanUpModifyDialog.FALSE_TRUE);
- registerPreference(nls);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
deleted file mode 100644
index 65bddf8a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.StatusDialog;
-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.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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-
-/**
- * The dialog to rename an imported profile.
- */
-public class AlreadyExistsDialog extends StatusDialog {
-
- private Composite fComposite;
- protected Text fNameText;
- private Button fRenameRadio, fOverwriteRadio;
-
- private final int NUM_COLUMNS= 2;
-
- private final StatusInfo fOk;
- private final StatusInfo fEmpty;
- private final StatusInfo fDuplicate;
-
- private final CustomProfile fProfile;
- private final ProfileManager fProfileManager;
-
- public AlreadyExistsDialog(Shell parentShell, CustomProfile profile, ProfileManager profileManager) {
- super(parentShell);
- fProfile= profile;
- fProfileManager= profileManager;
- fOk= new StatusInfo();
- fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_already_exists);
- fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty);
-
- setHelpAvailable(false);
- }
-
-
- public void create() {
- super.create();
- setTitle(FormatterMessages.AlreadyExistsDialog_dialog_title);
- }
-
- public Control createDialogArea(Composite parent) {
-
- initializeComposite(parent);
-
- createLabel(Messages.format(FormatterMessages.AlreadyExistsDialog_dialog_label, fProfile.getName()));
-
- fRenameRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_rename_radio_button_desc);
- fNameText= createTextField();
-
- fOverwriteRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_overwrite_radio_button_desc);
-
- fRenameRadio.setSelection(true);
-
- fNameText.setText(fProfile.getName());
- fNameText.setSelection(0, fProfile.getName().length());
- fNameText.setFocus();
-
- fNameText.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation();
- }
- });
-
- fRenameRadio.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fNameText.setEnabled(true);
- fNameText.setFocus();
- fNameText.setSelection(0, fNameText.getText().length());
- doValidation();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- fOverwriteRadio.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fNameText.setEnabled(false);
- doValidation();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- updateStatus(fDuplicate);
-
- applyDialogFont(fComposite);
-
- return fComposite;
- }
-
- private void initializeComposite(Composite parent) {
- fComposite= new Composite(parent, SWT.NULL);
-
- final GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.numColumns= NUM_COLUMNS;
-
- fComposite.setLayout(layout);
- }
-
- private Label createLabel(String text) {
- final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= NUM_COLUMNS;
- gd.widthHint= convertWidthInCharsToPixels(60);
- final Label label= new Label(fComposite, SWT.WRAP);
- label.setText(text);
- label.setLayoutData(gd);
- return label;
- }
-
- private Button createRadioButton(String text) {
- final GridData gd = new GridData();
- gd.horizontalSpan = NUM_COLUMNS;
- gd.widthHint= convertWidthInCharsToPixels(60);
- final Button radio= new Button(fComposite, SWT.RADIO);
- radio.setLayoutData(gd);
- radio.setText(text);
- return radio;
- }
-
- private Text createTextField() {
- final GridData gd = new GridData( GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= NUM_COLUMNS;
- gd.horizontalIndent= 15;
- final Text text= new Text(fComposite, SWT.SINGLE | SWT.BORDER);
- text.setLayoutData(gd);
- return text;
- }
-
-
- /**
- * Validate the current settings
- */
- protected void doValidation() {
-
- if (fOverwriteRadio.getSelection()) {
- updateStatus(fOk);
- return;
- }
-
- final String name= fNameText.getText().trim();
-
- if (name.length() == 0) {
- updateStatus(fEmpty);
- return;
- }
-
- if (fProfileManager.containsName(name)) {
- updateStatus(fDuplicate);
- return;
- }
-
- updateStatus(fOk);
- }
-
-
- protected void okPressed() {
- if (!getStatus().isOK())
- return;
- if (fRenameRadio.getSelection())
- fProfile.rename(fNameText.getText().trim(), fProfileManager);
- super.okPressed();
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BlankLinesTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BlankLinesTabPage.java
deleted file mode 100644
index 4e913419..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BlankLinesTabPage.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-
-public class BlankLinesTabPage extends FormatterTabPage {
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.BlankLinesTabPage_preview_header) +
- "var data;\n" + //$NON-NLS-1$
- "var data2;\n" + //$NON-NLS-1$
- "var data3;\n" + //$NON-NLS-1$
- "function foo(otherdata) {\n" + //$NON-NLS-1$
- "// Between here...\n" + //$NON-NLS-1$
- "\n\n\n\n\n" + //$NON-NLS-1$
- "// ...and here are 5 blank lines\n" + //$NON-NLS-1$
- " var first;\n" + //$NON-NLS-1$
- " var second;\n" + //$NON-NLS-1$
- " function foo2() {\n" + //$NON-NLS-1$
- " var abc;\n" + //$NON-NLS-1$
- " var xyz;\n" + //$NON-NLS-1$
- " };\n" + //$NON-NLS-1$
- "}\n"; //$NON-NLS-1$
-
- private final static int MIN_NUMBER_LINES= 0;
- private final static int MAX_NUMBER_LINES= 99;
-
-
- private CompilationUnitPreview fPreview;
-
- /**
- * Create a new BlankLinesTabPage.
- * @param modifyDialog The main configuration dialog
- *
- * @param workingValues The values wherein the options are stored.
- */
- public BlankLinesTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- Group group;
-
-// STP - Commented-out next 6 lines (20070207)
-// group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_compilation_unit_group_title);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_before_package, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_after_package, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_before_import, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_after_import, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_between_type_declarations, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS);
-
-// STP - Commented-out next 7 lines (20070207)
-// group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_class_group_title);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_first_decl, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_decls_of_same_kind, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_member_class_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_field_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_method_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD);
-// createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_at_beginning_of_method_body, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY);
-
-// STP - Added next 6 lines (20070207)
-group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_function_group_title);
-createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_function_option_before_first_decl, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION);
-createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_function_option_before_decls_of_same_kind, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK);
-createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_function_option_before_field_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD);
-createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_function_option_before_function_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD);
-createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_function_option_at_beginning_of_function_body, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY);
-
- group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_blank_lines_group_title);
- createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve, DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE);
- }
-
- protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- /*
- * A helper method to create a number preference for blank lines.
- */
- private void createBlankLineTextField(Composite composite, int numColumns, String message, String key) {
- createNumberPref(composite, numColumns, message, key, MIN_NUMBER_LINES, MAX_NUMBER_LINES);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
- */
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BracesTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BracesTabPage.java
deleted file mode 100644
index 50fb752b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/BracesTabPage.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-public class BracesTabPage extends FormatterTabPage {
-
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.BracesTabPage_preview_header) +
- "function foo(data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " var abc = 1;\n" + //$NON-NLS-1$
- " var xyz = 'one';\n" + //$NON-NLS-1$
- " var arr1 = [ '1', '2', '3', '4' ];\n" + //$NON-NLS-1$
- " var arr2 = [];\n" + //$NON-NLS-1$
- " var car = { carMake: 'Toyota', carModel: 'Celica', carYear: 2000 };\n" + //$NON-NLS-1$
- " var car2 = {};\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " switch (data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " case 0:\n" + //$NON-NLS-1$
- " abc = 0;\n" + //$NON-NLS-1$
- " xyz = 'zero';\n" + //$NON-NLS-1$
- " break;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " default:\n" + //$NON-NLS-1$
- " abc = -1;\n" + //$NON-NLS-1$
- " xyz = 'unknown';\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " }\n\n" + //$NON-NLS-1$
- " if ( document.form1.year.value > 2000 ) {\n" + //$NON-NLS-1$
- " abc += 27;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " else if ( document.form1.year.value > 1900 ) {\n" + //$NON-NLS-1$
- " abc += 19;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " else {\n" + //$NON-NLS-1$
- " abc = 0;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
-
-
-
- private CompilationUnitPreview fPreview;
-
-
- private final String [] fBracePositions= {
- DefaultCodeFormatterConstants.END_OF_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED
- };
-
- private final String [] fExtendedBracePositions= {
- DefaultCodeFormatterConstants.END_OF_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED,
- DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP
- };
-
- private final String [] fBracePositionNames= {
- FormatterMessages.BracesTabPage_position_same_line,
- FormatterMessages.BracesTabPage_position_next_line,
- FormatterMessages.BracesTabPage_position_next_line_indented
- };
-
- private final String [] fExtendedBracePositionNames= {
- FormatterMessages.BracesTabPage_position_same_line,
- FormatterMessages.BracesTabPage_position_next_line,
- FormatterMessages.BracesTabPage_position_next_line_indented,
- FormatterMessages.BracesTabPage_position_next_line_on_wrap
- };
-
-
- /**
- * Create a new BracesTabPage.
- * @param modifyDialog
- * @param workingValues
- */
- public BracesTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- final Group group= createGroup(numColumns, composite, FormatterMessages.BracesTabPage_group_brace_positions_title);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_class_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_anonymous_class_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_constructor_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_method_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enumconst_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_annotation_type_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks_in_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
- createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_switch_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
-
- ComboPreference objectInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_object_initializer, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_OBJLIT_INITIALIZER);
- final CheckboxPreference objectInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_object_initializer_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_OBJLIT_INITIALIZER_ON_ONE_LINE, FALSE_TRUE);
- objectInitOption.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- updateOptionEnablement((ComboPreference) o, objectInitCheckBox);
- }
- });
- updateOptionEnablement(objectInitOption, objectInitCheckBox);
-
-
- ComboPreference arrayInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_array_initializer, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
- final CheckboxPreference arrayInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_array_initializer_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, FALSE_TRUE);
-
- arrayInitOption.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- updateOptionEnablement((ComboPreference) o, arrayInitCheckBox);
- }
- });
- updateOptionEnablement(arrayInitOption, arrayInitCheckBox);
-
- }
-
- /**
- * @param arrayInitOption
- * @param arrayInitCheckBox
- */
- protected final void updateOptionEnablement(ComboPreference arrayInitOption, CheckboxPreference arrayInitCheckBox) {
- arrayInitCheckBox.setEnabled(!arrayInitOption.hasValue(DefaultCodeFormatterConstants.END_OF_LINE));
- }
-
- protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- private ComboPreference createBracesCombo(Composite composite, int numColumns, String message, String key) {
- return createComboPref(composite, numColumns, message, key, fBracePositions, fBracePositionNames);
- }
-
- private ComboPreference createExtendedBracesCombo(Composite composite, int numColumns, String message, String key) {
- return createComboPref(composite, numColumns, message, key, fExtendedBracePositions, fExtendedBracePositionNames);
- }
-
- private CheckboxPreference createIndentedCheckboxPref(Composite composite, int numColumns, String message, String key, String [] values) {
- CheckboxPreference pref= createCheckboxPref(composite, numColumns, message, key, values);
- GridData data= (GridData) pref.getControl().getLayoutData();
- data.horizontalIndent= fPixelConverter.convertWidthInCharsToPixels(1);
- return pref;
- }
-
-
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
deleted file mode 100644
index a6582873..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.List;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-
-/**
- * The code formatter preference page.
- */
-
-public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
-
- private static final String FORMATTER_DIALOG_PREFERENCE_KEY= "formatter_page"; //$NON-NLS-1$
-
- private static final String DIALOGSTORE_LASTSAVELOADPATH= JavaScriptUI.ID_PLUGIN + ".codeformatter"; //$NON-NLS-1$
-
- /**
- * Some Java source code used for preview.
- */
- protected final String PREVIEW= "/**\n* " + //$NON-NLS-1$
- FormatterMessages.CodingStyleConfigurationBlock_preview_title +
- "\n*/\n\n" + //$NON-NLS-1$
- "" + //$NON-NLS-1$
- "var index=0;" + //$NON-NLS-1$
- "var arr=[];" + //$NON-NLS-1$
- "var obj={x:\"\",y:function(){}};" + //$NON-NLS-1$
- "function foo(){var1= new Object();}" + //$NON-NLS-1$
- "function pop(){return arr[index--];}" + //$NON-NLS-1$
- "function push( elem){arr[index++]=elem;}" + //$NON-NLS-1$
- "function isEmpty() {return index==0;}" + //$NON-NLS-1$
- ""; //$NON-NLS-1$
-
- private class PreviewController implements Observer {
-
- public PreviewController(ProfileManager profileManager) {
- profileManager.addObserver(this);
- fJavaPreview.setWorkingValues(profileManager.getSelected().getSettings());
- fJavaPreview.update();
- }
-
- public void update(Observable o, Object arg) {
- final int value= ((Integer)arg).intValue();
- switch (value) {
- case ProfileManager.PROFILE_CREATED_EVENT:
- case ProfileManager.PROFILE_DELETED_EVENT:
- case ProfileManager.SELECTION_CHANGED_EVENT:
- case ProfileManager.SETTINGS_CHANGED_EVENT:
- fJavaPreview.setWorkingValues(((ProfileManager)o).getSelected().getSettings());
- fJavaPreview.update();
- }
- }
-
- }
-
-
- /**
- * The JavaPreview.
- */
- private JavaPreview fJavaPreview;
-
- /**
- * Create a new <code>CodeFormatterConfigurationBlock</code>.
- */
- public CodeFormatterConfigurationBlock(IProject project, PreferencesAccess access) {
- super(project, access, DIALOGSTORE_LASTSAVELOADPATH);
- }
-
- protected IProfileVersioner createProfileVersioner() {
- return new ProfileVersioner();
- }
-
- protected ProfileStore createProfileStore(IProfileVersioner versioner) {
- return new FormatterProfileStore(versioner);
- }
-
- protected ProfileManager createProfileManager(List profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) {
- return new FormatterProfileManager(profiles, context, access, profileVersioner);
- }
-
- protected void configurePreview(Composite composite, int numColumns, ProfileManager profileManager) {
- createLabel(composite, FormatterMessages.CodingStyleConfigurationBlock_preview_label_text, numColumns);
- CompilationUnitPreview result= new CompilationUnitPreview(profileManager.getSelected().getSettings(), composite);
- result.setPreviewText(PREVIEW);
- fJavaPreview= result;
-
- final GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = numColumns;
- gd.verticalSpan= 7;
- gd.widthHint = 0;
- gd.heightHint = 0;
- fJavaPreview.getControl().setLayoutData(gd);
-
- new PreviewController(profileManager);
- }
-
-
- protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) {
- return new FormatterModifyDialog(shell, profile, profileManager, profileStore, newProfile, FORMATTER_DIALOG_PREFERENCE_KEY, DIALOGSTORE_LASTSAVELOADPATH);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CommentsTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CommentsTabPage.java
deleted file mode 100644
index f6c8bbf2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CommentsTabPage.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-
-/**
- * Tab page for the comment formatter settings.
- */
-public class CommentsTabPage extends FormatterTabPage {
-
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- /**
- * Constant array for insert / not_insert.
- */
- private static String[] DO_NOT_INSERT_INSERT = {
- JavaScriptCore.DO_NOT_INSERT,
- JavaScriptCore.INSERT
- };
-
- private static abstract class Controller implements Observer {
-
- private final Collection fMasters;
- private final Collection fSlaves;
-
- public Controller(Collection masters, Collection slaves) {
- fMasters= masters;
- fSlaves= slaves;
- for (final Iterator iter= fMasters.iterator(); iter.hasNext();) {
- ((CheckboxPreference)iter.next()).addObserver(this);
- }
- }
-
- public void update(Observable o, Object arg) {
- boolean enabled= areSlavesEnabled();
-
- for (final Iterator iter= fSlaves.iterator(); iter.hasNext();) {
- final Object obj= iter.next();
- if (obj instanceof Preference) {
- ((Preference)obj).setEnabled(enabled);
- } else if (obj instanceof Control) {
- ((Group)obj).setEnabled(enabled);
- }
- }
- }
-
- public Collection getMasters() {
- return fMasters;
- }
-
- public Collection getSlaves() {
- return fSlaves;
- }
-
- protected abstract boolean areSlavesEnabled();
- }
-
- private final static class OrController extends Controller {
-
- public OrController(Collection masters, Collection slaves) {
- super(masters, slaves);
- update(null, null);
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean areSlavesEnabled() {
- for (final Iterator iter= getMasters().iterator(); iter.hasNext();) {
- if (((CheckboxPreference)iter.next()).getChecked())
- return true;
- }
- return false;
- }
- }
-
- private final String PREVIEW=
- createPreviewHeader("An example for comment formatting. This example is meant to illustrate the various possibilities offered by <i>Eclipse</i> in order to format comments.") + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * This is the comment for the example function.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- " function foo(arg) {\n" + //$NON-NLS-1$
- " /**\n" + //$NON-NLS-1$
- " *\n" + //$NON-NLS-1$
- " * These possibilities include:\n" + //$NON-NLS-1$
- " * <ul><li>Formatting of header comments.</li><li>Formatting of JSdoc tags</li></ul>\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- " var data;\n" + //$NON-NLS-1$
- " /**\n" + //$NON-NLS-1$
- " * The following is some sample code which illustrates source formatting within JSdoc comments:\n" + //$NON-NLS-1$
- " * <pre>function foo(a,b) { var a=1; var b=true; return a; }</pre>\n" + //$NON-NLS-1$
- " * Descriptions of parameters and return values are best appended at end of the JSdoc comment.\n" + //$NON-NLS-1$
- " * @param a The first parameter. This should be a number between 1 and 100.\n" + //$NON-NLS-1$
- " * @param b The second parameter. This should be a number between 1 and 5.\n" + //$NON-NLS-1$
- " * @return The result of the foo operation, usually within 1 and 100.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- " function foo2(a,b);\n" + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
-
- private CompilationUnitPreview fPreview;
-
- public CommentsTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- // global group
- final Group globalGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
- final CheckboxPreference javadoc= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.commentsTabPage_enable_javadoc_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT);
- final CheckboxPreference blockComment= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_enable_block_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT);
- final CheckboxPreference singleLineComments= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_enable_line_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT);
- final CheckboxPreference header= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER);
- createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_never_indent_block_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN);
- createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_never_indent_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN);
-
- // javadoc comment formatting settings
- final Group settingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group2_title);
- final CheckboxPreference html= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML);
- final CheckboxPreference code= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE);
- final CheckboxPreference blankJavadoc= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_blank_line_before_javadoc_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
- final CheckboxPreference indentJavadoc= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_javadoc_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS);
- final CheckboxPreference indentDesc= createCheckboxPref(settingsGroup, numColumns , FormatterMessages.CommentsTabPage_indent_description_after_param, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, FALSE_TRUE);
- ((GridData)indentDesc.getControl().getLayoutData()).horizontalIndent= fPixelConverter.convertWidthInCharsToPixels(4);
- final CheckboxPreference nlParam= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_line_after_param_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
- final CheckboxPreference blankLinesJavadoc= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT);
-
- // block comment settings
- final Group blockSettingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group4_title);
- final CheckboxPreference blankLinesBlock= createPrefTrueFalse(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_remove_blank_block_comment_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT);
-
- final Group widthGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group3_title);
- final NumberPreference lineWidth= createNumberPref(widthGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, 0, 9999);
-
- ArrayList javaDocMaster= new ArrayList();
- javaDocMaster.add(javadoc);
- javaDocMaster.add(header);
-
- ArrayList javaDocSlaves= new ArrayList();
- javaDocSlaves.add(settingsGroup);
- javaDocSlaves.add(html);
- javaDocSlaves.add(code);
- javaDocSlaves.add(blankJavadoc);
- javaDocSlaves.add(indentJavadoc);
- javaDocSlaves.add(nlParam);
- javaDocSlaves.add(blankLinesJavadoc);
-
- new OrController(javaDocMaster, javaDocSlaves);
-
- ArrayList indentMasters= new ArrayList();
- indentMasters.add(javadoc);
- indentMasters.add(header);
- indentMasters.add(indentJavadoc);
-
- ArrayList indentSlaves= new ArrayList();
- indentSlaves.add(indentDesc);
-
- new Controller(indentMasters, indentSlaves) {
- protected boolean areSlavesEnabled() {
- return (javadoc.getChecked() || header.getChecked()) && indentJavadoc.getChecked();
- }
- }.update(null, null);
-
- ArrayList blockMasters= new ArrayList();
- blockMasters.add(blockComment);
- blockMasters.add(header);
-
- ArrayList blockSlaves= new ArrayList();
- blockSlaves.add(blockSettingsGroup);
- blockSlaves.add(blankLinesBlock);
-
- new OrController(blockMasters, blockSlaves);
-
- ArrayList lineWidthMasters= new ArrayList();
- lineWidthMasters.add(javadoc);
- lineWidthMasters.add(blockComment);
- lineWidthMasters.add(singleLineComments);
- lineWidthMasters.add(header);
-
- ArrayList lineWidthSlaves= new ArrayList();
- lineWidthSlaves.add(widthGroup);
- lineWidthSlaves.add(lineWidth);
-
- new OrController(lineWidthMasters, lineWidthSlaves);
- }
-
- protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
- */
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-
- private CheckboxPreference createPrefTrueFalse(Composite composite, int numColumns, String text, String key) {
- return createCheckboxPref(composite, numColumns, text, key, FALSE_TRUE);
- }
-
- private CheckboxPreference createPrefInsert(Composite composite, int numColumns, String text, String key) {
- return createCheckboxPref(composite, numColumns, text, key, DO_NOT_INSERT_INSERT);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CompilationUnitPreview.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CompilationUnitPreview.java
deleted file mode 100644
index 0629126b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CompilationUnitPreview.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.IContentFormatterExtension;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.comment.CommentFormattingContext;
-
-
-public class CompilationUnitPreview extends JavaPreview {
-
- private String fPreviewText;
-
- /**
- * @param workingValues
- * @param parent
- */
- public CompilationUnitPreview(Map workingValues, Composite parent) {
-
- super(workingValues, parent);
- }
-
- protected void doFormatPreview() {
- if (fPreviewText == null) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
- fPreviewDocument.set(fPreviewText);
-
- fSourceViewer.setRedraw(false);
- final IFormattingContext context = new CommentFormattingContext();
- try {
- final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
- if (formatter instanceof IContentFormatterExtension) {
- final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
- context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues);
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
- extension.format(fPreviewDocument, context);
- } else
- formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
- } catch (Exception e) {
- final IStatus status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
- FormatterMessages.JavaPreview_formatter_exception, e);
- JavaScriptPlugin.log(status);
- } finally {
- context.dispose();
- fSourceViewer.setRedraw(true);
- }
- }
-
- public void setPreviewText(String previewText) {
-// if (previewText == null) throw new IllegalArgumentException();
- fPreviewText= previewText;
- update();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
deleted file mode 100644
index 7c385f34..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-
-public class ControlStatementsTabPage extends FormatterTabPage {
-
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- /**
- * Constant array for insert / not_insert.
- */
- private static String[] DO_NOT_INSERT_INSERT = {
- JavaScriptCore.DO_NOT_INSERT,
- JavaScriptCore.INSERT
- };
-
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.ControlStatementsTabPage_preview_header) +
- "function bar() {\n" + //$NON-NLS-1$
- " do {} while (true);\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "function foo2() {\n" + //$NON-NLS-1$
- " if (true) {\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " if (true) {\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " } else if (false) {\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " } else {\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "function foo(state) {\n" + //$NON-NLS-1$
- " if (true) return;\n" + //$NON-NLS-1$
- " if (true)\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " else if (false)\n" + //$NON-NLS-1$
- " return;\n" + //$NON-NLS-1$
- " else return;\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "function foo4(n) {\n" + //$NON-NLS-1$
- " if ( n < 0 ) {" + //$NON-NLS-1$
- " throw myException;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "try { a = foo3(b); } catch (e) { a = \"ERROR\"; } finally { c = a; }"; //$NON-NLS-1$
-
-
-
- private CompilationUnitPreview fPreview;
-
- protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
-
-
- public ControlStatementsTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_general_group_title);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_else_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, DO_NOT_INSERT_INSERT);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, DO_NOT_INSERT_INSERT);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_finally_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, DO_NOT_INSERT_INSERT);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, DO_NOT_INSERT_INSERT);
-
- final Group ifElseGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_if_else_group_title);
- fThenStatementPref= createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_then_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
-
- Label l= new Label(ifElseGroup, SWT.NONE);
- GridData gd= new GridData();
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4);
- l.setLayoutData(gd);
-
- fSimpleIfPref= createOption(ifElseGroup, numColumns - 1, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, FALSE_TRUE);
-
- fThenStatementPref.addObserver( new Observer() {
- public void update(Observable o, Object arg) {
- fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
- }
-
- });
-
- fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
-
- createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
- createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, FALSE_TRUE);
- createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, FALSE_TRUE);
- }
-
- protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
- */
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-
- private CheckboxPreference createOption(Composite composite, int span, String name, String key, String [] values) {
- return createCheckboxPref(composite, span, name, key, values);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CreateProfileDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CreateProfileDialog.java
deleted file mode 100644
index 92e4e694..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/CreateProfileDialog.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.StatusDialog;
-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.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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- * The dialog to create a new profile.
- */
-public class CreateProfileDialog extends StatusDialog {
-
-
- private static final String PREF_OPEN_EDIT_DIALOG= JavaScriptUI.ID_PLUGIN + ".codeformatter.create_profile_dialog.open_edit"; //$NON-NLS-1$
-
-
- private Text fNameText;
- private Combo fProfileCombo;
- private Button fEditCheckbox;
-
- private final static StatusInfo fOk= new StatusInfo();
- private final static StatusInfo fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_name_is_empty);
- private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists);
-
- private final ProfileManager fProfileManager;
- private final List fSortedProfiles;
- private final String [] fSortedNames;
-
- private CustomProfile fCreatedProfile;
- protected boolean fOpenEditDialog;
-
-
- private final IProfileVersioner fProfileVersioner;
-
- public CreateProfileDialog(Shell parentShell, ProfileManager profileManager, IProfileVersioner profileVersioner) {
- super(parentShell);
- fProfileManager= profileManager;
- fProfileVersioner= profileVersioner;
- fSortedProfiles= fProfileManager.getSortedProfiles();
- fSortedNames= fProfileManager.getSortedDisplayNames();
- }
-
-
- public void create() {
- super.create();
- setTitle(FormatterMessages.CreateProfileDialog_dialog_title);
- }
-
- public Control createDialogArea(Composite parent) {
-
- final int numColumns= 2;
-
- GridData gd;
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
-
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(layout);
-
- // Create "Profile name:" label
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = numColumns;
- gd.widthHint= convertWidthInCharsToPixels(60);
- final Label nameLabel = new Label(composite, SWT.WRAP);
- nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text);
- nameLabel.setLayoutData(gd);
-
- // Create text field to enter name
- gd = new GridData( GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= numColumns;
- fNameText= new Text(composite, SWT.SINGLE | SWT.BORDER);
- fNameText.setLayoutData(gd);
- fNameText.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doValidation();
- }
- });
-
- // Create "Initialize settings ..." label
- gd = new GridData();
- gd.horizontalSpan = numColumns;
- Label profileLabel = new Label(composite, SWT.WRAP);
- profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text);
- profileLabel.setLayoutData(gd);
-
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= numColumns;
- fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
- fProfileCombo.setLayoutData(gd);
-
-
- // "Open the edit dialog now" checkbox
- gd= new GridData();
- gd.horizontalSpan= numColumns;
- fEditCheckbox= new Button(composite, SWT.CHECK);
- fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text);
- fEditCheckbox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fOpenEditDialog= ((Button)e.widget).getSelection();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- final IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
- if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) {
- fOpenEditDialog= dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
- } else {
- fOpenEditDialog= true;
- }
- fEditCheckbox.setSelection(fOpenEditDialog);
-
- fProfileCombo.setItems(fSortedNames);
- fProfileCombo.setText(fProfileManager.getDefaultProfile().getName());
- updateStatus(fEmpty);
-
- applyDialogFont(composite);
-
- fNameText.setFocus();
-
- return composite;
- }
-
-
- /**
- * Validate the current settings
- */
- protected void doValidation() {
- final String name= fNameText.getText().trim();
-
- if (fProfileManager.containsName(name)) {
- updateStatus(fDuplicate);
- return;
- }
- if (name.length() == 0) {
- updateStatus(fEmpty);
- return;
- }
- updateStatus(fOk);
- }
-
-
- protected void okPressed() {
- if (!getStatus().isOK())
- return;
-
- JavaScriptPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);
-
- final Map baseSettings= new HashMap(((Profile)fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
- final String profileName= fNameText.getText();
-
- fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
- fProfileManager.addProfile(fCreatedProfile);
- super.okPressed();
- }
-
- public final CustomProfile getCreatedProfile() {
- return fCreatedProfile;
- }
-
- public final boolean openEditDialog() {
- return fOpenEditDialog;
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.java
deleted file mode 100644
index 720855fb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * istvan@benedek-home.de - 103706 [formatter] indent empty lines
- * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-final class FormatterMessages extends NLS {
-
- private static final String BUNDLE_NAME= FormatterMessages.class.getName();
-
- private FormatterMessages() {
- // Do not instantiate
- }
-
- public static String CommentsTabPage_remove_blank_block_comment_lines;
- public static String FormatterTabPage_ShowInvisibleCharacters_label;
- public static String ModifyDialog_BuiltIn_Status;
- public static String ModifyDialog_Duplicate_Status;
- public static String ModifyDialog_EmptyName_Status;
- public static String ModifyDialog_Export_Button;
- public static String ModifyDialog_NewCreated_Status;
- public static String ModifyDialog_ProfileName_Label;
- public static String ModifyDialog_Shared_Status;
- public static String ProfileConfigurationBlock_load_profile_wrong_profile_message;
- public static String WhiteSpaceTabPage_assignments;
- public static String WhiteSpaceTabPage_assignments_before_assignment_operator;
- public static String WhiteSpaceTabPage_assignments_after_assignment_operator;
- public static String WhiteSpaceTabPage_operators;
- public static String WhiteSpaceTabPage_operators_before_binary_operators;
- public static String WhiteSpaceTabPage_operators_after_binary_operators;
- public static String WhiteSpaceTabPage_operators_before_unary_operators;
- public static String WhiteSpaceTabPage_operators_after_unary_operators;
- public static String WhiteSpaceTabPage_operators_before_prefix_operators;
- public static String WhiteSpaceTabPage_operators_after_prefix_operators;
- public static String WhiteSpaceTabPage_operators_before_postfix_operators;
- public static String WhiteSpaceTabPage_operators_after_postfix_operators;
-// public static String WhiteSpaceTabPage_classes;
-// public static String WhiteSpaceTabPage_classes_before_opening_brace_of_a_class;
-// public static String WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class;
-// public static String WhiteSpaceTabPage_classes_before_comma_implements;
-// public static String WhiteSpaceTabPage_classes_after_comma_implements;
- public static String WhiteSpaceTabPage_methods;
- public static String WhiteSpaceTabPage_constructors;
- public static String WhiteSpaceTabPage_fields;
- public static String WhiteSpaceTabPage_fields_before_comma;
- public static String WhiteSpaceTabPage_fields_after_comma;
- public static String WhiteSpaceTabPage_localvars;
- public static String WhiteSpaceTabPage_localvars_before_comma;
- public static String WhiteSpaceTabPage_localvars_after_comma;
- public static String WhiteSpaceTabPage_arrayinit;
- public static String WhiteSpaceTabPage_arraydecls;
- public static String WhiteSpaceTabPage_arrayelem;
- public static String WhiteSpaceTabPage_arrayalloc;
- public static String WhiteSpaceTabPage_calls;
- public static String WhiteSpaceTabPage_calls_before_comma_in_method_args;
- public static String WhiteSpaceTabPage_calls_after_comma_in_method_args;
- public static String WhiteSpaceTabPage_calls_before_comma_in_alloc;
- public static String WhiteSpaceTabPage_calls_after_comma_in_alloc;
- public static String WhiteSpaceTabPage_calls_before_comma_in_qalloc;
- public static String WhiteSpaceTabPage_calls_after_comma_in_qalloc;
- public static String WhiteSpaceTabPage_statements;
- public static String WhiteSpaceTabPage_blocks;
- public static String WhiteSpaceTabPage_switch;
- public static String WhiteSpaceTabPage_switch_before_case_colon;
- public static String WhiteSpaceTabPage_switch_before_default_colon;
- public static String WhiteSpaceTabPage_do;
- public static String WhiteSpaceTabPage_try;
- public static String WhiteSpaceTabPage_if;
- public static String WhiteSpaceTabPage_for;
- public static String WhiteSpaceTabPage_for_before_comma_init;
- public static String WhiteSpaceTabPage_for_after_comma_init;
- public static String WhiteSpaceTabPage_for_before_comma_inc;
- public static String WhiteSpaceTabPage_for_after_comma_inc;
- public static String WhiteSpaceTabPage_labels;
-// public static String WhiteSpaceTabPage_annotations;
- public static String WhiteSpaceTabPage_annotation_types;
- public static String WhiteSpaceTabPage_param_type_ref;
- public static String WhiteSpaceTabPage_type_arguments;
- public static String WhiteSpaceTabPage_type_parameters;
- public static String WhiteSpaceTabPage_conditionals;
- public static String WhiteSpaceTabPage_typecasts;
- public static String WhiteSpaceTabPage_parenexpr;
- public static String WhiteSpaceTabPage_declarations;
- public static String WhiteSpaceTabPage_expressions;
- public static String WhiteSpaceTabPage_arrays;
- public static String WhiteSpaceTabPage_parameterized_types;
- public static String WhiteSpaceTabPage_after_opening_brace;
- public static String WhiteSpaceTabPage_after_closing_brace;
- public static String WhiteSpaceTabPage_before_opening_brace;
- public static String WhiteSpaceTabPage_before_closing_brace;
- public static String WhiteSpaceTabPage_between_empty_braces;
- public static String WhiteSpaceTabPage_after_opening_paren;
- public static String WhiteSpaceTabPage_after_closing_paren;
- public static String WhiteSpaceTabPage_before_opening_paren;
- public static String WhiteSpaceTabPage_before_closing_paren;
- public static String WhiteSpaceTabPage_between_empty_parens;
- public static String WhiteSpaceTabPage_after_opening_bracket;
- public static String WhiteSpaceTabPage_before_opening_bracket;
- public static String WhiteSpaceTabPage_before_closing_bracket;
- public static String WhiteSpaceTabPage_between_empty_brackets;
- public static String WhiteSpaceTabPage_before_comma_in_params;
- public static String WhiteSpaceTabPage_after_comma_in_params;
- public static String WhiteSpaceTabPage_before_comma_in_throws;
- public static String WhiteSpaceTabPage_after_comma_in_throws;
- public static String WhiteSpaceTabPage_before_ellipsis;
- public static String WhiteSpaceTabPage_after_ellipsis;
- public static String WhiteSpaceTabPage_before_comma;
- public static String WhiteSpaceTabPage_after_comma;
- public static String WhiteSpaceTabPage_after_semicolon;
- public static String WhiteSpaceTabPage_before_semicolon;
- public static String WhiteSpaceTabPage_before_colon;
- public static String WhiteSpaceTabPage_after_colon;
- public static String WhiteSpaceTabPage_before_question;
- public static String WhiteSpaceTabPage_after_question;
- public static String WhiteSpaceTabPage_after_opening_angle_bracket;
- public static String WhiteSpaceTabPage_after_closing_angle_bracket;
- public static String WhiteSpaceTabPage_before_opening_angle_bracket;
- public static String WhiteSpaceTabPage_before_closing_angle_bracket;
- public static String WhiteSpaceTabPage_before_and_list;
- public static String WhiteSpaceTabPage_after_and_list;
-// public static String WhiteSpaceTabPage_enum_decl_before_opening_brace;
-// public static String WhiteSpaceTabPage_enum_decl_before_comma;
-// public static String WhiteSpaceTabPage_enum_decl_after_comma;
-// public static String WhiteSpaceTabPage_enum_const_arg_before_opening_paren;
-// public static String WhiteSpaceTabPage_enum_const_arg_after_opening_paren;
-// public static String WhiteSpaceTabPage_enum_const_arg_between_empty_parens;
-// public static String WhiteSpaceTabPage_enum_const_arg_before_comma;
-// public static String WhiteSpaceTabPage_enum_const_arg_after_comma;
-// public static String WhiteSpaceTabPage_enum_const_arg_before_closing_paren;
-// public static String WhiteSpaceTabPage_enum_const_before_opening_brace;
- public static String WhiteSpaceTabPage_annot_type_method_before_opening_paren;
- public static String WhiteSpaceTabPage_annot_type_method_between_empty_parens;
- public static String WhiteSpaceTabPage_before_parenthesized_expressions;
- public static String WhiteSpaceTabPage_insert_space;
- public static String WhiteSpaceOptions_return;
- public static String WhiteSpaceOptions_throw;
- public static String WhiteSpaceOptions_before;
- public static String WhiteSpaceOptions_after;
- public static String WhiteSpaceOptions_operator;
- public static String WhiteSpaceOptions_assignment_operator;
- public static String WhiteSpaceOptions_binary_operator;
- public static String WhiteSpaceOptions_unary_operator;
- public static String WhiteSpaceOptions_prefix_operator;
- public static String WhiteSpaceOptions_postfix_operator;
- public static String WhiteSpaceOptions_opening_paren;
- public static String WhiteSpaceOptions_catch;
- public static String WhiteSpaceOptions_for;
- public static String WhiteSpaceOptions_if;
- public static String WhiteSpaceOptions_switch;
- public static String WhiteSpaceOptions_while;
- public static String WhiteSpaceOptions_assert;
- public static String WhiteSpaceOptions_member_function_declaration;
- public static String WhiteSpaceOptions_constructor;
- public static String WhiteSpaceOptions_method;
- public static String WhiteSpaceOptions_method_call;
- public static String WhiteSpaceOptions_paren_expr;
- public static String WhiteSpaceOptions_annotation_modifier;
- public static String WhiteSpaceOptions_annotation_modifier_args;
- public static String WhiteSpaceOptions_annotation_type_member;
- public static String WhiteSpaceOptions_annotation_type;
- public static String WhiteSpaceOptions_type_cast;
- public static String WhiteSpaceOptions_parameterized_type;
- public static String WhiteSpaceOptions_type_arguments;
- public static String WhiteSpaceOptions_type_parameters;
- public static String WhiteSpaceOptions_vararg_parameter;
- public static String WhiteSpaceOptions_closing_paren;
- public static String WhiteSpaceOptions_opening_brace;
- public static String WhiteSpaceOptions_closing_brace;
- public static String WhiteSpaceOptions_opening_bracket;
- public static String WhiteSpaceOptions_closing_bracket;
- public static String WhiteSpaceOptions_class_decl;
- public static String WhiteSpaceOptions_anon_class_decl;
- public static String WhiteSpaceOptions_initializer;
- public static String WhiteSpaceOptions_block;
- public static String WhiteSpaceOptions_array_decl;
- public static String WhiteSpaceOptions_array_element_access;
- public static String WhiteSpaceOptions_array_alloc;
- public static String WhiteSpaceOptions_array_init;
- public static String WhiteSpaceOptions_arguments;
- public static String WhiteSpaceOptions_initialization;
- public static String WhiteSpaceOptions_incrementation;
- public static String WhiteSpaceOptions_parameters;
- public static String WhiteSpaceOptions_explicit_constructor_call;
- public static String WhiteSpaceOptions_alloc_expr;
- public static String WhiteSpaceOptions_throws;
- public static String WhiteSpaceOptions_mult_decls;
- public static String WhiteSpaceOptions_local_vars;
- public static String WhiteSpaceOptions_fields;
- public static String WhiteSpaceOptions_implements_clause;
- public static String WhiteSpaceOptions_colon;
- public static String WhiteSpaceOptions_conditional;
- public static String WhiteSpaceOptions_wildcard;
- public static String WhiteSpaceOptions_label;
- public static String WhiteSpaceOptions_comma;
- public static String WhiteSpaceOptions_semicolon;
- public static String WhiteSpaceOptions_question_mark;
- public static String WhiteSpaceOptions_between_empty_parens;
- public static String WhiteSpaceOptions_between_empty_braces;
- public static String WhiteSpaceOptions_between_empty_brackets;
- public static String WhiteSpaceOptions_constructor_decl;
- public static String WhiteSpaceOptions_method_decl;
- public static String WhiteSpaceOptions_case;
- public static String WhiteSpaceOptions_default;
- public static String WhiteSpaceOptions_statements;
- public static String WhiteSpaceOptions_before_opening_paren;
- public static String WhiteSpaceOptions_after_opening_paren;
- public static String WhiteSpaceOptions_before_closing_paren;
- public static String WhiteSpaceOptions_after_closing_paren;
- public static String WhiteSpaceOptions_before_opening_brace;
- public static String WhiteSpaceOptions_after_opening_brace;
- public static String WhiteSpaceOptions_after_closing_brace;
- public static String WhiteSpaceOptions_before_closing_brace;
- public static String WhiteSpaceOptions_before_opening_bracket;
- public static String WhiteSpaceOptions_after_opening_bracket;
- public static String WhiteSpaceOptions_before_closing_bracket;
- public static String WhiteSpaceOptions_before_opening_angle_bracket;
- public static String WhiteSpaceOptions_after_opening_angle_bracket;
- public static String WhiteSpaceOptions_before_closing_angle_bracket;
- public static String WhiteSpaceOptions_after_closing_angle_bracket;
- public static String WhiteSpaceOptions_before_operator;
- public static String WhiteSpaceOptions_after_operator;
- public static String WhiteSpaceOptions_before_comma;
- public static String WhiteSpaceOptions_after_comma;
- public static String WhiteSpaceOptions_after_colon;
- public static String WhiteSpaceOptions_before_colon;
- public static String WhiteSpaceOptions_before_semicolon;
- public static String WhiteSpaceOptions_after_semicolon;
- public static String WhiteSpaceOptions_before_question_mark;
- public static String WhiteSpaceOptions_after_question_mark;
- public static String WhiteSpaceOptions_before_and;
- public static String WhiteSpaceOptions_after_and;
- public static String WhiteSpaceOptions_before_ellipsis;
- public static String WhiteSpaceOptions_after_ellipsis;
- public static String WhiteSpaceOptions_return_with_parenthesized_expression;
- public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
-
- // ===[ LineWrapping ]====================================================
- public static String LineWrappingTabPage_compact_if_else;
- public static String LineWrappingTabPage_extends_clause;
- public static String LineWrappingTabPage_enum_constant_arguments;
- public static String LineWrappingTabPage_enum_constants;
- public static String LineWrappingTabPage_implements_clause;
- public static String LineWrappingTabPage_parameters;
- public static String LineWrappingTabPage_arguments;
-// public static String LineWrappingTabPage_qualified_invocations;
-// public static String LineWrappingTabPage_throws_clause;
- public static String LineWrappingTabPage_object_allocation;
- public static String LineWrappingTabPage_qualified_object_allocation;
- public static String LineWrappingTabPage_array_init;
- public static String LineWrappingTabPage_explicit_constructor_invocations;
- public static String LineWrappingTabPage_conditionals;
- public static String LineWrappingTabPage_binary_exprs;
- public static String LineWrappingTabPage_indentation_default;
- public static String LineWrappingTabPage_indentation_on_column;
- public static String LineWrappingTabPage_indentation_by_one;
- public static String LineWrappingTabPage_class_decls;
- public static String LineWrappingTabPage_method_decls;
- public static String LineWrappingTabPage_constructor_decls;
- public static String LineWrappingTabPage_function_calls;
- public static String LineWrappingTabPage_expressions;
- public static String LineWrappingTabPage_statements;
- public static String LineWrappingTabPage_wrapping_policy_label_text;
- public static String LineWrappingTabPage_indentation_policy_label_text;
- public static String LineWrappingTabPage_force_split_checkbox_text;
- public static String LineWrappingTabPage_force_split_checkbox_multi_text;
- public static String LineWrappingTabPage_line_width_for_preview_label_text;
- public static String LineWrappingTabPage_group;
- public static String LineWrappingTabPage_multi_group;
- public static String LineWrappingTabPage_multiple_selections;
- public static String LineWrappingTabPage_occurences;
- public static String LineWrappingTabPage_splitting_do_not_split;
- public static String LineWrappingTabPage_splitting_wrap_when_necessary;
- public static String LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary;
- public static String LineWrappingTabPage_splitting_wrap_always;
- public static String LineWrappingTabPage_splitting_wrap_always_indent_all_but_first;
- public static String LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary;
- public static String LineWrappingTabPage_width_indent;
- public static String LineWrappingTabPage_width_indent_option_max_line_width;
- public static String LineWrappingTabPage_width_indent_option_default_indent_wrapped;
- public static String LineWrappingTabPage_width_indent_option_default_indent_array;
- public static String LineWrappingTabPage_width_indent_option_default_indent_objlit;
- public static String LineWrappingTabPage_error_invalid_value;
- public static String LineWrappingTabPage_assignment_alignment;
- public static String LineWrappingTabPage_binary_expression_wrap_operator;
- public static String LineWrappingTabPage_binary_expression;
- public static String LineWrappingTabPage_function_decls;
- public static String LineWrappingTabPage_object_init;
-
- public static String BlankLinesTabPage_preview_header;
- public static String BlankLinesTabPage_compilation_unit_group_title;
- public static String BlankLinesTabPage_compilation_unit_option_before_package;
- public static String BlankLinesTabPage_compilation_unit_option_after_package;
- public static String BlankLinesTabPage_compilation_unit_option_before_import;
- public static String BlankLinesTabPage_compilation_unit_option_after_import;
- public static String BlankLinesTabPage_compilation_unit_option_between_import_groups;
- public static String BlankLinesTabPage_compilation_unit_option_between_type_declarations;
-// public static String BlankLinesTabPage_class_group_title;
-// public static String BlankLinesTabPage_class_option_before_first_decl;
-// public static String BlankLinesTabPage_class_option_before_decls_of_same_kind;
-// public static String BlankLinesTabPage_class_option_before_member_class_decls;
-// public static String BlankLinesTabPage_class_option_before_field_decls;
-// public static String BlankLinesTabPage_class_option_before_method_decls;
-// public static String BlankLinesTabPage_class_option_at_beginning_of_method_body;
- public static String BlankLinesTabPage_blank_lines_group_title;
- public static String BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve;
- public static String BlankLinesTabPage_function_group_title;
- public static String BlankLinesTabPage_function_option_before_first_decl;
- public static String BlankLinesTabPage_function_option_before_decls_of_same_kind;
- public static String BlankLinesTabPage_function_option_before_field_decls;
- public static String BlankLinesTabPage_function_option_before_function_decls;
- public static String BlankLinesTabPage_function_option_at_beginning_of_function_body;
-
- public static String BracesTabPage_preview_header;
- public static String BracesTabPage_position_same_line;
- public static String BracesTabPage_position_next_line;
- public static String BracesTabPage_position_next_line_indented;
- public static String BracesTabPage_position_next_line_on_wrap;
- public static String BracesTabPage_group_brace_positions_title;
- public static String BracesTabPage_option_class_declaration;
- public static String BracesTabPage_option_anonymous_class_declaration;
- public static String BracesTabPage_option_method_declaration;
- public static String BracesTabPage_option_constructor_declaration;
- public static String BracesTabPage_option_blocks;
- public static String BracesTabPage_option_blocks_in_case;
- public static String BracesTabPage_option_switch_case;
- public static String BracesTabPage_option_array_initializer;
- public static String BracesTabPage_option_keep_empty_array_initializer_on_one_line;
- public static String BracesTabPage_option_annotation_type_declaration;
- public static String BracesTabPage_option_function_declaration;
- public static String BracesTabPage_option_object_initializer;
- public static String BracesTabPage_option_keep_empty_object_initializer_on_one_line;
-
-
- public static String CodingStyleConfigurationBlock_preview_title;
-
-
- // ===[ Comments ]========================================================
- public static String CommentsTabPage_group1_title;
- public static String commentsTabPage_enable_javadoc_comment_formatting;
- public static String CommentsTabPage_enable_line_comment_formatting;
- public static String CommentsTabPage_enable_block_comment_formatting;
- public static String CommentsTabPage_format_header;
- public static String CommentsTabPage_format_html;
- public static String CommentsTabPage_format_code_snippets;
- public static String CommentsTabPage_group2_title;
- public static String CommentsTabPage_clear_blank_lines;
- public static String CommentsTabPage_blank_line_before_javadoc_tags;
- public static String CommentsTabPage_indent_javadoc_tags;
- public static String CommentsTabPage_indent_description_after_param;
- public static String CommentsTabPage_new_line_after_param_tags;
- public static String CommentsTabPage_group3_title;
- public static String CommentsTabPage_group4_title;
- public static String CommentsTabPage_group5_title;
- public static String CommentsTabPage_line_width;
- public static String CommentsTabPage_never_indent_block_comments_on_first_column;
- public static String CommentsTabPage_never_indent_line_comments_on_first_column;
- public static String ControlStatementsTabPage_preview_header;
- public static String ControlStatementsTabPage_general_group_title;
- public static String ControlStatementsTabPage_general_group_insert_new_line_before_else_statements;
- public static String ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements;
- public static String ControlStatementsTabPage_general_group_insert_new_line_before_finally_statements;
- public static String ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements;
- public static String ControlStatementsTabPage_if_else_group_title;
- public static String ControlStatementsTabPage_if_else_group_keep_then_on_same_line;
- public static String ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line;
- public static String ControlStatementsTabPage_if_else_group_keep_else_on_same_line;
- public static String ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line;
- public static String ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line;
-
- public static String IndentationTabPage_preview_header;
- public static String IndentationTabPage_general_group_title;
- public static String IndentationTabPage_general_group_option_tab_policy;
- public static String IndentationTabPage_general_group_option_tab_policy_SPACE;
- public static String IndentationTabPage_general_group_option_tab_policy_TAB;
- public static String IndentationTabPage_general_group_option_tab_policy_MIXED;
- public static String IndentationTabPage_general_group_option_tab_size;
- public static String IndentationTabPage_general_group_option_indent_size;
- public static String IndentationTabPage_field_alignment_group_title;
- public static String IndentationTabPage_field_alignment_group_align_fields_in_columns;
- public static String IndentationTabPage_indent_group_title;
- public static String IndentationTabPage_class_group_option_indent_declarations_within_class_body;
- public static String IndentationTabPage_class_group_option_indent_declarations_within_annot_decl;
- public static String IndentationTabPage_block_group_option_indent_statements_compare_to_body;
- public static String IndentationTabPage_block_group_option_indent_statements_compare_to_block;
- public static String IndentationTabPage_switch_group_option_indent_statements_within_switch_body;
- public static String IndentationTabPage_switch_group_option_indent_statements_within_case_body;
- public static String IndentationTabPage_switch_group_option_indent_break_statements;
- public static String IndentationTabPage_indent_empty_lines;
- public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
-
- public static String ModifyDialog_tabpage_braces_title;
- public static String ModifyDialog_tabpage_indentation_title;
- public static String ModifyDialog_tabpage_whitespace_title;
- public static String ModifyDialog_tabpage_blank_lines_title;
- public static String ModifyDialog_tabpage_new_lines_title;
- public static String ModifyDialog_tabpage_control_statements_title;
- public static String ModifyDialog_tabpage_line_wrapping_title;
- public static String ModifyDialog_tabpage_comments_title;
-
- public static String NewLinesTabPage_preview_header;
- public static String NewLinesTabPage_newlines_group_title;
- public static String NewLinesTabPage_newlines_group_option_empty_class_body;
- public static String NewLinesTabPage_newlines_group_option_empty_annotation_decl_body;
- public static String NewLinesTabPage_newlines_group_option_empty_anonymous_class_body;
- public static String NewLinesTabPage_newlines_group_option_empty_method_body;
- public static String NewLinesTabPage_newlines_group_option_empty_block;
- public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;
- public static String NewLinesTabPage_empty_statement_group_title;
- public static String NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line;
- public static String NewLinesTabPage_arrayInitializer_group_title;
- public static String NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer;
- public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer;
- public static String NewLinesTabPage_annotations_group_title;
- public static String NewLinesTabPage_annotations_group_option_after_annotation;
- public static String NewLinesTabPage_newlines_group_option_empty_function_body;
- public static String NewLinesTabPage_objectInitializer_group_title;
- public static String NewLinesTabPage_object_group_option_after_opening_brace_of_object_initializer;
- public static String NewLinesTabPage_object_group_option_before_closing_brace_of_object_initializer;
- public static String NewLinesTabPage_object_group_option_after_comma_in_object_initializer;
-
- public static String ProfileManager_default_profile_name;
- public static String ProfileManager_eclipse_profile_name;
- public static String ProfileManager_java_conventions_profile_name;
-
- public static String JavaPreview_formatter_exception;
- public static String WhiteSpaceTabPage_sort_by_java_element;
- public static String WhiteSpaceTabPage_sort_by_syntax_element;
-
- public static String AlreadyExistsDialog_message_profile_already_exists;
- public static String AlreadyExistsDialog_message_profile_name_empty;
- public static String AlreadyExistsDialog_dialog_title;
- public static String AlreadyExistsDialog_dialog_label;
- public static String AlreadyExistsDialog_rename_radio_button_desc;
- public static String AlreadyExistsDialog_overwrite_radio_button_desc;
-
- public static String CodingStyleConfigurationBlock_save_profile_dialog_title;
- public static String CodingStyleConfigurationBlock_save_profile_error_title;
- public static String CodingStyleConfigurationBlock_save_profile_error_message;
- public static String CodingStyleConfigurationBlock_load_profile_dialog_title;
- public static String CodingStyleConfigurationBlock_load_profile_error_title;
- public static String CodingStyleConfigurationBlock_load_profile_error_message;
- public static String CodingStyleConfigurationBlock_load_profile_error_too_new_title;
- public static String CodingStyleConfigurationBlock_load_profile_error_too_new_message;
- public static String CodingStyleConfigurationBlock_save_profile_overwrite_title;
- public static String CodingStyleConfigurationBlock_save_profile_overwrite_message;
- public static String CodingStyleConfigurationBlock_edit_button_desc;
- public static String CodingStyleConfigurationBlock_remove_button_desc;
- public static String CodingStyleConfigurationBlock_new_button_desc;
- public static String CodingStyleConfigurationBlock_load_button_desc;
- public static String CodingStyleConfigurationBlock_save_button_desc;
- public static String CodingStyleConfigurationBlock_preview_label_text;
- public static String CodingStyleConfigurationBlock_error_reading_xml_message;
- public static String CodingStyleConfigurationBlock_error_serializing_xml_message;
- public static String CodingStyleConfigurationBlock_delete_confirmation_title;
- public static String CodingStyleConfigurationBlock_delete_confirmation_question;
-
- public static String CreateProfileDialog_status_message_profile_with_this_name_already_exists;
- public static String CreateProfileDialog_status_message_profile_name_is_empty;
- public static String CreateProfileDialog_dialog_title;
- public static String CreateProfileDialog_profile_name_label_text;
- public static String CreateProfileDialog_base_profile_label_text;
- public static String CreateProfileDialog_open_edit_dialog_checkbox_text;
-
- public static String ModifyDialog_dialog_title;
- public static String ModifyDialog_apply_button;
- public static String ModifyDialogTabPage_preview_label_text;
-
- public static String ProfileManager_unmanaged_profile;
- public static String ProfileManager_unmanaged_profile_with_name;
-
- public static String ModifyDialogTabPage_error_msg_values_text_unassigned;
- public static String ModifyDialogTabPage_error_msg_values_items_text_unassigned;
- public static String ModifyDialogTabPage_NumberPreference_error_invalid_key;
- public static String ModifyDialogTabPage_NumberPreference_error_invalid_value;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, FormatterMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.properties
deleted file mode 100644
index cd589614..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterMessages.properties
+++ /dev/null
@@ -1,554 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# istvan@benedek-home.de - 103706 [formatter] indent empty lines
-# Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
-###############################################################################
-
-
-WhiteSpaceTabPage_assignments=Assignments
-WhiteSpaceTabPage_assignments_before_assignment_operator=before assignment operator
-WhiteSpaceTabPage_assignments_after_assignment_operator=after assignment operator
-
-WhiteSpaceTabPage_operators=Operators
-WhiteSpaceTabPage_operators_before_binary_operators=before binary operators
-WhiteSpaceTabPage_operators_after_binary_operators=after binary operators
-WhiteSpaceTabPage_operators_before_unary_operators=before unary operators
-WhiteSpaceTabPage_operators_after_unary_operators=after unary operators
-WhiteSpaceTabPage_operators_before_prefix_operators=before prefix operators
-WhiteSpaceTabPage_operators_after_prefix_operators=after prefix operators
-WhiteSpaceTabPage_operators_before_postfix_operators=before postfix operators
-WhiteSpaceTabPage_operators_after_postfix_operators=after postfix operators
-
-#WhiteSpaceTabPage_classes=Classes
-#WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
-#WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class=before opening brace of an anonymous class
-#WhiteSpaceTabPage_classes_before_comma_implements=before comma in implements clause
-#WhiteSpaceTabPage_classes_after_comma_implements=after comma in implements clause
-
-WhiteSpaceTabPage_methods=Functions
-WhiteSpaceTabPage_constructors=Constructors
-
-WhiteSpaceTabPage_fields=Vars
-WhiteSpaceTabPage_fields_before_comma=before comma in multiple var declarations
-WhiteSpaceTabPage_fields_after_comma=after comma in multiple var declarations
-
-WhiteSpaceTabPage_localvars=Local variables
-WhiteSpaceTabPage_localvars_before_comma=before comma in multiple local declarations
-WhiteSpaceTabPage_localvars_after_comma=after comma in multiple local declarations
-
-WhiteSpaceTabPage_arrayinit=Array initializers
-WhiteSpaceTabPage_arraydecls=Array declarations
-WhiteSpaceTabPage_arrayelem=Array element access
-WhiteSpaceTabPage_arrayalloc=Array allocation
-
-WhiteSpaceTabPage_calls=Function invocations
-
-WhiteSpaceTabPage_calls_before_comma_in_method_args=before comma in function arguments
-WhiteSpaceTabPage_calls_after_comma_in_method_args=after comma in function arguments
-WhiteSpaceTabPage_calls_before_comma_in_alloc=before comma in object allocation arguments
-WhiteSpaceTabPage_calls_after_comma_in_alloc=after comma in object allocation arguments
-WhiteSpaceTabPage_calls_before_comma_in_qalloc=before comma in explicit constructor call
-WhiteSpaceTabPage_calls_after_comma_in_qalloc=after comma in explicit constructor call
-
-WhiteSpaceTabPage_statements=Control statements
-
-WhiteSpaceTabPage_blocks=Blocks
-
-WhiteSpaceTabPage_switch='switch'
-WhiteSpaceTabPage_switch_before_case_colon=before colon in case
-WhiteSpaceTabPage_switch_before_default_colon=before colon in default
-
-WhiteSpaceTabPage_do='while' & 'do while'
-
-
-WhiteSpaceTabPage_try='catch'
-
-WhiteSpaceTabPage_if='if else'
-
-WhiteSpaceTabPage_for='for'
-WhiteSpaceTabPage_for_before_comma_init=before comma in initialization
-WhiteSpaceTabPage_for_after_comma_init=after comma in initialization
-WhiteSpaceTabPage_for_before_comma_inc=before comma in increments
-WhiteSpaceTabPage_for_after_comma_inc=after comma in increments
-
-
-WhiteSpaceTabPage_labels=Labels
-#WhiteSpaceTabPage_annotations=Annotations
-WhiteSpaceTabPage_annotation_types=Annotation types
-WhiteSpaceTabPage_param_type_ref=Type reference
-WhiteSpaceTabPage_type_arguments=Type arguments
-WhiteSpaceTabPage_type_parameters=Type parameters
-
-WhiteSpaceTabPage_conditionals=Conditionals
-
-WhiteSpaceTabPage_typecasts=Type casts
-
-WhiteSpaceTabPage_parenexpr=Parenthesized expressions
-WhiteSpaceTabPage_declarations=Declarations
-WhiteSpaceTabPage_expressions=Expressions
-WhiteSpaceTabPage_arrays=Arrays
-WhiteSpaceTabPage_parameterized_types=Parameterized types
-
-WhiteSpaceTabPage_after_opening_brace=after opening brace
-WhiteSpaceTabPage_after_closing_brace=after closing brace
-WhiteSpaceTabPage_before_opening_brace=before opening brace
-WhiteSpaceTabPage_before_closing_brace=before closing brace
-WhiteSpaceTabPage_between_empty_braces=between empty braces
-
-
-WhiteSpaceTabPage_after_opening_paren=after opening parenthesis
-WhiteSpaceTabPage_after_closing_paren=after closing parenthesis
-WhiteSpaceTabPage_before_opening_paren=before opening parenthesis
-WhiteSpaceTabPage_before_closing_paren=before closing parenthesis
-WhiteSpaceTabPage_between_empty_parens=between empty parenthesis
-
-WhiteSpaceTabPage_after_opening_bracket=after opening bracket
-WhiteSpaceTabPage_before_opening_bracket=before opening bracket
-WhiteSpaceTabPage_before_closing_bracket=before closing bracket
-WhiteSpaceTabPage_between_empty_brackets=between empty brackets
-
-WhiteSpaceTabPage_before_comma_in_params=before comma in parameters
-WhiteSpaceTabPage_after_comma_in_params=after comma in parameters
-WhiteSpaceTabPage_before_comma_in_throws=before comma in 'throws' clause
-WhiteSpaceTabPage_after_comma_in_throws=after comma in 'throws' clause
-
-WhiteSpaceTabPage_before_ellipsis=before ellipsis in vararg parameters
-WhiteSpaceTabPage_after_ellipsis=after ellipsis in vararg parameters
-
-WhiteSpaceTabPage_before_comma=before comma
-WhiteSpaceTabPage_after_comma=after comma
-
-WhiteSpaceTabPage_after_semicolon=after semicolon
-WhiteSpaceTabPage_before_semicolon=before semicolon
-
-WhiteSpaceTabPage_before_colon=before colon
-WhiteSpaceTabPage_after_colon=after colon
-
-WhiteSpaceTabPage_before_question=before question mark
-WhiteSpaceTabPage_after_question=after question mark
-
-
-WhiteSpaceTabPage_after_opening_angle_bracket=after opening angle bracket
-WhiteSpaceTabPage_after_closing_angle_bracket=after closing angle bracket
-WhiteSpaceTabPage_before_opening_angle_bracket=before opening angle bracket
-WhiteSpaceTabPage_before_closing_angle_bracket=before closing angle bracket
-WhiteSpaceTabPage_before_parenthesized_expressions=before parenthesized expressions
-
-WhiteSpaceTabPage_before_and_list=before '&' in type bounds
-WhiteSpaceTabPage_after_and_list=after '&' in type bounds
-
-#WhiteSpaceTabPage_enum_decl_before_opening_brace=before opening brace in declaration
-#WhiteSpaceTabPage_enum_decl_before_comma=before comma between constants
-#WhiteSpaceTabPage_enum_decl_after_comma=after comma between constants
-#WhiteSpaceTabPage_enum_const_arg_before_opening_paren=before opening parenthesis in constant arguments
-#WhiteSpaceTabPage_enum_const_arg_after_opening_paren=after opening parenthesis in constant arguments
-#WhiteSpaceTabPage_enum_const_arg_between_empty_parens=between empty parenthesis in constant arguments
-#WhiteSpaceTabPage_enum_const_arg_before_comma=before comma in constant arguments
-#WhiteSpaceTabPage_enum_const_arg_after_comma=after comma in constant arguments
-#WhiteSpaceTabPage_enum_const_arg_before_closing_paren=before closing parenthesis in constant arguments
-#WhiteSpaceTabPage_enum_const_before_opening_brace=before opening brace of constant body
-
-WhiteSpaceTabPage_annot_type_method_before_opening_paren=before opening parenthesis in annotation type members
-WhiteSpaceTabPage_annot_type_method_between_empty_parens=between parenthesis in annotation type members
-
-
-WhiteSpaceOptions_before=Before
-WhiteSpaceOptions_after=After
-
-WhiteSpaceOptions_operator=Operator
-WhiteSpaceOptions_assignment_operator=Assignment operator
-WhiteSpaceOptions_binary_operator=Binary operator
-WhiteSpaceOptions_unary_operator=Unary operator
-WhiteSpaceOptions_prefix_operator=Prefix operator
-WhiteSpaceOptions_postfix_operator=Postfix operator
-
-
-WhiteSpaceOptions_opening_paren=Opening parenthesis
-WhiteSpaceOptions_catch='catch'
-WhiteSpaceOptions_for='for'
-WhiteSpaceOptions_if='if'
-WhiteSpaceOptions_switch='switch'
-WhiteSpaceOptions_while='while'
-WhiteSpaceOptions_assert='assert'
-WhiteSpaceOptions_member_function_declaration=Member function declaration
-WhiteSpaceOptions_constructor=Constructor
-WhiteSpaceOptions_method=Function
-WhiteSpaceOptions_method_call=Function call
-WhiteSpaceOptions_paren_expr=Parenthesized expression
-WhiteSpaceOptions_annotation_modifier=Annotation
-WhiteSpaceOptions_annotation_modifier_args=Annotation arguments
-WhiteSpaceOptions_annotation_type_member=Annotation type member
-WhiteSpaceOptions_annotation_type=Annotation type
-
-WhiteSpaceOptions_type_cast=Type cast
-WhiteSpaceOptions_parameterized_type=Parameterized type
-WhiteSpaceOptions_type_arguments=Type arguments
-WhiteSpaceOptions_type_parameters=Type parameters
-WhiteSpaceOptions_vararg_parameter=Vararg parameters
-
-WhiteSpaceOptions_closing_paren=Closing parenthesis
-
-WhiteSpaceOptions_opening_brace=Opening brace
-WhiteSpaceOptions_closing_brace=Closing brace
-WhiteSpaceOptions_opening_bracket=Opening bracket
-WhiteSpaceOptions_closing_bracket=Closing bracket
-WhiteSpaceOptions_class_decl=Type declaration
-WhiteSpaceOptions_anon_class_decl=Anonymous type declaration
-WhiteSpaceOptions_initializer=Array initializer
-WhiteSpaceOptions_block=Block
-
-WhiteSpaceOptions_array_decl=Array declaration
-WhiteSpaceOptions_array_element_access=Array element access
-WhiteSpaceOptions_array_alloc=Array allocation
-WhiteSpaceOptions_array_init=Array initializer
-
-WhiteSpaceOptions_arguments=Arguments
-WhiteSpaceOptions_initialization=Initialization
-WhiteSpaceOptions_incrementation=Increment
-WhiteSpaceOptions_parameters=Parameters
-
-WhiteSpaceOptions_explicit_constructor_call=Explicit constructor call
-WhiteSpaceOptions_alloc_expr=Allocation expression
-WhiteSpaceOptions_throws='throws' clause
-WhiteSpaceOptions_mult_decls=Multiple declarations
-WhiteSpaceOptions_local_vars=Local variables
-WhiteSpaceOptions_fields=Fields
-WhiteSpaceOptions_return='return'
-WhiteSpaceOptions_throw='throw'
-WhiteSpaceOptions_implements_clause='extends'/'implements' clause
-WhiteSpaceOptions_colon=Colon
-WhiteSpaceOptions_conditional=Conditional
-WhiteSpaceOptions_wildcard=Wildcard type
-WhiteSpaceOptions_label=Label
-WhiteSpaceOptions_comma=Comma
-
-WhiteSpaceOptions_semicolon=Semicolon
-WhiteSpaceOptions_question_mark=Question mark
-WhiteSpaceOptions_between_empty_parens=Between empty parenthesis
-WhiteSpaceOptions_between_empty_braces=Between empty braces
-WhiteSpaceOptions_between_empty_brackets=Between empty brackets
-WhiteSpaceOptions_constructor_decl=Constructor declaration
-WhiteSpaceOptions_method_decl=Function declaration
-WhiteSpaceOptions_case='case'
-WhiteSpaceOptions_default='default'
-WhiteSpaceOptions_statements=Statements
-
-
-
-WhiteSpaceOptions_before_opening_paren=Before opening parenthesis
-WhiteSpaceOptions_after_opening_paren=After opening parenthesis
-WhiteSpaceOptions_before_closing_paren=Before closing parenthesis
-
-WhiteSpaceOptions_after_closing_paren=After closing parenthesis
-WhiteSpaceOptions_before_opening_brace=Before opening brace
-WhiteSpaceOptions_after_opening_brace=After opening brace
-WhiteSpaceOptions_after_closing_brace=After closing brace
-WhiteSpaceOptions_before_closing_brace=Before closing brace
-WhiteSpaceOptions_before_opening_bracket=Before opening bracket
-WhiteSpaceOptions_after_opening_bracket=After opening bracket
-WhiteSpaceOptions_before_closing_bracket=Before closing bracket
-
-WhiteSpaceOptions_before_opening_angle_bracket=Before opening angle bracket
-WhiteSpaceOptions_after_opening_angle_bracket=After opening angle bracket
-WhiteSpaceOptions_before_closing_angle_bracket=Before closing angle bracket
-WhiteSpaceOptions_return_with_parenthesized_expression='return' with parenthesized expression
-WhiteSpaceOptions_throw_with_parenthesized_expression='throws' with parenthesized expression
-WhiteSpaceOptions_after_closing_angle_bracket=After closing angle bracket
-
-WhiteSpaceOptions_before_operator=Before operator
-WhiteSpaceOptions_after_operator=After operator
-WhiteSpaceOptions_before_comma=Before comma
-WhiteSpaceOptions_after_comma=After comma
-WhiteSpaceOptions_after_colon=After colon
-WhiteSpaceOptions_before_colon=Before colon
-WhiteSpaceOptions_before_semicolon=Before semicolon
-WhiteSpaceOptions_after_semicolon=After semicolon
-WhiteSpaceOptions_before_question_mark=Before question mark
-WhiteSpaceOptions_after_question_mark=After question mark
-
-WhiteSpaceOptions_before_and=Before & list
-WhiteSpaceOptions_after_and=After & list
-
-WhiteSpaceOptions_before_ellipsis=Before Ellipsis
-WhiteSpaceOptions_after_ellipsis=After Ellipsis
-
-WhiteSpaceTabPage_insert_space=&Insert space:
-
-
-#===[ LineWrapping ]==========================================================
-LineWrappingTabPage_compact_if_else=Compact 'if else'
-LineWrappingTabPage_extends_clause='extends' clause
-LineWrappingTabPage_enum_constant_arguments=Constant arguments
-LineWrappingTabPage_enum_constants=Constants
-LineWrappingTabPage_implements_clause='implements' clause
-LineWrappingTabPage_parameters=Parameters
-LineWrappingTabPage_arguments=Arguments
-#LineWrappingTabPage_qualified_invocations=Qualified invocations
-#LineWrappingTabPage_throws_clause='throws' clause
-LineWrappingTabPage_object_allocation=Object allocation arguments
-LineWrappingTabPage_qualified_object_allocation=Qualified object allocation arguments
-LineWrappingTabPage_array_init=Array initializers
-LineWrappingTabPage_explicit_constructor_invocations=Explicit constructor invocations
-LineWrappingTabPage_conditionals=Conditionals
-LineWrappingTabPage_binary_exprs=Binary expressions
-LineWrappingTabPage_indentation_default=Default indentation
-LineWrappingTabPage_indentation_on_column=Indent on column
-LineWrappingTabPage_indentation_by_one=Indent by one
-LineWrappingTabPage_class_decls=Class Declarations
-LineWrappingTabPage_method_decls=Function Declarations
-LineWrappingTabPage_constructor_decls=Constructor declarations
-LineWrappingTabPage_function_calls=Function Calls
-LineWrappingTabPage_expressions=Expressions
-LineWrappingTabPage_statements=Statements
-LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy:
-LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy:
-LineWrappingTabPage_force_split_checkbox_text=&Force split
-LineWrappingTabPage_force_split_checkbox_multi_text=&Force split
-LineWrappingTabPage_line_width_for_preview_label_text=&Set line width for preview window:
-LineWrappingTabPage_group=Settings for {0}
-LineWrappingTabPage_multi_group=Settings for {0} ({1} items)
-LineWrappingTabPage_multiple_selections=Settings for multiple selections ({0} items)
-LineWrappingTabPage_occurences={0} ({1} of {2})
-LineWrappingTabPage_splitting_do_not_split=Do not wrap
-LineWrappingTabPage_splitting_wrap_when_necessary=Wrap only when necessary
-LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary=Always wrap first element, others when necessary
-LineWrappingTabPage_splitting_wrap_always=Wrap all elements, every element on a new line
-LineWrappingTabPage_splitting_wrap_always_indent_all_but_first=Wrap all elements, indent all but the first element
-LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary=Wrap all elements, except first element if not necessary
-LineWrappingTabPage_width_indent=Line width and indentation levels
-LineWrappingTabPage_width_indent_option_max_line_width=Ma&ximum line width:
-LineWrappingTabPage_width_indent_option_default_indent_wrapped=Defa&ult indentation for wrapped lines:
-LineWrappingTabPage_width_indent_option_default_indent_array=Default indentation for arra&y initializers:
-LineWrappingTabPage_width_indent_option_default_indent_objlit=Default indentation for object literal initializers:
-LineWrappingTabPage_error_invalid_value=The key ''{0}'' contained an invalid value; resetting to defaults.
-LineWrappingTabPage_assignment_alignment=Assignments
-LineWrappingTabPage_function_decls=Function Declarations
-LineWrappingTabPage_object_init=Object initializers
-
-LineWrappingTabPage_binary_expression = Binary Expression settings
-LineWrappingTabPage_binary_expression_wrap_operator=Wrap &before operator
-
-#===[ BlankLines ]=========================================================
-BlankLinesTabPage_preview_header=Blank Lines
-BlankLinesTabPage_compilation_unit_group_title=Blank lines in JavaScript file
-BlankLinesTabPage_compilation_unit_option_before_package=Before p&ackage declaration:
-BlankLinesTabPage_compilation_unit_option_after_package=After packa&ge declaration:
-BlankLinesTabPage_compilation_unit_option_before_import=&Before import declaration:
-BlankLinesTabPage_compilation_unit_option_after_import=After import de&claration:
-BlankLinesTabPage_compilation_unit_option_between_import_groups=Between i&mport groups:
-BlankLinesTabPage_compilation_unit_option_between_type_declarations=Between class declarat&ions:
-#BlankLinesTabPage_class_group_title=Blank lines within class declarations
-#BlankLinesTabPage_class_option_before_first_decl=Before &first declaration:
-#BlankLinesTabPage_class_option_before_decls_of_same_kind=Before declarations of the same &kind:
-#BlankLinesTabPage_class_option_before_member_class_decls=Before member cla&ss declarations:
-#BlankLinesTabPage_class_option_before_field_decls=B&efore field declarations:
-#BlankLinesTabPage_class_option_before_method_decls=Before &function declarations:
-#BlankLinesTabPage_class_option_at_beginning_of_method_body= At beginning of function bod&y:
-BlankLinesTabPage_function_group_title=Blank lines within function declarations
-BlankLinesTabPage_function_option_before_first_decl=Before &first declaration:
-BlankLinesTabPage_function_option_before_decls_of_same_kind=Before declarations of the same &kind:
-BlankLinesTabPage_function_option_before_field_decls=B&efore field declarations:
-BlankLinesTabPage_function_option_before_function_decls=Before &function declarations:
-BlankLinesTabPage_function_option_at_beginning_of_function_body= At beginning of function bod&y:
-#BlankLinesTabPage_function_option_before_member_class_decls=Before member cla&ss declarations:
-BlankLinesTabPage_blank_lines_group_title=Existing blank lines
-BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve=N&umber of empty lines to preserve:
-
-BracesTabPage_preview_header=Braces
-BracesTabPage_position_same_line=Same line
-BracesTabPage_position_next_line=Next line
-BracesTabPage_position_next_line_indented=Next line indented
-BracesTabPage_position_next_line_on_wrap=Next line on wrap
-
-BracesTabPage_group_brace_positions_title=Brace positions
-BracesTabPage_option_class_declaration=&Class or interface declaration:
-BracesTabPage_option_anonymous_class_declaration=Anon&ymous class declaration:
-BracesTabPage_option_method_declaration=&Function declaration:
-BracesTabPage_option_constructor_declaration=Constr&uctor declaration:
-BracesTabPage_option_blocks=&Blocks:
-BracesTabPage_option_blocks_in_case=Bloc&ks in case statement:
-BracesTabPage_option_switch_case='&switch' statement:
-BracesTabPage_option_array_initializer=Array initiali&zer:
-BracesTabPage_option_keep_empty_array_initializer_on_one_line=Keep empty array &initializer on one line
-BracesTabPage_option_annotation_type_declaration=&Annotation type declaration:
-BracesTabPage_option_function_declaration=Fu&nction declaration:
-BracesTabPage_option_object_initializer=Object initiali&zer:
-BracesTabPage_option_keep_empty_object_initializer_on_one_line=Keep empty object &initializer on one line
-
-CodingStyleConfigurationBlock_preview_title=A sample source file for the code formatter preview
-
-#===[ Comments ]==============================================================
-CommentsTabPage_group1_title=General settings
-commentsTabPage_enable_javadoc_comment_formatting=Enable &Jsdoc comment formatting
-CommentsTabPage_enable_line_comment_formatting=Enable line &comment formatting
-CommentsTabPage_enable_block_comment_formatting=Enable &block comment formatting
-CommentsTabPage_remove_blank_block_comment_lines=Rem&ove blank lines
-CommentsTabPage_format_header=Enable &header comment formatting
-CommentsTabPage_format_html=Format HTML ta&gs
-CommentsTabPage_format_code_snippets=Format &JavaScript code snippets inside 'pre' tags
-
-CommentsTabPage_group2_title=Jsdoc comment settings
-CommentsTabPage_clear_blank_lines=Remove blank l&ines
-CommentsTabPage_blank_line_before_javadoc_tags=Blan&k line before Jsdoc tags
-CommentsTabPage_indent_javadoc_tags=Indent Jsdoc tag&s
-CommentsTabPage_indent_description_after_param=Indent description a&fter @param
-CommentsTabPage_new_line_after_param_tags=New line &after @param tags
-CommentsTabPage_group3_title=Line width
-CommentsTabPage_line_width=Ma&ximum line width for comments:
-
-CommentsTabPage_group4_title=Block comment settings
-
-CommentsTabPage_group5_title=Indentation settings
-CommentsTabPage_never_indent_block_comments_on_first_column=Never indent &block comments on first column
-CommentsTabPage_never_indent_line_comments_on_first_column=Never indent line &comments on first column
-ControlStatementsTabPage_preview_header=If...else
-ControlStatementsTabPage_general_group_title=General
-ControlStatementsTabPage_general_group_insert_new_line_before_else_statements=Insert new line before '&else' in an 'if' statement
-ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements=Insert new line before '&catch' in a 'try' statement
-ControlStatementsTabPage_general_group_insert_new_line_before_finally_statements=Insert new line before '&finally' in a 'try' statement
-ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements=Insert new line before 'w&hile' in a 'do' statement
-
-ControlStatementsTabPage_if_else_group_title='if else'
-ControlStatementsTabPage_if_else_group_keep_then_on_same_line=Keep 'then' statement &on same line
-ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line=Keep &simple 'if' on one line
-ControlStatementsTabPage_if_else_group_keep_else_on_same_line=Keep 'else' st&atement on same line
-ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line=&Keep 'else if' on one line
-ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line=Keep 'return' or 'throw' cla&use on one line
-
-IndentationTabPage_preview_header=Indentation
-
-IndentationTabPage_general_group_title=General settings
-IndentationTabPage_general_group_option_tab_policy=Tab polic&y:
-IndentationTabPage_general_group_option_tab_policy_SPACE=Spaces only
-IndentationTabPage_general_group_option_tab_policy_TAB=Tabs only
-IndentationTabPage_general_group_option_tab_policy_MIXED=Mixed
-IndentationTabPage_general_group_option_tab_size=Tab &size:
-IndentationTabPage_general_group_option_indent_size=&Indentation size:
-
-IndentationTabPage_field_alignment_group_title=Alignment of fields in class declarations
-IndentationTabPage_field_alignment_group_align_fields_in_columns=&Align fields in columns
-
-IndentationTabPage_indent_group_title=Indent
-
-IndentationTabPage_class_group_option_indent_declarations_within_class_body=Declarations within class &body
-IndentationTabPage_class_group_option_indent_declarations_within_annot_decl=Declarations within annotation declaration
-IndentationTabPage_block_group_option_indent_statements_compare_to_body=Stat&ements within function body
-IndentationTabPage_block_group_option_indent_statements_compare_to_block=Statements within bl&ocks
-IndentationTabPage_indent_empty_lines=Empty lines
-
-IndentationTabPage_switch_group_option_indent_statements_within_switch_body=Statements wit&hin 'switch' body
-IndentationTabPage_switch_group_option_indent_statements_within_case_body=Statements within 'case' bo&dy
-IndentationTabPage_switch_group_option_indent_break_statements='brea&k' statements
-
-IndentationTabPage_use_tabs_only_for_leading_indentations=Use tabs only for leading indentations
-
-ModifyDialog_tabpage_braces_title=B&races
-ModifyDialog_ProfileName_Label=&Profile name:
-ModifyDialog_NewCreated_Status=A new profile will be created.
-ModifyDialog_tabpage_indentation_title=In&dentation
-ModifyDialog_tabpage_whitespace_title=&White Space
-ModifyDialog_tabpage_blank_lines_title=Bla&nk Lines
-ModifyDialog_tabpage_new_lines_title=New &Lines
-ModifyDialog_tabpage_control_statements_title=Con&trol Statements
-ModifyDialog_tabpage_line_wrapping_title=Line Wra&pping
-ModifyDialog_tabpage_comments_title=Co&mments
-
-NewLinesTabPage_preview_header=New Lines
-NewLinesTabPage_newlines_group_title=Insert new line
-
-#===[ NewLines ]=========================================================
-NewLinesTabPage_newlines_group_option_empty_class_body=in empty &class body
-NewLinesTabPage_newlines_group_option_empty_annotation_decl_body=in empty annotation body
-NewLinesTabPage_newlines_group_option_empty_anonymous_class_body=in empty &anonymous class body
-NewLinesTabPage_newlines_group_option_empty_method_body=in empt&y function body
-NewLinesTabPage_newlines_group_option_empty_block=in empty &block
-NewLinesTabPage_newlines_group_option_empty_end_of_file=at end of &file
-NewLinesTabPage_empty_statement_group_title=Empty statements
-NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line=Put empty &statement on new line
-NewLinesTabPage_newlines_group_option_empty_function_body=in empt&y function body
-NewLinesTabPage_objectInitializer_group_title=Object initializers
-NewLinesTabPage_object_group_option_after_opening_brace_of_object_initializer=Insert new line after openin&g brace of object initializer
-NewLinesTabPage_object_group_option_before_closing_brace_of_object_initializer=Insert new line before closing brace of object initiali&zer
-NewLinesTabPage_object_group_option_after_comma_in_object_initializer=Insert new line after comma in object initializer
-
-NewLinesTabPage_arrayInitializer_group_title=Array initializers
-NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer=Insert new line after openin&g brace of array initializer
-NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer=Insert new line before closing brace of array initiali&zer
-
-NewLinesTabPage_annotations_group_title=Annotations
-NewLinesTabPage_annotations_group_option_after_annotation=&Insert new line after annotations
-
-#===[ ProfileManager ]===================================================
-ProfileManager_default_profile_name=Eclipse 2.1 [built-in]
-ProfileManager_eclipse_profile_name=Eclipse [built-in]
-ProfileManager_java_conventions_profile_name=Java Conventions [built-in]
-
-JavaPreview_formatter_exception=The formatter threw an unhandled exception while formatting the preview.
-WhiteSpaceTabPage_sort_by_java_element=Sort options by Java element
-WhiteSpaceTabPage_sort_by_syntax_element=Sort options by Syntax element
-
-
-AlreadyExistsDialog_message_profile_already_exists=A profile with this name already exists.
-AlreadyExistsDialog_message_profile_name_empty=Profile name is empty
-AlreadyExistsDialog_dialog_title=Load Profile
-AlreadyExistsDialog_dialog_label=A profile with the name ''{0}'' already exists in this workspace. What would you like to do?
-AlreadyExistsDialog_rename_radio_button_desc=&Rename the imported profile:
-AlreadyExistsDialog_overwrite_radio_button_desc=&Overwrite the existing profile
-
-CodingStyleConfigurationBlock_save_profile_dialog_title=Export Profile
-CodingStyleConfigurationBlock_save_profile_error_title=Export Profile
-CodingStyleConfigurationBlock_save_profile_error_message=Could not export the profiles.
-CodingStyleConfigurationBlock_load_profile_dialog_title=Import Profile
-CodingStyleConfigurationBlock_load_profile_error_title=Import Profile
-CodingStyleConfigurationBlock_load_profile_error_message=Import failed. Not a valid profile.
-CodingStyleConfigurationBlock_load_profile_error_too_new_title=Importing Profile
-CodingStyleConfigurationBlock_load_profile_error_too_new_message=This profile has been created with \
-a more recent Eclipse build than the one you are using. Some older settings might be reset to their \
-default values and newer settings are ignored. Please note \
-that upgrading profiles from older to newer builds is fully supported.
-CodingStyleConfigurationBlock_save_profile_overwrite_title=Export Profile
-CodingStyleConfigurationBlock_save_profile_overwrite_message=The file ''{0}'' already exists.\nDo you want to replace it?
-CodingStyleConfigurationBlock_edit_button_desc=&Edit...
-CodingStyleConfigurationBlock_remove_button_desc=&Remove
-CodingStyleConfigurationBlock_new_button_desc=Ne&w...
-CodingStyleConfigurationBlock_load_button_desc=I&mport...
-CodingStyleConfigurationBlock_save_button_desc=E&xport...
-CodingStyleConfigurationBlock_preview_label_text=Prev&iew:
-CodingStyleConfigurationBlock_error_reading_xml_message=Problems reading profiles from XML
-CodingStyleConfigurationBlock_error_serializing_xml_message=Problems serializing the profiles to XML
-CodingStyleConfigurationBlock_delete_confirmation_title=Confirm Remove
-CodingStyleConfigurationBlock_delete_confirmation_question=Are you sure you want to remove profile ''{0}''?
-
-CreateProfileDialog_status_message_profile_with_this_name_already_exists=A profile with this name already exists.
-CreateProfileDialog_status_message_profile_name_is_empty=Profile name is empty
-CreateProfileDialog_dialog_title=New Profile
-CreateProfileDialog_profile_name_label_text=&Profile name:
-CreateProfileDialog_base_profile_label_text=I&nitialize settings with the following profile:
-CreateProfileDialog_open_edit_dialog_checkbox_text=&Open the edit dialog now
-
-ModifyDialog_dialog_title=Profile ''{0}''
-ModifyDialog_apply_button=Apply
-ModifyDialog_Export_Button=&Export...
-ModifyDialog_Duplicate_Status=A profile with this name already exists.
-ModifyDialog_BuiltIn_Status=This is a built-in profile, change the name to create a new profile.
-ModifyDialog_Shared_Status=This is a shared profile, change the name to create a new profile.
-ModifyDialog_EmptyName_Status=Profile name is empty.
-ModifyDialogTabPage_preview_label_text=Pre&view:
-
-ProfileManager_unmanaged_profile=Unmanaged profile
-ProfileManager_unmanaged_profile_with_name=Unmanaged profile ''{0}''
-
-ModifyDialogTabPage_error_msg_values_text_unassigned=Values and text must be assigned.
-ModifyDialogTabPage_error_msg_values_items_text_unassigned=Values, items and text must be assigned.
-
-ModifyDialogTabPage_NumberPreference_error_invalid_key=The key {0} does not yield a valid integer value.
-ModifyDialogTabPage_NumberPreference_error_invalid_value=Invalid value: Please enter a number between {0} and {1}.
-ProfileConfigurationBlock_load_profile_wrong_profile_message=Import failed. This is not a valid profile: Expected ''{0}'' but encountered ''{1}''.
-FormatterTabPage_ShowInvisibleCharacters_label=Show &invisible characters
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterModifyDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
deleted file mode 100644
index fd4195b1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-
-public class FormatterModifyDialog extends ModifyDialog {
-
- public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
- super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey);
- }
-
- protected void addPages(Map values) {
- addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, values));
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileManager.java
deleted file mode 100644
index 4d0faed4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileManager.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class FormatterProfileManager extends ProfileManager {
-
- public final static String ECLIPSE21_PROFILE= "org.eclipse.wst.jsdt.ui.default_profile"; //$NON-NLS-1$
- public final static String ECLIPSE_PROFILE= "org.eclipse.wst.jsdt.ui.default.eclipse_profile"; //$NON-NLS-1$
- public final static String JAVA_PROFILE= "org.eclipse.wst.jsdt.ui.default.sun_profile"; //$NON-NLS-1$
-
- public final static String DEFAULT_PROFILE= ECLIPSE_PROFILE;
-
- private final static KeySet[] KEY_SETS= new KeySet[] {
- new KeySet(JavaScriptCore.PLUGIN_ID, new ArrayList(DefaultCodeFormatterConstants.getJavaConventionsSettings().keySet())),
- new KeySet(JavaScriptUI.ID_PLUGIN, Collections.EMPTY_LIST)
- };
-
- private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
- private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version"; //$NON-NLS-1$
-
- public FormatterProfileManager(List profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
- super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS, PROFILE_KEY, FORMATTER_SETTINGS_VERSION);
- }
-
- private static List addBuiltinProfiles(List profiles, IProfileVersioner profileVersioner) {
- final Profile javaProfile= new BuiltInProfile(JAVA_PROFILE, FormatterMessages.ProfileManager_java_conventions_profile_name, getJavaSettings(), 1, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
- profiles.add(javaProfile);
-
- final Profile eclipseProfile= new BuiltInProfile(ECLIPSE_PROFILE, FormatterMessages.ProfileManager_eclipse_profile_name, getEclipseSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
- profiles.add(eclipseProfile);
-
- final Profile eclipse21Profile= new BuiltInProfile(ECLIPSE21_PROFILE, FormatterMessages.ProfileManager_default_profile_name, getEclipse21Settings(), 3, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
- profiles.add(eclipse21Profile);
- return profiles;
- }
-
-
- /**
- * @return Returns the settings for the default profile.
- */
- public static Map getEclipse21Settings() {
- final Map options= DefaultCodeFormatterConstants.getEclipse21Settings();
-
- ProfileVersioner.setLatestCompliance(options);
- return options;
- }
-
- /**
- * @return Returns the settings for the new eclipse profile.
- */
- public static Map getEclipseSettings() {
- final Map options= DefaultCodeFormatterConstants.getEclipseDefaultSettings();
-
- ProfileVersioner.setLatestCompliance(options);
- return options;
- }
-
- /**
- * @return Returns the settings for the Java Conventions profile.
- */
- public static Map getJavaSettings() {
- final Map options= DefaultCodeFormatterConstants.getJavaConventionsSettings();
-
- ProfileVersioner.setLatestCompliance(options);
- return options;
- }
-
- /**
- * @return Returns the default settings.
- */
- public static Map getDefaultSettings() {
- return getEclipseSettings();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager#getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext)
- */
- protected String getSelectedProfileId(IScopeContext instanceScope) {
- String profileId= instanceScope.getNode(JavaScriptUI.ID_PLUGIN).get(PROFILE_KEY, null);
- if (profileId == null) {
- // request from bug 129427
- profileId= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN).get(PROFILE_KEY, null);
- // fix for bug 89739
- if (DEFAULT_PROFILE.equals(profileId)) { // default default:
- IEclipsePreferences node= instanceScope.getNode(JavaScriptCore.PLUGIN_ID);
- if (node != null) {
- String tabSetting= node.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, null);
- if (JavaScriptCore.SPACE.equals(tabSetting)) {
- profileId= JAVA_PROFILE;
- }
- }
- }
- }
- return profileId;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager#getDefaultProfile()
- */
- public Profile getDefaultProfile() {
- return getProfile(DEFAULT_PROFILE);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileStore.java
deleted file mode 100644
index 93cfa678..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterProfileStore.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.osgi.service.prefs.BackingStoreException;
-import org.xml.sax.InputSource;
-
-
-
-public class FormatterProfileStore extends ProfileStore {
-
- /**
- * Preference key where all profiles are stored
- */
- private static final String PREF_FORMATTER_PROFILES= "org.eclipse.wst.jsdt.ui.formatterprofiles"; //$NON-NLS-1$
-
- private final IProfileVersioner fProfileVersioner;
-
- public FormatterProfileStore(IProfileVersioner profileVersioner) {
- super(PREF_FORMATTER_PROFILES, profileVersioner);
- fProfileVersioner= profileVersioner;
- }
-
- /**
- * {@inheritDoc}
- */
- public List readProfiles(IScopeContext scope) throws CoreException {
- List profiles= super.readProfiles(scope);
- if (profiles == null) {
- profiles= readOldForCompatibility(scope);
- }
- return profiles;
- }
-
- /**
- * Read the available profiles from the internal XML file and return them
- * as collection.
- * @return returns a list of <code>CustomProfile</code> or <code>null</code>
- */
- private List readOldForCompatibility(IScopeContext instanceScope) {
-
- // in 3.0 M9 and less the profiles were stored in a file in the plugin's meta data
- final String STORE_FILE= "code_formatter_profiles.xml"; //$NON-NLS-1$
-
- File file= JavaScriptPlugin.getDefault().getStateLocation().append(STORE_FILE).toFile();
- if (!file.exists())
- return null;
-
- try {
- // note that it's wrong to use a file reader when XML declares UTF-8: Kept for compatibility
- final FileReader reader= new FileReader(file);
- try {
- List res= readProfilesFromStream(new InputSource(reader));
- if (res != null) {
- for (int i= 0; i < res.size(); i++) {
- fProfileVersioner.update((CustomProfile) res.get(i));
- }
- writeProfiles(res, instanceScope);
- }
- file.delete(); // remove after successful write
- return res;
- } finally {
- reader.close();
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e); // log but ignore
- } catch (IOException e) {
- JavaScriptPlugin.log(e); // log but ignore
- }
- return null;
- }
-
-
- public static void checkCurrentOptionsVersion() {
- PreferencesAccess access= PreferencesAccess.getOriginalPreferences();
- ProfileVersioner profileVersioner= new ProfileVersioner();
-
- IScopeContext instanceScope= access.getInstanceScope();
- IEclipsePreferences uiPreferences= instanceScope.getNode(JavaScriptUI.ID_PLUGIN);
- int version= uiPreferences.getInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, 0);
- if (version >= profileVersioner.getCurrentVersion()) {
- return; // is up to date
- }
- try {
- List profiles= (new FormatterProfileStore(profileVersioner)).readProfiles(instanceScope);
- if (profiles == null) {
- profiles= new ArrayList();
- }
- ProfileManager manager= new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
- if (manager.getSelected() instanceof CustomProfile) {
- manager.commitChanges(instanceScope); // updates JavaScriptCore options
- }
- uiPreferences.putInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, profileVersioner.getCurrentVersion());
- savePreferences(instanceScope);
-
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i= 0; i < projects.length; i++) {
- IScopeContext scope= access.getProjectScope(projects[i]);
- if (manager.hasProjectSpecificSettings(scope)) {
- manager= new FormatterProfileManager(profiles, scope, access, profileVersioner);
- manager.commitChanges(scope); // updates JavaScriptCore project options
- savePreferences(scope);
- }
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- } catch (BackingStoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- private static void savePreferences(final IScopeContext context) throws BackingStoreException {
- try {
- context.getNode(JavaScriptUI.ID_PLUGIN).flush();
- } finally {
- context.getNode(JavaScriptCore.PLUGIN_ID).flush();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterTabPage.java
deleted file mode 100644
index 26dd0c69..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/FormatterTabPage.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public abstract class FormatterTabPage extends ModifyDialogTabPage {
-
- private final static String SHOW_INVISIBLE_PREFERENCE_KEY= JavaScriptUI.ID_PLUGIN + ".formatter_page.show_invisible_characters"; //$NON-NLS-1$
-
- private JavaPreview fPreview;
- private final IDialogSettings fDialogSettings;
- private Button fShowInvisibleButton;
-
- public FormatterTabPage(IModificationListener modifyListener, Map workingValues) {
- super(modifyListener, workingValues);
-
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- }
-
- protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
-
- createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
-
- fShowInvisibleButton= new Button(composite, SWT.CHECK);
- fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label);
- fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
- fShowInvisibleButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
- fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, fShowInvisibleButton.getSelection());
- }
- });
- fShowInvisibleButton.setSelection(isShowInvisible());
-
- fPreview= doCreateJavaPreview(composite);
- fDefaultFocusManager.add(fPreview.getControl());
- fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
-
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
- gd.widthHint= 0;
- gd.heightHint=0;
- fPreview.getControl().setLayoutData(gd);
-
- return composite;
- }
-
- private boolean isShowInvisible() {
- return fDialogSettings.getBoolean(SHOW_INVISIBLE_PREFERENCE_KEY);
- }
-
- protected void doUpdatePreview() {
- boolean showInvisible= isShowInvisible();
- fPreview.showInvisibleCharacters(showInvisible);
- fShowInvisibleButton.setSelection(showInvisible);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IProfileVersioner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IProfileVersioner.java
deleted file mode 100644
index a61220b2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IProfileVersioner.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-
-public interface IProfileVersioner {
-
- public int getFirstVersion();
-
- public int getCurrentVersion();
-
- public String getProfileKind();
-
- /**
- * Update the <code>profile</code> to the
- * current version number
- */
- public void update(CustomProfile profile);
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IndentationTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IndentationTabPage.java
deleted file mode 100644
index 68bebb22..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/IndentationTabPage.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * istvan@benedek-home.de
- * - 103706 [formatter] indent empty lines
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-
-public class IndentationTabPage extends FormatterTabPage {
-
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.IndentationTabPage_preview_header) +
- "function foo(data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " var abc = 1;\n" + //$NON-NLS-1$
- " var xyz = 'one';\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " switch (data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " case 0:\n" + //$NON-NLS-1$
- " abc = 0;\n" + //$NON-NLS-1$
- " xyz = 'zero';\n" + //$NON-NLS-1$
- " break;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " default:\n" + //$NON-NLS-1$
- " abc = -1;\n" + //$NON-NLS-1$
- " xyz = 'unknown';\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " }\n\n" + //$NON-NLS-1$
- " if ( document.form1.year.value > 2000 ) {\n" + //$NON-NLS-1$
- " abc += 27;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " else if ( document.form1.year.value > 1900 ) {\n" + //$NON-NLS-1$
- " abc += 19;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " else {\n" + //$NON-NLS-1$
- " abc = 0;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
-
- private CompilationUnitPreview fPreview;
- private String fOldTabChar= null;
-
- public IndentationTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_general_group_title);
-
- final String[] tabPolicyValues= new String[] {JavaScriptCore.SPACE, JavaScriptCore.TAB, DefaultCodeFormatterConstants.MIXED};
- final String[] tabPolicyLabels= new String[] {
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE,
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB,
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED
- };
- final ComboPreference tabPolicy= createComboPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_policy, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels);
- final CheckboxPreference onlyForLeading= createCheckboxPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_use_tabs_only_for_leading_indentations, DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, FALSE_TRUE);
- final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
- final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
-
- String tabchar= (String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading);
- tabPolicy.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- updateTabPreferences((String) arg, tabSize, indentSize, onlyForLeading);
- }
- });
- tabSize.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- indentSize.updateWidget();
- }
- });
-
- final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_field_alignment_group_title);
- createCheckboxPref(typeMemberGroup, numColumns, FormatterMessages.IndentationTabPage_field_alignment_group_align_fields_in_columns, DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, FALSE_TRUE);
-
- final Group classGroup = createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_indent_group_title);
-// createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_class_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, FALSE_TRUE);
-// createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_enum_decl, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, FALSE_TRUE);
-// createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_enum_const, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, FALSE_TRUE);
-// createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_annot_decl, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER, FALSE_TRUE);
-
-
-// final Group blockGroup= createGroup(numColumns, composite, FormatterMessages.getString("IndentationTabPage.block_group.title")); //$NON-NLS-1$
- //createCheckboxPref(classGroup, numColumns, FormatterMessages.getString("IndentationTabPage.block_group.option.indent_statements_within_blocks_and_methods"), DefaultCodeFormatterConstants.FORMATTER_INDENT_BLOCK_STATEMENTS, FALSE_TRUE); //$NON-NLS-1$
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_block, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, FALSE_TRUE);
-
-
-// final Group switchGroup= createGroup(numColumns, composite, FormatterMessages.getString("IndentationTabPage.switch_group.title")); //$NON-NLS-1$
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_switch_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_case_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_break_statements, DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_indent_empty_lines, DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE);
- }
-
- public void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
- */
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-
- private void updateTabPreferences(String tabPolicy, NumberPreference tabPreference, NumberPreference indentPreference, CheckboxPreference onlyForLeading) {
- /*
- * If the tab-char is SPACE (or TAB), INDENTATION_SIZE
- * preference is not used by the core formatter. We piggy back the
- * visual tab length setting in that preference in that case. If the
- * user selects MIXED, we use the previous TAB_SIZE preference as the
- * new INDENTATION_SIZE (as this is what it really is) and set the
- * visual tab size to the value piggy backed in the INDENTATION_SIZE
- * preference. See also CodeFormatterUtil.
- */
- if (DefaultCodeFormatterConstants.MIXED.equals(tabPolicy)) {
- if (JavaScriptCore.SPACE.equals(fOldTabChar) || JavaScriptCore.TAB.equals(fOldTabChar))
- swapTabValues();
- tabPreference.setEnabled(true);
- tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- indentPreference.setEnabled(true);
- indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
- onlyForLeading.setEnabled(true);
- } else if (JavaScriptCore.SPACE.equals(tabPolicy)) {
- if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
- swapTabValues();
- tabPreference.setEnabled(true);
- tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
- indentPreference.setEnabled(true);
- indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- onlyForLeading.setEnabled(false);
- } else if (JavaScriptCore.TAB.equals(tabPolicy)) {
- if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
- swapTabValues();
- tabPreference.setEnabled(true);
- tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- indentPreference.setEnabled(false);
- indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- onlyForLeading.setEnabled(true);
- } else {
- Assert.isTrue(false);
- }
- fOldTabChar= tabPolicy;
- }
-
- private void swapTabValues() {
- Object tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- Object indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
- fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
- fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/JavaPreview.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/JavaPreview.java
deleted file mode 100644
index 30fa4964..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/JavaPreview.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.MarginPainter;
-import org.eclipse.jface.text.WhitespaceCharacterPainter;
-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.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public abstract class JavaPreview {
-
-
- private final class JavaSourcePreviewerUpdater {
-
- final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
- final Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- fSourceViewer.getTextWidget().setFont(font);
- if (fMarginPainter != null) {
- fMarginPainter.initialize();
- }
- }
- }
- };
-
- final IPropertyChangeListener propertyListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (fViewerConfiguration.affectsTextPresentation(event)) {
- fViewerConfiguration.handlePropertyChangeEvent(event);
- fSourceViewer.invalidateTextPresentation();
- }
- }
- };
-
-
- public JavaSourcePreviewerUpdater() {
-
- JFaceResources.getFontRegistry().addListener(fontListener);
- fPreferenceStore.addPropertyChangeListener(propertyListener);
-
- fSourceViewer.getTextWidget().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- JFaceResources.getFontRegistry().removeListener(fontListener);
- fPreferenceStore.removePropertyChangeListener(propertyListener);
- }
- });
- }
- }
-
- protected final SimpleJavaSourceViewerConfiguration fViewerConfiguration;
- protected final Document fPreviewDocument;
- protected final SourceViewer fSourceViewer;
- protected final IPreferenceStore fPreferenceStore;
-
- protected final MarginPainter fMarginPainter;
-
- protected Map fWorkingValues;
-
- private int fTabSize= 0;
- private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
-
- /**
- * Create a new Java preview
- * @param workingValues
- * @param parent
- */
- public JavaPreview(Map workingValues, Composite parent) {
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- fPreviewDocument= new Document();
- fWorkingValues= workingValues;
- tools.setupJavaDocumentPartitioner( fPreviewDocument, IJavaScriptPartitions.JAVA_PARTITIONING);
-
- PreferenceStore prioritizedSettings= new PreferenceStore();
- prioritizedSettings.setValue(JavaScriptCore.COMPILER_SOURCE, JavaScriptCore.VERSION_1_5);
- prioritizedSettings.setValue(JavaScriptCore.COMPILER_COMPLIANCE, JavaScriptCore.VERSION_1_5);
- prioritizedSettings.setValue(JavaScriptCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaScriptCore.VERSION_1_5);
- prioritizedSettings.setValue(JavaScriptCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaScriptCore.ERROR);
-
- IPreferenceStore[] chain= { prioritizedSettings, JavaScriptPlugin.getDefault().getCombinedPreferenceStore() };
- fPreferenceStore= new ChainedPreferenceStore(chain);
- fSourceViewer= new JavaSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
- fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaScriptPartitions.JAVA_PARTITIONING, true);
- fSourceViewer.configure(fViewerConfiguration);
- fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
-
- fMarginPainter= new MarginPainter(fSourceViewer);
- final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
- fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
- fSourceViewer.addPainter(fMarginPainter);
-
- new JavaSourcePreviewerUpdater();
- fSourceViewer.setDocument(fPreviewDocument);
- }
-
- public Control getControl() {
- return fSourceViewer.getControl();
- }
-
-
- public void update() {
- if (fWorkingValues == null) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
-
- // update the print margin
- final String value= (String)fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
- final int lineWidth= getPositiveIntValue(value, 0);
- fMarginPainter.setMarginRulerColumn(lineWidth);
-
- // update the tab size
- final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0);
- if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize);
- fTabSize= tabSize;
-
- final StyledText widget= (StyledText)fSourceViewer.getControl();
- final int height= widget.getClientArea().height;
- final int top0= widget.getTopPixel();
-
- final int totalPixels0= getHeightOfAllLines(widget);
- final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0;
-
- widget.setRedraw(false);
- doFormatPreview();
- fSourceViewer.setSelection(null);
-
- final int totalPixels1= getHeightOfAllLines(widget);
- final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
-
- final int top1= topPixelRange0 > 0 ? (int)(topPixelRange1 * top0 / (double)topPixelRange0) : 0;
- widget.setTopPixel(top1);
- widget.setRedraw(true);
- }
-
- private int getHeightOfAllLines(StyledText styledText) {
- int height= 0;
- int lineCount= styledText.getLineCount();
- for (int i= 0; i < lineCount; i++)
- height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i));
- return height;
- }
-
- protected abstract void doFormatPreview();
-
-
- private static int getPositiveIntValue(String string, int defaultValue) {
- try {
- int i= Integer.parseInt(string);
- if (i >= 0) {
- return i;
- }
- } catch (NumberFormatException e) {
- }
- return defaultValue;
- }
-
-
-
- public Map getWorkingValues() {
- return fWorkingValues;
- }
-
-
- public void setWorkingValues(Map workingValues) {
- fWorkingValues= workingValues;
- }
-
- public void showInvisibleCharacters(boolean enable) {
- if (enable) {
- if (fWhitespaceCharacterPainter == null) {
- fWhitespaceCharacterPainter= new WhitespaceCharacterPainter(fSourceViewer);
- fSourceViewer.addPainter(fWhitespaceCharacterPainter);
- }
- } else {
- fSourceViewer.removePainter(fWhitespaceCharacterPainter);
- fWhitespaceCharacterPainter= null;
- }
- update();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/LineWrappingTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
deleted file mode 100644
index f640bc67..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
+++ /dev/null
@@ -1,893 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.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.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-/**
- * The line wrapping tab page.
- */
-public class LineWrappingTabPage extends FormatterTabPage {
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- /**
- * Represents a line wrapping category. All members are final.
- */
- private final static class Category {
- public final String key;
- public final String name;
- public final String previewText;
- public final List children;
- public final List preferences;
-
- public int index;
-
- public Category(String _key, String _previewText, String _name) {
- this.key= _key;
- this.name= _name;
- this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null;
- children= new ArrayList();
- preferences= new ArrayList();
- }
-
- /**
- * @param _name Category name
- */
- public Category(String _name) {
- this(null, null, _name);
- }
-
- public String toString() {
- return name;
- }
-
- public void addPreference(Preference specificPreference) {
- preferences.add(specificPreference);
- }
-
- public Preference[] getSpecificPreferences() {
- return (Preference[])preferences.toArray(new Preference[preferences.size()]);
- }
- }
-
-
- private final static String PREF_CATEGORY_INDEX= JavaScriptUI.ID_PLUGIN + "formatter_page.line_wrapping_tab_page.last_category_index"; //$NON-NLS-1$
-
-
- private final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener {
-
- private final List fCategoriesList;
-
- private int fIndex= 0;
-
- public CategoryListener(List categoriesTree) {
- fCategoriesList= new ArrayList();
- flatten(fCategoriesList, categoriesTree);
- }
-
- private void flatten(List categoriesList, List categoriesTree) {
- for (final Iterator iter= categoriesTree.iterator(); iter.hasNext(); ) {
- final Category category= (Category) iter.next();
- category.index= fIndex++;
- categoriesList.add(category);
- flatten(categoriesList, category.children);
- }
- }
-
- public void add(Category category) {
- category.index= fIndex++;
- fCategoriesList.add(category);
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- if (event != null)
- fSelection= (IStructuredSelection)event.getSelection();
-
- if (fSelection.size() == 0) {
- disableAll();
- return;
- }
-
- if (!fOptionsGroup.isEnabled())
- enableDefaultComponents(true);
-
- fSelectionState.refreshState(fSelection);
-
- final Category category= (Category)fSelection.getFirstElement();
- fDialogSettings.put(PREF_CATEGORY_INDEX, category.index);
-
- fOptionsGroup.setText(getGroupLabel(category));
- }
-
- private String getGroupLabel(Category category) {
- if (fSelection.size() == 1) {
- if (fSelectionState.getElements().size() == 1)
- return Messages.format(FormatterMessages.LineWrappingTabPage_group, category.name.toLowerCase());
- return Messages.format(FormatterMessages.LineWrappingTabPage_multi_group, new String[] {category.name.toLowerCase(), Integer.toString(fSelectionState.getElements().size())});
- }
- return Messages.format(FormatterMessages.LineWrappingTabPage_multiple_selections, new String[] {Integer.toString(fSelectionState.getElements().size())});
- }
-
- private void disableAll() {
- enableDefaultComponents(false);
- fIndentStyleCombo.setEnabled(false);
- fForceSplit.setEnabled(false);
- }
-
- private void enableDefaultComponents(boolean enabled) {
- fOptionsGroup.setEnabled(enabled);
- fWrappingStyleCombo.setEnabled(enabled);
- fWrappingStylePolicy.setEnabled(enabled);
- }
-
- public void restoreSelection() {
- int index;
- try {
- index= fDialogSettings.getInt(PREF_CATEGORY_INDEX);
- } catch (NumberFormatException ex) {
- index= -1;
- }
- if (index < 0 || index > fCategoriesList.size() - 1) {
- index= 1; // In order to select a category with preview initially
- }
- final Category category= (Category)fCategoriesList.get(index);
- fCategoriesViewer.setSelection(new StructuredSelection(new Category[] {category}));
- }
-
- public void doubleClick(DoubleClickEvent event) {
- final ISelection selection= event.getSelection();
- if (selection instanceof IStructuredSelection) {
- final Category node= (Category)((IStructuredSelection)selection).getFirstElement();
- fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
- }
- }
- }
-
- private class SelectionState {
- private List fElements= new ArrayList();
- private boolean fRequiresRelayout;
-
- public void refreshState(IStructuredSelection selection) {
- Map wrappingStyleMap= new HashMap();
- Map indentStyleMap= new HashMap();
- Map forceWrappingMap= new HashMap();
- fRequiresRelayout= false;
- showSpecificControls(false);
- fElements.clear();
- evaluateElements(selection.iterator());
- evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
- setPreviewText(getPreviewText(wrappingStyleMap, indentStyleMap, forceWrappingMap));
- refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
- }
-
- public List getElements() {
- return fElements;
- }
-
- private void evaluateElements(Iterator iterator) {
- Category category;
- String value;
- while (iterator.hasNext()) {
- category= (Category) iterator.next();
- value= (String)fWorkingValues.get(category.key);
- if (value != null) {
- if (!fElements.contains(category))
- fElements.add(category);
- }
- else {
- evaluateElements(category.children.iterator());
- }
- }
- }
-
- private void evaluateMaps(Map wrappingStyleMap, Map indentStyleMap, Map forceWrappingMap) {
- Iterator iterator= fElements.iterator();
- while (iterator.hasNext()) {
- insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, (Category)iterator.next());
- }
- }
-
- private String getPreviewText(Map wrappingMap, Map indentMap, Map forceMap) {
- Iterator iterator= fElements.iterator();
- String previewText= ""; //$NON-NLS-1$
- while (iterator.hasNext()) {
- Category category= (Category)iterator.next();
- previewText= previewText + category.previewText + "\n\n"; //$NON-NLS-1$
- }
- return previewText;
- }
-
- private void insertIntoMap(Map wrappingMap, Map indentMap, Map forceMap, Category category) {
- final String value= (String)fWorkingValues.get(category.key);
- Integer wrappingStyle;
- Integer indentStyle;
- Boolean forceWrapping;
-
- try {
- wrappingStyle= new Integer(DefaultCodeFormatterConstants.getWrappingStyle(value));
- indentStyle= new Integer(DefaultCodeFormatterConstants.getIndentStyle(value));
- forceWrapping= new Boolean(DefaultCodeFormatterConstants.getForceWrapping(value));
- } catch (IllegalArgumentException e) {
- forceWrapping= new Boolean(false);
- indentStyle= new Integer(DefaultCodeFormatterConstants.INDENT_DEFAULT);
- wrappingStyle= new Integer(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
- }
-
- increaseMapEntry(wrappingMap, wrappingStyle);
- increaseMapEntry(indentMap, indentStyle);
- increaseMapEntry(forceMap, forceWrapping);
- }
-
- private void increaseMapEntry(Map map, Object type) {
- Integer count= (Integer)map.get(type);
- if (count == null) // not in map yet -> count == 0
- map.put(type, new Integer(1));
- else
- map.put(type, new Integer(count.intValue() + 1));
- }
-
- private void refreshControls(Map wrappingStyleMap, Map indentStyleMap, Map forceWrappingMap) {
- updateCombos(wrappingStyleMap, indentStyleMap);
- updateButton(forceWrappingMap);
- Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap);
- boolean isInhomogeneous= (fElements.size() != ((Integer)wrappingStyleMap.get(wrappingStyleMax)).intValue());
- updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue());
- showSpecificControls(true);
- if (fRequiresRelayout) {
- fOptionsComposite.layout(true, true);
- }
- doUpdatePreview();
- notifyValuesModified();
- }
-
- private void showSpecificControls(boolean show) {
- if (fElements.size() != 1)
- return;
-
- Preference[] preferences= ((Category)fElements.get(0)).getSpecificPreferences();
- if (preferences.length == 0)
- return;
-
- fRequiresRelayout= true;
- for (int i= 0; i < preferences.length; i++) {
- Preference preference= preferences[i];
- Control control= preference.getControl();
- control.setVisible(show);
- ((GridData)control.getLayoutData()).exclude= !show;
- }
- }
-
- private Integer getWrappingStyleMax(Map wrappingStyleMap) {
- int maxCount= 0, maxStyle= 0;
- for (int i=0; i<WRAPPING_NAMES.length; i++) {
- Integer count= (Integer)wrappingStyleMap.get(new Integer(i));
- if (count == null)
- continue;
- if (count.intValue() > maxCount) {
- maxCount= count.intValue();
- maxStyle= i;
- }
- }
- return new Integer(maxStyle);
- }
-
- private void updateButton(Map forceWrappingMap) {
- Integer nrOfTrue= (Integer)forceWrappingMap.get(Boolean.TRUE);
- Integer nrOfFalse= (Integer)forceWrappingMap.get(Boolean.FALSE);
-
- if (nrOfTrue == null || nrOfFalse == null)
- fForceSplit.setSelection(nrOfTrue != null);
- else
- fForceSplit.setSelection(nrOfTrue.intValue() > nrOfFalse.intValue());
-
- int max= getMax(nrOfTrue, nrOfFalse);
- String label= FormatterMessages.LineWrappingTabPage_force_split_checkbox_multi_text;
- fForceSplit.setText(getLabelText(label, max, fElements.size()));
- }
-
- private String getLabelText(String label, int count, int nElements) {
- if (nElements == 1 || count == 0)
- return label;
- return Messages.format(FormatterMessages.LineWrappingTabPage_occurences, new String[] {label, Integer.toString(count), Integer.toString(nElements)});
- }
-
- private int getMax(Integer nrOfTrue, Integer nrOfFalse) {
- if (nrOfTrue == null)
- return nrOfFalse.intValue();
- if (nrOfFalse == null)
- return nrOfTrue.intValue();
- if (nrOfTrue.compareTo(nrOfFalse) >= 0)
- return nrOfTrue.intValue();
- return nrOfFalse.intValue();
- }
-
- private void updateCombos(Map wrappingStyleMap, Map indentStyleMap) {
- updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
- updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
- }
-
- private void updateCombo(Combo combo, Map map, final String[] items) {
- String[] newItems= new String[items.length];
- int maxCount= 0, maxStyle= 0;
-
- for(int i = 0; i < items.length; i++) {
- Integer count= (Integer) map.get(new Integer(i));
- int val= (count == null) ? 0 : count.intValue();
- if (val > maxCount) {
- maxCount= val;
- maxStyle= i;
- }
- newItems[i]= getLabelText(items[i], val, fElements.size());
- }
- combo.setItems(newItems);
- combo.setText(newItems[maxStyle]);
- }
- }
-
- protected static final String[] INDENT_NAMES = {
- FormatterMessages.LineWrappingTabPage_indentation_default,
- FormatterMessages.LineWrappingTabPage_indentation_on_column,
- FormatterMessages.LineWrappingTabPage_indentation_by_one
- };
-
-
- protected static final String[] WRAPPING_NAMES = {
- FormatterMessages.LineWrappingTabPage_splitting_do_not_split,
- FormatterMessages.LineWrappingTabPage_splitting_wrap_when_necessary, // COMPACT_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary, // COMPACT_FIRST_BREAK_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always, // ONE_PER_LINE_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always_indent_all_but_first, // NEXT_SHIFTED_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary
- };
-
-
- private final Category fCompactIfCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
- "function foo(int argument) {\n" + //$NON-NLS-1$
- " if (argument==0)\n" + //$NON-NLS-1$
- " return 0;\n" + //$NON-NLS-1$
- " if (argument==1)\n" + //$NON-NLS-1$
- " return 42;\n" + //$NON-NLS-1$
- " else\n" + //$NON-NLS-1$
- " return 43;\n" + //$NON-NLS-1$
- "}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_compact_if_else
- );
-
-
-// private final Category fTypeDeclarationSuperclassCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION,
-// "class Example extends OtherClass {}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_extends_clause
-// );
-//
-//
-// private final Category fTypeDeclarationSuperinterfacesCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION,
-// "class Example implements I1, I2, I3 {}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_implements_clause
-// );
-
-
-// private final Category fConstructorDeclarationsParametersCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
-// "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
-// "Example() {}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_parameters
-// );
-
- private final Category fMethodDeclarationsParametersCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
- "function foo(arg1, arg2, arg3, arg4, arg5, arg6) { var x = 0; return x;}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_parameters
- );
-
- private final Category fMessageSendArgumentsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
- "function foo() {Other.bar( 100, 200, 300, 400, 500, 600, 700, 800, 900 );}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_arguments
- );
-
-// private final Category fMessageSendSelectorCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION,
-// "function foofoofoofoofoo(aLongParmName) {return aLongParmName.getFirstSomething();}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_qualified_invocations
-// );
-
-// private final Category fMethodThrowsClauseCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
-// "class Example {" + //$NON-NLS-1$
-// "int foo() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
-// " return Other.doSomething();}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_throws_clause
-// );
-
-// private final Category fConstructorThrowsClauseCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION,
-// "class Example {" + //$NON-NLS-1$
-// "Example() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
-// " return Other.doSomething();}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_throws_clause
-// );
-
-
- private final Category fAllocationExpressionArgumentsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
- "foo( new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 ) );", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_object_allocation
- );
-
-// private final Category fQualifiedAllocationExpressionCategory= new Category (
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION,
-// "class Example {SomeClass foo() {return SomeOtherClass.new SomeClass(100, 200, 300, 400, 500 );}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_qualified_object_allocation
-// );
-
- private final Category fArrayInitializerExpressionsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER,
- "fArray= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_array_init
- );
-
- private final Category fObjectInitializerExpressionsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER,
- "anObject = { color:'red', wheels:4, engine:{ cylinders:4, size:2.2 } };", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_object_init
- );
-
-// private final Category fExplicitConstructorArgumentsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL,
-// "class Example extends AnotherClass {Example() {super(100, 200, 300, 400, 500, 600, 700);}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations
-// );
-
- private final Category fConditionalExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
- "function exampleFunction( anArgument) {return anArgument ? 100000 : 200000;}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_conditionals
- );
-
- private final Category fBinaryExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION,
- "function foo() {" + //$NON-NLS-1$
- " var sum= 100 + 200 + 300 + 400 + 500 + 600 + 700 + 800;" + //$NON-NLS-1$
- " var product= 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10;" + //$NON-NLS-1$
- " var val= true && false && true && false && true;" + //$NON-NLS-1$
- " return product / sum;}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_binary_exprs
- );
-
-// private final Category fEnumConstArgumentsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT,
-// "enum Example {" + //$NON-NLS-1$
-// "GREEN(0, 255, 0), RED(255, 0, 0) }", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_enum_constant_arguments
-// );
-
-// private final Category fEnumDeclInterfacesCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION,
-// "enum Example implements A, B, C {" + //$NON-NLS-1$
-// "}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_enum_superinterfaces
-// );
-//
-// private final Category fEnumConstantsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
-// "enum Example {" + //$NON-NLS-1$
-// "CANCELLED, RUNNING, WAITING, FINISHED }" + //$NON-NLS-1$
-// "enum Example {" + //$NON-NLS-1$
-// "GREEN(0, 255, 0), RED(255, 0, 0) }", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_enum_constants
-// );
-
- private final Category fAssignmentCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
- "var string = \"TextTextText\";\n" + //$NON-NLS-1$
- "function foo() {\n" + //$NON-NLS-1$
- " for (int i = 0; i < 10; i++) {\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- " var s;\n" + //$NON-NLS-1$
- " s = \"TextTextText\";\n" + //$NON-NLS-1$
- "}\n", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_assignment_alignment
- );
-
- /**
- * The default preview line width.
- */
- private static int DEFAULT_PREVIEW_WINDOW_LINE_WIDTH= 40;
-
- /**
- * The key to save the user's preview window width in the dialog settings.
- */
- private static final String PREF_PREVIEW_LINE_WIDTH= JavaScriptUI.ID_PLUGIN + ".codeformatter.line_wrapping_tab_page.preview_line_width"; //$NON-NLS-1$
-
- /**
- * The dialog settings.
- */
- protected final IDialogSettings fDialogSettings;
-
- protected TreeViewer fCategoriesViewer;
- protected Label fWrappingStylePolicy;
- protected Combo fWrappingStyleCombo;
- protected Label fIndentStylePolicy;
- protected Combo fIndentStyleCombo;
- protected Button fForceSplit;
-
- protected CompilationUnitPreview fPreview;
-
- protected Group fOptionsGroup;
-
- /**
- * A collection containing the categories tree. This is used as model for the tree viewer.
- * @see TreeViewer
- */
- private final List fCategories;
-
- /**
- * The category listener which makes the selection persistent.
- */
- protected final CategoryListener fCategoryListener;
-
- /**
- * The current selection of elements.
- */
- protected IStructuredSelection fSelection;
-
- /**
- * An object containing the state for the UI.
- */
- SelectionState fSelectionState;
-
- /**
- * A special options store wherein the preview line width is kept.
- */
- protected final Map fPreviewPreferences;
-
- /**
- * The key for the preview line width.
- */
- private final String LINE_SPLIT= DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT;
-
-
- private Composite fOptionsComposite;
-
- /**
- * Create a new line wrapping tab page.
- * @param modifyDialog
- * @param workingValues
- */
- public LineWrappingTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
-
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
-
- final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
-
- fPreviewPreferences= new HashMap();
- fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
-
- fCategories= createCategories();
- fCategoryListener= new CategoryListener(fCategories);
- }
-
- /**
- * @return Create the categories tree.
- */
- protected List createCategories() {
-
-// final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls);
-// classDeclarations.children.add(fTypeDeclarationSuperclassCategory);
-// classDeclarations.children.add(fTypeDeclarationSuperinterfacesCategory);
-
-// final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls);
-// constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
-// constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
-
- final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_method_decls);
- methodDeclarations.children.add(fMethodDeclarationsParametersCategory);
-// methodDeclarations.children.add(fMethodThrowsClauseCategory);
-
-// final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls);
-// enumDeclarations.children.add(fEnumConstantsCategory);
-// enumDeclarations.children.add(fEnumDeclInterfacesCategory);
-// enumDeclarations.children.add(fEnumConstArgumentsCategory);
-
- final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls);
- functionCalls.children.add(fMessageSendArgumentsCategory);
-// functionCalls.children.add(fMessageSendSelectorCategory);
-// functionCalls.children.add(fExplicitConstructorArgumentsCategory);
- functionCalls.children.add(fAllocationExpressionArgumentsCategory);
-// functionCalls.children.add(fQualifiedAllocationExpressionCategory);
-
- final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions);
- expressions.children.add(fBinaryExpressionCategory);
- expressions.children.add(fConditionalExpressionCategory);
- expressions.children.add(fArrayInitializerExpressionsCategory);
- expressions.children.add(fObjectInitializerExpressionsCategory);
- expressions.children.add(fAssignmentCategory);
-
- final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
- statements.children.add(fCompactIfCategory);
-
- final List root= new ArrayList();
-// root.add(classDeclarations);
-// root.add(constructorDeclarations);
- root.add(methodDeclarations);
-// root.add(enumDeclarations);
- root.add(functionCalls);
- root.add(expressions);
- root.add(statements);
-
- return root;
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- fOptionsComposite= composite;
-
- final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_width_indent);
-
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999);
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999);
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, 0, 9999);
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_objlit, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_OBJLIT_INITIALIZER, 0, 9999);
-
- fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
- fCategoriesViewer.setContentProvider(new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- return ((Collection)inputElement).toArray();
- }
- public Object[] getChildren(Object parentElement) {
- return ((Category)parentElement).children.toArray();
- }
- public Object getParent(Object element) { return null; }
- public boolean hasChildren(Object element) {
- return !((Category)element).children.isEmpty();
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
- public void dispose() {}
- });
- fCategoriesViewer.setLabelProvider(new LabelProvider());
- fCategoriesViewer.setInput(fCategories);
-
- fCategoriesViewer.setExpandedElements(fCategories.toArray());
-
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT);
- fCategoriesViewer.getControl().setLayoutData(gd);
-
- fOptionsGroup = createGroup(numColumns, composite, ""); //$NON-NLS-1$
-
- // label "Select split style:"
- fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text);
-
- // combo SplitStyleCombo
- fWrappingStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
- fWrappingStyleCombo.setItems(WRAPPING_NAMES);
- fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
-
- // label "Select indentation style:"
- fIndentStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_indentation_policy_label_text);
-
- // combo SplitStyleCombo
- fIndentStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
- fIndentStyleCombo.setItems(INDENT_NAMES);
- fIndentStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
-
- // button "Force split"
- fForceSplit= new Button(fOptionsGroup, SWT.CHECK);
- fForceSplit.setLayoutData(createGridData(numColumns - 1, GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.DEFAULT));
- fForceSplit.setText(FormatterMessages.LineWrappingTabPage_force_split_checkbox_text);
-
- Preference expressionWrapPositionPreference= createCheckboxPref(fOptionsGroup, 1, FormatterMessages.LineWrappingTabPage_binary_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, FALSE_TRUE);
- Control control= expressionWrapPositionPreference.getControl();
- control.setVisible(false);
- ((GridData)control.getLayoutData()).exclude= true;
- fBinaryExpressionCategory.addPreference(expressionWrapPositionPreference);
-
- // selection state object
- fSelectionState= new SelectionState();
-
- }
-
-
- protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
-
- super.doCreatePreviewPane(composite, numColumns);
-
- final NumberPreference previewLineWidth= new NumberPreference(composite, numColumns / 2, fPreviewPreferences, LINE_SPLIT,
- 0, 9999, FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text);
- fDefaultFocusManager.add(previewLineWidth);
- previewLineWidth.addObserver(fUpdater);
- previewLineWidth.addObserver(new Observer() {
- public void update(Observable o, Object arg) {
- fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, (String)fPreviewPreferences.get(LINE_SPLIT));
- }
- });
-
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
- */
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
-
- protected void initializePage() {
-
- fCategoriesViewer.addSelectionChangedListener(fCategoryListener);
- fCategoriesViewer.addDoubleClickListener(fCategoryListener);
-
- fForceSplit.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- forceSplitChanged(fForceSplit.getSelection());
- }
- });
- fIndentStyleCombo.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- indentStyleChanged(((Combo)e.widget).getSelectionIndex());
- }
- });
- fWrappingStyleCombo.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- wrappingStyleChanged(((Combo)e.widget).getSelectionIndex());
- }
- });
-
- fCategoryListener.restoreSelection();
-
- fDefaultFocusManager.add(fCategoriesViewer.getControl());
- fDefaultFocusManager.add(fWrappingStyleCombo);
- fDefaultFocusManager.add(fIndentStyleCombo);
- fDefaultFocusManager.add(fForceSplit);
- }
-
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- final Object normalSetting= fWorkingValues.get(LINE_SPLIT);
- fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
- fPreview.update();
- fWorkingValues.put(LINE_SPLIT, normalSetting);
- }
-
- protected void setPreviewText(String text) {
- final Object normalSetting= fWorkingValues.get(LINE_SPLIT);
- fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
- fPreview.setPreviewText(text);
- fWorkingValues.put(LINE_SPLIT, normalSetting);
- }
-
- protected void forceSplitChanged(boolean forceSplit) {
- Iterator iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= ((Category)iterator.next()).key;
- try {
- changeForceSplit(currentKey, forceSplit);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
- }
-
- private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{
- String value= (String)fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
- if (value == null)
- throw new IllegalArgumentException();
- fWorkingValues.put(currentKey, value);
- }
-
- protected void wrappingStyleChanged(int wrappingStyle) {
- Iterator iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= ((Category)iterator.next()).key;
- try {
- changeWrappingStyle(currentKey, wrappingStyle);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT));
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
- }
-
- private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException {
- String value= (String)fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
- if (value == null)
- throw new IllegalArgumentException();
- fWorkingValues.put(currentKey, value);
- }
-
- protected void indentStyleChanged(int indentStyle) {
- Iterator iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= ((Category)iterator.next()).key;
- try {
- changeIndentStyle(currentKey, indentStyle);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
- }
-
- private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{
- String value= (String)fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
- if (value == null)
- throw new IllegalArgumentException();
- fWorkingValues.put(currentKey, value);
- }
-
- protected void updateControlEnablement(boolean inhomogenous, int wrappingStyle) {
- boolean doSplit= wrappingStyle != DefaultCodeFormatterConstants.WRAP_NO_SPLIT;
- fIndentStylePolicy.setEnabled(true);
- fIndentStyleCombo.setEnabled(inhomogenous || doSplit);
- fForceSplit.setEnabled(inhomogenous || doSplit);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialog.java
deleted file mode 100644
index c72473d5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialog.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public abstract class ModifyDialog extends StatusDialog implements IModificationListener {
-
- /**
- * The keys to retrieve the preferred area from the dialog settings.
- */
- private static final String DS_KEY_PREFERRED_WIDTH= "modify_dialog.preferred_width"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_HEIGHT= "modify_dialog.preferred_height"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_X= "modify_dialog.preferred_x"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_Y= "modify_dialog.preferred_y"; //$NON-NLS-1$
-
-
- /**
- * The key to store the number (beginning at 0) of the tab page which had the
- * focus last time.
- */
- private static final String DS_KEY_LAST_FOCUS= "modify_dialog.last_focus"; //$NON-NLS-1$
-
- private static final int APPLAY_BUTTON_ID= IDialogConstants.CLIENT_ID;
- private static final int SAVE_BUTTON_ID= IDialogConstants.CLIENT_ID + 1;
-
- private final String fKeyPreferredWidth;
- private final String fKeyPreferredHight;
- private final String fKeyPreferredX;
- private final String fKeyPreferredY;
- private final String fKeyLastFocus;
- private final String fLastSaveLoadPathKey;
- private final ProfileStore fProfileStore;
- private final boolean fNewProfile;
- private Profile fProfile;
- private final Map fWorkingValues;
- private final List fTabPages;
- private final IDialogSettings fDialogSettings;
- private TabFolder fTabFolder;
- private final ProfileManager fProfileManager;
- private Button fApplyButton;
- private Button fSaveButton;
- private StringDialogField fProfileNameField;
-
- public ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
- super(parentShell);
-
- fProfileStore= profileStore;
- fLastSaveLoadPathKey= lastSavePathKey;
-
- fKeyPreferredWidth= JavaScriptUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_WIDTH;
- fKeyPreferredHight= JavaScriptUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_HEIGHT;
- fKeyPreferredX= JavaScriptUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_X;
- fKeyPreferredY= JavaScriptUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_Y;
- fKeyLastFocus= JavaScriptUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_LAST_FOCUS;
-
- fProfileManager= profileManager;
- fNewProfile= newProfile;
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX );
-
- fProfile= profile;
- setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()));
- fWorkingValues= new HashMap(fProfile.getSettings());
- setStatusLineAboveButtons(false);
- fTabPages= new ArrayList();
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- }
-
- protected abstract void addPages(Map values);
-
- public void create() {
- super.create();
- int lastFocusNr= 0;
- try {
- lastFocusNr= fDialogSettings.getInt(fKeyLastFocus);
- if (lastFocusNr < 0) lastFocusNr= 0;
- if (lastFocusNr > fTabPages.size() - 1) lastFocusNr= fTabPages.size() - 1;
- } catch (NumberFormatException x) {
- lastFocusNr= 0;
- }
-
- if (!fNewProfile) {
- fTabFolder.setSelection(lastFocusNr);
- ((ModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
- }
- }
-
- protected Control createDialogArea(Composite parent) {
-
- final Composite composite= (Composite)super.createDialogArea(parent);
-
- Composite nameComposite= new Composite(composite, SWT.NONE);
- nameComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- nameComposite.setLayout(new GridLayout(3, false));
-
- fProfileNameField= new StringDialogField();
- fProfileNameField.setLabelText(FormatterMessages.ModifyDialog_ProfileName_Label);
- fProfileNameField.setText(fProfile.getName());
- fProfileNameField.getLabelControl(nameComposite).setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- fProfileNameField.getTextControl(nameComposite).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- fProfileNameField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- doValidate();
- }
- });
-
- fSaveButton= createButton(nameComposite, SAVE_BUTTON_ID, FormatterMessages.ModifyDialog_Export_Button, false);
-
- fTabFolder = new TabFolder(composite, SWT.NONE);
- fTabFolder.setFont(composite.getFont());
- fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- addPages(fWorkingValues);
-
- applyDialogFont(composite);
-
- fTabFolder.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
- public void widgetSelected(SelectionEvent e) {
- final TabItem tabItem= (TabItem)e.item;
- final ModifyDialogTabPage page= (ModifyDialogTabPage)tabItem.getData();
- // page.fSashForm.setWeights();
- fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page));
- page.makeVisible();
- }
- });
-
- doValidate();
-
- return composite;
- }
-
- public void updateStatus(IStatus status) {
- if (status == null) {
- doValidate();
- } else {
- super.updateStatus(status);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
- protected Point getInitialSize() {
- Point initialSize= super.getInitialSize();
- try {
- int lastWidth= fDialogSettings.getInt(fKeyPreferredWidth);
- if (initialSize.x > lastWidth)
- lastWidth= initialSize.x;
- int lastHeight= fDialogSettings.getInt(fKeyPreferredHight);
- if (initialSize.y > lastHeight)
- lastHeight= initialSize.x;
- return new Point(lastWidth, lastHeight);
- } catch (NumberFormatException ex) {
- }
- return initialSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
- */
- protected Point getInitialLocation(Point initialSize) {
- try {
- return new Point(fDialogSettings.getInt(fKeyPreferredX), fDialogSettings.getInt(fKeyPreferredY));
- } catch (NumberFormatException ex) {
- return super.getInitialLocation(initialSize);
- }
- }
-
- public boolean close() {
- final Rectangle shell= getShell().getBounds();
-
- fDialogSettings.put(fKeyPreferredWidth, shell.width);
- fDialogSettings.put(fKeyPreferredHight, shell.height);
- fDialogSettings.put(fKeyPreferredX, shell.x);
- fDialogSettings.put(fKeyPreferredY, shell.y);
-
- return super.close();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- applyPressed();
- super.okPressed();
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == APPLAY_BUTTON_ID) {
- applyPressed();
- setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, fProfile.getName()));
- } else if (buttonId == SAVE_BUTTON_ID) {
- saveButtonPressed();
- } else {
- super.buttonPressed(buttonId);
- }
- }
-
- private void applyPressed() {
- if (!fProfile.getName().equals(fProfileNameField.getText())) {
- fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager);
- }
- fProfile.setSettings(new HashMap(fWorkingValues));
- fProfileManager.setSelected(fProfile);
- doValidate();
- }
-
- private void saveButtonPressed() {
- Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());
-
- final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
- dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
-
- final String lastPath= JavaScriptPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
- if (lastPath != null) {
- dialog.setFilterPath(lastPath);
- }
- final String path= dialog.open();
- if (path == null)
- return;
-
- JavaScriptPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$
-
- final File file= new File(path);
- if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, path))) {
- return;
- }
- String encoding= ProfileStore.ENCODING;
- final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
- if (type != null)
- encoding= type.getDefaultCharset();
- final Collection profiles= new ArrayList();
- profiles.add(selected);
- try {
- fProfileStore.writeProfilesToFile(profiles, file, encoding);
- } catch (CoreException e) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
- ExceptionHandler.handle(e, getShell(), title, message);
- }
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- fApplyButton= createButton(parent, APPLAY_BUTTON_ID, FormatterMessages.ModifyDialog_apply_button, false);
- fApplyButton.setEnabled(false);
-
- GridLayout layout= (GridLayout) parent.getLayout();
- layout.numColumns++;
- layout.makeColumnsEqualWidth= false;
- Label label= new Label(parent, SWT.NONE);
- GridData data= new GridData();
- data.widthHint= layout.horizontalSpacing;
- label.setLayoutData(data);
- super.createButtonsForButtonBar(parent);
- }
-
- protected final void addTabPage(String title, ModifyDialogTabPage tabPage) {
- final TabItem tabItem= new TabItem(fTabFolder, SWT.NONE);
- applyDialogFont(tabItem.getControl());
- tabItem.setText(title);
- tabItem.setData(tabPage);
- tabItem.setControl(tabPage.createContents(fTabFolder));
- fTabPages.add(tabPage);
- }
-
- public void valuesModified() {
- doValidate();
- }
-
- protected void updateButtonsEnableState(IStatus status) {
- super.updateButtonsEnableState(status);
- if (fApplyButton != null && !fApplyButton.isDisposed()) {
- fApplyButton.setEnabled(hasChanges() && !status.matches(IStatus.ERROR));
- }
- if (fSaveButton != null && !fSaveButton.isDisposed()) {
- fSaveButton.setEnabled(!validateProfileName().matches(IStatus.ERROR));
- }
- }
-
- private void doValidate() {
- IStatus status= validateProfileName();
- if (status.matches(IStatus.ERROR)) {
- updateStatus(status);
- return;
- }
-
- String name= fProfileNameField.getText().trim();
- if (!name.equals(fProfile.getName()) && fProfileManager.containsName(name)) {
- updateStatus(new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, FormatterMessages.ModifyDialog_Duplicate_Status));
- return;
- }
-
- if (fProfile.isBuiltInProfile() || fProfile.isSharedProfile()) {
- updateStatus(new Status(IStatus.INFO, JavaScriptUI.ID_PLUGIN, FormatterMessages.ModifyDialog_NewCreated_Status));
- return;
- }
-
- updateStatus(StatusInfo.OK_STATUS);
- }
-
- private IStatus validateProfileName() {
- final String name= fProfileNameField.getText().trim();
-
- if (fProfile.isBuiltInProfile()) {
- if (fProfile.getName().equals(name)) {
- return new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, FormatterMessages.ModifyDialog_BuiltIn_Status);
- }
- }
-
- if (fProfile.isSharedProfile()) {
- if (fProfile.getName().equals(name)) {
- return new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, FormatterMessages.ModifyDialog_Shared_Status);
- }
- }
-
- if (name.length() == 0) {
- return new Status(IStatus.ERROR, JavaScriptUI.ID_PLUGIN, FormatterMessages.ModifyDialog_EmptyName_Status);
- }
-
- return StatusInfo.OK_STATUS;
- }
-
- private boolean hasChanges() {
- if (!fProfileNameField.getText().trim().equals(fProfile.getName()))
- return true;
-
- Iterator iter= fProfile.getSettings().entrySet().iterator();
- for (;iter.hasNext();) {
- Map.Entry curr= (Map.Entry) iter.next();
- if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
deleted file mode 100644
index e540b1e8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
+++ /dev/null
@@ -1,817 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-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.Text;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public abstract class ModifyDialogTabPage {
-
- public interface IModificationListener {
-
- void updateStatus(IStatus status);
-
- void valuesModified();
-
- }
-
- /**
- * This is the default listener for any of the Preference
- * classes. It is added by the respective factory methods and
- * updates the page's preview on each change.
- */
- protected final Observer fUpdater= new Observer() {
- public void update(Observable o, Object arg) {
- doUpdatePreview();
- notifyValuesModified();
- }
- };
-
-
- /**
- * The base class of all Preference classes. A preference class provides a wrapper
- * around one or more SWT widgets and handles the input of values for some key.
- * On each change, the new value is written to the map and the listeners are notified.
- */
- protected abstract class Preference extends Observable {
- private final Map fPreferences;
- private boolean fEnabled;
- private String fKey;
-
- /**
- * Create a new Preference.
- * @param preferences The map where the value is written.
- * @param key The key for which a value is managed.
- */
- public Preference(Map preferences, String key) {
- fPreferences= preferences;
- fEnabled= true;
- fKey= key;
- }
- /**
- * @return Gets the map of this Preference.
- */
- protected final Map getPreferences() {
- return fPreferences;
- }
-
- /**
- * Set the enabled state of all SWT widgets of this preference.
- * @param enabled new value
- */
- public final void setEnabled(boolean enabled) {
- fEnabled= enabled;
- updateWidget();
- }
-
- /**
- * @return Gets the enabled state of all SWT widgets of this Preference.
- */
- public final boolean getEnabled() {
- return fEnabled;
- }
-
- /**
- * Set the key which is used to store the value.
- * @param key New value
- */
- public final void setKey(String key) {
- if (key == null || !fKey.equals(key)) {
- fKey= key;
- updateWidget();
- }
- }
- /**
- * @return Gets the currently used key which is used to store the value.
- */
- public final String getKey() {
- return fKey;
- }
-
- /**
- * Returns the main control of a preference, which is mainly used to
- * manage the focus. This may be <code>null</code> if the preference doesn't
- * have a control which is able to have the focus.
- * @return The main control
- */
- public abstract Control getControl();
-
- /**
- * To be implemented in subclasses. Update the SWT widgets when the state
- * of this object has changed (enabled, key, ...).
- */
- protected abstract void updateWidget();
- }
-
- /**
- * Wrapper around a checkbox and a label.
- */
- protected class ButtonPreference extends Preference {
- private final String[] fValues;
- private final Button fCheckbox;
-
- /**
- * Create a new CheckboxPreference.
- * @param composite The composite on which the SWT widgets are added.
- * @param numColumns The number of columns in the composite's GridLayout.
- * @param preferences The map to store the values.
- * @param key The key to store the values.
- * @param values An array of two elements indicating the values to store on unchecked/checked.
- * @param text The label text for this Preference.
- * @param style SWT style flag for the button
- */
- public ButtonPreference(Composite composite, int numColumns,
- Map preferences, String key,
- String [] values, String text, int style) {
- super(preferences, key);
- if (values == null || text == null)
- throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned);
- fValues= values;
-
- fCheckbox= new Button(composite, style);
- fCheckbox.setText(text);
- fCheckbox.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
- fCheckbox.setFont(composite.getFont());
-
- updateWidget();
-
- fCheckbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- checkboxChecked(((Button)e.widget).getSelection());
- }
- });
- }
-
- protected void checkboxChecked(boolean state) {
- getPreferences().put(getKey(), state ? fValues[1] : fValues[0]);
- setChanged();
- notifyObservers();
- }
-
- protected void updateWidget() {
- if (getKey() != null) {
- fCheckbox.setEnabled(getEnabled());
- fCheckbox.setSelection(getChecked());
- } else {
- fCheckbox.setSelection(false);
- fCheckbox.setEnabled(false);
- }
- }
-
- public boolean getChecked() {
- return fValues[1].equals(getPreferences().get(getKey()));
- }
-
- public void setChecked(boolean checked) {
- getPreferences().put(getKey(), checked ? fValues[1] : fValues[0]);
- updateWidget();
- checkboxChecked(checked);
- }
-
- public Control getControl() {
- return fCheckbox;
- }
- }
-
- protected final class CheckboxPreference extends ButtonPreference {
- public CheckboxPreference(Composite composite, int numColumns, Map preferences, String key, String[] values, String text) {
- super(composite, numColumns, preferences, key, values, text, SWT.CHECK);
- }
- }
-
- protected final class RadioPreference extends ButtonPreference {
- public RadioPreference(Composite composite, int numColumns, Map preferences, String key, String[] values, String text) {
- super(composite, numColumns, preferences, key, values, text, SWT.RADIO);
- }
- }
-
- /**
- * Wrapper around a Combo box.
- */
- protected final class ComboPreference extends Preference {
- private final String [] fItems;
- private final String[] fValues;
- private final Combo fCombo;
-
- /**
- * Create a new ComboPreference.
- * @param composite The composite on which the SWT widgets are added.
- * @param numColumns The number of columns in the composite's GridLayout.
- * @param preferences The map to store the values.
- * @param key The key to store the values.
- * @param values An array of n elements indicating the values to store for each selection.
- * @param text The label text for this Preference.
- * @param items An array of n elements indicating the text to be written in the combo box.
- */
- public ComboPreference(Composite composite, int numColumns,
- Map preferences, String key,
- String [] values, String text, String [] items) {
- super(preferences, key);
- if (values == null || items == null || text == null)
- throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned);
- fValues= values;
- fItems= items;
- createLabel(numColumns - 1, composite, text);
- fCombo= new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
- fCombo.setFont(composite.getFont());
- fCombo.setItems(items);
-
- int max= 0;
- for (int i= 0; i < items.length; i++)
- if (items[i].length() > max) max= items[i].length();
-
- fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));
-
- updateWidget();
-
- fCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- comboSelected(((Combo)e.widget).getSelectionIndex());
- }
- });
- }
-
- protected void comboSelected(int index) {
- getPreferences().put(getKey(), fValues[index]);
- setChanged();
- notifyObservers(fValues[index]);
- }
-
- protected void updateWidget() {
- if (getKey() != null) {
- fCombo.setEnabled(getEnabled());
- fCombo.setText(getSelectedItem());
- } else {
- fCombo.setText(""); //$NON-NLS-1$
- fCombo.setEnabled(false);
- }
- }
-
- public String getSelectedItem() {
- final String selected= (String)getPreferences().get(getKey());
- for (int i= 0; i < fValues.length; i++) {
- if (fValues[i].equals(selected)) {
- return fItems[i];
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- public boolean hasValue(String value) {
- return value.equals(getPreferences().get(getKey()));
- }
-
- public Control getControl() {
- return fCombo;
- }
- }
-
- /**
- * Wrapper around a textfied which requests an integer input of a given range.
- */
- protected final class NumberPreference extends Preference {
-
- private final int fMinValue, fMaxValue;
- private final Label fNumberLabel;
- private final Text fNumberText;
-
- protected int fSelected;
- protected int fOldSelected;
-
-
- /**
- * Create a new NumberPreference.
- * @param composite The composite on which the SWT widgets are added.
- * @param numColumns The number of columns in the composite's GridLayout.
- * @param preferences The map to store the values.
- * @param key The key to store the values.
- * @param minValue The minimum value which is valid input.
- * @param maxValue The maximum value which is valid input.
- * @param text The label text for this Preference.
- */
- public NumberPreference(Composite composite, int numColumns,
- Map preferences, String key,
- int minValue, int maxValue, String text) {
- super(preferences, key);
-
- fNumberLabel= createLabel(numColumns - 1, composite, text, GridData.FILL_HORIZONTAL);
- fNumberText= new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
- fNumberText.setFont(composite.getFont());
-
- final int length= Integer.toString(maxValue).length() + 3;
- fNumberText.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END, fPixelConverter.convertWidthInCharsToPixels(length)));
-
- fMinValue= minValue;
- fMaxValue= maxValue;
-
- updateWidget();
-
- fNumberText.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- NumberPreference.this.focusGained();
- }
- public void focusLost(FocusEvent e) {
- NumberPreference.this.focusLost();
- }
- });
-
- fNumberText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- fieldModified();
- }
- });
- }
-
- private IStatus createErrorStatus() {
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_value, new String [] {Integer.toString(fMinValue), Integer.toString(fMaxValue)}), null);
-
- }
-
- protected void focusGained() {
- fOldSelected= fSelected;
- fNumberText.setSelection(0, fNumberText.getCharCount());
- }
-
- protected void focusLost() {
- updateStatus(null);
- final String input= fNumberText.getText();
- if (!validInput(input))
- fSelected= fOldSelected;
- else
- fSelected= Integer.parseInt(input);
- if (fSelected != fOldSelected) {
- saveSelected();
- fNumberText.setText(Integer.toString(fSelected));
- }
- }
-
-
- protected void fieldModified() {
- final String trimInput= fNumberText.getText().trim();
- final boolean valid= validInput(trimInput);
-
- updateStatus(valid ? null : createErrorStatus());
-
- if (valid) {
- final int number= Integer.parseInt(trimInput);
- if (fSelected != number) {
- fSelected= number;
- saveSelected();
- }
- }
- }
-
- private boolean validInput(String trimInput) {
- int number;
-
- try {
- number= Integer.parseInt(trimInput);
- } catch (NumberFormatException x) {
- return false;
- }
-
- if (number < fMinValue) return false;
- if (number > fMaxValue) return false;
- return true;
- }
-
- private void saveSelected() {
- getPreferences().put(getKey(), Integer.toString(fSelected));
- setChanged();
- notifyObservers();
- }
-
- protected void updateWidget() {
- final boolean hasKey= getKey() != null;
-
- fNumberLabel.setEnabled(hasKey && getEnabled());
- fNumberText.setEnabled(hasKey && getEnabled());
-
- if (hasKey) {
- String s= (String)getPreferences().get(getKey());
- try {
- fSelected= Integer.parseInt(s);
- } catch (NumberFormatException e) {
- final String message= Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey());
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, message, e));
- s= ""; //$NON-NLS-1$
- }
- fNumberText.setText(s);
- } else {
- fNumberText.setText(""); //$NON-NLS-1$
- }
- }
-
- public Control getControl() {
- return fNumberText;
- }
- }
-
-
- /**
- * This class provides the default way to preserve and re-establish the focus
- * over multiple modify sessions. Each ModifyDialogTabPage has its own instance,
- * and it should add all relevant controls upon creation, always in the same sequence.
- * This established a mapping of controls to indexes, which allows to restore the focus
- * in a later session.
- * The index is saved in the dialog settings, and there is only one common preference for
- * all tab pages. It is always the currently active tab page which stores its focus
- * index.
- */
- protected final static class DefaultFocusManager extends FocusAdapter {
-
- private final static String PREF_LAST_FOCUS_INDEX= JavaScriptUI.ID_PLUGIN + "formatter_page.modify_dialog_tab_page.last_focus_index"; //$NON-NLS-1$
-
- private final IDialogSettings fDialogSettings;
-
- private final Map fItemMap;
- private final List fItemList;
-
- private int fIndex;
-
- public DefaultFocusManager() {
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- fItemMap= new HashMap();
- fItemList= new ArrayList();
- fIndex= 0;
- }
-
- public void focusGained(FocusEvent e) {
- fDialogSettings.put(PREF_LAST_FOCUS_INDEX, ((Integer)fItemMap.get(e.widget)).intValue());
- }
-
- public void add(Control control) {
- control.addFocusListener(this);
- fItemList.add(fIndex, control);
- fItemMap.put(control, new Integer(fIndex++));
- }
-
- public void add(Preference preference) {
- final Control control= preference.getControl();
- if (control != null)
- add(control);
- }
-
- public boolean isUsed() {
- return fIndex != 0;
- }
-
- public void restoreFocus() {
- int index= 0;
- try {
- index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
- // make sure the value is within the range
- if ((index >= 0) && (index <= fItemList.size() - 1)) {
- ((Control)fItemList.get(index)).setFocus();
- }
- } catch (NumberFormatException ex) {
- // this is the first time
- }
- }
-
- public void resetFocus() {
- fDialogSettings.put(PREF_LAST_FOCUS_INDEX, -1);
- }
- }
-
- /**
- * The default focus manager. This widget knows all widgets which can have the focus
- * and listens for focusGained events, on which it stores the index of the current
- * focus holder. When the dialog is restarted, <code>restoreFocus()</code> sets the
- * focus to the last control which had it.
- *
- * The standard Preference object are managed by this focus manager if they are created
- * using the respective factory methods. Other SWT widgets can be added in subclasses
- * when they are created.
- */
- protected final DefaultFocusManager fDefaultFocusManager;
-
- /**
- * A pixel converter for layout calculations
- */
- protected PixelConverter fPixelConverter;
-
-
- /**
- * The map where the current settings are stored.
- */
- protected final Map fWorkingValues;
-
- /**
- * The modify dialog where we can display status messages.
- */
- private final IModificationListener fModifyListener;
-
-
- /*
- * Create a new <code>ModifyDialogTabPage</code>
- */
- public ModifyDialogTabPage(IModificationListener modifyListener, Map workingValues) {
- fWorkingValues= workingValues;
- fModifyListener= modifyListener;
- fDefaultFocusManager= new DefaultFocusManager();
- }
-
- /**
- * Create the contents of this tab page. Subclasses cannot override this,
- * instead they must implement <code>doCreatePreferences</code>. <code>doCreatePreview</code> may also
- * be overridden as necessary.
- * @param parent The parent composite
- * @return Created content control
- */
- public final Composite createContents(Composite parent) {
- final int numColumns= 4;
-
- if (fPixelConverter == null) {
- fPixelConverter= new PixelConverter(parent);
- }
-
- final SashForm fSashForm = new SashForm(parent, SWT.HORIZONTAL);
- fSashForm.setFont(parent.getFont());
-
- final Composite settingsPane= new Composite(fSashForm, SWT.NONE);
- settingsPane.setFont(fSashForm.getFont());
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= (int)(1.5 * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- settingsPane.setLayout(layout);
- doCreatePreferences(settingsPane, numColumns);
-
- final Composite previewPane= new Composite(fSashForm, SWT.NONE);
- previewPane.setLayout(createGridLayout(numColumns, true));
- previewPane.setFont(fSashForm.getFont());
- doCreatePreviewPane(previewPane, numColumns);
-
- initializePage();
-
- fSashForm.setWeights(new int [] {3, 3});
- return fSashForm;
- }
-
- /**
- * This method is called after all controls have been alloated, including the preview.
- * It can be used to set the preview text and to create listeners.
- *
- */
- protected abstract void initializePage();
-
-
- /**
- * Create the left side of the modify dialog. This is meant to be implemented by subclasses.
- * @param composite Composite to create in
- * @param numColumns Number of columns to use
- */
- protected abstract void doCreatePreferences(Composite composite, int numColumns);
-
-
- /**
- * Create the right side of the modify dialog. By default, the preview is displayed there.
- * Subclasses can override this method in order to customize the right-hand side of the
- * dialog.
- * @param composite Composite to create in
- * @param numColumns Number of columns to use
- * @return Created composite
- */
- protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
-
- createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
-
- final JavaPreview preview= doCreateJavaPreview(composite);
- fDefaultFocusManager.add(preview.getControl());
-
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
- gd.widthHint= 0;
- gd.heightHint=0;
- preview.getControl().setLayoutData(gd);
-
- return composite;
- }
-
-
- /**
- * To be implemented by subclasses. This method should return an instance of JavaPreview.
- * Currently, the choice is between CompilationUnitPreview which contains a valid compilation
- * unit, or a SnippetPreview which formats several independent code snippets and displays them
- * in the same window.
- * @param parent Parent composite
- * @return Created preview
- */
- protected abstract JavaPreview doCreateJavaPreview(Composite parent);
-
-
- /**
- * This is called when the page becomes visible.
- * Common tasks to do include:
- * <ul><li>Updating the preview.</li>
- * <li>Setting the focus</li>
- * </ul>
- */
- final public void makeVisible() {
- fDefaultFocusManager.resetFocus();
- doUpdatePreview();
- }
-
- /**
- * Update the preview. To be implemented by subclasses.
- */
- protected abstract void doUpdatePreview();
-
- protected void notifyValuesModified() {
- fModifyListener.valuesModified();
- }
- /**
- * Each tab page should remember where its last focus was, and reset it
- * correctly within this method. This method is only called after
- * initialization on the first tab page to be displayed in order to restore
- * the focus of the last session.
- */
- public void setInitialFocus() {
- if (fDefaultFocusManager.isUsed()) {
- fDefaultFocusManager.restoreFocus();
- }
- }
-
-
- /**
- * Set the status field on the dialog. This can be used by tab pages to report
- * inconsistent input. The OK button is disabled if the kind is IStatus.ERROR.
- * @param status Status describing the current page error state
- */
- protected void updateStatus(IStatus status) {
- fModifyListener.updateStatus(status);
- }
-
- /*
- * Factory methods to make GUI construction easier
- */
-
- /*
- * Create a GridLayout with the default margin and spacing settings, as
- * well as the specified number of columns.
- */
- protected GridLayout createGridLayout(int numColumns, boolean margins) {
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- if (margins) {
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- } else {
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- }
- return layout;
- }
-
- /*
- * Convenience method to create a GridData.
- */
- protected static GridData createGridData(int numColumns, int style, int widthHint) {
- final GridData gd= new GridData(style);
- gd.horizontalSpan= numColumns;
- gd.widthHint= widthHint;
- return gd;
- }
-
-
- /*
- * Convenience method to create a label.
- */
- protected static Label createLabel(int numColumns, Composite parent, String text) {
- return createLabel(numColumns, parent, text, GridData.FILL_HORIZONTAL);
- }
-
- /*
- * Convenience method to create a label
- */
- protected static Label createLabel(int numColumns, Composite parent, String text, int gridDataStyle) {
- final Label label= new Label(parent, SWT.WRAP);
- label.setFont(parent.getFont());
- label.setText(text);
-
- PixelConverter pixelConverter= new PixelConverter(parent);
- label.setLayoutData(createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150)));
- return label;
- }
-
- /*
- * Convenience method to create a group
- */
- protected Group createGroup(int numColumns, Composite parent, String text ) {
- final Group group= new Group(parent, SWT.NONE);
- group.setFont(parent.getFont());
- group.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
-
- //layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- //layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
-
- group.setLayout(layout);//createGridLayout(numColumns, true));
- group.setText(text);
- return group;
- }
-
-
- /*
- * Convenience method to create a NumberPreference. The widget is registered as
- * a potential focus holder, and the default updater is added.
- */
- protected NumberPreference createNumberPref(Composite composite, int numColumns, String name, String key,
- int minValue, int maxValue) {
- final NumberPreference pref= new NumberPreference(composite, numColumns, fWorkingValues,
- key, minValue, maxValue, name);
- fDefaultFocusManager.add(pref);
- pref.addObserver(fUpdater);
- return pref;
- }
-
- /*
- * Convenience method to create a ComboPreference. The widget is registered as
- * a potential focus holder, and the default updater is added.
- */
- protected ComboPreference createComboPref(Composite composite, int numColumns, String name,
- String key, String [] values, String [] items) {
- final ComboPreference pref= new ComboPreference(composite, numColumns,
- fWorkingValues, key, values, name, items);
- fDefaultFocusManager.add(pref);
- pref.addObserver(fUpdater);
- return pref;
- }
-
- /*
- * Convenience method to create a CheckboxPreference. The widget is registered as
- * a potential focus holder, and the default updater is added.
- */
- protected CheckboxPreference createCheckboxPref(Composite composite, int numColumns, String name, String key,
- String [] values) {
- final CheckboxPreference pref= new CheckboxPreference(composite, numColumns,
- fWorkingValues, key, values, name);
- fDefaultFocusManager.add(pref);
- pref.addObserver(fUpdater);
- return pref;
- }
-
- protected RadioPreference createRadioPref(Composite composite, int numColumns, String name, String key,
- String [] values) {
- final RadioPreference pref= new RadioPreference(composite, numColumns,
- fWorkingValues, key, values, name);
- fDefaultFocusManager.add(pref);
- pref.addObserver(fUpdater);
- return pref;
- }
-
-
- /*
- * Create a nice javadoc comment for some string.
- */
- protected static String createPreviewHeader(String title) {
- return "/**\n* " + title + "\n*/\n"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/NewLinesTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/NewLinesTabPage.java
deleted file mode 100644
index 78f88cc3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/NewLinesTabPage.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-
-
-
-public class NewLinesTabPage extends FormatterTabPage {
-
- /**
- * Constant array for boolean selection
- */
- private static String[] FALSE_TRUE = {
- DefaultCodeFormatterConstants.FALSE,
- DefaultCodeFormatterConstants.TRUE
- };
-
- /**
- * Constant array for insert / not_insert.
- */
- private static String[] DO_NOT_INSERT_INSERT = {
- JavaScriptCore.DO_NOT_INSERT,
- JavaScriptCore.INSERT
- };
-
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.NewLinesTabPage_preview_header) +
- "var someData;\n" + //$NON-NLS-1$
- "var someMoreData = 5;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "function foo(data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " var abc = 1;\n" + //$NON-NLS-1$
- " var xyz = 'one';\n" + //$NON-NLS-1$
- " var arr1 = ['123',function() {return 5},'abc'];\n" + //$NON-NLS-1$
- " var obj1 = { make: 'Ford', model: 'Thunderbird', year: 1967 };\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " if (data>5) {\n" + //$NON-NLS-1$
- " data = 5;\n" + //$NON-NLS-1$
- " } else {\n" + //$NON-NLS-1$
- " data--;\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " switch (data) {\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " case 0:\n" + //$NON-NLS-1$
- " abc = 0;\n" + //$NON-NLS-1$
- " xyz = 'zero';\n" + //$NON-NLS-1$
- " break;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " default:\n" + //$NON-NLS-1$
- " abc = -1;\n" + //$NON-NLS-1$
- " xyz = 'unknown';\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- " }\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
-
-
-
- protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
-
- private CompilationUnitPreview fPreview;
-
- public NewLinesTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
-
- final Group newlinesGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_newlines_group_title);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_anonymous_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
- createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_method_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, DO_NOT_INSERT_INSERT);
- createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPa/ge_newlines_group_option_empty_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_constant, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_annotation_decl_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, DO_NOT_INSERT_INSERT);
- createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, DO_NOT_INSERT_INSERT);
-
- final Group objectInitializerGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_objectInitializer_group_title);
- createPref(objectInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_object_group_option_after_opening_brace_of_object_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_OBJLIT_INITIALIZER, DO_NOT_INSERT_INSERT);
- createPref(objectInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_object_group_option_before_closing_brace_of_object_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_OBJLIT_INITIALIZER, DO_NOT_INSERT_INSERT);
- createPref(objectInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_object_group_option_after_comma_in_object_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_COMMA_IN_OBJLIT_INITIALIZER, DO_NOT_INSERT_INSERT);
-
- final Group arrayInitializerGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_arrayInitializer_group_title);
- createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
- createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
-
- final Group emptyStatementsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_empty_statement_group_title);
- createPref(emptyStatementsGroup, numColumns, FormatterMessages.NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, FALSE_TRUE);
-
-// final Group annotationsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_annotations_group_title);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_option_after_annotation, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DO_NOT_INSERT_INSERT);
-
- }
-
- protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
- }
-
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new CompilationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-
- private CheckboxPreference createPref(Composite composite, int numColumns, String message, String key, String[] values) {
- return createCheckboxPref(composite, numColumns, message, key, values);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
deleted file mode 100644
index df47a709..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.window.Window;
-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.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesMessages;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.osgi.service.prefs.BackingStoreException;
-
-public abstract class ProfileConfigurationBlock {
-
- private class StoreUpdater implements Observer {
-
- public StoreUpdater() {
- fProfileManager.addObserver(this);
- }
-
- public void update(Observable o, Object arg) {
- try {
- fPreferenceListenerEnabled= false;
- final int value= ((Integer)arg).intValue();
- switch (value) {
- case ProfileManager.PROFILE_DELETED_EVENT:
- case ProfileManager.PROFILE_RENAMED_EVENT:
- case ProfileManager.PROFILE_CREATED_EVENT:
- case ProfileManager.SETTINGS_CHANGED_EVENT:
- try {
- fProfileStore.writeProfiles(fProfileManager.getSortedProfiles(), fInstanceScope); // update profile store
- fProfileManager.commitChanges(fCurrContext);
- } catch (CoreException x) {
- JavaScriptPlugin.log(x);
- }
- break;
- case ProfileManager.SELECTION_CHANGED_EVENT:
- fProfileManager.commitChanges(fCurrContext);
- break;
- }
- } finally {
- fPreferenceListenerEnabled= true;
- }
- }
- }
-
- class ProfileComboController implements Observer, SelectionListener {
-
- private final List fSortedProfiles;
-
- public ProfileComboController() {
- fSortedProfiles= fProfileManager.getSortedProfiles();
- fProfileCombo.addSelectionListener(this);
- fProfileManager.addObserver(this);
- updateProfiles();
- updateSelection();
- }
-
- public void widgetSelected(SelectionEvent e) {
- final int index= fProfileCombo.getSelectionIndex();
- fProfileManager.setSelected((Profile)fSortedProfiles.get(index));
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void update(Observable o, Object arg) {
- if (arg == null) return;
- final int value= ((Integer)arg).intValue();
- switch (value) {
- case ProfileManager.PROFILE_CREATED_EVENT:
- case ProfileManager.PROFILE_DELETED_EVENT:
- case ProfileManager.PROFILE_RENAMED_EVENT:
- updateProfiles();
- updateSelection();
- break;
- case ProfileManager.SELECTION_CHANGED_EVENT:
- updateSelection();
- break;
- }
- }
-
- private void updateProfiles() {
- fProfileCombo.setItems(fProfileManager.getSortedDisplayNames());
- }
-
- private void updateSelection() {
- fProfileCombo.setText(fProfileManager.getSelected().getName());
- }
- }
-
- class ButtonController implements Observer, SelectionListener {
-
- public ButtonController() {
- fProfileManager.addObserver(this);
- fNewButton.addSelectionListener(this);
- fEditButton.addSelectionListener(this);
- fDeleteButton.addSelectionListener(this);
- fLoadButton.addSelectionListener(this);
- update(fProfileManager, null);
- }
-
- public void update(Observable o, Object arg) {
- Profile selected= ((ProfileManager)o).getSelected();
- final boolean notBuiltIn= !selected.isBuiltInProfile();
- fDeleteButton.setEnabled(notBuiltIn);
- }
-
- public void widgetSelected(SelectionEvent e) {
- final Button button= (Button)e.widget;
- if (button == fEditButton)
- modifyButtonPressed();
- else if (button == fDeleteButton)
- deleteButtonPressed();
- else if (button == fNewButton)
- newButtonPressed();
- else if (button == fLoadButton)
- loadButtonPressed();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- private void modifyButtonPressed() {
- final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), fProfileManager.getSelected(), fProfileManager, fProfileStore, false);
- modifyDialog.open();
- }
-
- private void deleteButtonPressed() {
- if (MessageDialog.openQuestion(
- fComposite.getShell(),
- FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title,
- Messages.format(FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question, fProfileManager.getSelected().getName()))) {
- fProfileManager.deleteSelected();
- }
- }
-
- private void newButtonPressed() {
- final CreateProfileDialog p= new CreateProfileDialog(fComposite.getShell(), fProfileManager, fProfileVersioner);
- if (p.open() != Window.OK)
- return;
- if (!p.openEditDialog())
- return;
- final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), p.getCreatedProfile(), fProfileManager, fProfileStore, true);
- modifyDialog.open();
- }
-
- private void loadButtonPressed() {
- final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.OPEN);
- dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title);
- dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
- final String lastPath= JavaScriptPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$NON-NLS-1$
- if (lastPath != null) {
- dialog.setFilterPath(lastPath);
- }
- final String path= dialog.open();
- if (path == null)
- return;
- JavaScriptPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
-
- final File file= new File(path);
- Collection profiles= null;
- try {
- profiles= fProfileStore.readProfilesFromFile(file);
- } catch (CoreException e) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message;
- ExceptionHandler.handle(e, fComposite.getShell(), title, message);
- }
- if (profiles == null || profiles.isEmpty())
- return;
-
- final CustomProfile profile= (CustomProfile)profiles.iterator().next();
-
- if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
- final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] {fProfileVersioner.getProfileKind(), profile.getKind()});
- MessageDialog.openError(fComposite.getShell(), title, message);
- return;
- }
-
- if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message;
- MessageDialog.openWarning(fComposite.getShell(), title, message);
- }
-
- if (fProfileManager.containsName(profile.getName())) {
- final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager);
- if (aeDialog.open() != Window.OK)
- return;
- }
- fProfileVersioner.update(profile);
- fProfileManager.addProfile(profile);
- }
- }
-
- /**
- * The GUI controls
- */
- private Composite fComposite;
- private Combo fProfileCombo;
- private Button fEditButton;
- private Button fDeleteButton;
- private Button fNewButton;
- private Button fLoadButton;
-
- private PixelConverter fPixConv;
- /**
- * The ProfileManager, the model of this page.
- */
- private final ProfileManager fProfileManager;
- private final IScopeContext fCurrContext;
- private final IScopeContext fInstanceScope;
- private final ProfileStore fProfileStore;
- private final IProfileVersioner fProfileVersioner;
- private final String fLastSaveLoadPathKey;
- private IPreferenceChangeListener fPreferenceListener;
- private final PreferencesAccess fPreferenceAccess;
- private boolean fPreferenceListenerEnabled;
-
- public ProfileConfigurationBlock(IProject project, final PreferencesAccess access, String lastSaveLoadPathKey) {
-
- fPreferenceAccess= access;
- fLastSaveLoadPathKey= lastSaveLoadPathKey;
-
- fProfileVersioner= createProfileVersioner();
- fProfileStore= createProfileStore(fProfileVersioner);
- fInstanceScope= access.getInstanceScope();
- if (project != null) {
- fCurrContext= access.getProjectScope(project);
- } else {
- fCurrContext= fInstanceScope;
- }
-
- List profiles= null;
- try {
- profiles= fProfileStore.readProfiles(fInstanceScope);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- if (profiles == null) {
- try {
- // bug 129427
- profiles= fProfileStore.readProfiles(new DefaultScope());
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- if (profiles == null)
- profiles= new ArrayList();
-
- fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
-
- new StoreUpdater();
-
- fPreferenceListenerEnabled= true;
- fPreferenceListener= new IPreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- if (fPreferenceListenerEnabled) {
- preferenceChanged(event);
- }
- }
- };
- access.getInstanceScope().getNode(JavaScriptUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceListener);
-
- }
-
- protected void preferenceChanged(PreferenceChangeEvent event) {
-
- }
-
- protected abstract IProfileVersioner createProfileVersioner();
-
- protected abstract ProfileStore createProfileStore(IProfileVersioner versioner);
-
- protected abstract ProfileManager createProfileManager(List profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner);
-
- protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile);
-
- protected abstract void configurePreview(Composite composite, int numColumns, ProfileManager profileManager);
-
- private static Button createButton(Composite composite, String text, final int style) {
- final Button button= new Button(composite, SWT.PUSH);
- button.setFont(composite.getFont());
- button.setText(text);
-
- final GridData gd= new GridData(style);
- gd.widthHint= SWTUtil.getButtonWidthHint(button);
- button.setLayoutData(gd);
- return button;
- }
-
- /**
- * Create the contents
- * @param parent Parent composite
- * @return Created control
- */
- public Composite createContents(Composite parent) {
-
- final int numColumns = 5;
-
- fPixConv = new PixelConverter(parent);
- fComposite = createComposite(parent, numColumns);
-
- Label profileLabel= new Label(fComposite, SWT.NONE);
- profileLabel.setText(PreferencesMessages.CleanUpPreferencePage_Description);
- GridData data= new GridData(SWT.FILL, SWT.FILL, true, false);
- data.horizontalSpan= numColumns;
- profileLabel.setLayoutData(data);
-
- fProfileCombo= createProfileCombo(fComposite, 3, fPixConv.convertWidthInCharsToPixels(20));
- fEditButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
- fDeleteButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_remove_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
-
- fNewButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
- fLoadButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc, GridData.HORIZONTAL_ALIGN_END);
- createLabel(fComposite, "", 3); //$NON-NLS-1$
-
- configurePreview(fComposite, numColumns, fProfileManager);
-
- new ButtonController();
- new ProfileComboController();
-
- return fComposite;
- }
-
- private static Combo createProfileCombo(Composite composite, int span, int widthHint) {
- final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = span;
- gd.widthHint= widthHint;
-
- final Combo combo= new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY );
- combo.setFont(composite.getFont());
- combo.setLayoutData(gd);
- return combo;
- }
-
- protected static Label createLabel(Composite composite, String text, int numColumns) {
- final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = numColumns;
- gd.widthHint= 0;
-
- final Label label = new Label(composite, SWT.WRAP);
- label.setFont(composite.getFont());
- label.setText(text);
- label.setLayoutData(gd);
- return label;
- }
-
- private Composite createComposite(Composite parent, int numColumns) {
- final Composite composite = new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
-
- final GridLayout layout = new GridLayout(numColumns, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- return composite;
- }
-
- public final boolean hasProjectSpecificOptions(IProject project) {
- if (project != null) {
- return fProfileManager.hasProjectSpecificSettings(new ProjectScope(project));
- }
- return false;
- }
-
- public boolean performOk() {
- return true;
- }
-
- public void performApply() {
- try {
- fCurrContext.getNode(JavaScriptUI.ID_PLUGIN).flush();
- fCurrContext.getNode(JavaScriptCore.PLUGIN_ID).flush();
- if (fCurrContext != fInstanceScope) {
- fInstanceScope.getNode(JavaScriptUI.ID_PLUGIN).flush();
- fInstanceScope.getNode(JavaScriptCore.PLUGIN_ID).flush();
- }
- } catch (BackingStoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- public void performDefaults() {
- Profile profile= fProfileManager.getDefaultProfile();
- if (profile != null) {
- int defaultIndex= fProfileManager.getSortedProfiles().indexOf(profile);
- if (defaultIndex != -1) {
- fProfileManager.setSelected(profile);
- }
- }
- }
-
- public void dispose() {
- if (fPreferenceListener != null) {
- fPreferenceAccess.getInstanceScope().getNode(JavaScriptUI.ID_PLUGIN).removePreferenceChangeListener(fPreferenceListener);
- fPreferenceListener= null;
- }
- }
-
- public void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- if (useProjectSpecificSettings) {
- fProfileManager.commitChanges(fCurrContext);
- } else {
- fProfileManager.clearAllSettings(fCurrContext);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileManager.java
deleted file mode 100644
index 9053cb46..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileManager.java
+++ /dev/null
@@ -1,795 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Observable;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.preferences.PreferencesAccess;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * The model for the set of profiles which are available in the workbench.
- */
-public abstract class ProfileManager extends Observable {
-
- public static final class KeySet {
-
- private final List fKeys;
- private final String fNodeName;
-
- public KeySet(String nodeName, List keys) {
- fNodeName= nodeName;
- fKeys= keys;
- }
-
- public String getNodeName() {
- return fNodeName;
- }
-
- public List getKeys() {
- return fKeys;
- }
- }
-
- /**
- * A prefix which is prepended to every ID of a user-defined profile, in order
- * to differentiate it from a built-in profile.
- */
- public final static String ID_PREFIX= "_"; //$NON-NLS-1$
-
- /**
- * Represents a profile with a unique ID, a name and a map
- * containing the code formatter settings.
- */
- public static abstract class Profile implements Comparable {
-
- public abstract String getName();
- public abstract Profile rename(String name, ProfileManager manager);
-
- public abstract Map getSettings();
- public abstract void setSettings(Map settings);
-
- public abstract int getVersion();
-
- public boolean hasEqualSettings(Map otherMap, List allKeys) {
- Map settings= getSettings();
- for (Iterator iter= allKeys.iterator(); iter.hasNext(); ){
- String key= (String) iter.next();
- Object other= otherMap.get(key);
- Object curr= settings.get(key);
- if (other == null) {
- if (curr != null) {
- return false;
- }
- } else if (!other.equals(curr)) {
- return false;
- }
- }
- return true;
- }
-
- public abstract boolean isProfileToSave();
-
- public abstract String getID();
-
- public boolean isSharedProfile() {
- return false;
- }
-
- public boolean isBuiltInProfile() {
- return false;
- }
- }
-
- /**
- * Represents a built-in profile. The state of a built-in profile
- * cannot be changed after instantiation.
- */
- public static final class BuiltInProfile extends Profile {
- private final String fName;
- private final String fID;
- private final Map fSettings;
- private final int fOrder;
- private final int fCurrentVersion;
- private final String fProfileKind;
-
- public BuiltInProfile(String ID, String name, Map settings, int order, int currentVersion, String profileKind) {
- fName= name;
- fID= ID;
- fSettings= settings;
- fOrder= order;
- fCurrentVersion= currentVersion;
- fProfileKind= profileKind;
- }
-
- public String getName() {
- return fName;
- }
-
- public Profile rename(String name, ProfileManager manager) {
- final String trimmed= name.trim();
- CustomProfile newProfile= new CustomProfile(trimmed, fSettings, fCurrentVersion, fProfileKind);
- manager.addProfile(newProfile);
- return newProfile;
- }
-
- public Map getSettings() {
- return fSettings;
- }
-
- public void setSettings(Map settings) {
- }
-
- public String getID() {
- return fID;
- }
-
- public final int compareTo(Object o) {
- if (o instanceof BuiltInProfile) {
- return fOrder - ((BuiltInProfile)o).fOrder;
- }
- return -1;
- }
-
- public boolean isProfileToSave() {
- return false;
- }
-
- public boolean isBuiltInProfile() {
- return true;
- }
-
- public int getVersion() {
- return fCurrentVersion;
- }
-
- }
-
- /**
- * Represents a user-defined profile. A custom profile can be modified after instantiation.
- */
- public static class CustomProfile extends Profile {
- private String fName;
- private Map fSettings;
- protected ProfileManager fManager;
- private int fVersion;
- private final String fKind;
-
- public CustomProfile(String name, Map settings, int version, String kind) {
- fName= name;
- fSettings= settings;
- fVersion= version;
- fKind= kind;
- }
-
- public String getName() {
- return fName;
- }
-
- public Profile rename(String name, ProfileManager manager) {
- final String trimmed= name.trim();
- if (trimmed.equals(getName()))
- return this;
-
- String oldID= getID(); // remember old id before changing name
- fName= trimmed;
-
- manager.profileRenamed(this, oldID);
- return this;
- }
-
- public Map getSettings() {
- return fSettings;
- }
-
- public void setSettings(Map settings) {
- if (settings == null)
- throw new IllegalArgumentException();
- fSettings= settings;
- if (fManager != null) {
- fManager.profileChanged(this);
- }
- }
-
- public String getID() {
- return ID_PREFIX + fName;
- }
-
- public void setManager(ProfileManager profileManager) {
- fManager= profileManager;
- }
-
- public ProfileManager getManager() {
- return fManager;
- }
-
- public int getVersion() {
- return fVersion;
- }
-
- public void setVersion(int version) {
- fVersion= version;
- }
-
- public int compareTo(Object o) {
- if (o instanceof SharedProfile) {
- return -1;
- }
- if (o instanceof CustomProfile) {
- return getName().compareToIgnoreCase(((Profile)o).getName());
- }
- return 1;
- }
-
- public boolean isProfileToSave() {
- return true;
- }
-
- public String getKind() {
- return fKind;
- }
-
- }
-
- public final class SharedProfile extends CustomProfile {
-
- public SharedProfile(String oldName, Map options, int version, String profileKind) {
- super(oldName, options, version, profileKind);
- }
-
- public Profile rename(String name, ProfileManager manager) {
- CustomProfile profile= new CustomProfile(name.trim(), getSettings(), getVersion(), getKind());
-
- manager.profileReplaced(this, profile);
- return profile;
- }
-
- public String getID() {
- return SHARED_PROFILE;
- }
-
- public final int compareTo(Object o) {
- return 1;
- }
-
- public boolean isProfileToSave() {
- return false;
- }
-
- public boolean isSharedProfile() {
- return true;
- }
- }
-
-
- /**
- * The possible events for observers listening to this class.
- */
- public final static int SELECTION_CHANGED_EVENT= 1;
- public final static int PROFILE_DELETED_EVENT= 2;
- public final static int PROFILE_RENAMED_EVENT= 3;
- public final static int PROFILE_CREATED_EVENT= 4;
- public final static int SETTINGS_CHANGED_EVENT= 5;
-
-
- /**
- * The key of the preference where the selected profile is stored.
- */
- private final String fProfileKey;
-
- /**
- * The key of the preference where the version of the current settings is stored
- */
- private final String fProfileVersionKey;
-
-
- private final static String SHARED_PROFILE= "org.eclipse.wst.jsdt.ui.default.shared"; //$NON-NLS-1$
-
-
- /**
- * A map containing the available profiles, using the IDs as keys.
- */
- private final Map fProfiles;
-
- /**
- * The available profiles, sorted by name.
- */
- private final List fProfilesByName;
-
-
- /**
- * The currently selected profile.
- */
- private Profile fSelected;
-
-
- /**
- * The keys of the options to be saved with each profile
- */
- private final KeySet[] fKeySets;
-
- private final PreferencesAccess fPreferencesAccess;
- private final IProfileVersioner fProfileVersioner;
-
- /**
- * Create and initialize a new profile manager.
- * @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
- * @param profileVersioner
- */
- public ProfileManager(
- List profiles,
- IScopeContext context,
- PreferencesAccess preferencesAccess,
- IProfileVersioner profileVersioner,
- KeySet[] keySets,
- String profileKey,
- String profileVersionKey) {
-
- fPreferencesAccess= preferencesAccess;
- fProfileVersioner= profileVersioner;
- fKeySets= keySets;
- fProfileKey= profileKey;
- fProfileVersionKey= profileVersionKey;
-
- fProfiles= new HashMap();
- fProfilesByName= new ArrayList();
-
- for (final Iterator iter = profiles.iterator(); iter.hasNext();) {
- final Profile profile= (Profile) iter.next();
- if (profile instanceof CustomProfile) {
- ((CustomProfile)profile).setManager(this);
- }
- fProfiles.put(profile.getID(), profile);
- fProfilesByName.add(profile);
- }
-
- Collections.sort(fProfilesByName);
-
- String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope());
-
- Profile profile= (Profile) fProfiles.get(profileId);
- if (profile == null) {
- profile= getDefaultProfile();
- }
- fSelected= profile;
-
- if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
- Map map= readFromPreferenceStore(context, profile);
- if (map != null) {
-
- List allKeys= new ArrayList();
- for (int i= 0; i < fKeySets.length; i++) {
- allKeys.addAll(fKeySets[i].getKeys());
- }
- Collections.sort(allKeys);
-
- Profile matching= null;
-
- String projProfileId= context.getNode(JavaScriptUI.ID_PLUGIN).get(fProfileKey, null);
- if (projProfileId != null) {
- Profile curr= (Profile) fProfiles.get(projProfileId);
- if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
- matching= curr;
- }
- } else {
- // old version: look for similar
- for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
- Profile curr= (Profile) iter.next();
- if (curr.hasEqualSettings(map, allKeys)) {
- matching= curr;
- break;
- }
- }
- }
- if (matching == null) {
- String name;
- if (projProfileId != null && !fProfiles.containsKey(projProfileId)) {
- name= Messages.format(FormatterMessages.ProfileManager_unmanaged_profile_with_name, projProfileId.substring(ID_PREFIX.length()));
- } else {
- name= FormatterMessages.ProfileManager_unmanaged_profile;
- }
- // current settings do not correspond to any profile -> create a 'team' profile
- SharedProfile shared= new SharedProfile(name, map, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
- shared.setManager(this);
- fProfiles.put(shared.getID(), shared);
- fProfilesByName.add(shared); // add last
- matching= shared;
- }
- fSelected= matching;
- }
- }
- }
-
- protected String getSelectedProfileId(IScopeContext instanceScope) {
- String profileId= instanceScope.getNode(JavaScriptUI.ID_PLUGIN).get(fProfileKey, null);
- if (profileId == null) {
- // request from bug 129427
- profileId= new DefaultScope().getNode(JavaScriptUI.ID_PLUGIN).get(fProfileKey, null);
- }
- return profileId;
- }
-
- /**
- * Notify observers with a message. The message must be one of the following:
- * @param message Message to send out
- *
- * @see #SELECTION_CHANGED_EVENT
- * @see #PROFILE_DELETED_EVENT
- * @see #PROFILE_RENAMED_EVENT
- * @see #PROFILE_CREATED_EVENT
- * @see #SETTINGS_CHANGED_EVENT
- */
- protected void notifyObservers(int message) {
- setChanged();
- notifyObservers(new Integer(message));
- }
-
- public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
- for (int i= 0; i < keySets.length; i++) {
- KeySet keySet= keySets[i];
- IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
- for (final Iterator keyIter= keySet.getKeys().iterator(); keyIter.hasNext();) {
- final String key= (String)keyIter.next();
- Object val= preferences.get(key, null);
- if (val != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean hasProjectSpecificSettings(IScopeContext context) {
- return hasProjectSpecificSettings(context, fKeySets);
- }
-
- /**
- * Only to read project specific settings to find out to what profile it matches.
- * @param context The project context
- */
- private Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
- final Map profileOptions= new HashMap();
- IEclipsePreferences uiPrefs= context.getNode(JavaScriptUI.ID_PLUGIN);
-
- int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
- if (version != fProfileVersioner.getCurrentVersion()) {
- Map allOptions= new HashMap();
- for (int i= 0; i < fKeySets.length; i++) {
- addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
- }
- CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
- fProfileVersioner.update(profile);
- return profile.getSettings();
- }
-
- boolean hasValues= false;
- for (int i= 0; i < fKeySets.length; i++) {
- KeySet keySet= fKeySets[i];
- IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
- for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
- final String key= (String) keyIter.next();
- Object val= preferences.get(key, null);
- if (val != null) {
- hasValues= true;
- } else {
- val= workspaceProfile.getSettings().get(key);
- }
- profileOptions.put(key, val);
- }
- }
-
- if (!hasValues) {
- return null;
- }
-
- setLatestCompliance(profileOptions);
- return profileOptions;
- }
-
-
- /**
- * @param uiPrefs
- * @param allOptions
- */
- private void addAll(IEclipsePreferences uiPrefs, Map allOptions) {
- try {
- String[] keys= uiPrefs.keys();
- for (int i= 0; i < keys.length; i++) {
- String key= keys[i];
- String val= uiPrefs.get(key, null);
- if (val != null) {
- allOptions.put(key, val);
- }
- }
- } catch (BackingStoreException e) {
- // ignore
- }
-
- }
-
- private boolean updatePreferences(IEclipsePreferences prefs, List keys, Map profileOptions) {
- boolean hasChanges= false;
- for (final Iterator keyIter = keys.iterator(); keyIter.hasNext(); ) {
- final String key= (String) keyIter.next();
- final String oldVal= prefs.get(key, null);
- final String val= (String) profileOptions.get(key);
- if (val == null) {
- if (oldVal != null) {
- prefs.remove(key);
- hasChanges= true;
- }
- } else if (!val.equals(oldVal)) {
- prefs.put(key, val);
- hasChanges= true;
- }
- }
- return hasChanges;
- }
-
-
- /**
- * Update all formatter settings with the settings of the specified profile.
- * @param profile The profile to write to the preference store
- */
- private void writeToPreferenceStore(Profile profile, IScopeContext context) {
- final Map profileOptions= profile.getSettings();
-
- for (int i= 0; i < fKeySets.length; i++) {
- updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
- }
-
- final IEclipsePreferences uiPrefs= context.getNode(JavaScriptUI.ID_PLUGIN);
- if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
- uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
- }
-
- if (context.getName() == InstanceScope.SCOPE) {
- uiPrefs.put(fProfileKey, profile.getID());
- } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
- uiPrefs.put(fProfileKey, profile.getID());
- }
- }
-
-
- /**
- * Get an immutable list as view on all profiles, sorted alphabetically. Unless the set
- * of profiles has been modified between the two calls, the sequence is guaranteed to
- * correspond to the one returned by <code>getSortedNames</code>.
- * @return a list of elements of type <code>Profile</code>
- *
- * @see #getSortedDisplayNames()
- */
- public List getSortedProfiles() {
- return Collections.unmodifiableList(fProfilesByName);
- }
-
- /**
- * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of
- * profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one
- * returned by <code>getSortedProfiles</code>.
- * @return All names, sorted alphabetically
- * @see #getSortedProfiles()
- */
- public String[] getSortedDisplayNames() {
- final String[] sortedNames= new String[fProfilesByName.size()];
- int i= 0;
- for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
- Profile curr= (Profile) iter.next();
- sortedNames[i++]= curr.getName();
- }
- return sortedNames;
- }
-
- /**
- * Get the profile for this profile id.
- * @param ID The profile ID
- * @return The profile with the given ID or <code>null</code>
- */
- public Profile getProfile(String ID) {
- return (Profile)fProfiles.get(ID);
- }
-
- /**
- * Activate the selected profile, update all necessary options in
- * preferences and save profiles to disk.
- */
- public void commitChanges(IScopeContext scopeContext) {
- if (fSelected != null) {
- writeToPreferenceStore(fSelected, scopeContext);
- }
- }
-
- public void clearAllSettings(IScopeContext context) {
- for (int i= 0; i < fKeySets.length; i++) {
- updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.EMPTY_MAP);
- }
-
- final IEclipsePreferences uiPrefs= context.getNode(JavaScriptUI.ID_PLUGIN);
- uiPrefs.remove(fProfileKey);
- }
-
- /**
- * Get the currently selected profile.
- * @return The currently selected profile.
- */
- public Profile getSelected() {
- return fSelected;
- }
-
- /**
- * Set the selected profile. The profile must already be contained in this profile manager.
- * @param profile The profile to select
- */
- public void setSelected(Profile profile) {
- final Profile newSelected= (Profile)fProfiles.get(profile.getID());
- if (newSelected != null && !newSelected.equals(fSelected)) {
- fSelected= newSelected;
- notifyObservers(SELECTION_CHANGED_EVENT);
- }
- }
-
- /**
- * Check whether a user-defined profile in this profile manager
- * already has this name.
- * @param name The name to test for
- * @return Returns <code>true</code> if a profile with the given name exists
- */
- public boolean containsName(String name) {
- for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
- Profile curr= (Profile) iter.next();
- if (name.equals(curr.getName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Add a new custom profile to this profile manager.
- * @param profile The profile to add
- */
- public void addProfile(CustomProfile profile) {
- profile.setManager(this);
- final CustomProfile oldProfile= (CustomProfile)fProfiles.get(profile.getID());
- if (oldProfile != null) {
- fProfiles.remove(oldProfile.getID());
- fProfilesByName.remove(oldProfile);
- oldProfile.setManager(null);
- }
- fProfiles.put(profile.getID(), profile);
- fProfilesByName.add(profile);
- Collections.sort(fProfilesByName);
- fSelected= profile;
- notifyObservers(PROFILE_CREATED_EVENT);
- }
-
- /**
- * Delete the currently selected profile from this profile manager. The next profile
- * in the list is selected.
- * @return true if the profile has been successfully removed, false otherwise.
- */
- public boolean deleteSelected() {
- if (!(fSelected instanceof CustomProfile))
- return false;
-
- return deleteProfile((CustomProfile)fSelected);
- }
-
- public boolean deleteProfile(CustomProfile profile) {
- int index= fProfilesByName.indexOf(profile);
-
- fProfiles.remove(profile.getID());
- fProfilesByName.remove(profile);
-
- profile.setManager(null);
-
- if (index >= fProfilesByName.size())
- index--;
- fSelected= (Profile) fProfilesByName.get(index);
-
- if (!profile.isSharedProfile()) {
- updateProfilesWithName(profile.getID(), null, false);
- }
-
- notifyObservers(PROFILE_DELETED_EVENT);
- return true;
- }
-
-
- public void profileRenamed(CustomProfile profile, String oldID) {
- fProfiles.remove(oldID);
- fProfiles.put(profile.getID(), profile);
-
- if (!profile.isSharedProfile()) {
- updateProfilesWithName(oldID, profile, false);
- }
-
- Collections.sort(fProfilesByName);
- notifyObservers(PROFILE_RENAMED_EVENT);
- }
-
- public void profileReplaced(CustomProfile oldProfile, CustomProfile newProfile) {
- fProfiles.remove(oldProfile.getID());
- fProfiles.put(newProfile.getID(), newProfile);
- fProfilesByName.remove(oldProfile);
- fProfilesByName.add(newProfile);
- Collections.sort(fProfilesByName);
-
- if (!oldProfile.isSharedProfile()) {
- updateProfilesWithName(oldProfile.getID(), null, false);
- }
-
- setSelected(newProfile);
- notifyObservers(PROFILE_CREATED_EVENT);
- notifyObservers(SELECTION_CHANGED_EVENT);
- }
-
- public void profileChanged(CustomProfile profile) {
- if (!profile.isSharedProfile()) {
- updateProfilesWithName(profile.getID(), profile, true);
- }
-
- notifyObservers(SETTINGS_CHANGED_EVENT);
- }
-
-
- protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i= 0; i < projects.length; i++) {
- IScopeContext projectScope= fPreferencesAccess.getProjectScope(projects[i]);
- IEclipsePreferences node= projectScope.getNode(JavaScriptUI.ID_PLUGIN);
- String profileId= node.get(fProfileKey, null);
- if (oldName.equals(profileId)) {
- if (newProfile == null) {
- node.remove(fProfileKey);
- } else {
- if (applySettings) {
- writeToPreferenceStore(newProfile, projectScope);
- } else {
- node.put(fProfileKey, newProfile.getID());
- }
- }
- }
- }
-
- IScopeContext instanceScope= fPreferencesAccess.getInstanceScope();
- final IEclipsePreferences uiPrefs= instanceScope.getNode(JavaScriptUI.ID_PLUGIN);
- if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
- writeToPreferenceStore(newProfile, instanceScope);
- }
- }
-
- private static void setLatestCompliance(Map map) {
- JavaModelUtil.set50CompilanceOptions(map);
- }
-
- public abstract Profile getDefaultProfile();
-
- public IProfileVersioner getProfileVersioner() {
- return fProfileVersioner;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileStore.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileStore.java
deleted file mode 100644
index 0031f254..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileStore.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-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.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIException;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-
-/**
- * Can load/store profiles from/to profilesKey
- */
-public class ProfileStore {
-
- /** The default encoding to use */
- public static final String ENCODING= "UTF-8"; //$NON-NLS-1$
-
- protected static final String VERSION_KEY_SUFFIX= ".version"; //$NON-NLS-1$
-
- /**
- * A SAX event handler to parse the xml format for profiles.
- */
- private final static class ProfileDefaultHandler extends DefaultHandler {
-
- private List fProfiles;
- private int fVersion;
-
- private String fName;
- private Map fSettings;
- private String fKind;
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
-
- if (qName.equals(XML_NODE_SETTING)) {
-
- final String key= attributes.getValue(XML_ATTRIBUTE_ID);
- final String value= attributes.getValue(XML_ATTRIBUTE_VALUE);
- fSettings.put(key, value);
-
- } else if (qName.equals(XML_NODE_PROFILE)) {
-
- fName= attributes.getValue(XML_ATTRIBUTE_NAME);
- fKind= attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);
- if (fKind == null) //Can only be an CodeFormatterProfile created pre 3.3M2
- fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
-
- fSettings= new HashMap(200);
-
- }
- else if (qName.equals(XML_NODE_ROOT)) {
-
- fProfiles= new ArrayList();
- try {
- fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
- } catch (NumberFormatException ex) {
- throw new SAXException(ex);
- }
-
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- if (qName.equals(XML_NODE_PROFILE)) {
- fProfiles.add(new CustomProfile(fName, fSettings, fVersion, fKind));
- fName= null;
- fSettings= null;
- fKind= null;
- }
- }
-
- public List getProfiles() {
- return fProfiles;
- }
-
- }
-
- /**
- * Identifiers for the XML file.
- */
- private final static String XML_NODE_ROOT= "profiles"; //$NON-NLS-1$
- private final static String XML_NODE_PROFILE= "profile"; //$NON-NLS-1$
- private final static String XML_NODE_SETTING= "setting"; //$NON-NLS-1$
-
- private final static String XML_ATTRIBUTE_VERSION= "version"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_ID= "id"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_PROFILE_KIND= "kind"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_VALUE= "value"; //$NON-NLS-1$
-
- private final IProfileVersioner fProfileVersioner;
- private final String fProfilesKey;
- private final String fProfilesVersionKey;
-
-
- public ProfileStore(String profilesKey, IProfileVersioner profileVersioner) {
- fProfilesKey= profilesKey;
- fProfileVersioner= profileVersioner;
- fProfilesVersionKey= profilesKey + VERSION_KEY_SUFFIX;
- }
-
- /**
- * @return Returns the collection of profiles currently stored in the preference store or
- * <code>null</code> if the loading failed. The elements are of type {@link ProfileManager.CustomProfile}
- * and are all updated to the latest version.
- * @throws CoreException
- */
- public List readProfiles(IScopeContext scope) throws CoreException {
- return readProfilesFromString(scope.getNode(JavaScriptUI.ID_PLUGIN).get(fProfilesKey, null));
- }
-
- public void writeProfiles(Collection profiles, IScopeContext instanceScope) throws CoreException {
- ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
- try {
- writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner);
- String val;
- try {
- val= stream.toString(ENCODING);
- } catch (UnsupportedEncodingException e) {
- val= stream.toString();
- }
- IEclipsePreferences uiPreferences = instanceScope.getNode(JavaScriptUI.ID_PLUGIN);
- uiPreferences.put(fProfilesKey, val);
- uiPreferences.putInt(fProfilesVersionKey, fProfileVersioner.getCurrentVersion());
- } finally {
- try { stream.close(); } catch (IOException e) { /* ignore */ }
- }
- }
-
- public List readProfilesFromString(String profiles) throws CoreException {
- if (profiles != null && profiles.length() > 0) {
- byte[] bytes;
- try {
- bytes= profiles.getBytes(ENCODING);
- } catch (UnsupportedEncodingException e) {
- bytes= profiles.getBytes();
- }
- InputStream is= new ByteArrayInputStream(bytes);
- try {
- List res= readProfilesFromStream(new InputSource(is));
- if (res != null) {
- for (int i= 0; i < res.size(); i++) {
- fProfileVersioner.update((CustomProfile) res.get(i));
- }
- }
- return res;
- } finally {
- try { is.close(); } catch (IOException e) { /* ignore */ }
- }
- }
- return null;
- }
-
-
- /**
- * Read the available profiles from the internal XML file and return them
- * as collection or <code>null</code> if the file is not a profile file.
- * @param file The file to read from
- * @return returns a list of <code>CustomProfile</code> or <code>null</code>
- * @throws CoreException
- */
- public List readProfilesFromFile(File file) throws CoreException {
- try {
- final FileInputStream reader= new FileInputStream(file);
- try {
- return readProfilesFromStream(new InputSource(reader));
- } finally {
- try { reader.close(); } catch (IOException e) { /* ignore */ }
- }
- } catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
- }
- }
-
- /**
- * Load profiles from a XML stream and add them to a map or <code>null</code> if the source is not a profile store.
- * @param inputSource The input stream
- * @return returns a list of <code>CustomProfile</code> or <code>null</code>
- * @throws CoreException
- */
- public static List readProfilesFromStream(InputSource inputSource) throws CoreException {
-
- final ProfileDefaultHandler handler= new ProfileDefaultHandler();
- try {
- final SAXParserFactory factory= SAXParserFactory.newInstance();
- final SAXParser parser= factory.newSAXParser();
- parser.parse(inputSource, handler);
- } catch (SAXException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
- } catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
- } catch (ParserConfigurationException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
- }
- return handler.getProfiles();
- }
-
- /**
- * Write the available profiles to the internal XML file.
- * @param profiles List of <code>CustomProfile</code>
- * @param file File to write
- * @param encoding the encoding to use
- * @throws CoreException
- */
- public void writeProfilesToFile(Collection profiles, File file, String encoding) throws CoreException {
- final OutputStream stream;
- try {
- stream= new FileOutputStream(file);
- try {
- writeProfilesToStream(profiles, stream, encoding, fProfileVersioner);
- } finally {
- try { stream.close(); } catch (IOException e) { /* ignore */ }
- }
- } catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
- }
- }
-
- /**
- * Save profiles to an XML stream
- * @param profiles the list of <code>CustomProfile</code>
- * @param stream the stream to write to
- * @param encoding the encoding to use
- * @throws CoreException
- */
- public static void writeProfilesToStream(Collection profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException {
-
- try {
- final DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- final DocumentBuilder builder= factory.newDocumentBuilder();
- final Document document= builder.newDocument();
-
- final Element rootElement = document.createElement(XML_NODE_ROOT);
- rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
-
- document.appendChild(rootElement);
-
- for(final Iterator iter= profiles.iterator(); iter.hasNext();) {
- final Profile profile= (Profile)iter.next();
- if (profile.isProfileToSave()) {
- final Element profileElement= createProfileElement(profile, document, profileVersioner);
- rootElement.appendChild(profileElement);
- }
- }
-
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.transform(new DOMSource(document), new StreamResult(stream));
- } catch (TransformerException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
- } catch (ParserConfigurationException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
- }
- }
-
-
- /*
- * Create a new profile element in the specified document. The profile is not added
- * to the document by this method.
- */
- private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) {
- final Element element= document.createElement(XML_NODE_PROFILE);
- element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName());
- element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
- element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind());
-
- final Iterator keyIter= profile.getSettings().keySet().iterator();
-
- while (keyIter.hasNext()) {
- final String key= (String)keyIter.next();
- final String value= (String)profile.getSettings().get(key);
- if (value != null) {
- final Element setting= document.createElement(XML_NODE_SETTING);
- setting.setAttribute(XML_ATTRIBUTE_ID, key);
- setting.setAttribute(XML_ATTRIBUTE_VALUE, value);
- element.appendChild(setting);
- } else {
- JavaScriptPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$
- }
- }
- return element;
- }
-
-
- /*
- * Creates a UI exception for logging purposes
- */
- private static JavaUIException createException(Throwable t, String message) {
- return new JavaUIException(JavaUIStatus.createError(IStatus.ERROR, message, t));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileVersioner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileVersioner.java
deleted file mode 100644
index 2432699e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/ProfileVersioner.java
+++ /dev/null
@@ -1,687 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-
-
-public class ProfileVersioner implements IProfileVersioner {
-
- public static final String CODE_FORMATTER_PROFILE_KIND= "CodeFormatterProfile"; //$NON-NLS-1$
-
- private static final int VERSION_1= 1; // < 20040113 (includes M6)
- private static final int VERSION_2= 2; // before renaming almost all
- private static final int VERSION_3= 3; // after renaming almost all
- private static final int VERSION_4= 4;
- private static final int VERSION_5= 5; // after splitting of FORMATTER_INDENT_BLOCK_STATEMENTS
- private static final int VERSION_6= 6; // after splitting of new_line_in_control_statements
- private static final int VERSION_7= 7; // after moving comment formatter to JSDT Core
- private static final int VERSION_8= 8; // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=89739
- private static final int VERSION_9= 9; // after storing project profile names in preferences
- private static final int VERSION_10= 10; // splitting options for annotation types
- private static final int VERSION_11= 11; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49412
-
- private static final int CURRENT_VERSION= VERSION_11;
-
- public int getFirstVersion() {
- return VERSION_1;
- }
-
- public int getCurrentVersion() {
- return CURRENT_VERSION;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getProfileKind() {
- return CODE_FORMATTER_PROFILE_KIND;
- }
-
- public void update(CustomProfile profile) {
- final Map oldSettings= profile.getSettings();
- Map newSettings= updateAndComplete(oldSettings, profile.getVersion());
- profile.setVersion(CURRENT_VERSION);
- profile.setSettings(newSettings);
- }
-
- private static Map updateAndComplete(Map oldSettings, int version) {
- final Map newSettings= FormatterProfileManager.getDefaultSettings();
-
- switch (version) {
-
- case VERSION_1:
- version1to2(oldSettings);
-
- case VERSION_2:
- version2to3(oldSettings);
-
- case VERSION_3:
- version3to4(oldSettings);
-
- case VERSION_4:
- version4to5(oldSettings);
-
- case VERSION_5:
- version5to6(oldSettings);
-
- case VERSION_6:
- version6to7(oldSettings);
-
- case VERSION_7:
- case VERSION_8:
- case VERSION_9:
- version9to10(oldSettings);
-
- case VERSION_10 :
- version10to11(oldSettings);
-
- default:
- for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) {
- final String key= (String)iter.next();
- if (!newSettings.containsKey(key))
- continue;
-
- final String value= (String)oldSettings.get(key);
- if (value != null) {
- newSettings.put(key, value);
- }
- }
-
- }
- setLatestCompliance(newSettings);
- return newSettings;
- }
-
- /**
- * Updates the map to use the latest the source compliance
- * @param map The map to update
- */
- public static void setLatestCompliance(Map map) {
- JavaModelUtil.set50CompilanceOptions(map);
- }
-
- private static void version1to2(final Map oldSettings) {
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_WITHIN_MESSAGE_SEND,
- FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_MESSAGE_SEND,
- FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_MESSAGE_SEND);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_OPEN_PAREN_IN_PARENTHESIZED_EXPRESSION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION);
-
- checkAndReplace(oldSettings,
- JavaScriptCore.PLUGIN_ID + ".formatter.inset_space_between_empty_arguments", //$NON-NLS-1$
- FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_ARGUMENTS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_METHOD_DECLARATION_OPEN_PAREN,
- FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_OPEN_PAREN);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_OPEN_PAREN_IN_PARENTHESIZED_EXPRESSION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION);
- }
-
- public static int getVersionStatus(CustomProfile profile) {
- final int version= profile.getVersion();
- if (version < CURRENT_VERSION)
- return -1;
- else if (version > CURRENT_VERSION)
- return 1;
- else
- return 0;
- }
-
-
- private static void mapOldValueRangeToNew(Map settings, String oldKey, String [] oldValues,
- String newKey, String [] newValues) {
-
- if (!settings.containsKey(oldKey))
- return;
-
- final String value= ((String)settings.get(oldKey));
-
- if (value == null)
- return;
-
- for (int i = 0; i < oldValues.length; i++) {
- if (value.equals(oldValues[i])) {
- settings.put(newKey, newValues[i]);
- }
- }
-
- }
-
- private static void duplicate(Map settings, String existingKey, String newKey) {
- checkAndReplace(settings, existingKey, new String [] {newKey});
- }
-
- private static void checkAndReplace(Map settings, String oldKey, String newKey) {
- checkAndReplace(settings, oldKey, new String [] {newKey});
- }
-
- private static void checkAndReplace(Map settings, String oldKey, String newKey1, String newKey2) {
- checkAndReplace(settings, oldKey, new String [] {newKey1, newKey2});
- }
-
- private static void checkAndReplace(Map settings, String oldKey, String [] newKeys) {
- if (!settings.containsKey(oldKey))
- return;
-
- final String value= (String)settings.get(oldKey);
-
- if (value == null)
- return;
-
- for (int i = 0; i < newKeys.length; i++) {
- settings.put(newKeys[i], value);
- }
- }
-
- private static void checkAndReplaceBooleanWithINSERT(Map settings, String oldKey, String newKey) {
- if (!settings.containsKey(oldKey))
- return;
-
- String value= (String)settings.get(oldKey);
-
- if (value == null)
- return;
-
- if (DefaultCodeFormatterConstants.TRUE.equals(value))
- value= JavaScriptCore.INSERT;
- else
- value= JavaScriptCore.DO_NOT_INSERT;
-
- settings.put(newKey, value);
- }
-
-
- private static void version2to3(Map oldSettings) {
-
- checkAndReplace(oldSettings,
- FORMATTER_ARRAY_INITIALIZER_CONTINUATION_INDENTATION,
- DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_BLOCK_CLOSE_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_CATCH_EXPRESSION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_FOR_PARENS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_IF_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_SWITCH_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_SYNCHRONIZED_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_IN_WHILE_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MESSAGESEND_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_THROWS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_THROWS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_MESSAGE_SEND,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_MESSAGE_SEND,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_THROWS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_THROWS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICITCONSTRUCTORCALL_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICITCONSTRUCTORCALL_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS);
-
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MESSAGESEND_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_FIRST_ARGUMENT,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_MESSAGE_SEND,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_ANONYMOUS_TYPE_OPEN_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_BLOCK_OPEN_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_CATCH_EXPRESSION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_METHOD_OPEN_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_OPEN_PAREN,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_FIRST_INITIALIZER,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_FOR_PAREN,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_IF_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_MESSAGE_SEND,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_METHOD_DECLARATION_OPEN_PAREN,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_OPEN_PAREN_IN_PARENTHESIZED_EXPRESSION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_SWITCH_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_SWITCH_OPEN_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_SYNCHRONIZED_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_TYPE_OPEN_BRACE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_WHILE_CONDITION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_REFERENCE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_ARRAY_INITIALIZER,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_MESSAGESEND_ARGUMENTS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_FORMAT_GUARDIAN_CLAUSE_ON_ONE_LINE,
- DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_BRACKET_IN_ARRAY_REFERENCE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_BRACKET_IN_ARRAY_TYPE_REFERENCE,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATORS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR);
-
- checkAndReplace(oldSettings,
- FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATORS,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR);
-
- checkAndReplace(oldSettings,
- FORMATTER_ALLOCATION_EXPRESSION_ARGUMENTS_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION);
-
- checkAndReplace(oldSettings,
- FORMATTER_COMPACT_IF_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
-
- checkAndReplace(oldSettings,
- FORMATTER_MESSAGE_SEND_ARGUMENTS_ALIGNMENT ,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_QUALIFIED_ALLOCATION_EXPRESSION_ARGUMENTS_ALIGNMENT ,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION);
-
- checkAndReplace(oldSettings,
- FORMATTER_BINARY_EXPRESSION_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION);
-
- checkAndReplace(oldSettings,
- FORMATTER_COMPACT_IF_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
-
- checkAndReplace(oldSettings,
- FORMATTER_CONDITIONAL_EXPRESSION_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
-
- checkAndReplace(oldSettings,
- FORMATTER_ARRAY_INITIALIZER_EXPRESSIONS_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
-
- checkAndReplace(oldSettings,
- FORMATTER_METHOD_DECLARATION_ARGUMENTS_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_MESSAGE_SEND_SELECTOR_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_TYPE_DECLARATION_SUPERCLASS_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_TYPE_DECLARATION_SUPERINTERFACES_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_METHOD_THROWS_CLAUSE_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_EXPLICIT_CONSTRUCTOR_ARGUMENTS_ALIGNMENT,
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL);
-
-
- mapOldValueRangeToNew(oldSettings,
- FORMATTER_TYPE_MEMBER_ALIGNMENT, new String [] {FORMATTER_NO_ALIGNMENT, FORMATTER_MULTICOLUMN},
- DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, new String [] {DefaultCodeFormatterConstants.FALSE, DefaultCodeFormatterConstants.TRUE});
-
-
- checkAndReplace(oldSettings,
- FORMATTER_ANONYMOUS_TYPE_DECLARATION_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_ARRAY_INITIALIZER_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
-
- checkAndReplace(oldSettings,
- FORMATTER_BLOCK_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
-
- checkAndReplace(oldSettings,
- FORMATTER_METHOD_DECLARATION_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_TYPE_DECLARATION_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
-
- checkAndReplace(oldSettings,
- FORMATTER_SWITCH_BRACE_POSITION,
- DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
-
- }
-
- private static void version3to4(Map oldSettings) {
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.align_type_members_on_columns", //$NON-NLS-1$
- DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);
-
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma__in_superinterfaces", //$NON-NLS-1$
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES);
-
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma__in_superinterfaces", //$NON-NLS-1$
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES);
-
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_arguments_in_method_invocation", //$NON-NLS-1$
- DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION);
- }
-
- private static void version4to5(Map oldSettings) {
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.formatter.indent_block_statements", //$NON-NLS-1$
- new String[] { DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK });
- }
-
- private static void version5to6(Map oldSettings) {
- checkAndReplace(oldSettings,
- "org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_control_statements", //$NON-NLS-1$
- new String[] {
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT
- });
- }
-
- private static void version6to7(Map oldSettings) {
- checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMAT, FORMATTER_COMMENT_FORMAT2);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMATHEADER, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMATSOURCE, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_INDENTPARAMETERDESCRIPTION, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_INDENTROOTTAGS, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_LINELENGTH, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_CLEARBLANKLINES, FORMATTER_COMMENT_CLEAR_BLANK_LINES);
- checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMATHTML, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML);
-
- checkAndReplaceBooleanWithINSERT(oldSettings, FORMATTER_COMMENT_NEWLINEFORPARAMETER, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
- checkAndReplaceBooleanWithINSERT(oldSettings, FORMATTER_COMMENT_SEPARATEROOTTAGS, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
- }
-
- private static void version9to10(Map oldSettings) {
- duplicate(oldSettings,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION,
- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION);
- duplicate(oldSettings,
- DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER,
- DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER);
- }
-
- private static void version10to11(Map oldSettings) {
- checkAndReplace(oldSettings,
- FORMATTER_COMMENT_FORMAT2,
- new String[] {
- DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT,
- DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT,
- DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT
- });
- checkAndReplace(oldSettings, FORMATTER_COMMENT_CLEAR_BLANK_LINES,
- new String[] {
- DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT,
- DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT,
- });
- }
-
- /* old format constant values */
-
- private static final String FORMATTER_METHOD_DECLARATION_ARGUMENTS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.method_declaration_arguments_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_MESSAGE_SEND_ARGUMENTS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.message_send_arguments_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_MESSAGE_SEND_SELECTOR_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.message_send_selector_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_QUALIFIED_ALLOCATION_EXPRESSION_ARGUMENTS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.qualified_allocation_expression_arguments_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_TYPE_DECLARATION_SUPERCLASS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.type_declaration_superclass_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_TYPE_DECLARATION_SUPERINTERFACES_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.type_declaration_superinterfaces_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_METHOD_THROWS_CLAUSE_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.method_throws_clause_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_CONDITIONAL_EXPRESSION_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.conditional_expression_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_ALLOCATION_EXPRESSION_ARGUMENTS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.allocation_expression_arguments_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_COMPACT_IF_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.compact_if_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_ARRAY_INITIALIZER_EXPRESSIONS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.array_initializer_expressions_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_BINARY_EXPRESSION_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.binary_expression_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_EXPLICIT_CONSTRUCTOR_ARGUMENTS_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.explicit_constructor_arguments_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_ANONYMOUS_TYPE_DECLARATION_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.anonymous_type_declaration_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_ARRAY_INITIALIZER_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.array_initializer_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_BLOCK_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.block_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_METHOD_DECLARATION_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.method_declaration_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_TYPE_DECLARATION_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.type_declaration_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_SWITCH_BRACE_POSITION = JavaScriptCore.PLUGIN_ID + ".formatter.switch_brace_position"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MESSAGESEND_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_messagesend_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_OPEN_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_open_paren_in_parenthesized_expression"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_MESSAGE_SEND = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_message_send"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_MESSAGE_SEND = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_message_send"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MESSAGESEND_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_messagesend_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_MESSAGE_SEND = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_message_send"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_FIRST_ARGUMENT = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_first_argument"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_between_empty_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_WITHIN_MESSAGE_SEND = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_within_message_send"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_BLOCK_CLOSE_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_block_close_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_ANONYMOUS_TYPE_OPEN_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_anonymous_type_open_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_BLOCK_OPEN_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_block_open_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_CATCH_EXPRESSION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_catch_expression"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_OPEN_PAREN = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_constructor_declaration_open_paren"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_FIRST_INITIALIZER = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_first_initializer"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_FOR_PAREN = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_for_paren"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_IF_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_if_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_METHOD_DECLARATION_OPEN_PAREN = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_method_declaration_open_paren"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_METHOD_OPEN_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_method_open_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_OPEN_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_open_paren_in_parenthesized_expression"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_SWITCH_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_switch_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_SWITCH_OPEN_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_switch_open_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_SYNCHRONIZED_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_synchronized_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_TYPE_OPEN_BRACE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_type_open_brace"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_WHILE_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_while_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_REFERENCE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_between_brackets_in_array_reference";//$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_ARRAY_INITIALIZER = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_between_empty_array_initializer"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_MESSAGESEND_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_between_empty_messagesend_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_CATCH_EXPRESSION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_catch_expression"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_FOR_PARENS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_for_parens"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_IF_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_if_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_SWITCH_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_switch_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_SYNCHRONIZED_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_synchronized_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_IN_WHILE_CONDITION = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_in_while_condition"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_BRACKET_IN_ARRAY_REFERENCE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_bracket_in_array_reference";//$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_BRACKET_IN_ARRAY_TYPE_REFERENCE = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_bracket_in_array_type_reference"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATORS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_assignment_operators"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATORS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_assignment_operators"; //$NON-NLS-1$
- private static final String FORMATTER_FORMAT_GUARDIAN_CLAUSE_ON_ONE_LINE = JavaScriptCore.PLUGIN_ID + ".formatter.format_guardian_clause_on_one_line"; //$NON-NLS-1$
- private static final String FORMATTER_ARRAY_INITIALIZER_CONTINUATION_INDENTATION = JavaScriptCore.PLUGIN_ID + ".formatter.array_initializer_continuation_indentation"; //$NON-NLS-1$
- private static final String FORMATTER_TYPE_MEMBER_ALIGNMENT = JavaScriptCore.PLUGIN_ID + ".formatter.type_member_alignment"; //$NON-NLS-1$
- private static final String FORMATTER_MULTICOLUMN = "256"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_THROWS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_throws"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_THROWS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_throws"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICITCONSTRUCTORCALL_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICITCONSTRUCTORCALL_ARGUMENTS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_explicitconstructorcall_arguments"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_THROWS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_throws"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_THROWS = JavaScriptCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_throws"; //$NON-NLS-1$
- private static final String FORMATTER_NO_ALIGNMENT = "0";//$NON-NLS-1$
- private static final String FORMATTER_COMMENT_FORMAT2= JavaScriptCore.PLUGIN_ID + ".formatter.comment.format_comments"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_CLEAR_BLANK_LINES= JavaScriptCore.PLUGIN_ID + ".formatter.comment.clear_blank_lines"; //$NON-NLS-1$
-
- // Old comment formatter constants
- private static final String FORMATTER_COMMENT_FORMATSOURCE= "comment_format_source_code"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_INDENTPARAMETERDESCRIPTION= "comment_indent_parameter_description"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_FORMATHEADER= "comment_format_header"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_INDENTROOTTAGS= "comment_indent_root_tags"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_FORMAT= "comment_format_comments"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_NEWLINEFORPARAMETER= "comment_new_line_for_parameter"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_SEPARATEROOTTAGS= "comment_separate_root_tags"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_CLEARBLANKLINES= "comment_clear_blank_lines"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_LINELENGTH= "comment_line_length"; //$NON-NLS-1$
- private static final String FORMATTER_COMMENT_FORMATHTML= "comment_format_html"; //$NON-NLS-1$
-
- }
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/SnippetPreview.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/SnippetPreview.java
deleted file mode 100644
index 815d9d32..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/SnippetPreview.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaStatusConstants;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-
-public class SnippetPreview extends JavaPreview {
-
- public final static class PreviewSnippet {
-
- public String header;
- public final String source;
- public final int kind;
-
- public PreviewSnippet(int kind, String source) {
- this.kind= kind;
- this.source= source;
- }
- }
-
- private ArrayList fSnippets;
-
- public SnippetPreview(Map workingValues, Composite parent) {
- super(workingValues, parent);
- fSnippets= new ArrayList();
- }
-
- protected void doFormatPreview() {
- if (fSnippets.isEmpty()) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
-
- //This delimiter looks best for invisible characters
- final String delimiter= "\n"; //$NON-NLS-1$
-
- final StringBuffer buffer= new StringBuffer();
- for (final Iterator iter= fSnippets.iterator(); iter.hasNext();) {
- final PreviewSnippet snippet= (PreviewSnippet) iter.next();
- String formattedSource;
- try {
- formattedSource= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, null, delimiter, fWorkingValues);
- } catch (Exception e) {
- final IStatus status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
- FormatterMessages.JavaPreview_formatter_exception, e);
- JavaScriptPlugin.log(status);
- continue;
- }
- buffer.append(delimiter);
- buffer.append(formattedSource);
- buffer.append(delimiter);
- buffer.append(delimiter);
- }
- fPreviewDocument.set(buffer.toString());
- }
-
-
-
- public void add(PreviewSnippet snippet) {
- fSnippets.add(snippet);
- }
-
- public void remove(PreviewSnippet snippet) {
- fSnippets.remove(snippet);
- }
-
- public void addAll(Collection snippets) {
- fSnippets.addAll(snippets);
- }
-
- public void clear() {
- fSnippets.clear();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
deleted file mode 100644
index 1f4d357c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
+++ /dev/null
@@ -1,1273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.SnippetPreview.PreviewSnippet;
-
-
-/**
- * Manage code formatter white space options on a higher level.
- */
-public final class WhiteSpaceOptions {
-
- /**
- * Represents a node in the options tree.
- */
- public abstract static class Node {
-
- private final InnerNode fParent;
- private final String fName;
-
- public int index;
-
- protected final Map fWorkingValues;
- protected final ArrayList fChildren;
-
- public Node(InnerNode parent, Map workingValues, String message) {
- if (workingValues == null || message == null)
- throw new IllegalArgumentException();
- fParent= parent;
- fWorkingValues= workingValues;
- fName= message;
- fChildren= new ArrayList();
- if (fParent != null)
- fParent.add(this);
- }
-
- public abstract void setChecked(boolean checked);
-
- public boolean hasChildren() {
- return !fChildren.isEmpty();
- }
-
- public List getChildren() {
- return Collections.unmodifiableList(fChildren);
- }
-
- public InnerNode getParent() {
- return fParent;
- }
-
- public final String toString() {
- return fName;
- }
-
- public abstract List getSnippets();
-
- public abstract void getCheckedLeafs(List list);
- }
-
- /**
- * A node representing a group of options in the tree.
- */
- public static class InnerNode extends Node {
-
- public InnerNode(InnerNode parent, Map workingValues, String messageKey) {
- super(parent, workingValues, messageKey);
- }
-
- public void setChecked(boolean checked) {
- for (final Iterator iter = fChildren.iterator(); iter.hasNext();)
- ((Node)iter.next()).setChecked(checked);
- }
-
- public void add(Node child) {
- fChildren.add(child);
- }
-
- public List getSnippets() {
- final ArrayList snippets= new ArrayList(fChildren.size());
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- final List childSnippets= ((Node)iter.next()).getSnippets();
- for (final Iterator chIter= childSnippets.iterator(); chIter.hasNext(); ) {
- final Object snippet= chIter.next();
- if (!snippets.contains(snippet))
- snippets.add(snippet);
- }
- }
- return snippets;
- }
-
- public void getCheckedLeafs(List list) {
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- ((Node)iter.next()).getCheckedLeafs(list);
- }
- }
- }
-
-
- /**
- * A node representing a concrete white space option in the tree.
- */
- public static class OptionNode extends Node {
- private final String fKey;
- private final ArrayList fSnippets;
-
- public OptionNode(InnerNode parent, Map workingValues, String messageKey, String key, PreviewSnippet snippet) {
- super(parent, workingValues, messageKey);
- fKey= key;
- fSnippets= new ArrayList(1);
- fSnippets.add(snippet);
- }
-
- public void setChecked(boolean checked) {
- fWorkingValues.put(fKey, checked ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- }
-
- public boolean getChecked() {
- return JavaScriptCore.INSERT.equals(fWorkingValues.get(fKey));
- }
-
- public List getSnippets() {
- return fSnippets;
- }
-
- public void getCheckedLeafs(List list) {
- if (getChecked())
- list.add(this);
- }
- }
-
-
-
- /**
- * Preview snippets.
- */
-
- private final PreviewSnippet FOR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "for (i= 0, j= array.length; i < array.length; i++, j--) {}\nfor (s in MyData) {}"); //$NON-NLS-1$
-
- private final PreviewSnippet WHILE_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "while (condition) {}; do {} while (condition);"); //$NON-NLS-1$
-
- private final PreviewSnippet CATCH_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
-// "try { number= Integer.parseInt(value); } catch (NumberFormatException e) {}"); //$NON-NLS-1$
- "try {\n} catch (err) {\n}"); //$NON-NLS-1$
-
- private final PreviewSnippet IF_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
-
-// private final PreviewSnippet SYNCHRONIZED_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "synchronized (list) { list.add(element); }"); //$NON-NLS-1$
-
- private final PreviewSnippet SWITCH_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
-
- private final PreviewSnippet CONSTRUCTOR_DECL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "MyClass() throws E0, E1 { this(0,0,0);}" + //$NON-NLS-1$
-// "MyClass(int x, int y, int z) throws E0, E1 { super(x, y, z, true);}"); //$NON-NLS-1$
- CodeFormatter.K_STATEMENTS,
- "function Foo(x, y) {\n this.x = 1;\n this.y = 2;\n}\n" + //$NON-NLS-1$
- "obj1 = new Foo();\nobj2 = new Foo(3, 4);"); //$NON-NLS-1$
-
- private final PreviewSnippet METHOD_DECL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "void foo() throws E0, E1 {};" + //$NON-NLS-1$
-// "void bar(int x, int y) throws E0, E1 {}"); //$NON-NLS-1$
- CodeFormatter.K_STATEMENTS,
- "function foo() {};\nfunction bar(x,y){}"); //$NON-NLS-1$
-
- private final PreviewSnippet ARRAY_DECL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "int [] array0= new int [] {};\n" + //$NON-NLS-1$
-// "int [] array1= new int [] {1, 2, 3};\n" + //$NON-NLS-1$
-// "int [] array2= new int[3];"); //$NON-NLS-1$
- CodeFormatter.K_EXPRESSION,
- "var arr0=new Array();\n" + //$NON-NLS-1$
- "var arr1=new Array(4);\n" + //$NON-NLS-1$
- "var arr2=[];\n" + //$NON-NLS-1$
- "var arr3=[4];\n" + //$NON-NLS-1$
- "var arr4=[\'one\',\'two\',\'three\']"); //$NON-NLS-1$
-
- private final PreviewSnippet ARRAY_REF_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
-// "array[i].foo();"); //$NON-NLS-1$
- "array[i];"); //$NON-NLS-1$
-
- private final PreviewSnippet METHOD_CALL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "foo();\n" + //$NON-NLS-1$
- "bar(x, y);"); //$NON-NLS-1$
-
-// private final PreviewSnippet CONSTR_CALL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "this();\n\n" + //$NON-NLS-1$
-// "this(x, y);\n"); //$NON-NLS-1$
-
- private final PreviewSnippet ALLOC_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "s= new Foo(); p= new Bar(x, y);"); //$NON-NLS-1$
-
- private final PreviewSnippet LABEL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "label: for (i= 0; i<list.length; i++) {for (j= 0; j < list[i].length; j++) continue label;}"); //$NON-NLS-1$
-
-// private final PreviewSnippet SEMICOLON_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
-
- private final PreviewSnippet CONDITIONAL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "value= condition ? TRUE : FALSE;"); //$NON-NLS-1$
-
-// private final PreviewSnippet CLASS_DECL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_JAVASCRIPT_UNIT,
-// "class MyClass implements I0, I1, I2 {}"); //$NON-NLS-1$
-
-// private final PreviewSnippet ANON_CLASS_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "AnonClass= new AnonClass() {void foo(Some s) { }};"); //$NON-NLS-1$
-
- private final PreviewSnippet OPERATOR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "var arr= new Array();\nvar a= -4 + -9;\nvar b= a++ / --a;\na += 4;\nvar value= true && false;"); //$NON-NLS-1$
-
-// private final PreviewSnippet CAST_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "String s= ((String)object);"); //$NON-NLS-1$
-
- private final PreviewSnippet MULT_LOCAL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
-// "int a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
- "var a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
-
-// private final PreviewSnippet MULT_FIELD_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
-
- private final PreviewSnippet BLOCK_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
-
- private final PreviewSnippet PAREN_EXPR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "result= (a *( b + c + d) * (e + f));"); //$NON-NLS-1$
-
- private final PreviewSnippet ASSERT_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "assert condition : reportError();" //$NON-NLS-1$
- );
-
- private final PreviewSnippet RETURN_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "return (o);" //$NON-NLS-1$
- );
-
- private final PreviewSnippet THROW_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "throw (e);" //$NON-NLS-1$
- );
-
-// private final PreviewSnippet ANNOTATION_DECL_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "@interface MyAnnotation { String value(); }\n@interface OtherAnnotation { }\n" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet ANNOTATION_MODIFIER_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "@Annot(x=23, y=-3)\npublic class A { }\n" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet ENUM_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "enum MyEnum { GREEN(0, 1), RED() {\nvoid process() {}\n}\n}" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet PARAMETERIZED_TYPE_REFERENCE_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "Map<String, Element> map=\n new HashMap<String, Element>();" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet TYPE_ARGUMENTS_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_STATEMENTS,
-// "x.<String, Element>foo();" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet TYPE_PARAMETER_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "class MyGenericType<S, T extends Element & List> { }" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet VARARG_PARAMETER_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "void format(String s, Object ... args) {}" //$NON-NLS-1$
-// );
-
-// private final PreviewSnippet WILDCARD_PREVIEW= new PreviewSnippet(
-// CodeFormatter.K_CLASS_BODY_DECLARATIONS,
-// "Map<X<?>, Y<? extends K, ? super V>> t;" //$NON-NLS-1$
-// );
-
- /**
- * Create the tree, in this order: syntax element - position - abstract element
- * @param workingValues
- * @return returns roots (type <code>Node</code>)
- */
- public List createTreeBySyntaxElem(Map workingValues) {
- final ArrayList roots= new ArrayList();
-
- InnerNode element;
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_paren);
- createBeforeOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_paren);
- createBeforeClosingParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
-// createAfterCloseParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_brace);
- createBeforeOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_brace);
-// createBeforeClosingBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterCloseBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_bracket);
- createBeforeOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_bracket);
- createBeforeClosingBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_operator);
- createBeforeOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_comma);
- createBeforeCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_colon);
- createBeforeColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_semicolon);
- createBeforeSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_question_mark);
- createBeforeQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
- createBetweenEmptyParenTree(workingValues, element);
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
- createBetweenEmptyBracesTree(workingValues, element);
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
- createBetweenEmptyBracketsTree(workingValues, element);
- roots.add(element);
-
- return roots;
- }
-
- /**
- * Create the tree, in this order: position - syntax element - abstract
- * element
- * @param workingValues
- * @return returns roots (type <code>Node</code>)
- */
- public List createAltTree(Map workingValues) {
-
- final ArrayList roots= new ArrayList();
-
- InnerNode parent;
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_paren);
- createBeforeOpenParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_paren);
- createAfterOpenParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_paren);
- createBeforeClosingParenTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_paren);
-// createAfterCloseParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
- createBetweenEmptyParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_brace);
- createBeforeOpenBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_brace);
- createAfterOpenBraceTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_brace);
-// createBeforeClosingBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_brace);
- createAfterCloseBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
- createBetweenEmptyBracesTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_bracket);
- createBeforeOpenBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_bracket);
- createAfterOpenBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_bracket);
- createBeforeClosingBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
- createBetweenEmptyBracketsTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_angle_bracket);
-// createBeforeOpenAngleBracketTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_angle_bracket);
-// createAfterOpenAngleBracketTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_angle_bracket);
-// createBeforeClosingAngleBracketTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_angle_bracket);
-// createAfterClosingAngleBracketTree(workingValues, parent);
-
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_operator);
- createBeforeOperatorTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_operator);
- createAfterOperatorTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_comma);
- createBeforeCommaTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_comma);
- createAfterCommaTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_colon);
- createAfterColonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_colon);
- createBeforeColonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon);
- createBeforeSemicolonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_semicolon);
- createAfterSemicolonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_question_mark);
- createBeforeQuestionTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_question_mark);
- createAfterQuestionTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_at);
-// createBeforeAtTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_at);
-// createAfterAtTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_and);
-// createBeforeAndTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_and);
-// createAfterAndTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_ellipsis);
-// createBeforeEllipsis(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_ellipsis);
-// createAfterEllipsis(workingValues, parent);
-
- return roots;
- }
-
- private InnerNode createParentNode(List roots, Map workingValues, String text) {
- final InnerNode parent= new InnerNode(null, workingValues, text);
- roots.add(parent);
- return parent;
- }
-
- public ArrayList createTreeByJavaElement(Map workingValues) {
-
- final InnerNode declarations= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_declarations);
-// createClassTree(workingValues, declarations);
-// createFieldTree(workingValues, declarations);
- createLocalVariableTree(workingValues, declarations);
-// createConstructorTree(workingValues, declarations);
- createMethodDeclTree(workingValues, declarations);
- createLabelTree(workingValues, declarations);
-// createAnnotationTree(workingValues, declarations);
-// createEnumTree(workingValues, declarations);
-// createAnnotationTypeTree(workingValues, declarations);
-
- final InnerNode statements= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_statements);
-// createOption(statements, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
- createBlockTree(workingValues, statements);
- createIfStatementTree(workingValues, statements);
- createForStatementTree(workingValues, statements);
- createSwitchStatementTree(workingValues, statements);
- createDoWhileTree(workingValues, statements);
-// createSynchronizedTree(workingValues, statements);
- createTryStatementTree(workingValues, statements);
-// createAssertTree(workingValues, statements);
- createReturnTree(workingValues, statements);
- createThrowTree(workingValues, statements);
-
- final InnerNode expressions= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_expressions);
- createFunctionCallTree(workingValues, expressions);
- createAssignmentTree(workingValues, expressions);
- createOperatorTree(workingValues, expressions);
- createParenthesizedExpressionTree(workingValues, expressions);
-// createTypecastTree(workingValues, expressions);
- createConditionalTree(workingValues, expressions);
-
- final InnerNode arrays= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_arrays);
- createArrayDeclarationTree(workingValues, arrays);
- createArrayAllocTree(workingValues, arrays);
- createArrayInitializerTree(workingValues, arrays);
- createArrayElementAccessTree(workingValues, arrays);
-
-// final InnerNode paramtypes= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_parameterized_types);
-// createParameterizedTypeTree(workingValues, paramtypes);
-// createTypeArgumentTree(workingValues, paramtypes);
-// createTypeParameterTree(workingValues, paramtypes);
-// createWildcardTypeTree(workingValues, paramtypes);
-
- final ArrayList roots= new ArrayList();
- roots.add(declarations);
- roots.add(statements);
- roots.add(expressions);
- roots.add(arrays);
-// roots.add(paramtypes);
- return roots;
- }
-
- private void createBeforeQuestionTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_wildcard, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD, WILDCARD_PREVIEW);
- }
-
-// private void createBeforeAtTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
-// }
-
-// private void createBeforeAndTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER, TYPE_PARAMETER_PREVIEW);
-// }
-
- private void createBeforeSemicolonTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
- }
-
- private void createBeforeColonTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assert, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, ASSERT_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
-
- final InnerNode switchStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch);
- createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_case, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
- createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR, FOR_PREVIEW);
- }
-
- private void createBeforeCommaTree(Map workingValues, final InnerNode parent) {
-
- final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for);
- createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
- createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
-
- final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_explicit_constructor_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_alloc_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
-
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
-
- final InnerNode throwsDecl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throws);
- createOption(throwsDecl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(throwsDecl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
-
- final InnerNode multDecls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_mult_decls);
-// createOption(multDecls, workingValues, FormatterMessages.WhiteSpaceOptions_fields, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW);
- createOption(multDecls, workingValues, FormatterMessages.WhiteSpaceOptions_local_vars, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_implements_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, ENUM_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameterized_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
- }
-
- private void createBeforeOperatorTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- }
-
- private void createBeforeClosingBracketTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_element_access, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
- }
-
-// private void createBeforeClosingAngleBracketTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameterized_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// }
-
-
- private void createBeforeOpenBracketTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_element_access, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
- }
-
-// private void createBeforeOpenAngleBracketTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameterized_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// }
-
-// private void createBeforeClosingBraceTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, CLASS_DECL_PREVIEW);
-// }
-
- private void createBeforeOpenBraceTree(Map workingValues, final InnerNode parent) {
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_anon_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW);
-
- final InnerNode functionDecl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration); {
- createOption(functionDecl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
- createOption(functionDecl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- }
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
- }
-
- private void createBeforeClosingParenTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
-
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-
- }
-
- private void createBeforeOpenParenTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
-
- final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type_member, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);
-
- }
-
- private void createAfterQuestionTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_wildcard, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD, WILDCARD_PREVIEW);
- }
-
-// private void createAfterAtTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
-// }
-
-// private void createAfterAndTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER, TYPE_PARAMETER_PREVIEW);
-// }
-
-// private void createBeforeEllipsis(Map workingValues, InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// }
-
-// private void createAfterEllipsis(Map workingValues, InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// }
-
- private void createAfterSemicolonTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
- }
-
- private void createAfterColonTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assert, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, ASSERT_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR, FOR_PREVIEW);
- }
-
- private void createAfterCommaTree(Map workingValues, final InnerNode parent) {
-
- final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); {
- createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
- createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
- }
- final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments); {
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_explicit_constructor_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_alloc_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
- }
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters); {
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- }
- final InnerNode throwsDecl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throws); {
- createOption(throwsDecl, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW);
- createOption(throwsDecl, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
- }
- final InnerNode multDecls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_mult_decls); {
-// createOption(multDecls, workingValues, FormatterMessages.WhiteSpaceOptions_fields, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW);
- createOption(multDecls, workingValues, FormatterMessages.WhiteSpaceOptions_local_vars, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW);
- }
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_implements_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, ENUM_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameterized_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
- }
-
- private void createAfterOperatorTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- }
-
- private void createAfterOpenBracketTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_element_access, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
- }
-
-// private void createAfterOpenAngleBracketTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameterized_type, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// }
-
- private void createAfterOpenBraceTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- }
-
- private void createAfterCloseBraceTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- }
-
-// private void createAfterCloseParenTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
-// }
-
-// private void createAfterClosingAngleBracketTree(Map workingValues, final InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
- //createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// }
-
- private void createAfterOpenParenTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
- final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration); {
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- }
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
- }
-
- private void createBetweenEmptyParenTree(Map workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_constructor_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
-
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type_member, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);
- }
-
- private void createBetweenEmptyBracketsTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_array_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW);
- }
-
- private void createBetweenEmptyBracesTree(Map workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- }
-
- // syntax element tree
-
-// private InnerNode createClassTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_comma_implements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_comma_implements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW);
-// return root;
-// }
-
- private InnerNode createAssignmentTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- return root;
- }
-
- private InnerNode createOperatorTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- return root;
- }
-
- private InnerNode createMethodDeclTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_methods);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_ellipsis, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_ellipsis, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_throws, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_throws, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
-
- return root;
- }
-
-// private InnerNode createConstructorTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_constructors);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW);
-//// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_throws, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW);
-//// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_throws, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createFieldTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_fields);
-//
-//// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_fields_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_fields_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_LOCAL_PREVIEW);
-// return root;
-// }
-
- private InnerNode createLocalVariableTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_localvars);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_localvars_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_localvars_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW);
- return root;
- }
-
- private InnerNode createArrayInitializerTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_arrayinit);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_braces, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createArrayDeclarationTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_arraydecls);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_brackets, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createArrayElementAccessTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_arrayelem);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW);
-
- return root;
- }
-
- private InnerNode createArrayAllocTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_arrayalloc);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_brackets, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createFunctionCallTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_method_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_method_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_qalloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_qalloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createBlockTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- return root;
- }
-
- private InnerNode createSwitchStatementTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_default_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- return root;
- }
-
- private InnerNode createDoWhileTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
- return root;
- }
-
-// private InnerNode createSynchronizedTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_synchronized);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
-// return root;
-// }
-
- private InnerNode createTryStatementTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
- return root;
- }
- private InnerNode createIfStatementTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
- return root;
- }
-
- private InnerNode createForStatementTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR, FOR_PREVIEW);
-
- return root;
- }
-
-// private InnerNode createAssertTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assert);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, ASSERT_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, ASSERT_PREVIEW);
-// return root;
-// }
-//
- private InnerNode createReturnTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
- return root;
- }
-
- private InnerNode createThrowTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
- return root;
- }
-
- private InnerNode createLabelTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- return root;
- }
-
-// private InnerNode createAnnotationTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_annotations);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_at, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// //createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW); //$NON-NLS-1$
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
-// //createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW); //$NON-NLS-1$
-//
-// return root;
-// }
-
-// private InnerNode createAnnotationTypeTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_annotation_types);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_at, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_at, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION, ANNOTATION_DECL_PREVIEW);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_annot_type_method_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_annot_type_method_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createEnumTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_enums);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_decl_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION, ENUM_PREVIEW);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_decl_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_decl_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS, ENUM_PREVIEW);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, ENUM_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_arg_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// //createOption(inner, workingValues, "WhiteSpaceTabPage.enum_const_arg.after_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW); //$NON-NLS-1$
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_enum_const_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT, ENUM_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createParameterizedTypeTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_param_type_ref);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, PARAMETERIZED_TYPE_REFERENCE_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, PARAMETERIZED_TYPE_REFERENCE_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, PARAMETERIZED_TYPE_REFERENCE_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, PARAMETERIZED_TYPE_REFERENCE_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, PARAMETERIZED_TYPE_REFERENCE_PREVIEW);
- //createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_angle_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
-// return root;
-// }
-
-// private InnerNode createTypeArgumentTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_type_arguments);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, TYPE_ARGUMENTS_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createTypeParameterTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_type_parameters);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_and_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER, TYPE_PARAMETER_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_and_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER, TYPE_PARAMETER_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createWildcardTypeTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_wildcardtype);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD, WILDCARD_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD, WILDCARD_PREVIEW);
-// return root;
-// }
-
-
- private InnerNode createConditionalTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- return root;
- }
-
-
-// private InnerNode createTypecastTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts);
-//
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
-// return root;
-// }
-
-
- private InnerNode createParenthesizedExpressionTree(Map workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- return root;
- }
-
-
-
- private static InnerNode createChild(InnerNode root, Map workingValues, String message) {
- return new InnerNode(root, workingValues, message);
- }
-
- private static OptionNode createOption(InnerNode root, Map workingValues, String message, String key, PreviewSnippet snippet) {
- return new OptionNode(root, workingValues, message, key, snippet);
- }
-
- public static void makeIndexForNodes(List tree, List flatList) {
- for (final Iterator iter= tree.iterator(); iter.hasNext();) {
- final Node node= (Node) iter.next();
- node.index= flatList.size();
- flatList.add(node);
- makeIndexForNodes(node.getChildren(), flatList);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
deleted file mode 100644
index 0bb5552b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.preferences.formatter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.WhiteSpaceOptions.InnerNode;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.WhiteSpaceOptions.Node;
-import org.eclipse.wst.jsdt.internal.ui.preferences.formatter.WhiteSpaceOptions.OptionNode;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public class WhiteSpaceTabPage extends FormatterTabPage {
-
-
- /**
- * Encapsulates a view of the options tree which is structured by
- * syntactical element.
- */
-
- private final class SyntaxComponent implements ISelectionChangedListener, ICheckStateListener, IDoubleClickListener {
-
- private final String PREF_NODE_KEY= JavaScriptUI.ID_PLUGIN + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
-
- private final List fIndexedNodeList;
- private final List fTree;
-
- private ContainerCheckedTreeViewer fTreeViewer;
- private Composite fComposite;
-
- private Node fLastSelected= null;
-
- public SyntaxComponent() {
- fIndexedNodeList= new ArrayList();
- fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
- WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
- }
-
- public void createContents(final int numColumns, final Composite parent) {
- fComposite= new Composite(parent, SWT.NONE);
- fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
- fComposite.setLayout(createGridLayout(numColumns, false));
-
- createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space);
-
- fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
- fTreeViewer.setContentProvider(new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- return ((Collection)inputElement).toArray();
- }
- public Object[] getChildren(Object parentElement) {
- return ((Node)parentElement).getChildren().toArray();
- }
- public Object getParent(Object element) {
- return ((Node)element).getParent();
- }
- public boolean hasChildren(Object element) {
- return ((Node)element).hasChildren();
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
- public void dispose() {}
- });
- fTreeViewer.setLabelProvider(new LabelProvider());
- fTreeViewer.getControl().setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, SWT.DEFAULT));
- fDefaultFocusManager.add(fTreeViewer.getControl());
- }
-
- public void initialize() {
- fTreeViewer.addCheckStateListener(this);
- fTreeViewer.addSelectionChangedListener(this);
- fTreeViewer.addDoubleClickListener(this);
- fTreeViewer.setInput(fTree);
- restoreSelection();
- refreshState();
- }
-
- public void refreshState() {
- final ArrayList checked= new ArrayList(100);
- for (Iterator iter= fTree.iterator(); iter.hasNext();)
- ((Node) iter.next()).getCheckedLeafs(checked);
- fTreeViewer.setGrayedElements(new Object[0]);
- fTreeViewer.setCheckedElements(checked.toArray());
- fPreview.clear();
- if (fLastSelected != null) {
- fPreview.addAll(fLastSelected.getSnippets());
- }
- doUpdatePreview();
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
- if (selection.isEmpty())
- return;
- final Node node= (Node)selection.getFirstElement();
- if (node == fLastSelected)
- return;
- fDialogSettings.put(PREF_NODE_KEY, node.index);
- fPreview.clear();
- fPreview.addAll(node.getSnippets());
- doUpdatePreview();
- fLastSelected= node;
- }
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- final Node node= (Node)event.getElement();
- node.setChecked(event.getChecked());
- doUpdatePreview();
- notifyValuesModified();
- }
-
- public void restoreSelection() {
- int index;
- try {
- index= fDialogSettings.getInt(PREF_NODE_KEY);
- } catch (NumberFormatException ex) {
- index= -1;
- }
- if (index < 0 || index > fIndexedNodeList.size() - 1) {
- index= 0;
- }
- final Node node= (Node)fIndexedNodeList.get(index);
- if (node != null) {
- fTreeViewer.expandToLevel(node, 0);
- fTreeViewer.setSelection(new StructuredSelection(new Node [] {node}));
- fLastSelected= node;
- }
- }
-
- public void doubleClick(DoubleClickEvent event) {
- final ISelection selection= event.getSelection();
- if (selection instanceof IStructuredSelection) {
- final Node node= (Node)((IStructuredSelection)selection).getFirstElement();
- fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
- }
- }
-
- public Control getControl() {
- return fComposite;
- }
- }
-
-
-
- private final class JavaElementComponent implements ISelectionChangedListener, ICheckStateListener {
-
- private final String PREF_INNER_INDEX= JavaScriptUI.ID_PLUGIN + "formatter_page.white_space.java_view.inner"; //$NON-NLS-1$
- private final String PREF_OPTION_INDEX= JavaScriptUI.ID_PLUGIN + "formatter_page.white_space.java_view.option"; //$NON-NLS-1$
-
- private final ArrayList fIndexedNodeList;
- private final ArrayList fTree;
-
- private InnerNode fLastSelected;
-
- private TreeViewer fInnerViewer;
- private CheckboxTableViewer fOptionsViewer;
-
- private Composite fComposite;
-
- public JavaElementComponent() {
- fIndexedNodeList= new ArrayList();
- fTree= new WhiteSpaceOptions().createTreeByJavaElement(fWorkingValues);
- WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
- }
-
- public void createContents(int numColumns, Composite parent) {
-
- fComposite= new Composite(parent, SWT.NONE);
- fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
- fComposite.setLayout(createGridLayout(numColumns, false));
-
- createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space, GridData.HORIZONTAL_ALIGN_BEGINNING);
-
- final SashForm sashForm= new SashForm(fComposite, SWT.VERTICAL);
- sashForm.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
-
- fInnerViewer= new TreeViewer(sashForm, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
-
- fInnerViewer.setContentProvider(new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- return ((Collection)inputElement).toArray();
- }
- public Object[] getChildren(Object parentElement) {
- final List children= ((Node)parentElement).getChildren();
- final ArrayList innerChildren= new ArrayList();
- for (final Iterator iter= children.iterator(); iter.hasNext();) {
- final Object o= iter.next();
- if (o instanceof InnerNode) innerChildren.add(o);
- }
- return innerChildren.toArray();
- }
- public Object getParent(Object element) {
- if (element instanceof InnerNode)
- return ((InnerNode)element).getParent();
- return null;
- }
- public boolean hasChildren(Object element) {
- final List children= ((Node)element).getChildren();
- for (final Iterator iter= children.iterator(); iter.hasNext();)
- if (iter.next() instanceof InnerNode) return true;
- return false;
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
- public void dispose() {}
- });
-
- fInnerViewer.setLabelProvider(new LabelProvider());
-
- final GridData innerGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
- innerGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
- fInnerViewer.getControl().setLayoutData(innerGd);
-
- fOptionsViewer= CheckboxTableViewer.newCheckList(sashForm, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
- fOptionsViewer.setContentProvider(new ArrayContentProvider());
- fOptionsViewer.setLabelProvider(new LabelProvider());
-
- final GridData optionsGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
- optionsGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
- fOptionsViewer.getControl().setLayoutData(optionsGd);
-
- fDefaultFocusManager.add(fInnerViewer.getControl());
- fDefaultFocusManager.add(fOptionsViewer.getControl());
-
- fInnerViewer.setInput(fTree);
- }
-
- public void refreshState() {
- if (fLastSelected != null) {
- innerViewerChanged(fLastSelected);
- }
- }
-
- public void initialize() {
- fInnerViewer.addSelectionChangedListener(this);
- fOptionsViewer.addSelectionChangedListener(this);
- fOptionsViewer.addCheckStateListener(this);
- restoreSelections();
- refreshState();
- }
-
- private void restoreSelections() {
- Node node;
- final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
- node= (Node)fIndexedNodeList.get(innerIndex);
- if (node instanceof InnerNode) {
- fInnerViewer.expandToLevel(node, 0);
- fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
- fLastSelected= (InnerNode)node;
- }
-
- final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
- node= (Node)fIndexedNodeList.get(optionIndex);
- if (node instanceof OptionNode) {
- fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
- }
-
- }
-
- private int getValidatedIndex(String key) {
- int index;
- try {
- index= fDialogSettings.getInt(key);
- } catch (NumberFormatException ex) {
- index= 0;
- }
- if (index < 0 || index > fIndexedNodeList.size() - 1) {
- index= 0;
- }
- return index;
- }
-
- public Control getControl() {
- return fComposite;
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
-
- if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node))
- return;
-
- final Node selected= (Node)selection.getFirstElement();
-
- if (selected == null || selected == fLastSelected)
- return;
-
-
- if (event.getSource() == fInnerViewer && selected instanceof InnerNode) {
- fLastSelected= (InnerNode)selected;
- fDialogSettings.put(PREF_INNER_INDEX, selected.index);
- innerViewerChanged((InnerNode)selected);
- }
- else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode)
- fDialogSettings.put(PREF_OPTION_INDEX, selected.index);
- }
-
- private void innerViewerChanged(InnerNode selectedNode) {
-
- final List children= selectedNode.getChildren();
-
- final ArrayList optionsChildren= new ArrayList();
- for (final Iterator iter= children.iterator(); iter.hasNext();) {
- final Object o= iter.next();
- if (o instanceof OptionNode) optionsChildren.add(o);
- }
-
- fOptionsViewer.setInput(optionsChildren.toArray());
-
- for (final Iterator iter= optionsChildren.iterator(); iter.hasNext();) {
- final OptionNode child= (OptionNode)iter.next();
- fOptionsViewer.setChecked(child, child.getChecked());
- }
-
- fPreview.clear();
- fPreview.addAll(selectedNode.getSnippets());
- doUpdatePreview();
- }
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- final OptionNode option= (OptionNode)event.getElement();
- if (option != null)
- option.setChecked(event.getChecked());
- doUpdatePreview();
- notifyValuesModified();
- }
- }
-
-
-
- /**
- * This component switches between the two view and is responsible for delegating
- * the appropriate update requests.
- */
- private final class SwitchComponent extends SelectionAdapter {
- private final String PREF_VIEW_KEY= JavaScriptUI.ID_PLUGIN + "formatter_page.white_space_tab_page.view"; //$NON-NLS-1$
- private final String [] fItems= new String [] {
- FormatterMessages.WhiteSpaceTabPage_sort_by_java_element,
- FormatterMessages.WhiteSpaceTabPage_sort_by_syntax_element
- };
-
- private Combo fSwitchCombo;
- private PageBook fPageBook;
- private final SyntaxComponent fSyntaxComponent;
- private final JavaElementComponent fJavaElementComponent;
-
- public SwitchComponent() {
- fSyntaxComponent= new SyntaxComponent();
- fJavaElementComponent= new JavaElementComponent();
- }
-
- public void widgetSelected(SelectionEvent e) {
- final int index= fSwitchCombo.getSelectionIndex();
- if (index == 0) {
- fDialogSettings.put(PREF_VIEW_KEY, false);
- fJavaElementComponent.refreshState();
- fPageBook.showPage(fJavaElementComponent.getControl());
- }
- else if (index == 1) {
- fDialogSettings.put(PREF_VIEW_KEY, true);
- fSyntaxComponent.refreshState();
- fPageBook.showPage(fSyntaxComponent.getControl());
- }
- }
-
- public void createContents(int numColumns, Composite parent) {
-
- fPageBook= new PageBook(parent, SWT.NONE);
- fPageBook.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
-
- fJavaElementComponent.createContents(numColumns, fPageBook);
- fSyntaxComponent.createContents(numColumns, fPageBook);
-
- fSwitchCombo= new Combo(parent, SWT.READ_ONLY);
- final GridData gd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT);
- fSwitchCombo.setLayoutData(gd);
- fSwitchCombo.setItems(fItems);
- }
-
- public void initialize() {
- fSwitchCombo.addSelectionListener(this);
- fJavaElementComponent.initialize();
- fSyntaxComponent.initialize();
- restoreSelection();
- }
-
- private void restoreSelection() {
- final boolean selectSyntax= fDialogSettings.getBoolean(PREF_VIEW_KEY);
- if (selectSyntax) {
- fSyntaxComponent.refreshState();
- fSwitchCombo.setText(fItems[1]);
- fPageBook.showPage(fSyntaxComponent.getControl());
- } else {
- fJavaElementComponent.refreshState();
- fSwitchCombo.setText(fItems[0]);
- fPageBook.showPage(fJavaElementComponent.getControl());
- }
- }
- }
-
-
-
-
- private final SwitchComponent fSwitchComponent;
- protected final IDialogSettings fDialogSettings;
-
- protected SnippetPreview fPreview;
-
-
- /**
- * Create a new white space dialog page.
- * @param modifyDialog
- * @param workingValues
- */
- public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map workingValues) {
- super(modifyDialog, workingValues);
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- fSwitchComponent= new SwitchComponent();
- }
-
- protected void doCreatePreferences(Composite composite, int numColumns) {
- fSwitchComponent.createContents(numColumns, composite);
- }
-
- protected void initializePage() {
- fSwitchComponent.initialize();
- }
-
- protected JavaPreview doCreateJavaPreview(Composite parent) {
- fPreview= new SnippetPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionHandler.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionHandler.java
deleted file mode 100644
index 0ad0032e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionHandler.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-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.ProgressMonitorWrapper;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.swt.SWT;
-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.Shell;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-/**
- * Copy of org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler
- *
- */
-public class ChangeExceptionHandler {
-
- public static class NotCancelableProgressMonitor extends ProgressMonitorWrapper {
- public NotCancelableProgressMonitor(IProgressMonitor monitor) {
- super(monitor);
- }
- public void setCanceled(boolean b) {
- // ignore set cancel
- }
- public boolean isCanceled() {
- return false;
- }
- }
-
- private Shell fParent;
- private String fName;
-
- private static class RefactorErrorDialog extends ErrorDialog {
- public RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status, int displayMask) {
- super(parentShell, dialogTitle, dialogMessage, status, displayMask);
- }
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button ok= getButton(IDialogConstants.OK_ID);
- ok.setText( RefactoringMessages.ChangeExceptionHandler_undo_button);
- Button abort= createButton(parent, IDialogConstants.CANCEL_ID, RefactoringMessages.ChangeExceptionHandler_abort_button, true);
- abort.moveBelow(ok);
- abort.setFocus();
- }
- protected Control createMessageArea (Composite parent) {
- Control result= super.createMessageArea(parent);
- new Label(parent, SWT.NONE); // filler
- Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.ChangeExceptionHandler_message);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- applyDialogFont(result);
- return result;
- }
- }
-
- public ChangeExceptionHandler(Shell parent, Refactoring refactoring) {
- fParent= parent;
- fName= refactoring.getName();
- }
-
- public void handle(Change change, RuntimeException exception) {
- JavaScriptPlugin.log(exception);
- IStatus status= null;
- if (exception.getMessage() == null) {
- status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR,
- RefactoringMessages.ChangeExceptionHandler_status_without_detail, exception);
- } else {
- status= new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR,
- exception.getMessage(), exception);
- }
- handle(change, status);
- }
-
- public void handle(Change change, CoreException exception) {
- JavaScriptPlugin.log(exception);
- handle(change, exception.getStatus());
- }
-
- private void handle(Change change, IStatus status) {
- if (change instanceof CompositeChange) {
- Change undo= ((CompositeChange)change).getUndoUntilException();
- if (undo != null) {
- JavaScriptPlugin.log(status);
- final ErrorDialog dialog= new RefactorErrorDialog(fParent,
- RefactoringMessages.ChangeExceptionHandler_dialog_title,
- Messages.format(RefactoringMessages.ChangeExceptionHandler_dialog_message, fName),
- status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
- int result= dialog.open();
- if (result == IDialogConstants.OK_ID) {
- performUndo(undo);
- }
- return;
- }
- }
- ErrorDialog dialog= new ErrorDialog(fParent,
- RefactoringMessages.ChangeExceptionHandler_dialog_title,
- Messages.format(RefactoringMessages.ChangeExceptionHandler_dialog_message, fName),
- status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
- dialog.open();
- }
-
- private void performUndo(final Change undo) {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 11); //$NON-NLS-1$
- try {
- undo.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
- if (undo.isValid(new SubProgressMonitor(monitor,1)).hasFatalError()) {
- monitor.done();
- return;
- }
- undo.perform(new SubProgressMonitor(monitor, 9));
- } finally {
- undo.dispose();
- }
- }
- };
- WorkbenchRunnableAdapter adapter= new WorkbenchRunnableAdapter(runnable,
- ResourcesPlugin.getWorkspace().getRoot());
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(fParent);
- try {
- dialog.run(false, false, adapter);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, fParent,
- RefactoringMessages.ChangeExceptionHandler_undo_dialog_title,
- RefactoringMessages.ChangeExceptionHandler_undo_dialog_message + fName);
- } catch (InterruptedException e) {
- // can't happen
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionsControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionsControl.java
deleted file mode 100644
index 70192378..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeExceptionsControl.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-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.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Table;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeHierarchy;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ExceptionInfo;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-/**
- * A special control to add and remove thrown exceptions.
- */
-public class ChangeExceptionsControl extends Composite {
-//TODO: cleanup, adapt NLS strings
-
- private static class ExceptionInfoContentProvider implements IStructuredContentProvider {
- public Object[] getElements(Object inputElement) {
- return removeMarkedAsDeleted((List) inputElement);
- }
- private ExceptionInfo[] removeMarkedAsDeleted(List exceptionInfos){
- List result= new ArrayList(exceptionInfos.size());
- for (Iterator iter= exceptionInfos.iterator(); iter.hasNext();) {
- ExceptionInfo info= (ExceptionInfo) iter.next();
- if (! info.isDeleted())
- result.add(info);
- }
- return (ExceptionInfo[]) result.toArray(new ExceptionInfo[result.size()]);
- }
- public void dispose() {
- // do nothing
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
- }
-
- private static class ExceptionInfoLabelProvider extends LabelProvider implements ITableLabelProvider {
- private Image fInterfaceImage;
-
- public ExceptionInfoLabelProvider() {
- super();
- fInterfaceImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CLASS);
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return fInterfaceImage;
- }
- public String getColumnText(Object element, int columnIndex) {
- ExceptionInfo info= (ExceptionInfo) element;
- return info.getType().getFullyQualifiedName();
- }
- }
-
- private final IExceptionListChangeListener fListener;
- private final IJavaScriptProject fProject;
-
- private TableViewer fTableViewer;
- private Button fRemoveButton;
- private List fExceptionInfos;
-
- public ChangeExceptionsControl(Composite parent, int style, IExceptionListChangeListener listener, IJavaScriptProject project) {
- super(parent, style);
- Assert.isNotNull(listener);
- fListener= listener;
- Assert.isNotNull(project);
- fProject= project;
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- setLayout(layout);
-
- createExceptionList(this);
- createButtonComposite(this);
- }
-
- public void setInput(List exceptionInfos) {
- Assert.isNotNull(exceptionInfos);
- fExceptionInfos= exceptionInfos;
- fTableViewer.setInput(fExceptionInfos);
- if (fExceptionInfos.size() > 0)
- fTableViewer.setSelection(new StructuredSelection(fExceptionInfos.get(0)));
- }
-
- private void createExceptionList(Composite parent) {
- final Table table= new Table(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fTableViewer= new TableViewer(table);
- fTableViewer.setUseHashlookup(true);
- fTableViewer.setContentProvider(new ExceptionInfoContentProvider());
- fTableViewer.setLabelProvider(new ExceptionInfoLabelProvider());
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonsEnabledState();
- }
- });
- }
-
- private ExceptionInfo[] getSelectedItems() {
- ISelection selection= fTableViewer.getSelection();
- if (selection == null)
- return new ExceptionInfo[0];
-
- if (!(selection instanceof IStructuredSelection))
- return new ExceptionInfo[0];
-
- List selected= ((IStructuredSelection) selection).toList();
- return (ExceptionInfo[]) selected.toArray(new ExceptionInfo[selected.size()]);
- }
-
- // ---- Button bar --------------------------------------------------------------------------------------
-
- private void createButtonComposite(Composite parent) {
- Composite buttonComposite= new Composite(parent, SWT.NONE);
- buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- buttonComposite.setLayout(gl);
-
- createAddButton(buttonComposite);
- fRemoveButton= createRemoveButton(buttonComposite);
- updateButtonsEnabledState();
- }
-
- private void updateButtonsEnabledState() {
- if (fRemoveButton != null)
- fRemoveButton.setEnabled(getTableSelectionCount() != 0);
- }
-
- private int getTableSelectionCount() {
- return getTable().getSelectionCount();
- }
-
- private int getTableItemCount() {
- return getTable().getItemCount();
- }
-
- private Table getTable() {
- return fTableViewer.getTable();
- }
-
- private Button createAddButton(Composite buttonComposite) {
- Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.ChangeExceptionsControl_buttons_add);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.setEnabled(true);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- doAddException();
- }
- });
- return button;
- }
-
- private void doAddException() {
- IType newException= chooseException();
- if (newException == null)
- return;
-
- ExceptionInfo info= findExceptionInfo(newException);
- if (info != null) {
- if (info.isDeleted()) {
- info.markAsOld();
- fTableViewer.refresh();
- }
- fListener.exceptionListChanged();
- fTableViewer.getControl().setFocus();
- fTableViewer.setSelection(new StructuredSelection(info), true);
- return;
- }
-
- info= ExceptionInfo.createInfoForAddedException(newException);
- fExceptionInfos.add(info);
- fListener.exceptionListChanged();
- fTableViewer.refresh();
- fTableViewer.getControl().setFocus();
- int row= getTableItemCount() - 1;
- getTable().setSelection(row);
- updateButtonsEnabledState();
-
- }
-
- private IType chooseException() {
- IJavaScriptElement[] elements= new IJavaScriptElement[] { fProject.getJavaScriptProject() };
- final IJavaScriptSearchScope scope= SearchEngine.createJavaSearchScope(elements);
-
- FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
- PlatformUI.getWorkbench().getProgressService(), scope, IJavaScriptSearchConstants.CLASS);
- dialog.setTitle(RefactoringMessages.ChangeExceptionsControl_choose_title);
- dialog.setMessage(RefactoringMessages.ChangeExceptionsControl_choose_message);
- dialog.setInitialPattern("*Exception*"); //$NON-NLS-1$
- dialog.setValidator(new ISelectionStatusValidator() {
- public IStatus validate(Object[] selection) {
- if (selection.length == 0)
- return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
- try {
- return checkException((IType)selection[0]);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return StatusInfo.OK_STATUS;
- }
- }
- });
-
- if (dialog.open() == Window.OK) {
- return (IType) dialog.getFirstResult();
- }
- return null;
- }
-
- private IStatus checkException(final IType type) throws JavaScriptModelException {
- ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor());
- IType curr= type;
- while (curr != null) {
- String name= curr.getFullyQualifiedName();
- if ("java.lang.Throwable".equals(name)) //$NON-NLS-1$
- return StatusInfo.OK_STATUS;
- curr= hierarchy.getSuperclass(curr);
- }
- return JavaUIStatus.createError(IStatus.ERROR,
- RefactoringMessages.ChangeExceptionsControl_not_exception, null);
- }
-
- private ExceptionInfo findExceptionInfo(IType exception) {
- for (Iterator iter= fExceptionInfos.iterator(); iter.hasNext(); ) {
- ExceptionInfo info= (ExceptionInfo) iter.next();
- if (info.getType().equals(exception))
- return info;
- }
- return null;
- }
-
- private Button createRemoveButton(Composite buttonComposite) {
- final Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.ChangeExceptionsControl_buttons_remove);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index= getTable().getSelectionIndices()[0];
- ExceptionInfo[] selected= getSelectedItems();
- for (int i= 0; i < selected.length; i++) {
- if (selected[i].isAdded())
- fExceptionInfos.remove(selected[i]);
- else
- selected[i].markAsDeleted();
- }
- restoreSelection(index);
- }
- private void restoreSelection(int index) {
- fTableViewer.refresh();
- fTableViewer.getControl().setFocus();
- int itemCount= getTableItemCount();
- if (itemCount != 0) {
- if (index >= itemCount)
- index= itemCount - 1;
- getTable().setSelection(index);
- }
- fListener.exceptionListChanged();
- updateButtonsEnabledState();
- }
- });
- return button;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeParametersControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeParametersControl.java
deleted file mode 100644
index 6ffe9b08..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeParametersControl.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-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.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.contentassist.ContentAssistHandler;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.codemanipulation.StubUtility;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.StubTypeContext;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TableTextCellEditor;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.VariableNamesProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TableLayoutComposite;
-
-/**
- * A special control to edit and reorder method parameters.
- */
-public class ChangeParametersControl extends Composite {
-
-
- static final boolean SHOW_TYPES=false;
- public static class Mode {
- private final String fName;
- private Mode(String name) {
- fName= name;
- }
- public static final Mode EXTRACT_METHOD= new Mode("EXTRACT_METHOD"); //$NON-NLS-1$
- public static final Mode CHANGE_METHOD_SIGNATURE= new Mode("CHANGE_METHOD_SIGNATURE"); //$NON-NLS-1$
- public static final Mode INTRODUCE_PARAMETER= new Mode("INTRODUCE_PARAMETER"); //$NON-NLS-1$
- public String toString() {
- return fName;
- }
- public boolean canChangeTypes() {
- return this == CHANGE_METHOD_SIGNATURE;
- }
- public boolean canAddParameters() {
- return this == Mode.CHANGE_METHOD_SIGNATURE;
- }
- public boolean canChangeDefault() {
- return this == Mode.CHANGE_METHOD_SIGNATURE;
- }
- }
-
- private static class ParameterInfoContentProvider implements IStructuredContentProvider {
- public Object[] getElements(Object inputElement) {
- return removeMarkedAsDeleted((List) inputElement);
- }
- private ParameterInfo[] removeMarkedAsDeleted(List paramInfos){
- List result= new ArrayList(paramInfos.size());
- for (Iterator iter= paramInfos.iterator(); iter.hasNext();) {
- ParameterInfo info= (ParameterInfo) iter.next();
- if (! info.isDeleted())
- result.add(info);
- }
- return (ParameterInfo[]) result.toArray(new ParameterInfo[result.size()]);
- }
- public void dispose() {
- // do nothing
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
- }
-
- private static class ParameterInfoLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider {
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- public String getColumnText(Object element, int columnIndex) {
- ParameterInfo info= (ParameterInfo) element;
- switch (columnIndex) {
- case TYPE_PROP:
- return info.getNewTypeName();
- case NEWNAME_PROP:
- return info.getNewName();
- case DEFAULT_PROP:
- if (info.isAdded())
- return info.getDefaultValue();
- else
- return "-"; //$NON-NLS-1$
- default:
- throw new IllegalArgumentException(columnIndex + ": " + element); //$NON-NLS-1$
- }
- }
- public Font getFont(Object element, int columnIndex) {
- ParameterInfo info= (ParameterInfo) element;
- if (info.isAdded())
- return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
- else
- return null;
- }
- }
-
- private class ParametersCellModifier implements ICellModifier {
- public boolean canModify(Object element, String property) {
- Assert.isTrue(element instanceof ParameterInfo);
- if (JavaScriptCore.IS_ECMASCRIPT4 && property.equals(PROPERTIES[TYPE_PROP]))
- return fMode.canChangeTypes();
- else if (property.equals(PROPERTIES[NEWNAME_PROP]))
- return true;
- else if (property.equals(PROPERTIES[DEFAULT_PROP]))
- return (((ParameterInfo)element).isAdded());
- Assert.isTrue(false);
- return false;
- }
- public Object getValue(Object element, String property) {
- Assert.isTrue(element instanceof ParameterInfo);
- if (JavaScriptCore.IS_ECMASCRIPT4 && property.equals(PROPERTIES[TYPE_PROP]))
- return ((ParameterInfo) element).getNewTypeName();
- else if (property.equals(PROPERTIES[NEWNAME_PROP]))
- return ((ParameterInfo) element).getNewName();
- else if (property.equals(PROPERTIES[DEFAULT_PROP]))
- return ((ParameterInfo) element).getDefaultValue();
- Assert.isTrue(false);
- return null;
- }
- public void modify(Object element, String property, Object value) {
- if (element instanceof TableItem)
- element= ((TableItem) element).getData();
- if (!(element instanceof ParameterInfo))
- return;
- boolean unchanged;
- ParameterInfo parameterInfo= (ParameterInfo) element;
- if (property.equals(PROPERTIES[NEWNAME_PROP])) {
- unchanged= parameterInfo.getNewName().equals(value);
- parameterInfo.setNewName((String) value);
- } else if (property.equals(PROPERTIES[DEFAULT_PROP])) {
- unchanged= parameterInfo.getDefaultValue().equals(value);
- parameterInfo.setDefaultValue((String) value);
- } else if (property.equals(PROPERTIES[TYPE_PROP])) {
- unchanged= parameterInfo.getNewTypeName().equals(value);
- parameterInfo.setNewTypeName((String) value);
- } else {
- throw new IllegalStateException();
- }
- if (! unchanged) {
- ChangeParametersControl.this.fListener.parameterChanged(parameterInfo);
- ChangeParametersControl.this.fTableViewer.update(parameterInfo, new String[] { property });
- }
- }
- }
-
- private static final String[] PROPERTIES_NO_RETURN = new String[] { RefactoringMessages.ChangeParametersControl_new, RefactoringMessages.ChangeParametersControl_default };
- private static final String[] PROPERTIES_WITH_RETURN = new String[] { RefactoringMessages.ChangeParametersControl_type, RefactoringMessages.ChangeParametersControl_new, RefactoringMessages.ChangeParametersControl_default };
-
- private static final String[] PROPERTIES= JavaScriptCore.IS_ECMASCRIPT4?PROPERTIES_WITH_RETURN:PROPERTIES_NO_RETURN;
-
-
-
-
- private static final int TYPE_PROP= JavaScriptCore.IS_ECMASCRIPT4?0:-1;
- private static final int NEWNAME_PROP= JavaScriptCore.IS_ECMASCRIPT4?1:0;
- private static final int DEFAULT_PROP= JavaScriptCore.IS_ECMASCRIPT4?2:1;
-
- private static final int ROW_COUNT= 7;
-
- private final Mode fMode;
- private final IParameterListChangeListener fListener;
- private List fParameterInfos;
- private final StubTypeContext fTypeContext;
- private final String[] fParamNameProposals;
- private ContentAssistHandler fNameContentAssistHandler;
-
- private TableViewer fTableViewer;
- private Button fUpButton;
- private Button fDownButton;
- private Button fEditButton;
- private Button fAddButton;
- private Button fRemoveButton;
-
- public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener, Mode mode, StubTypeContext typeContext) {
- this(parent, style, label, listener, mode, typeContext, new String[0]);
- }
-
- public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener, Mode mode) {
- this(parent, style, label, listener, mode, null, new String[0]);
- }
-
- public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener, Mode mode, String[] paramNameProposals) {
- this(parent, style, label, listener, mode, null, paramNameProposals);
- }
-
- /**
- * @param label the label before the table or <code>null</code>
- * @param typeContext the package in which to complete types
- */
- private ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener, Mode mode, StubTypeContext typeContext, String[] paramNameProposals) {
- super(parent, style);
- Assert.isNotNull(listener);
- fListener= listener;
- fMode= mode;
- fTypeContext= typeContext;
- fParamNameProposals= paramNameProposals;
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- setLayout(layout);
-
- if (label != null) {
- Label tableLabel= new Label(this, SWT.NONE);
- GridData labelGd= new GridData();
- labelGd.horizontalSpan= 2;
- tableLabel.setLayoutData(labelGd);
- tableLabel.setText(label);
- }
-
- createParameterList(this);
- createButtonComposite(this);
- }
-
-
- public void setInput(List parameterInfos) {
- Assert.isNotNull(parameterInfos);
- fParameterInfos= parameterInfos;
- fTableViewer.setInput(fParameterInfos);
- if (fParameterInfos.size() > 0)
- fTableViewer.setSelection(new StructuredSelection(fParameterInfos.get(0)));
- }
-
- public void editParameter(ParameterInfo info) {
- fTableViewer.getControl().setFocus();
- if (! info.isDeleted()) {
- fTableViewer.setSelection(new StructuredSelection(info), true);
- updateButtonsEnabledState();
- editColumnOrNextPossible(NEWNAME_PROP);
- return;
- }
- }
-
- // ---- Parameter table -----------------------------------------------------------------------------------
-
- private void createParameterList(Composite parent) {
- TableLayoutComposite layouter= new TableLayoutComposite(parent, SWT.NONE);
- addColumnLayoutData(layouter);
-
- final Table table= new Table(layouter, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- TableColumn tc;
-
-// if (SHOW_TYPES)
-// {
- if(JavaScriptCore.IS_ECMASCRIPT4) {
- tc= new TableColumn(table, SWT.NONE, TYPE_PROP);
- tc.setResizable(true);
- tc.setText(SHOW_TYPES?RefactoringMessages.ChangeParametersControl_table_type:""); //$NON-NLS-1$
-//
- }
-
- int index= NEWNAME_PROP;
-// if (!SHOW_TYPES)
-// index--;
- tc= new TableColumn(table, SWT.NONE,index);
- tc.setResizable(true);
- tc.setText(RefactoringMessages.ChangeParametersControl_table_name);
-
- if (fMode.canChangeDefault()){
- index= DEFAULT_PROP;
-// if (!SHOW_TYPES)
-// index--;
- tc= new TableColumn(table, SWT.NONE, index);
- tc.setResizable(true);
- tc.setText(RefactoringMessages.ChangeParametersControl_table_defaultValue);
- }
-
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= SWTUtil.getTableHeightHint(table, ROW_COUNT);
- gd.widthHint= 40;
- layouter.setLayoutData(gd);
-
- fTableViewer= new TableViewer(table);
- fTableViewer.setUseHashlookup(true);
- fTableViewer.setContentProvider(new ParameterInfoContentProvider());
- fTableViewer.setLabelProvider(new ParameterInfoLabelProvider());
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonsEnabledState();
- }
- });
-
- table.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN && e.stateMask == SWT.NONE) {
- editColumnOrNextPossible(0);
- e.detail= SWT.TRAVERSE_NONE;
- }
- }
- });
- table.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.F2 && e.stateMask == SWT.NONE) {
- editColumnOrNextPossible(0);
- e.doit= false;
- }
- }
- });
-
- addCellEditors();
- }
-
- private void editColumnOrNextPossible(int column){
- ParameterInfo[] selected= getSelectedElements();
- if (selected.length != 1)
- return;
- int nextColumn= column;
- do {
- fTableViewer.editElement(selected[0], nextColumn);
- if (fTableViewer.isCellEditorActive())
- return;
- nextColumn= nextColumn(nextColumn);
- } while (nextColumn != column);
- }
-
- private void editColumnOrPrevPossible(int column){
- ParameterInfo[] selected= getSelectedElements();
- if (selected.length != 1)
- return;
- int prevColumn= column;
- do {
- fTableViewer.editElement(selected[0], prevColumn);
- if (fTableViewer.isCellEditorActive())
- return;
- prevColumn= prevColumn(prevColumn);
- } while (prevColumn != column);
- }
-
- private int nextColumn(int column) {
- return (column >= getTable().getColumnCount() - 1) ? 0 : column + 1;
- }
-
- private int prevColumn(int column) {
- return (column <= 0) ? getTable().getColumnCount() - 1 : column - 1;
- }
-
- private void addColumnLayoutData(TableLayoutComposite layouter) {
- if (fMode.canChangeDefault()){
- // layouter.addColumnData(new ColumnWeightData(33, true));
- layouter.addColumnData(new ColumnWeightData(33, true));
- layouter.addColumnData(new ColumnWeightData(34, true));
- } else if (SHOW_TYPES){
- layouter.addColumnData(new ColumnWeightData(50, true));
- layouter.addColumnData(new ColumnWeightData(50, true));
- }
- else
- {
- layouter.addColumnData(new ColumnWeightData(1, true));
- layouter.addColumnData(new ColumnWeightData(99, true));
- }
- }
-
- private ParameterInfo[] getSelectedElements() {
- ISelection selection= fTableViewer.getSelection();
- if (selection == null)
- return new ParameterInfo[0];
-
- if (!(selection instanceof IStructuredSelection))
- return new ParameterInfo[0];
-
- List selected= ((IStructuredSelection) selection).toList();
- return (ParameterInfo[]) selected.toArray(new ParameterInfo[selected.size()]);
- }
-
- // ---- Button bar --------------------------------------------------------------------------------------
-
- private void createButtonComposite(Composite parent) {
- Composite buttonComposite= new Composite(parent, SWT.NONE);
- buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- buttonComposite.setLayout(gl);
-
- if (fMode.canAddParameters())
- fAddButton= createAddButton(buttonComposite);
-
- fEditButton= createEditButton(buttonComposite);
-
- if (fMode.canAddParameters())
- fRemoveButton= createRemoveButton(buttonComposite);
-
- if (buttonComposite.getChildren().length != 0)
- addSpacer(buttonComposite);
-
- fUpButton= createButton(buttonComposite, RefactoringMessages.ChangeParametersControl_buttons_move_up, true);
- fDownButton= createButton(buttonComposite, RefactoringMessages.ChangeParametersControl_buttons_move_down, false);
-
- updateButtonsEnabledState();
- }
-
- private void addSpacer(Composite parent) {
- Label label= new Label(parent, SWT.NONE);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= 5;
- label.setLayoutData(gd);
- }
-
- private void updateButtonsEnabledState() {
- fUpButton.setEnabled(canMove(true));
- fDownButton.setEnabled(canMove(false));
- if (fEditButton != null)
- fEditButton.setEnabled(getTableSelectionCount() == 1);
- if (fAddButton != null)
- fAddButton.setEnabled(true);
- if (fRemoveButton != null)
- fRemoveButton.setEnabled(getTableSelectionCount() != 0);
- }
-
- private int getTableSelectionCount() {
- return getTable().getSelectionCount();
- }
-
- private int getTableItemCount() {
- return getTable().getItemCount();
- }
-
- private Table getTable() {
- return fTableViewer.getTable();
- }
-
- private Button createEditButton(Composite buttonComposite) {
- Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.ChangeParametersControl_buttons_edit);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- ParameterInfo[] selected= getSelectedElements();
- Assert.isTrue(selected.length == 1);
- ParameterInfo parameterInfo= selected[0];
- ParameterEditDialog dialog= new ParameterEditDialog(getShell(), parameterInfo, fMode.canChangeTypes(), fMode.canChangeDefault(), fTypeContext);
- dialog.open();
- fListener.parameterChanged(parameterInfo);
- fTableViewer.update(parameterInfo, PROPERTIES);
- } finally {
- fTableViewer.getControl().setFocus();
- }
- }
- });
- return button;
- }
-
- private Button createAddButton(Composite buttonComposite) {
- Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.ChangeParametersControl_buttons_add);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- String[] excludedParamNames= new String[fParameterInfos.size()];
- for (int i= 0; i < fParameterInfos.size(); i++) {
- ParameterInfo info= (ParameterInfo) fParameterInfos.get(i);
- excludedParamNames[i]= info.getNewName();
- }
- IJavaScriptProject javaProject= fTypeContext.getCuHandle().getJavaScriptProject();
- String newParamName= StubUtility.suggestArgumentName(javaProject, RefactoringMessages.ChangeParametersControl_new_parameter_default_name, excludedParamNames);
- ParameterInfo newInfo= ParameterInfo.createInfoForAddedParameter("Object", newParamName, "null"); //$NON-NLS-1$ //$NON-NLS-2$
- int insertIndex= fParameterInfos.size();
- for (int i= fParameterInfos.size() - 1; i >= 0; i--) {
- ParameterInfo info= (ParameterInfo) fParameterInfos.get(i);
- if (info.isNewVarargs()) {
- insertIndex= i;
- break;
- }
- }
- fParameterInfos.add(insertIndex, newInfo);
- fListener.parameterAdded(newInfo);
- fTableViewer.refresh();
- fTableViewer.getControl().setFocus();
- fTableViewer.setSelection(new StructuredSelection(newInfo), true);
- updateButtonsEnabledState();
- editColumnOrNextPossible(0);
- }
- });
- return button;
- }
-
- private Button createRemoveButton(Composite buttonComposite) {
- final Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.ChangeParametersControl_buttons_remove);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index= getTable().getSelectionIndices()[0];
- ParameterInfo[] selected= getSelectedElements();
- for (int i= 0; i < selected.length; i++) {
- if (selected[i].isAdded())
- fParameterInfos.remove(selected[i]);
- else
- selected[i].markAsDeleted();
- }
- restoreSelection(index);
- }
- private void restoreSelection(int index) {
- fTableViewer.refresh();
- fTableViewer.getControl().setFocus();
- int itemCount= getTableItemCount();
- if (itemCount != 0 && index >= itemCount) {
- index= itemCount - 1;
- getTable().setSelection(index);
- }
- fListener.parameterListChanged();
- updateButtonsEnabledState();
- }
- });
- return button;
- }
-
- private Button createButton(Composite buttonComposite, String text, final boolean up) {
- Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(text);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ISelection savedSelection= fTableViewer.getSelection();
- if (savedSelection == null)
- return;
- ParameterInfo[] selection= getSelectedElements();
- if (selection.length == 0)
- return;
-
- if (up) {
- moveUp(selection);
- } else {
- moveDown(selection);
- }
- fTableViewer.refresh();
- fTableViewer.setSelection(savedSelection);
- fListener.parameterListChanged();
- fTableViewer.getControl().setFocus();
- }
- });
- return button;
- }
-
- //---- editing -----------------------------------------------------------------------------------------------
-
- private void addCellEditors() {
- fTableViewer.setColumnProperties(PROPERTIES);
-
- final TableTextCellEditor editors[]= new TableTextCellEditor[PROPERTIES.length];
-
- if(JavaScriptCore.IS_ECMASCRIPT4) editors[TYPE_PROP]= new TableTextCellEditor(fTableViewer, TYPE_PROP);
- editors[NEWNAME_PROP]= new TableTextCellEditor(fTableViewer, NEWNAME_PROP);
- editors[DEFAULT_PROP]= new TableTextCellEditor(fTableViewer, DEFAULT_PROP);
-
- if (fMode.canChangeTypes() && (JavaScriptCore.IS_ECMASCRIPT4) ) {
- SubjectControlContentAssistant assistant= installParameterTypeContentAssist(editors[TYPE_PROP].getText());
- editors[TYPE_PROP].setContentAssistant(assistant);
- }
- if (fParamNameProposals.length > 0 ) {
- SubjectControlContentAssistant assistant= installParameterNameContentAssist(editors[NEWNAME_PROP].getText());
- editors[NEWNAME_PROP].setContentAssistant(assistant);
- }
-
- for (int i = 0; i < editors.length; i++) {
- final int editorColumn= i;
- final TableTextCellEditor editor = editors[i];
- // support tabbing between columns while editing:
- editor.getText().addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- switch (e.detail) {
- case SWT.TRAVERSE_TAB_NEXT :
- editColumnOrNextPossible(nextColumn(editorColumn));
- e.detail= SWT.TRAVERSE_NONE;
- break;
-
- case SWT.TRAVERSE_TAB_PREVIOUS :
- editColumnOrPrevPossible(prevColumn(editorColumn));
- e.detail= SWT.TRAVERSE_NONE;
- break;
-
- default :
- break;
- }
- }
- });
- TextFieldNavigationHandler.install(editor.getText());
- }
-
- editors[NEWNAME_PROP].setActivationListener(new TableTextCellEditor.IActivationListener(){
- public void activate() {
- ParameterInfo[] selected= getSelectedElements();
- if (selected.length == 1 && fNameContentAssistHandler != null) {
- fNameContentAssistHandler.setEnabled(selected[0].isAdded());
- }
- }
- });
-
- fTableViewer.setCellEditors(editors);
- fTableViewer.setCellModifier(new ParametersCellModifier());
- }
-
- private SubjectControlContentAssistant installParameterTypeContentAssist(Text text) {
- JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(true, false);
- if (fTypeContext == null)
- processor.setCompletionContext(null, null, null);
- else
- processor.setCompletionContext(fTypeContext.getCuHandle(), fTypeContext.getBeforeString(), fTypeContext.getAfterString());
- SubjectControlContentAssistant contentAssistant= ControlContentAssistHelper.createJavaContentAssistant(processor);
- ContentAssistHandler.createHandlerForText(text, contentAssistant);
- return contentAssistant;
- }
-
- private SubjectControlContentAssistant installParameterNameContentAssist(Text text) {
- VariableNamesProcessor processor= new VariableNamesProcessor(fParamNameProposals);
- SubjectControlContentAssistant contentAssistant= ControlContentAssistHelper.createJavaContentAssistant(processor);
- fNameContentAssistHandler= ContentAssistHandler.createHandlerForText(text, contentAssistant);
- return contentAssistant;
- }
-
- //---- change order ----------------------------------------------------------------------------------------
-
- private void moveUp(ParameterInfo[] selection) {
- moveUp(fParameterInfos, Arrays.asList(selection));
- }
-
- private void moveDown(ParameterInfo[] selection) {
- Collections.reverse(fParameterInfos);
- moveUp(fParameterInfos, Arrays.asList(selection));
- Collections.reverse(fParameterInfos);
- }
-
- private static void moveUp(List elements, List move) {
- List res= new ArrayList(elements.size());
- List deleted= new ArrayList();
- Object floating= null;
- for (Iterator iter= elements.iterator(); iter.hasNext();) {
- Object curr= iter.next();
- if (move.contains(curr)) {
- res.add(curr);
- } else if (((ParameterInfo) curr).isDeleted()) {
- deleted.add(curr);
- } else {
- if (floating != null)
- res.add(floating);
- floating= curr;
- }
- }
- if (floating != null) {
- res.add(floating);
- }
- res.addAll(deleted);
- elements.clear();
- for (Iterator iter= res.iterator(); iter.hasNext();) {
- elements.add(iter.next());
- }
- }
-
- private boolean canMove(boolean up) {
- int notDeletedInfosCount= getNotDeletedInfosCount();
- if (notDeletedInfosCount == 0)
- return false;
- int[] indc= getTable().getSelectionIndices();
- if (indc.length == 0)
- return false;
- int invalid= up ? 0 : notDeletedInfosCount - 1;
- for (int i= 0; i < indc.length; i++) {
- if (indc[i] == invalid)
- return false;
- }
- return true;
- }
-
- private int getNotDeletedInfosCount(){
- if (fParameterInfos == null) // during initialization
- return 0;
- int result= 0;
- for (Iterator iter= fParameterInfos.iterator(); iter.hasNext();) {
- ParameterInfo info= (ParameterInfo) iter.next();
- if (! info.isDeleted())
- result++;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeSignatureWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeSignatureWizard.java
deleted file mode 100644
index 0d6d6785..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeSignatureWizard.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.StubTypeContext;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-public class ChangeSignatureWizard extends RefactoringWizard {
-
- public ChangeSignatureWizard(ChangeSignatureRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ChangeSignatureRefactoring_modify_Parameters);
- }
-
- protected void addUserInputPages(){
- addPage(new ChangeSignatureInputPage());
- }
-
- private static class ChangeSignatureInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "ChangeSignatureInputPage"; //$NON-NLS-1$
- private JavaSourceViewer fSignaturePreview;
- private Document fSignaturePreviewDocument;
- private Button fLeaveDelegateCheckBox;
- private Button fDeprecateDelegateCheckBox;
-
- public ChangeSignatureInputPage() {
- super(PAGE_NAME);
- setMessage(RefactoringMessages.ChangeSignatureInputPage_change);
- fSignaturePreviewDocument= new Document();
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- composite.setLayout(layout);
- initializeDialogUnits(composite);
-
- try {
- createHeadControls(composite);
-
-
- createParameterExceptionsFolder(composite);
- fLeaveDelegateCheckBox= DelegateUIHelper.generateLeaveDelegateCheckbox(composite, getRefactoring(), false);
- if (fLeaveDelegateCheckBox != null) {
- fDeprecateDelegateCheckBox= new Button(composite, SWT.CHECK);
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.horizontalIndent= (layout.marginWidth + fDeprecateDelegateCheckBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- data.horizontalSpan= 2;
- fDeprecateDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox.setText(DelegateUIHelper.getDeprecateDelegateCheckBoxTitle());
- final ChangeSignatureRefactoring refactoring= getChangeMethodSignatureRefactoring();
- fDeprecateDelegateCheckBox.setSelection(DelegateUIHelper.loadDeprecateDelegateSetting(refactoring));
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- fDeprecateDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- }
- });
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
- Label sep= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- sep.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- createSignaturePreview(composite);
-
- update(false);
- setControl(composite);
- Dialog.applyDialogFont(composite);
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.ChangeSignatureInputPage_Change_Signature, RefactoringMessages.ChangeSignatureInputPage_Internal_Error);
- }
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.MODIFY_PARAMETERS_WIZARD_PAGE);
- }
-
- private void createHeadControls(Composite parent) throws JavaScriptModelException {
- //must create controls column-wise to get mnemonics working:
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout layout= new GridLayout(3, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- if(JavaScriptCore.IS_ECMASCRIPT4) {
- createAccessControl(composite);
- createReturnTypeControl(composite);
- }
- createNameControl(composite);
- }
-
- private void createAccessControl(Composite parent) throws JavaScriptModelException {
- Composite access= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- access.setLayout(layout);
-
- final int[] availableVisibilities= getChangeMethodSignatureRefactoring().getAvailableVisibilities();
- int currentVisibility= getChangeMethodSignatureRefactoring().getVisibility();
-
- Label label= new Label(access, SWT.NONE);
- label.setText(RefactoringMessages.ChangeSignatureInputPage_access_modifier);
-
- final Combo combo= new Combo(access, SWT.DROP_DOWN | SWT.READ_ONLY);
- if (availableVisibilities.length == 0) {
- combo.setEnabled(false);
- } else {
- for (int i= 0; i < availableVisibilities.length; i++) {
- combo.add(getAccessModifierString(availableVisibilities[i]));
- }
- combo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int newVisibility= availableVisibilities[combo.getSelectionIndex()];
- getChangeMethodSignatureRefactoring().setVisibility(newVisibility);
- update(true);
- }
- });
- }
- combo.setText(getAccessModifierString(currentVisibility));
- combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- // ensure that "Access modifier:" and "Return type:" Labels are not too close:
- Dialog.applyDialogFont(access);
- access.pack();
- int minLabelWidth= label.getSize().x + 3 * layout.horizontalSpacing;
- if (minLabelWidth > combo.getSize().x)
- label.setLayoutData(new GridData(minLabelWidth, label.getSize().y));
- }
-
- private String getAccessModifierString(int modifier) {
- switch (modifier) {
- case Modifier.PUBLIC :
- return JdtFlags.VISIBILITY_STRING_PUBLIC;
- case Modifier.PROTECTED :
- return JdtFlags.VISIBILITY_STRING_PROTECTED;
- case Modifier.NONE :
- return RefactoringMessages.ChangeSignatureInputPage_default;
- case Modifier.PRIVATE :
- return JdtFlags.VISIBILITY_STRING_PRIVATE;
- default :
- throw new IllegalArgumentException("\"" + modifier + "\" is not a Modifier constant"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private void createReturnTypeControl(Composite parent) {
- Composite returnType= new Composite(parent, SWT.NONE);
- returnType.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- returnType.setLayout(layout);
-
- Label label= new Label(returnType, SWT.NONE);
- label.setText(RefactoringMessages.ChangeSignatureInputPage_return_type);
-
- final Text text= new Text(returnType, SWT.BORDER);
- text.setText(getChangeMethodSignatureRefactoring().getReturnTypeString());
- text.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- TextFieldNavigationHandler.install(text);
-
- if (getChangeMethodSignatureRefactoring().canChangeNameAndReturnType()) {
- text.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- getChangeMethodSignatureRefactoring().setNewReturnTypeName(text.getText());
- update(true);
- }
- });
- } else {
- text.setEnabled(false);
- }
-
- JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(true, true);
- StubTypeContext stubTypeContext= getChangeMethodSignatureRefactoring().getStubTypeContext();
- processor.setCompletionContext(stubTypeContext.getCuHandle(), stubTypeContext.getBeforeString(), stubTypeContext.getAfterString());
- ControlContentAssistHelper.createTextContentAssistant(text, processor);
- }
-
- private void createNameControl(Composite parent) {
- Composite name= new Composite(parent, SWT.NONE);
- name.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- name.setLayout(layout);
-
- Label label= new Label(name, SWT.NONE);
- label.setText(RefactoringMessages.ChangeSignatureInputPage_method_name);
-
- final Text text= new Text(name, SWT.BORDER);
- text.setText(getChangeMethodSignatureRefactoring().getMethodName());
- text.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- TextFieldNavigationHandler.install(text);
-
- if (getChangeMethodSignatureRefactoring().canChangeNameAndReturnType()) {
- text.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- getChangeMethodSignatureRefactoring().setNewMethodName(text.getText());
- update(true);
- }
- });
- } else {
- text.setEnabled(false);
- }
- }
-
- private void createParameterExceptionsFolder(Composite composite) {
- TabFolder folder= new TabFolder(composite, SWT.TOP);
- folder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TabItem item= new TabItem(folder, SWT.NONE);
- item.setText(RefactoringMessages.ChangeSignatureInputPage_parameters);
- item.setControl(createParameterTableControl(folder));
- if(JavaScriptCore.IS_ECMASCRIPT4) {
- TabItem itemEx= new TabItem(folder, SWT.NONE);
- itemEx.setText(RefactoringMessages.ChangeSignatureInputPage_exceptions);
- itemEx.setControl(createExceptionsTableControl(folder));
- }
- folder.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ((TabItem) e.item).getControl().setFocus();
- }
- });
- }
-
- private Control createParameterTableControl(Composite composite) {
-
- Composite border= new Composite(composite, SWT.NONE);
- border.setLayout(new GridLayout());
-
- String labelText= null; //no label
- ChangeParametersControl cp= new ChangeParametersControl(border, SWT.NONE, labelText, new IParameterListChangeListener() {
- public void parameterChanged(ParameterInfo parameter) {
- update(true);
- }
- public void parameterListChanged() {
- update(true);
- }
- public void parameterAdded(ParameterInfo parameter) {
- update(true);
- }
- }, ChangeParametersControl.Mode.CHANGE_METHOD_SIGNATURE, getChangeMethodSignatureRefactoring().getStubTypeContext());
- cp.setLayoutData(new GridData(GridData.FILL_BOTH));
- cp.setInput(getChangeMethodSignatureRefactoring().getParameterInfos());
- return border;
- }
-
- private Control createExceptionsTableControl(Composite parent) {
- Composite border= new Composite(parent, SWT.NONE);
- border.setLayout(new GridLayout());
-
- ChangeExceptionsControl cp= new ChangeExceptionsControl(border, SWT.NONE, new IExceptionListChangeListener() {
- public void exceptionListChanged() {
- update(true);
- }
- }, getChangeMethodSignatureRefactoring().getMethod().getJavaScriptProject());
- cp.setLayoutData(new GridData(GridData.FILL_BOTH));
- cp.setInput(getChangeMethodSignatureRefactoring().getExceptionInfos());
- return border;
- }
-
- public void dispose() {
- DelegateUIHelper.saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
- DelegateUIHelper.saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
- super.dispose();
- }
-
- private void createSignaturePreview(Composite composite) {
- Label previewLabel= new Label(composite, SWT.NONE);
- previewLabel.setText(RefactoringMessages.ChangeSignatureInputPage_method_Signature_Preview);
-
-// //XXX: use ViewForm to draw a flat border. Beware of common problems with wrapping layouts
-// //inside GridLayout. GridData must be constrained to force wrapping. See bug 9866 et al.
-// ViewForm border= new ViewForm(composite, SWT.BORDER | SWT.FLAT);
-
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSignaturePreview= new JavaSourceViewer(composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store);
- fSignaturePreview.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- fSignaturePreview.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- fSignaturePreview.getTextWidget().setBackground(composite.getBackground());
- fSignaturePreview.setDocument(fSignaturePreviewDocument);
- fSignaturePreview.setEditable(false);
-
- //Layouting problems with wrapped text: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866
- Control signaturePreviewControl= fSignaturePreview.getControl();
- PixelConverter pixelConverter= new PixelConverter(signaturePreviewControl);
- GridData gdata= new GridData(GridData.FILL_BOTH);
- gdata.widthHint= pixelConverter.convertWidthInCharsToPixels(50);
- gdata.heightHint= pixelConverter.convertHeightInCharsToPixels(2);
- signaturePreviewControl.setLayoutData(gdata);
-
-// //XXX must force JavaSourceViewer text widget to wrap:
-// border.setContent(signaturePreviewControl);
-// GridData borderData= new GridData(GridData.FILL_BOTH);
-// borderData.widthHint= gdata.widthHint;
-// borderData.heightHint= gdata.heightHint;
-// border.setLayoutData(borderData);
- }
-
- private ChangeSignatureRefactoring getChangeMethodSignatureRefactoring(){
- return (ChangeSignatureRefactoring)getRefactoring();
- }
-
- private void update(boolean displayErrorMessage){
- updateStatus(displayErrorMessage);
- updateSignaturePreview();
- }
-
- private void updateStatus(boolean displayErrorMessage) {
- try{
- if (getChangeMethodSignatureRefactoring().isSignatureSameAsInitial()){
- if (displayErrorMessage)
- setErrorMessage(RefactoringMessages.ChangeSignatureInputPage_unchanged);
- else
- setErrorMessage(null);
- setPageComplete(false);
- return;
- }
- RefactoringStatus nameCheck= getChangeMethodSignatureRefactoring().checkSignature();
- if (displayErrorMessage) {
- setPageComplete(nameCheck);
- } else {
- setErrorMessage(null);
- setPageComplete(true);
- }
- } catch (JavaScriptModelException e){
- setErrorMessage(RefactoringMessages.ChangeSignatureInputPage_Internal_Error);
- setPageComplete(false);
- JavaScriptPlugin.log(e);
- }
- }
-
- private void updateSignaturePreview() {
- try{
- int top= fSignaturePreview.getTextWidget().getTopPixel();
- fSignaturePreviewDocument.set(getChangeMethodSignatureRefactoring().getNewMethodSignature());
- fSignaturePreview.getTextWidget().setTopPixel(top);
- } catch (JavaScriptModelException e){
- ExceptionHandler.handle(e, RefactoringMessages.ChangeSignatureRefactoring_modify_Parameters, RefactoringMessages.ChangeSignatureInputPage_exception);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeContentProvider.java
deleted file mode 100644
index 91b8a0bb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeContentProvider.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ChangeTypeRefactoring;
-
-class ChangeTypeContentProvider implements ITreeContentProvider {
-
- private ChangeTypeRefactoring fGeneralizeType;
-
- ChangeTypeContentProvider(ChangeTypeRefactoring gt){
- fGeneralizeType= gt;
- }
-
- public Object[] getChildren(Object element) {
- if (element instanceof RootType){
- return ((RootType)element).getChildren();
- }
- Object[] superTypes = getDirectSuperTypes((ITypeBinding)element).toArray();
- Arrays.sort(superTypes, new Comparator(){
- public int compare(Object o1, Object o2) {
- String name1 = ((ITypeBinding)o1).getQualifiedName();
- String name2 = ((ITypeBinding)o2).getQualifiedName();
- return name1.compareTo(name2);
- }
- });
- return superTypes;
- }
-
- /**
- * Returns the direct superclass and direct superinterfaces. Class Object is
- * included in the result if the root of the hierarchy is a top-level
- * interface.
- */
- public Set/*<ITypeBinding>*/ getDirectSuperTypes(ITypeBinding type){
- Set/*<ITypeBinding>*/ result= new HashSet();
- if (type.getSuperclass() != null){
- result.add(type.getSuperclass());
- }
- ITypeBinding[] interfaces= type.getInterfaces();
- for (int i=0; i < interfaces.length; i++){
- result.add(interfaces[i]);
- }
- if (fGeneralizeType.getOriginalType().isInterface() && type != fGeneralizeType.getObject()){
- result.add(fGeneralizeType.getObject());
- }
- return result;
- }
-
- public Object[] getElements(Object element) {
- Assert.isTrue(element instanceof RootType);
- return ((RootType)element).getChildren();
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /**
- * Artificial "root node" of the tree view. This is needed to handle situations where the replacement
- * types do not have a single common supertype. Also, the tree view does not show the root node by
- * default.
- */
- static class RootType {
- RootType(ITypeBinding root){
- fRoot = root;
- }
- public ITypeBinding[] getChildren(){
- return new ITypeBinding[]{ fRoot };
- }
- private ITypeBinding fRoot;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeWizard.java
deleted file mode 100644
index 0e024db7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ChangeTypeWizard.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ChangeTypeRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.BindingLabelProvider;
-
-
-/**
- * @author tip
- */
-public class ChangeTypeWizard extends RefactoringWizard {
-
- private ChangeTypeRefactoring fCT;
-
- public ChangeTypeWizard(ChangeTypeRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ChangeTypeWizard_title);
- fCT= ref;
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new ChangeTypeInputPage());
- }
-
- // For debugging
- static String print(Collection/*<ITypeBinding>*/ types){
- if (types.isEmpty())
- return "{ }"; //$NON-NLS-1$
- String result = "{ "; //$NON-NLS-1$
- for (Iterator it=types.iterator(); it.hasNext(); ){
- ITypeBinding type= (ITypeBinding)it.next();
- result += type.getQualifiedName();
- if (it.hasNext()){
- result += ", "; //$NON-NLS-1$
- } else {
- result += " }"; //$NON-NLS-1$
- }
- }
- return result;
- }
-
-
- /**
- * A JavaScriptElementLabelProvider that supports graying out of invalid types.
- */
- private class ChangeTypeLabelProvider extends BindingLabelProvider
- implements IColorProvider {
-
- private Color fGrayColor;
- private HashMap/*<Image color, Image gray>*/ fGrayImages;
-
- public ChangeTypeLabelProvider(){
- fGrayColor= Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- fGrayImages= new HashMap();
- }
-
- private Collection/*<ITypeBinding>*/ fInvalidTypes;
-
- public void grayOut(Collection/*<ITypeBinding>*/ invalidTypes){
- fInvalidTypes= invalidTypes;
- /*
- * Invalidate all labels. Invalidating only invalid types doesn't
- * work since there can be multiple nodes in the tree that
- * correspond to the same invalid IType. The TreeViewer only updates
- * the label of one of these ITypes and leaves the others in their
- * old state.
- */
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (isInvalid(element))
- return fGrayColor;
- else
- return null;
- }
-
- private boolean isInvalid(Object element) {
- if (fInvalidTypes == null)
- return false; // initially, everything is enabled
- else
- return fInvalidTypes.contains(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- public Color getBackground(Object element) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- Image image= super.getImage(element);
- if (isInvalid(element) && image != null) {
- Image grayImage= (Image) fGrayImages.get(image);
- if (grayImage == null) {
- grayImage= new Image(Display.getCurrent(), image, SWT.IMAGE_GRAY);
- fGrayImages.put(image, grayImage);
- }
- return grayImage;
- } else {
- return image;
- }
- }
-
- public void dispose() {
- for (Iterator iter= fGrayImages.values().iterator(); iter.hasNext();) {
- Image image= (Image) iter.next();
- image.dispose();
- }
- fGrayImages.clear();
- super.dispose();
- }
- }
-
- private class ChangeTypeInputPage extends UserInputWizardPage{
-
- public static final String PAGE_NAME= "ChangeTypeInputPage";//$NON-NLS-1$
- private final String MESSAGE= RefactoringMessages.ChangeTypeInputPage_Select_Type;
- private ChangeTypeLabelProvider fLabelProvider;
- private TreeViewer fTreeViewer;
- private boolean fTreeUpdated= false;
-
- public ChangeTypeInputPage() {
- super(PAGE_NAME);
- setMessage(MESSAGE);
- }
-
- private class ValidTypesTask implements Runnable {
- private Collection/*<ITypeBinding>*/ fInvalidTypes;
- private Collection/*<ITypeBinding>*/ fValidTypes;
- public void run() {
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) {
- pm.beginTask(RefactoringMessages.ChangeTypeWizard_analyzing, 1000);
- ChangeTypeRefactoring ct= (ChangeTypeRefactoring)ChangeTypeWizard.this.getRefactoring();
- fInvalidTypes = new HashSet();
- fInvalidTypes.addAll(fCT.getAllSuperTypes(ct.getOriginalType()));
- fValidTypes= ct.computeValidTypes(new SubProgressMonitor(pm, 950));
- fInvalidTypes.add(ct.getOriginalType());
- fInvalidTypes.removeAll(fValidTypes);
- pm.worked(50);
- pm.done();
- }
- };
- boolean internalError= false;
- try {
- getWizard().getContainer().run(true, true, runnable);
- } catch (InvocationTargetException e) {
- internalError= true;
- JavaScriptPlugin.log(e);
- ChangeTypeInputPage.this.setErrorMessage(RefactoringMessages.ChangeTypeWizard_internalError);
- } catch (InterruptedException e) {
- ChangeTypeInputPage.this.setMessage(RefactoringMessages.ChangeTypeWizard_computationInterrupted);
- }
-
- fLabelProvider.grayOut(fInvalidTypes);
-
- if (internalError) {
- setPageComplete(false);
- } else if (fValidTypes == null || fValidTypes.size() == 0){
- ChangeTypeInputPage.this.setErrorMessage(RefactoringMessages.ChangeTypeWizard_declCannotBeChanged);
- setPageComplete(false);
- } else {
- TreeItem selection= getInitialSelection(fValidTypes);
- fTreeViewer.getTree().setSelection(new TreeItem[]{ selection });
- setPageComplete(true);
- ChangeTypeInputPage.this.setMessage(""); //$NON-NLS-1$
- }
- }
- }
-
- private TreeItem getInitialSelection(Collection/*<ITypeBinding>*/ types) {
-
- // first, find a most general valid type (there may be more than one)
- ITypeBinding type= (ITypeBinding)types.iterator().next();
- for (Iterator it= types.iterator(); it.hasNext(); ){
- ITypeBinding other= (ITypeBinding)it.next();
- if (getGeneralizeTypeRefactoring().isSubTypeOf(type, other)){
- type= other;
- }
- }
-
- // now find a corresponding TreeItem (there may be more than one)
- return findItem(fTreeViewer.getTree().getItems(), type);
- }
-
- private TreeItem findItem(TreeItem[] items, ITypeBinding type){
- for (int i=0; i < items.length; i++){
- if (items[i].getData().equals(type)) return items[i];
- }
- for (int i=0; i < items.length; i++){
- TreeItem item= findItem(items[i].getItems(), type);
- if (item != null) return item;
- }
- return null;
- }
-
-
- public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- setControl(composite);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData());
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(Messages.format(
- RefactoringMessages.ChangeTypeWizard_pleaseChooseType,
- ((ChangeTypeRefactoring) getRefactoring()).getTarget()));
- label.setLayoutData(new GridData());
-
- addTreeComponent(composite);
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CHANGE_TYPE_WIZARD_PAGE);
- }
-
- /**
- * Tree-viewer that shows the allowable types in a tree view.
- */
- private void addTreeComponent(Composite parent) {
- fTreeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.grabExcessHorizontalSpace= true;
- gd.grabExcessVerticalSpace= true;
- GC gc= null;
- try {
- gc= new GC(parent);
- gc.setFont(gc.getFont());
- gd.heightHint= Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), 6); // 6 characters tall
- } finally {
- if (gc != null) {
- gc.dispose();
- gc= null;
- }
- }
- fTreeViewer.getTree().setLayoutData(gd);
-
- fTreeViewer.setContentProvider(new ChangeTypeContentProvider(((ChangeTypeRefactoring)getRefactoring())));
- fLabelProvider= new ChangeTypeLabelProvider();
- fTreeViewer.setLabelProvider(fLabelProvider);
- ISelectionChangedListener listener= new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection= (IStructuredSelection)event.getSelection();
- typeSelected((ITypeBinding)selection.getFirstElement());
- }
- };
- fTreeViewer.addSelectionChangedListener(listener);
- fTreeViewer.setInput(new ChangeTypeContentProvider.RootType(getGeneralizeTypeRefactoring().getOriginalType()));
- fTreeViewer.expandToLevel(10);
- }
-
- private void typeSelected(ITypeBinding type) {
- boolean isValid= getGeneralizeTypeRefactoring().getValidTypes().contains(type);
- ChangeTypeInputPage.this.setPageComplete(isValid);
- if (isValid) {
- ChangeTypeInputPage.this.setMessage(""); //$NON-NLS-1$
- } else {
- if (getGeneralizeTypeRefactoring().getOriginalType().equals(type)) {
- ChangeTypeInputPage.this.setMessage(Messages.format(
- RefactoringMessages.ChangeTypeWizard_with_itself, type.getName()));
-
- } else {
- ChangeTypeInputPage.this.setMessage(Messages.format(
- RefactoringMessages.ChangeTypeWizard_grayed_types,
- new Object[] {type.getName(), getGeneralizeTypeRefactoring().getOriginalType().getName()}));
- }
- }
- }
-
- private ChangeTypeRefactoring getGeneralizeTypeRefactoring(){
- return (ChangeTypeRefactoring)getRefactoring();
- }
- /*
- * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- initializeRefactoring();
- return super.getNextPage();
- }
-
- private ITypeBinding getSelectedType() {
- IStructuredSelection ss= (IStructuredSelection)fTreeViewer.getSelection();
- return (ITypeBinding)ss.getFirstElement();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizardPage#performFinish()
- */
- public boolean performFinish(){
- initializeRefactoring();
- return super.performFinish();
- }
-
- private void initializeRefactoring() {
- getGeneralizeTypeRefactoring().setSelectedType(getSelectedType());
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
- */
- public void dispose() {
- fTreeViewer= null;
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible && fTreeViewer != null)
- fTreeViewer.getTree().setFocus();
- if (!fTreeUpdated){
- fTreeViewer.getTree().getDisplay().asyncExec(new ValidTypesTask());
- fTreeUpdated= true;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ComboSelectionDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ComboSelectionDialog.java
deleted file mode 100644
index 447c6669..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ComboSelectionDialog.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.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;
-
-
-class ComboSelectionDialog extends Dialog{
-
- private String fSelection= null;
- private final String fShellTitle;
- private final String fLabelText;
- private final String[] fAllowedStrings;
- private final int fInitialSelectionIndex;
- public ComboSelectionDialog(Shell parentShell, String shellTitle, String labelText, String[] comboStrings, int initialSelectionIndex) {
- super(parentShell);
- Assert.isNotNull(shellTitle);
- Assert.isNotNull(labelText);
- Assert.isTrue(comboStrings.length > 0);
- Assert.isTrue(initialSelectionIndex >= 0 && initialSelectionIndex < comboStrings.length);
- fShellTitle= shellTitle;
- fLabelText= labelText;
- fAllowedStrings= comboStrings;
- fInitialSelectionIndex= initialSelectionIndex;
- }
-
- String getSelectedString(){
- return fSelection;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- getShell().setText(fShellTitle);
-
- Composite composite = (Composite)super.createDialogArea(parent);
- Composite innerComposite = new Composite(composite, SWT.NONE);
- innerComposite.setLayoutData(new GridData());
- GridLayout gl= new GridLayout();
- gl.numColumns= 2;
- innerComposite.setLayout(gl);
-
- Label label= new Label(innerComposite, SWT.NONE);
- label.setText(fLabelText);
- label.setLayoutData(new GridData());
-
- final Combo combo= new Combo(innerComposite, SWT.READ_ONLY);
- for (int i = 0; i < fAllowedStrings.length; i++) {
- combo.add(fAllowedStrings[i]);
- }
- combo.select(fInitialSelectionIndex);
- fSelection= combo.getItem(combo.getSelectionIndex());
- GridData gd= new GridData();
- gd.widthHint= convertWidthInCharsToPixels(getMaxStringLength());
- combo.setLayoutData(gd);
- combo.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- fSelection= combo.getItem(combo.getSelectionIndex());
- }
- });
- applyDialogFont(composite);
- return composite;
- }
-
- private int getMaxStringLength() {
- int max= 0;
- for (int i= 0; i < fAllowedStrings.length; i++) {
- max= Math.max(max, fAllowedStrings[i].length());
- }
- return max;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CompilationUnitChangeNode.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CompilationUnitChangeNode.java
deleted file mode 100644
index 9103bf71..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CompilationUnitChangeNode.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.ltk.core.refactoring.TextEditBasedChange;
-import org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup;
-import org.eclipse.ltk.ui.refactoring.LanguageElementNode;
-import org.eclipse.ltk.ui.refactoring.TextEditChangeNode;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class CompilationUnitChangeNode extends TextEditChangeNode {
-
- static final ChildNode[] EMPTY_CHILDREN= new ChildNode[0];
-
- private static class JavaLanguageNode extends LanguageElementNode {
-
- private IJavaScriptElement fJavaElement;
- private static JavaElementImageProvider fgImageProvider= new JavaElementImageProvider();
-
- public JavaLanguageNode(TextEditChangeNode parent, IJavaScriptElement element) {
- super(parent);
- fJavaElement= element;
- Assert.isNotNull(fJavaElement);
- }
-
- public JavaLanguageNode(ChildNode parent, IJavaScriptElement element) {
- super(parent);
- fJavaElement= element;
- Assert.isNotNull(fJavaElement);
- }
-
- public String getText() {
- return JavaScriptElementLabels.getElementLabel(fJavaElement, JavaScriptElementLabels.ALL_DEFAULT);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return fgImageProvider.getJavaImageDescriptor(
- fJavaElement,
- JavaElementImageProvider.OVERLAY_ICONS | JavaElementImageProvider.SMALL_ICONS);
- }
-
- public IRegion getTextRange() throws CoreException {
- ISourceRange range= ((ISourceReference)fJavaElement).getSourceRange();
- return new Region(range.getOffset(), range.getLength());
- }
- }
-
- public CompilationUnitChangeNode(TextEditBasedChange change) {
- super(change);
- }
-
- protected ChildNode[] createChildNodes() {
- final TextEditBasedChange change= getTextEditBasedChange();
- IJavaScriptUnit cunit= (IJavaScriptUnit) change.getAdapter(IJavaScriptUnit.class);
- if (cunit != null) {
- List children= new ArrayList(5);
- Map map= new HashMap(20);
- TextEditBasedChangeGroup[] changes= getSortedChangeGroups(change);
- for (int i= 0; i < changes.length; i++) {
- TextEditBasedChangeGroup tec= changes[i];
- try {
- IJavaScriptElement element= getModifiedJavaElement(tec, cunit);
- if (element.equals(cunit)) {
- children.add(createTextEditGroupNode(this, tec));
- } else {
- JavaLanguageNode pjce= getChangeElement(map, element, children, this);
- pjce.addChild(createTextEditGroupNode(pjce, tec));
- }
- } catch (JavaScriptModelException e) {
- children.add(createTextEditGroupNode(this, tec));
- }
- }
- return (ChildNode[]) children.toArray(new ChildNode[children.size()]);
- } else {
- return EMPTY_CHILDREN;
- }
- }
-
- private static class OffsetComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- TextEditBasedChangeGroup c1= (TextEditBasedChangeGroup)o1;
- TextEditBasedChangeGroup c2= (TextEditBasedChangeGroup)o2;
- int p1= getOffset(c1);
- int p2= getOffset(c2);
- if (p1 < p2)
- return -1;
- if (p1 > p2)
- return 1;
- // same offset
- return 0;
- }
- private int getOffset(TextEditBasedChangeGroup edit) {
- return edit.getRegion().getOffset();
- }
- }
-
- private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) {
- TextEditBasedChangeGroup[] edits= change.getChangeGroups();
- List result= new ArrayList(edits.length);
- for (int i= 0; i < edits.length; i++) {
- if (!edits[i].getTextEditGroup().isEmpty())
- result.add(edits[i]);
- }
- Comparator comparator= new OffsetComparator();
- Collections.sort(result, comparator);
- return (TextEditBasedChangeGroup[])result.toArray(new TextEditBasedChangeGroup[result.size()]);
- }
-
- private IJavaScriptElement getModifiedJavaElement(TextEditBasedChangeGroup edit, IJavaScriptUnit cunit) throws JavaScriptModelException {
- IRegion range= edit.getRegion();
- if (range.getOffset() == 0 && range.getLength() == 0)
- return cunit;
- IJavaScriptElement result= cunit.getElementAt(range.getOffset());
- if (result == null)
- return cunit;
-
- try {
- while(true) {
- ISourceReference ref= (ISourceReference)result;
- IRegion sRange= new Region(ref.getSourceRange().getOffset(), ref.getSourceRange().getLength());
- if (result.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT || result.getParent() == null || coveredBy(edit, sRange))
- break;
- result= result.getParent();
- }
- } catch(JavaScriptModelException e) {
- // Do nothing, use old value.
- } catch(ClassCastException e) {
- // Do nothing, use old value.
- }
- return result;
- }
-
- private JavaLanguageNode getChangeElement(Map map, IJavaScriptElement element, List children, TextEditChangeNode cunitChange) {
- JavaLanguageNode result= (JavaLanguageNode)map.get(element);
- if (result != null)
- return result;
- IJavaScriptElement parent= element.getParent();
- if (parent instanceof IJavaScriptUnit) {
- result= new JavaLanguageNode(cunitChange, element);
- children.add(result);
- map.put(element, result);
- } else {
- JavaLanguageNode parentChange= getChangeElement(map, parent, children, cunitChange);
- result= new JavaLanguageNode(parentChange, element);
- parentChange.addChild(result);
- map.put(element, result);
- }
- return result;
- }
-
- private boolean coveredBy(TextEditBasedChangeGroup group, IRegion sourceRegion) {
- int sLength= sourceRegion.getLength();
- if (sLength == 0)
- return false;
- int sOffset= sourceRegion.getOffset();
- int sEnd= sOffset + sLength - 1;
- TextEdit[] edits= group.getTextEdits();
- for (int i= 0; i < edits.length; i++) {
- TextEdit edit= edits[i];
- if (edit.isDeleted())
- return false;
- int rOffset= edit.getOffset();
- int rLength= edit.getLength();
- int rEnd= rOffset + rLength - 1;
- if (rLength == 0) {
- if (!(sOffset < rOffset && rOffset <= sEnd))
- return false;
- } else {
- if (!(sOffset <= rOffset && rEnd <= sEnd))
- return false;
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ConvertAnonymousToNestedWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ConvertAnonymousToNestedWizard.java
deleted file mode 100644
index 604eb35c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ConvertAnonymousToNestedWizard.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ConvertAnonymousToNestedRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-
-public class ConvertAnonymousToNestedWizard extends RefactoringWizard {
-
- public ConvertAnonymousToNestedWizard(ConvertAnonymousToNestedRefactoring ref) {
- super(ref, PREVIEW_EXPAND_FIRST_NODE | DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ConvertAnonymousToNestedAction_wizard_title);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new ConvertAnonymousToNestedInputPage());
- }
-
- private static class ConvertAnonymousToNestedInputPage extends UserInputWizardPage {
-
- private static final String DESCRIPTION = RefactoringMessages.ConvertAnonymousToNestedInputPage_description;
- public static final String PAGE_NAME= "ConvertAnonymousToNestedInputPage";//$NON-NLS-1$
-
- public ConvertAnonymousToNestedInputPage() {
- super(PAGE_NAME);
- setDescription(DESCRIPTION);
- }
-
- public void createControl(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- result.setLayout(layout);
-
- addVisibilityControl(result);
- Text textField= addFieldNameField(result);
- addDeclareFinalCheckbox(result);
- addDeclareAsStaticCheckbox(result);
-
- textField.setFocus();
- setPageComplete(false);
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CONVERT_ANONYMOUS_TO_NESTED_WIZARD_PAGE);
- }
-
- private Text addFieldNameField(Composite result) {
- Label nameLabel= new Label(result, SWT.NONE);
- nameLabel.setText(RefactoringMessages.ConvertAnonymousToNestedInputPage_class_name);
- nameLabel.setLayoutData(new GridData());
-
- final Text classNameField= new Text(result, SWT.BORDER | SWT.SINGLE);
- classNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- classNameField.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- ConvertAnonymousToNestedInputPage.this.getConvertRefactoring().setClassName(classNameField.getText());
- ConvertAnonymousToNestedInputPage.this.updateStatus();
- }
- });
- TextFieldNavigationHandler.install(classNameField);
- return classNameField;
- }
-
- private void updateStatus() {
- setPageComplete(getConvertRefactoring().validateInput());
- }
-
- private void addVisibilityControl(Composite result) {
- int[] availableVisibilities= getConvertRefactoring().getAvailableVisibilities();
- int currectVisibility= getConvertRefactoring().getVisibility();
- IVisibilityChangeListener visibilityChangeListener= new IVisibilityChangeListener(){
- public void visibilityChanged(int newVisibility) {
- getConvertRefactoring().setVisibility(newVisibility);
- }
-
- public void modifierChanged(int modifier, boolean isChecked) {
- }
- };
- Composite visibilityComposite= VisibilityControlUtil.createVisibilityControl(result, visibilityChangeListener, availableVisibilities, currectVisibility);
- if(visibilityComposite != null) {
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- visibilityComposite.setLayoutData(gd);
- }
- }
-
- public void addDeclareFinalCheckbox(Composite result) {
- GridData gd;
- final Button declareFinalCheckbox= new Button(result, SWT.CHECK);
- declareFinalCheckbox.setEnabled(getConvertRefactoring().canEnableSettingFinal());
- declareFinalCheckbox.setSelection(getConvertRefactoring().getDeclareFinal());
- declareFinalCheckbox.setText(RefactoringMessages.ConvertAnonymousToNestedInputPage_declare_final);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- declareFinalCheckbox.setLayoutData(gd);
- declareFinalCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getConvertRefactoring().setDeclareFinal(declareFinalCheckbox.getSelection());
- }
- });
- }
-
- public void addDeclareAsStaticCheckbox(Composite result) {
- GridData gd;
- final Button declareAsStaticCheckbox= new Button(result, SWT.CHECK);
- ConvertAnonymousToNestedRefactoring r= getConvertRefactoring();
- declareAsStaticCheckbox.setEnabled((!r.mustInnerClassBeStatic() && !r.isLocalInnerType()));
- declareAsStaticCheckbox.setSelection(getConvertRefactoring().getDeclareStatic());
- declareAsStaticCheckbox.setText(RefactoringMessages.ConvertAnonymousToNestedInputPage_declare_static);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- declareAsStaticCheckbox.setLayoutData(gd);
- declareAsStaticCheckbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getConvertRefactoring().setDeclareStatic(declareAsStaticCheckbox.getSelection());
- }
- });
- }
-
- private ConvertAnonymousToNestedRefactoring getConvertRefactoring(){
- return (ConvertAnonymousToNestedRefactoring)getRefactoring();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CreateTextFileChangePreviewViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CreateTextFileChangePreviewViewer.java
deleted file mode 100644
index 0aadda6b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/CreateTextFileChangePreviewViewer.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.ui.refactoring.ChangePreviewViewerInput;
-import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.changes.CreateTextFileChange;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ViewerPane;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-/**
- * Change preview viewer for <code>CreateTextFileChange</code> objects.
- */
-public final class CreateTextFileChangePreviewViewer implements IChangePreviewViewer {
-
- private static class CreateTextFilePreviewer extends ViewerPane {
-
- private ImageDescriptor fDescriptor;
-
- private Image fImage;
-
- public CreateTextFilePreviewer(Composite parent, int style) {
- super(parent, style);
- }
-
- public void setImageDescriptor(ImageDescriptor imageDescriptor) {
- fDescriptor= imageDescriptor;
- }
-
- public void setText(String text) {
- super.setText(text);
- Image current= null;
- if (fDescriptor != null) {
- current= fImage;
- fImage= fDescriptor.createImage();
- } else {
- current= fImage;
- fImage= null;
- }
- setImage(fImage);
- if (current != null) {
- current.dispose();
- }
- }
-
- }
-
- private CreateTextFilePreviewer fPane;
-
- private SourceViewer fSourceViewer;
-
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- fPane= new CreateTextFilePreviewer(parent, SWT.BORDER | SWT.FLAT);
- Dialog.applyDialogFont(fPane);
-
- fSourceViewer= new SourceViewer(fPane, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
- fSourceViewer.setEditable(false);
- fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- fPane.setContent(fSourceViewer.getControl());
- }
-
- /**
- * {@inheritDoc}
- */
- public Control getControl() {
- return fPane;
- }
-
- public void refresh() {
- fSourceViewer.refresh();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setInput(ChangePreviewViewerInput input) {
- Change change= input.getChange();
- if (change != null) {
- Object element= change.getModifiedElement();
- if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) element;
- IWorkbenchAdapter workbenchAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
- if (workbenchAdapter != null) {
- fPane.setImageDescriptor(workbenchAdapter.getImageDescriptor(element));
- } else {
- fPane.setImageDescriptor(null);
- }
- } else {
- fPane.setImageDescriptor(null);
- }
- }
- if (!(change instanceof CreateTextFileChange)) {
- fSourceViewer.setInput(null);
- fPane.setText(""); //$NON-NLS-1$
- return;
- }
- CreateTextFileChange textFileChange= (CreateTextFileChange) change;
- fPane.setText(textFileChange.getName());
- IDocument document= new Document(textFileChange.getPreview());
- // This is a temporary work around until we get the
- // source viewer registry.
- fSourceViewer.unconfigure();
- String textType= textFileChange.getTextType();
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- if ("java".equals(textType)) { //$NON-NLS-1$
- textTools.setupJavaDocumentPartitioner(document);
- fSourceViewer.configure(new JavaScriptSourceViewerConfiguration(textTools.getColorManager(), store, null, null));
- }
-// else if ("properties".equals(textType)) { //$NON-NLS-1$
-// PropertiesFileDocumentSetupParticipant.setupDocument(document);
-// fSourceViewer.configure(new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, null, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
-// }
- else {
- fSourceViewer.configure(new SourceViewerConfiguration());
- }
- fSourceViewer.setInput(document);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/DelegateUIHelper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/DelegateUIHelper.java
deleted file mode 100644
index c5e407b2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/DelegateUIHelper.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.IDelegateUpdating;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * This is a helper class to keep a consistent design between refactorings
- * capable of creating delegates.
- *
- *
- *
- */
-public class DelegateUIHelper {
-
- public static Button generateDeprecateDelegateCheckbox(Composite parent, Refactoring refactoring) {
- final IDelegateUpdating updating= (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
- if (updating == null || !updating.canEnableDelegateUpdating())
- return null;
- final Button button= createCheckbox(parent, getDeprecateDelegateCheckBoxTitle(), loadDeprecateDelegateSetting(updating));
- updating.setDeprecateDelegates(button.getSelection());
- button.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- updating.setDeprecateDelegates(button.getSelection());
- }
- });
- return button;
- }
-
- public static Button generateLeaveDelegateCheckbox(Composite parent, Refactoring refactoring, boolean plural) {
- final IDelegateUpdating updating= (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
- if (updating == null || !updating.canEnableDelegateUpdating())
- return null;
- final Button button= createCheckbox(parent, updating.getDelegateUpdatingTitle(plural), loadLeaveDelegateSetting(updating));
- updating.setDelegateUpdating(button.getSelection());
- button.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- updating.setDelegateUpdating(button.getSelection());
- }
- });
- return button;
- }
-
- public static void saveLeaveDelegateSetting(Button button) {
- saveBooleanSetting(DELEGATE_UPDATING, button);
- }
-
- public static void saveDeprecateDelegateSetting(Button button) {
- saveBooleanSetting(DELEGATE_DEPRECATION, button);
- }
-
- public static boolean loadLeaveDelegateSetting(IDelegateUpdating refactoring) {
- return getBooleanSetting(DELEGATE_UPDATING, refactoring.getDelegateUpdating());
- }
-
- public static boolean loadDeprecateDelegateSetting(IDelegateUpdating refactoring) {
- return getBooleanSetting(DELEGATE_DEPRECATION, refactoring.getDeprecateDelegates());
- }
-
- public static String getDeprecateDelegateCheckBoxTitle() {
- return RefactoringMessages.DelegateCreator_deprecate_delegates;
- }
-
- // ************** Helper methods *******************
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String DELEGATE_UPDATING= "delegateUpdating"; //$NON-NLS-1$
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String DELEGATE_DEPRECATION= "delegateDeprecation"; //$NON-NLS-1$
-
- private DelegateUIHelper() {
- // no instances
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- return checkBox;
- }
-
- private static boolean getBooleanSetting(String key, boolean defaultValue) {
- String update= JavaScriptPlugin.getDefault().getDialogSettings().get(key);
- if (update != null)
- return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
- }
-
- private static void saveBooleanSetting(String key, Button button) {
- if (button != null && !button.isDisposed() && button.getEnabled())
- JavaScriptPlugin.getDefault().getDialogSettings().put(key, button.getSelection());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractConstantWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractConstantWizard.java
deleted file mode 100644
index 02594f6b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractConstantWizard.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ExtractConstantRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.VariableNamesProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-
-public class ExtractConstantWizard extends RefactoringWizard {
-
- private static final String MESSAGE = RefactoringMessages.ExtractConstantInputPage_enter_name;
-
- public ExtractConstantWizard(ExtractConstantRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.ExtractConstantWizard_defaultPageTitle);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
-
- String message= null;
- int messageType= IMessageProvider.NONE;
- if(!getExtractConstantRefactoring().selectionAllStaticFinal()) {
- message= RefactoringMessages.ExtractConstantInputPage_selection_refers_to_nonfinal_fields;
- messageType= IMessageProvider.INFORMATION;
- } else {
- message= MESSAGE;
- messageType= IMessageProvider.NONE;
- }
-
- String[] guessedNames= getExtractConstantRefactoring().guessConstantNames();
- String initialValue= guessedNames.length == 0 ? "" : guessedNames[0]; //$NON-NLS-1$
- addPage(new ExtractConstantInputPage(message, messageType, initialValue, guessedNames));
- }
-
- private ExtractConstantRefactoring getExtractConstantRefactoring(){
- return (ExtractConstantRefactoring) getRefactoring();
- }
-
- private static class ExtractConstantInputPage extends TextInputWizardPage {
- private static final String QUALIFY_REFERENCES= "qualifyReferences"; //$NON-NLS-1$
-
- private Label fLabel;
- private final boolean fInitialValid;
- private final int fOriginalMessageType;
- private final String fOriginalMessage;
-
- private Button fQualifyReferences;
- private String[] fConstNameProposals;
-
- private VariableNamesProcessor fContentAssistProcessor;
- private String fAccessModifier;
-
- public ExtractConstantInputPage(String description, int messageType, String initialValue, String[] guessedNames) {
- super(description, true, initialValue);
- fOriginalMessage= description;
- fOriginalMessageType= messageType;
- fInitialValid= ! ("".equals(initialValue)); //$NON-NLS-1$
- fConstNameProposals= guessedNames;
- }
-
- public void createControl(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- result.setLayout(layout);
- RowLayouter layouter= new RowLayouter(2);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ExtractConstantInputPage_constant_name);
-
- Text text= createTextInputField(result);
- text.selectAll();
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- if (fConstNameProposals.length > 0) {
- fContentAssistProcessor= new VariableNamesProcessor(fConstNameProposals);
- ControlContentAssistHelper.createTextContentAssistant(text, fContentAssistProcessor);
- }
-
- layouter.perform(label, text, 1);
-
- addAccessModifierGroup(result, layouter);
- addReplaceAllCheckbox(result, layouter);
- addQualifyReferencesCheckbox(result, layouter);
- addSeparator(result, layouter);
- addLabel(result, layouter);
-
- validateTextField(text.getText());
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_CONSTANT_WIZARD_PAGE);
- }
-
- private void addAccessModifierGroup(Composite result, RowLayouter layouter) {
- fAccessModifier= getExtractConstantRefactoring().getVisibility();
- if (getExtractConstantRefactoring().getTargetIsInterface())
- return;
-
- Label label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ExtractConstantInputPage_access_modifiers);
-
- Composite group= new Composite(result, SWT.NONE);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout layout= new GridLayout();
- layout.numColumns= 4; layout.marginWidth= 0;
- group.setLayout(layout);
-
- String[] labels= new String[] {
- RefactoringMessages.ExtractMethodInputPage_public,
- RefactoringMessages.ExtractMethodInputPage_protected,
- RefactoringMessages.ExtractMethodInputPage_default,
- RefactoringMessages.ExtractMethodInputPage_private
- };
- String[] data= new String[] { JdtFlags.VISIBILITY_STRING_PUBLIC,
- JdtFlags.VISIBILITY_STRING_PROTECTED,
- JdtFlags.VISIBILITY_STRING_PACKAGE,
- JdtFlags.VISIBILITY_STRING_PRIVATE }; //
-
- updateContentAssistImage();
- for (int i= 0; i < labels.length; i++) {
- Button radio= new Button(group, SWT.RADIO);
- radio.setText(labels[i]);
- radio.setData(data[i]);
- if (data[i] == fAccessModifier)
- radio.setSelection(true);
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- setAccessModifier((String)event.widget.getData());
- }
- });
- }
- layouter.perform(label, group, 1);
- }
-
- private void updateContentAssistImage() {
- if (fContentAssistProcessor == null)
- return;
-
- int flags;
- if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PRIVATE) {
- flags= Flags.AccPrivate;
- } else if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PROTECTED) {
- flags= Flags.AccProtected;
- } else if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PUBLIC) {
- flags= Flags.AccPublic;
- } else {
- flags= Flags.AccDefault;
- }
- ImageDescriptor imageDesc= JavaElementImageProvider.getFieldImageDescriptor(false, flags);
- imageDesc= new JavaScriptElementImageDescriptor(imageDesc, JavaScriptElementImageDescriptor.STATIC | JavaScriptElementImageDescriptor.FINAL, JavaElementImageProvider.BIG_SIZE);
- fContentAssistProcessor.setProposalImageDescriptor(imageDesc);
- }
-
- private void addReplaceAllCheckbox(Composite result, RowLayouter layouter) {
- String title= RefactoringMessages.ExtractConstantInputPage_replace_all;
- boolean defaultValue= getExtractConstantRefactoring().replaceAllOccurrences();
- final Button checkBox= createCheckbox(result, title, defaultValue, layouter);
- getExtractConstantRefactoring().setReplaceAllOccurrences(checkBox.getSelection());
- checkBox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getExtractConstantRefactoring().setReplaceAllOccurrences(checkBox.getSelection());
- }
- });
- }
-
- private void addQualifyReferencesCheckbox(Composite result, RowLayouter layouter) {
- String title= RefactoringMessages.ExtractConstantInputPage_qualify_constant_references_with_class_name;
- boolean defaultValue= getBooleanSetting(QUALIFY_REFERENCES, getExtractConstantRefactoring().qualifyReferencesWithDeclaringClassName());
- fQualifyReferences= createCheckbox(result, title, defaultValue, layouter);
- getExtractConstantRefactoring().setQualifyReferencesWithDeclaringClassName(fQualifyReferences.getSelection());
- fQualifyReferences.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getExtractConstantRefactoring().setQualifyReferencesWithDeclaringClassName(fQualifyReferences.getSelection());
- }
- });
- }
-
- private void addLabel(Composite result, RowLayouter layouter) {
- fLabel= new Label(result, SWT.WRAP);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(50);
- fLabel.setLayoutData(gd);
- updatePreviewLabel();
- layouter.perform(fLabel);
- }
-
- private void addSeparator(Composite result, RowLayouter layouter) {
- Label separator= new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- layouter.perform(separator);
- }
-
- private void updatePreviewLabel(){
- try {
- if (fLabel != null)
- fLabel.setText(RefactoringMessages.ExtractConstantInputPage_signature_preview + getExtractConstantRefactoring().getConstantSignaturePreview());
- } catch(JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.ExtractTempInputPage_extract_local, RefactoringMessages.ExtractConstantInputPage_exception);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#validateTextField(String)
- */
- protected RefactoringStatus validateTextField(String text) {
- try {
- getExtractConstantRefactoring().setConstantName(text);
- updatePreviewLabel();
- RefactoringStatus result= getExtractConstantRefactoring().checkConstantNameOnChange();
- if (fOriginalMessageType == IMessageProvider.INFORMATION && result.getSeverity() == RefactoringStatus.OK)
- return RefactoringStatus.createInfoStatus(fOriginalMessage);
- else
- return result;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ExtractConstantInputPage_Internal_Error);
- }
- }
-
- private void setAccessModifier(String accessModifier) {
- getExtractConstantRefactoring().setVisibility(accessModifier);
- fAccessModifier= accessModifier;
- updateContentAssistImage();
- updatePreviewLabel();
- }
-
- private ExtractConstantRefactoring getExtractConstantRefactoring(){
- return (ExtractConstantRefactoring)getRefactoring();
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value, RowLayouter layouter){
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- layouter.perform(checkBox);
- return checkBox;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#isInitialInputValid()
- */
- protected boolean isInitialInputValid() {
- return fInitialValid;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#restoreMessage()
- */
- protected void restoreMessage() {
- setMessage(fOriginalMessage, fOriginalMessageType);
- }
-
- private boolean getBooleanSetting(String key, boolean defaultValue) {
- String update= getRefactoringSettings().get(key);
- if (update != null)
- return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
- }
-
- private void saveBooleanSetting(String key, Button checkBox) {
- if (checkBox != null)
- getRefactoringSettings().put(key, checkBox.getSelection());
- }
-
- private boolean saveSettings() {
- if (getContainer() instanceof Dialog)
- return ((Dialog)getContainer()).getReturnCode() == IDialogConstants.OK_ID;
- return true;
- }
-
- public void dispose() {
- if (saveSettings()) {
- saveBooleanSetting(QUALIFY_REFERENCES, fQualifyReferences);
- }
- super.dispose();
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractInterfaceWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractInterfaceWizard.java
deleted file mode 100644
index 0fd96659..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractInterfaceWizard.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-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.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.constraints.SuperTypeRefactoringProcessor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class ExtractInterfaceWizard extends RefactoringWizard {
-
- public ExtractInterfaceWizard(ExtractInterfaceRefactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ExtractInterfaceWizard_Extract_Interface);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new ExtractInterfaceInputPage());
- }
-
- private static class ExtractInterfaceInputPage extends TextInputWizardPage {
-
- private Button fReplaceAllCheckbox;
- private Button fDeclarePublicCheckbox;
- private Button fDeclareAbstractCheckbox;
- private Button fGenerateCommentsCheckbox;
- private Button fInstanceofCheckbox;
- private CheckboxTableViewer fTableViewer;
- private static final String DESCRIPTION = RefactoringMessages.ExtractInterfaceInputPage_description;
- private static final String SETTING_PUBLIC= "Public";//$NON-NLS-1$
- private static final String SETTING_ABSTRACT= "Abstract";//$NON-NLS-1$
- private static final String SETTING_REPLACE= "Replace"; //$NON-NLS-1$
- private static final String SETTING_COMMENTS= "Comments"; //$NON-NLS-1$
- private static final String SETTING_INSTANCEOF= "InstanceOf"; //$NON-NLS-1$
- private Button fSelectAllButton;
- private Button fDeselectAllButton;
-
- public ExtractInterfaceInputPage() {
- super(DESCRIPTION, true);
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- result.setLayout(layout);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ExtractInterfaceInputPage_Interface_name);
-
- Text text= createTextInputField(result);
- text.selectAll();
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- addReplaceAllCheckbox(result);
- addInstanceofCheckbox(result, layout.marginWidth);
- fReplaceAllCheckbox.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- fInstanceofCheckbox.setEnabled(fReplaceAllCheckbox.getSelection());
- }
- });
- addDeclareAsPublicCheckbox(result);
- addDeclareAsAbstractCheckbox(result);
-
- Label separator= new Label(result, SWT.NONE);
- GridData gd= new GridData();
- gd.horizontalSpan= 2;
- separator.setLayoutData(gd);
-
- Label tableLabel= new Label(result, SWT.NONE);
- tableLabel.setText(RefactoringMessages.ExtractInterfaceInputPage_Members);
- tableLabel.setEnabled(anyMembersToExtract());
- gd= new GridData();
- gd.horizontalSpan= 2;
- tableLabel.setLayoutData(gd);
-
- addMemberListComposite(result);
- addGenerateCommentsCheckbox(result);
- Dialog.applyDialogFont(result);
- initializeCheckboxes();
- updateUIElementEnablement();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_INTERFACE_WIZARD_PAGE);
- }
-
- private void addGenerateCommentsCheckbox(Composite result) {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- String title= RefactoringMessages.ExtractInterfaceWizard_generate_comments;
- fGenerateCommentsCheckbox= createCheckbox(result, title, false);
- processor.setComments(fGenerateCommentsCheckbox.getSelection());
- fGenerateCommentsCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- processor.setComments(fGenerateCommentsCheckbox.getSelection());
- }
- });
- }
-
- private void addInstanceofCheckbox(Composite result, int margin) {
- final SuperTypeRefactoringProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- String title= RefactoringMessages.ExtractInterfaceWizard_use_supertype;
- fInstanceofCheckbox= new Button(result, SWT.CHECK);
- fInstanceofCheckbox.setSelection(false);
- GridData gd= new GridData();
- gd.horizontalIndent= (margin + fInstanceofCheckbox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- gd.horizontalSpan= 2;
- fInstanceofCheckbox.setLayoutData(gd);
- fInstanceofCheckbox.setText(title);
- processor.setInstanceOf(fInstanceofCheckbox.getSelection());
- fInstanceofCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- processor.setInstanceOf(fInstanceofCheckbox.getSelection());
- }
- });
- }
-
- private void addMemberListComposite(Composite result) {
- Composite composite= new Composite(result, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(12);
- gd.horizontalSpan= 2;
- composite.setLayoutData(gd);
-
- fTableViewer= CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
- fTableViewer.setLabelProvider(createLabelProvider());
- fTableViewer.setContentProvider(new ArrayContentProvider());
- try {
- fTableViewer.setInput(getExtractableMembers());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.ExtractInterfaceInputPage_Extract_Interface, RefactoringMessages.ExtractInterfaceInputPage_Internal_Error);
- fTableViewer.setInput(new IMember[0]);
- }
- fTableViewer.addCheckStateListener(new ICheckStateListener(){
- public void checkStateChanged(CheckStateChangedEvent event) {
- ExtractInterfaceInputPage.this.updateUIElementEnablement();
- }
- });
- fTableViewer.setComparator(new JavaScriptElementComparator());
- fTableViewer.getControl().setEnabled(anyMembersToExtract());
-
- createButtonComposite(composite);
- }
-
- private IMember[] getExtractableMembers() throws JavaScriptModelException {
- return getExtractInterfaceRefactoring().getExtractInterfaceProcessor().getExtractableMembers();
- }
-
- protected void updateUIElementEnablement() {
- final IMember[] checked= getCheckedMembers();
- IMember[] extractable;
- try {
- extractable= getExtractableMembers();
- } catch (JavaScriptModelException exception) {
- extractable= new IMember[0];
- JavaScriptPlugin.log(exception);
- }
- final boolean enabled= containsMethods(checked);
- fDeclarePublicCheckbox.setEnabled(enabled);
- fDeclareAbstractCheckbox.setEnabled(enabled);
- fGenerateCommentsCheckbox.setEnabled(enabled);
- fInstanceofCheckbox.setEnabled(fReplaceAllCheckbox.getSelection());
- fSelectAllButton.setEnabled(checked.length < extractable.length);
- fDeselectAllButton.setEnabled(checked.length > 0);
- }
-
- private static boolean containsMethods(IMember[] members) {
- for (int i= 0; i < members.length; i++) {
- if (members[i].getElementType() == IJavaScriptElement.METHOD)
- return true;
- }
- return false;
- }
-
- private ILabelProvider createLabelProvider(){
- AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
- );
-
- return new DecoratingJavaLabelProvider(lprovider);
- }
-
- private void createButtonComposite(Composite composite) {
- GridData gd;
- Composite buttonComposite= new Composite(composite, SWT.NONE);
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- buttonComposite.setLayout(gl);
- gd= new GridData(GridData.FILL_VERTICAL);
- buttonComposite.setLayoutData(gd);
-
- fSelectAllButton= new Button(buttonComposite, SWT.PUSH);
- fSelectAllButton.setText(RefactoringMessages.ExtractInterfaceInputPage_Select_All);
- fSelectAllButton.setEnabled(anyMembersToExtract());
- fSelectAllButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fSelectAllButton);
- fSelectAllButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- fTableViewer.setAllChecked(true);
- ExtractInterfaceInputPage.this.updateUIElementEnablement();
- }
- });
-
- fDeselectAllButton= new Button(buttonComposite, SWT.PUSH);
- fDeselectAllButton.setText(RefactoringMessages.ExtractInterfaceInputPage_Deselect_All);
- fDeselectAllButton.setEnabled(anyMembersToExtract());
- fDeselectAllButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fDeselectAllButton);
- fDeselectAllButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- fTableViewer.setAllChecked(false);
- ExtractInterfaceInputPage.this.updateUIElementEnablement();
- }
- });
- }
-
- private boolean anyMembersToExtract() {
- try {
- return getExtractableMembers().length > 0;
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
-
- private void addReplaceAllCheckbox(Composite result) {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- String title= RefactoringMessages.ExtractInterfaceInputPage_change_references;
- boolean defaultValue= processor.isReplace();
- fReplaceAllCheckbox= createCheckbox(result, title, defaultValue);
- processor.setReplace(fReplaceAllCheckbox.getSelection());
- fReplaceAllCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- processor.setReplace(fReplaceAllCheckbox.getSelection());
- }
- });
- }
-
- private void addDeclareAsPublicCheckbox(Composite result) {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- String[] keys= {RefactoringMessages.ExtractInterfaceWizard_public_label};
- String title= Messages.format(RefactoringMessages.ExtractInterfaceWizard_12, keys);
- boolean defaultValue= processor.getPublic();
- fDeclarePublicCheckbox= createCheckbox(result, title, defaultValue);
- processor.setPublic(fDeclarePublicCheckbox.getSelection());
- fDeclarePublicCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- processor.setPublic(fDeclarePublicCheckbox.getSelection());
- }
- });
- }
-
- private void addDeclareAsAbstractCheckbox(Composite result) {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- String[] keys= {RefactoringMessages.ExtractInterfaceWizard_abstract_label};
- String title= Messages.format(RefactoringMessages.ExtractInterfaceWizard_12, keys);
- boolean defaultValue= processor.getAbstract();
- fDeclareAbstractCheckbox= createCheckbox(result, title, defaultValue);
- processor.setAbstract(fDeclareAbstractCheckbox.getSelection());
- fDeclareAbstractCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- processor.setAbstract(fDeclareAbstractCheckbox.getSelection());
- }
- });
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value){
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- GridData layoutData= new GridData();
- layoutData.horizontalSpan= 2;
-
- checkBox.setLayoutData(layoutData);
- return checkBox;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#validateTextField(String)
- */
- protected RefactoringStatus validateTextField(String text) {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- processor.setTypeName(text);
- return processor.checkTypeName(text);
- }
-
- private ExtractInterfaceRefactoring getExtractInterfaceRefactoring() {
- return (ExtractInterfaceRefactoring) getRefactoring();
- }
-
- /*
- * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- try {
- initializeRefactoring();
- storeDialogSettings();
- return super.getNextPage();
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return null;
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizardPage#performFinish()
- */
- public boolean performFinish(){
- try {
- initializeRefactoring();
- storeDialogSettings();
- return super.performFinish();
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return false;
- }
- }
-
- private void initializeRefactoring() throws JavaScriptModelException {
- final ExtractInterfaceProcessor processor= getExtractInterfaceRefactoring().getExtractInterfaceProcessor();
- processor.setTypeName(getText());
- processor.setReplace(fReplaceAllCheckbox.getSelection());
- processor.setExtractedMembers(getCheckedMembers());
- processor.setAbstract(fDeclareAbstractCheckbox.getSelection());
- processor.setPublic(fDeclarePublicCheckbox.getSelection());
- processor.setComments(fGenerateCommentsCheckbox.getSelection());
- processor.setInstanceOf(fInstanceofCheckbox.getSelection());
- }
-
- private IMember[] getCheckedMembers() {
- List checked= Arrays.asList(fTableViewer.getCheckedElements());
- return (IMember[]) checked.toArray(new IMember[checked.size()]);
- }
-
- public void dispose() {
- fInstanceofCheckbox= null;
- fGenerateCommentsCheckbox= null;
- fReplaceAllCheckbox= null;
- fTableViewer= null;
- super.dispose();
- }
-
- private void initializeCheckboxes() {
- initializeCheckBox(fDeclarePublicCheckbox, SETTING_PUBLIC, true);
- initializeCheckBox(fDeclareAbstractCheckbox, SETTING_ABSTRACT, true);
- initializeCheckBox(fReplaceAllCheckbox, SETTING_REPLACE, true);
- initializeCheckBox(fGenerateCommentsCheckbox, SETTING_COMMENTS, true);
- initializeCheckBox(fInstanceofCheckbox, SETTING_INSTANCEOF, false);
- }
-
- private void initializeCheckBox(Button checkbox, String property, boolean def) {
- String s= JavaScriptPlugin.getDefault().getDialogSettings().get(property);
- if (s != null)
- checkbox.setSelection(new Boolean(s).booleanValue());
- else
- checkbox.setSelection(def);
- }
-
- private void storeDialogSettings() {
- final IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- settings.put(SETTING_PUBLIC, fDeclarePublicCheckbox.getSelection());
- settings.put(SETTING_ABSTRACT, fDeclareAbstractCheckbox.getSelection());
- settings.put(SETTING_REPLACE, fReplaceAllCheckbox.getSelection());
- settings.put(SETTING_COMMENTS, fGenerateCommentsCheckbox.getSelection());
- settings.put(SETTING_INSTANCEOF, fInstanceofCheckbox.getSelection());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMemberPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMemberPage.java
deleted file mode 100644
index d6fafa40..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMemberPage.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-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.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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractSupertypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractSupertypeRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Wizard page for the extract supertype refactoring, which, apart from pull up
- * facilities, also allows to specify the types where to extract the supertype.
- *
- *
- */
-public final class ExtractSupertypeMemberPage extends PullUpMemberPage {
-
- /** Dialog to select supertypes */
- private static class SupertypeSelectionDialog extends SelectionDialog {
-
- /** The table viewer */
- private TableViewer fViewer;
-
- /**
- * Creates a new supertype selection dialog.
- *
- * @param shell
- * the parent shell
- */
- public SupertypeSelectionDialog(final Shell shell) {
- super(shell);
- }
-
- /**
- * {@inheritDoc}
- */
- public void create() {
- setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
- super.create();
- getShell().setText(RefactoringMessages.ExtractSupertypeMemberPage_choose_type_caption);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Control createDialogArea(final Composite composite) {
- Assert.isNotNull(composite);
- setMessage(RefactoringMessages.ExtractSupertypeMemberPage_choose_type_message);
- final Composite control= (Composite) super.createDialogArea(composite);
- createMessageArea(control);
- fViewer= new TableViewer(control, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- fViewer.setLabelProvider(createLabelProvider());
- fViewer.setContentProvider(new ArrayContentProvider());
- fViewer.setComparator(new SupertypeSelectionViewerSorter());
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- setSelectionResult(((IStructuredSelection) fViewer.getSelection()).toArray());
- }
- });
- fViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(final DoubleClickEvent event) {
- setSelectionResult(((IStructuredSelection) fViewer.getSelection()).toArray());
- close();
- }
- });
- final GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= convertHeightInCharsToPixels(15);
- data.widthHint= convertWidthInCharsToPixels(55);
- fViewer.getTable().setLayoutData(data);
- applyDialogFont(control);
- return control;
- }
-
- /**
- * Sets the input of this dialog.
- *
- * @param object
- * the input
- */
- public void setInput(final Object object) {
- fViewer.setInput(object);
- }
- }
-
- /** The label provider */
- private static class SupertypeSelectionLabelProvider extends AppearanceAwareLabelProvider implements ITableLabelProvider {
-
- /**
- * Creates a new supertype selection label provider.
- *
- * @param textFlags
- * the text flags
- * @param imageFlags
- * the image flags
- */
- public SupertypeSelectionLabelProvider(final long textFlags, final int imageFlags) {
- super(textFlags, imageFlags);
- }
-
- /**
- * {@inheritDoc}
- */
- public Image getColumnImage(final Object element, final int index) {
- return getImage(element);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getColumnText(final Object element, final int index) {
- return getText(element);
- }
- }
-
- /** The viewer sorter */
- private static class SupertypeSelectionViewerSorter extends ViewerComparator {
-
- /**
- * {@inheritDoc}
- */
- public int compare(final Viewer viewer, final Object first, final Object second) {
- final IType predecessor= (IType) first;
- final IType successor= (IType) second;
- return getComparator().compare(predecessor.getElementName(), successor.getElementName());
- }
- }
-
- /**
- * Creates a label provider for a type list.
- *
- * @return a label provider
- */
- private static ILabelProvider createLabelProvider() {
- return new SupertypeSelectionLabelProvider(JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.T_POST_QUALIFIED, JavaElementImageProvider.OVERLAY_ICONS);
- }
-
- /** The supertype name field */
- private Text fNameField;
-
- /** The table viewer */
- private TableViewer fTableViewer;
-
- /** The types to extract */
- private final Set fTypesToExtract= new HashSet(2);
-
- /**
- * Creates a new extract supertype member page.
- *
- * @param name
- * the page name
- * @param page
- * the method page
- */
- public ExtractSupertypeMemberPage(final String name, final ExtractSupertypeMethodPage page) {
- super(name, page);
- setDescription(RefactoringMessages.ExtractSupertypeMemberPage_page_title);
- METHOD_LABELS[PULL_UP_ACTION]= RefactoringMessages.ExtractSupertypeMemberPage_extract;
- METHOD_LABELS[DECLARE_ABSTRACT_ACTION]= RefactoringMessages.ExtractSupertypeMemberPage_declare_abstract;
- TYPE_LABELS[PULL_UP_ACTION]= RefactoringMessages.ExtractSupertypeMemberPage_extract;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void checkPageCompletionStatus(final boolean display) {
- final RefactoringStatus status= getProcessor().checkExtractedCompilationUnit();
- setMessage(null);
- if (display)
- setPageComplete(status);
- else
- setPageComplete(!status.hasFatalError());
- fSuccessorPage.fireSettingsChanged();
- }
-
- /**
- * Computes the candidate types.
- *
- * @throws InterruptedException
- * if the computation has been interrupted
- */
- protected void computeCandidateTypes() throws InterruptedException {
- if (fCandidateTypes != null && fCandidateTypes.length > 0)
- return;
- try {
- getWizard().getContainer().run(true, true, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor monitor) throws InvocationTargetException {
- try {
- fCandidateTypes= getProcessor().getCandidateTypes(new RefactoringStatus(), monitor);
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException exception) {
- ExceptionHandler.handle(exception, getShell(), RefactoringMessages.ExtractSupertypeMemberPage_extract_supertype, RefactoringMessages.PullUpInputPage_exception);
- } catch (InterruptedException exception) {
- fCandidateTypes= new IType[0];
- throw new InterruptedException();
- } catch (OperationCanceledException exception) {
- fCandidateTypes= new IType[0];
- }
- }
-
- /**
- * Creates the button composite.
- *
- * @param parent
- * the parent control
- */
- protected void createButtonComposite(final Composite parent) {
- final Composite buttons= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- buttons.setLayout(layout);
- buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL));
-
- final Button addButton= new Button(buttons, SWT.PUSH);
- addButton.setText(RefactoringMessages.ExtractSupertypeMemberPage_add_button_label);
- addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(addButton);
- addButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- try {
- computeCandidateTypes();
- } catch (InterruptedException exception) {
- return;
- }
- final LinkedList list= new LinkedList(Arrays.asList(fCandidateTypes));
- for (final Iterator outer= list.iterator(); outer.hasNext();) {
- final IType first= (IType) outer.next();
- for (final Iterator inner= fTypesToExtract.iterator(); inner.hasNext();) {
- final IType second= (IType) inner.next();
- if (second.getFullyQualifiedName().equals(first.getFullyQualifiedName()))
- outer.remove();
- }
- }
- final SupertypeSelectionDialog dialog= new SupertypeSelectionDialog(getShell());
- dialog.create();
- dialog.setInput(list.toArray());
- final int result= dialog.open();
- if (result == Window.OK) {
- final Object[] objects= dialog.getResult();
- if (objects != null && objects.length > 0) {
- for (int index= 0; index < objects.length; index++) {
- fTypesToExtract.add(objects[index]);
- }
- fTableViewer.setInput(fTypesToExtract.toArray());
- handleTypesChanged();
- }
- }
- }
- });
-
- final Button removeButton= new Button(buttons, SWT.PUSH);
- removeButton.setText(RefactoringMessages.ExtractSupertypeMemberPage_remove_button_label);
- removeButton.setEnabled(fCandidateTypes.length > 0 && !fTableViewer.getSelection().isEmpty());
- removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(removeButton);
- removeButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- final IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
- if (!selection.isEmpty()) {
- final IType declaring= getDeclaringType();
- for (final Iterator iterator= selection.iterator(); iterator.hasNext();) {
- final Object element= iterator.next();
- if (!declaring.equals(element))
- fTypesToExtract.remove(element);
- }
- fTableViewer.setInput(fTypesToExtract.toArray());
- handleTypesChanged();
- }
- }
- });
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- final IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
- if (selection.isEmpty()) {
- removeButton.setEnabled(false);
- return;
- } else {
- final Object[] elements= selection.toArray();
- if (elements.length == 1 && elements[0].equals(getDeclaringType())) {
- removeButton.setEnabled(false);
- return;
- }
- }
- removeButton.setEnabled(true);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public void createControl(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
- createSuperTypeField(composite);
- createSpacer(composite);
- createSuperTypeCheckbox(composite);
- createInstanceOfCheckbox(composite, layout.marginWidth);
- createStubCheckbox(composite);
- createSuperTypeControl(composite);
- createSpacer(composite);
- createMemberTableLabel(composite);
- createMemberTableComposite(composite);
- createStatusLine(composite);
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- initializeEnablement();
- initializeCheckboxes();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_SUPERTYPE_WIZARD_PAGE);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void createSuperTypeControl(final Composite parent) {
- try {
- createSuperTypeList(parent);
- } catch (JavaScriptModelException exception) {
- ExceptionHandler.handle(exception, getShell(), RefactoringMessages.ExtractSupertypeMemberPage_extract_supertype, RefactoringMessages.PullUpInputPage_exception);
- }
- }
-
- /**
- * Creates the super type field.
- *
- * @param parent
- * the parent control
- */
- protected void createSuperTypeField(final Composite parent) {
- final Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.ExtractSupertypeMemberPage_name_label);
- label.setLayoutData(new GridData());
-
- fNameField= new Text(parent, SWT.BORDER);
- fNameField.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- handleNameChanged(fNameField.getText());
- }
- });
- fNameField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- TextFieldNavigationHandler.install(fNameField);
- }
-
- /**
- * Creates the super type list.
- *
- * @param parent
- * the parent control
- */
- protected void createSuperTypeList(final Composite parent) throws JavaScriptModelException {
- createSpacer(parent);
-
- final Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.ExtractSupertypeMemberPage_types_list_caption);
- GridData data= new GridData();
- data.horizontalSpan= 2;
- label.setLayoutData(data);
-
- final Composite composite= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
- data= new GridData(GridData.FILL_BOTH);
- data.horizontalSpan= 2;
- composite.setLayoutData(data);
-
- fTableViewer= new TableViewer(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- data= new GridData(GridData.FILL_BOTH);
- data.heightHint= SWTUtil.getTableHeightHint(fTableViewer.getTable(), 3);
- fTableViewer.getTable().setLayoutData(data);
- fTableViewer.setLabelProvider(createLabelProvider());
- fTableViewer.setContentProvider(new ArrayContentProvider());
- fTableViewer.setComparator(new JavaScriptElementComparator());
- fTypesToExtract.add(getDeclaringType());
- fTableViewer.setInput(fTypesToExtract.toArray());
-
- createButtonComposite(composite);
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getCreateStubsButtonLabel() {
- return RefactoringMessages.ExtractSupertypeMemberPage_create_stubs_label;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getDeclareAbstractActionLabel() {
- return RefactoringMessages.ExtractSupertypeMemberPage_declare_abstract;
- }
-
- /**
- * Returns the declaring type.
- *
- * @return the declaring type
- */
- public IType getDeclaringType() {
- return getProcessor().getDeclaringType();
- }
-
- /**
- * {@inheritDoc}
- */
- public IType getDestinationType() {
- return getProcessor().computeExtractedType(fNameField.getText());
- }
-
- /**
- * Returns the extract supertype refactoring.
- */
- public ExtractSupertypeRefactoring getExtractSuperTypeRefactoring() {
- return (ExtractSupertypeRefactoring) getRefactoring();
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getInstanceofButtonLabel() {
- return RefactoringMessages.ExtractSupertypeMemberPage_use_supertype_label;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getNoMembersMessage() {
- return RefactoringMessages.ExtractSupertypeMemberPage_no_members_selected;
- }
-
- /**
- * Returns the refactoring processor.
- *
- * @return the refactoring processor
- */
- protected ExtractSupertypeProcessor getProcessor() {
- return getExtractSuperTypeRefactoring().getExtractSupertypeProcessor();
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getPullUpActionLabel() {
- return RefactoringMessages.ExtractSupertypeMemberPage_extract;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getReplaceButtonLabel() {
- return RefactoringMessages.ExtractSupertypeMemberPage_use_instanceof_label;
- }
-
- /**
- * {@inheritDoc}
- */
- protected int getTableRowCount() {
- return 6;
- }
-
- /**
- * Handles the name changed event.
- *
- * @param name
- * the name
- */
- protected void handleNameChanged(final String name) {
- if (name != null)
- getProcessor().setTypeName(name);
- checkPageCompletionStatus(true);
- }
-
- /**
- * Handles the types changed event.
- */
- protected void handleTypesChanged() {
- getProcessor().setTypesToExtract((IType[]) fTypesToExtract.toArray(new IType[fTypesToExtract.size()]));
- }
-
- /**
- * {@inheritDoc}
- */
- public void setVisible(final boolean visible) {
- super.setVisible(visible);
- if (visible) {
- fNameField.setFocus();
- getProcessor().resetChanges();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMethodPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMethodPage.java
deleted file mode 100644
index 0f8f564b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeMethodPage.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractSupertypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ExtractSupertypeRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Wizard page to select methods to be deleted after extract supertype.
- *
- *
- */
-public class ExtractSupertypeMethodPage extends PullUpMethodPage {
-
- /**
- * Returns the extract supertype refactoring.
- */
- public ExtractSupertypeRefactoring getExtractSuperTypeRefactoring() {
- return (ExtractSupertypeRefactoring) getRefactoring();
- }
-
- /**
- * Returns the refactoring processor.
- *
- * @return the refactoring processor
- */
- protected ExtractSupertypeProcessor getProcessor() {
- return getExtractSuperTypeRefactoring().getExtractSupertypeProcessor();
- }
-
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_SUPERTYPE_WIZARD_PAGE);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setVisible(final boolean visible) {
- if (visible) {
- final ExtractSupertypeProcessor processor= getProcessor();
- processor.resetChanges();
- try {
- getWizard().getContainer().run(false, false, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- processor.createWorkingCopyLayer(monitor);
- }
- });
- } catch (InvocationTargetException exception) {
- JavaScriptPlugin.log(exception);
- } catch (InterruptedException exception) {
- // Does not happen
- }
- }
- super.setVisible(visible);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeWizard.java
deleted file mode 100644
index 6485a654..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractSupertypeWizard.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Refactoring wizard for the extract supertype refactoring.
- *
- *
- */
-public final class ExtractSupertypeWizard extends RefactoringWizard {
-
- /** The page name */
- private static final String PAGE_NAME= "ExtractSupertypeMemberPage"; //$NON-NLS-1$
-
- /**
- * Creates a new extract supertype wizard.
- *
- * @param refactoring
- * the refactoring
- */
- public ExtractSupertypeWizard(final Refactoring refactoring) {
- super(refactoring, WIZARD_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ExtractSupertypeWizard_defaultPageTitle);
- setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_REFACTOR_EXTRACT_SUPERTYPE);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void addUserInputPages() {
- final ExtractSupertypeMethodPage page= new ExtractSupertypeMethodPage();
- addPage(new ExtractSupertypeMemberPage(PAGE_NAME, page));
- addPage(page);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractTempWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractTempWizard.java
deleted file mode 100644
index fff3a2bb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ExtractTempWizard.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ExtractTempRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.VariableNamesProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-
-public class ExtractTempWizard extends RefactoringWizard {
-
- /* package */ static final String DIALOG_SETTING_SECTION= "ExtractTempWizard"; //$NON-NLS-1$
-
- public ExtractTempWizard(ExtractTempRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.ExtractTempWizard_defaultPageTitle);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new ExtractTempInputPage(getExtractTempRefactoring().guessTempNames()));
- }
-
- private ExtractTempRefactoring getExtractTempRefactoring(){
- return (ExtractTempRefactoring)getRefactoring();
- }
-
- private static class ExtractTempInputPage extends TextInputWizardPage {
-
- private static final String DECLARE_FINAL= "declareFinal"; //$NON-NLS-1$
- private static final String REPLACE_ALL= "replaceOccurrences"; //$NON-NLS-1$
-
- private final boolean fInitialValid;
- private static final String DESCRIPTION = RefactoringMessages.ExtractTempInputPage_enter_name;
- private String[] fTempNameProposals;
- private IDialogSettings fSettings;
-
- public ExtractTempInputPage(String[] tempNameProposals) {
- super(DESCRIPTION, true, tempNameProposals.length == 0 ? "" : tempNameProposals[0]); //$NON-NLS-1$
- Assert.isNotNull(tempNameProposals);
- fTempNameProposals= tempNameProposals;
- fInitialValid= tempNameProposals.length > 0;
- }
-
- public void createControl(Composite parent) {
- loadSettings();
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- result.setLayout(layout);
- RowLayouter layouter= new RowLayouter(2);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ExtractTempInputPage_variable_name);
-
- Text text= createTextInputField(result);
- text.selectAll();
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- ControlContentAssistHelper.createTextContentAssistant(text, new VariableNamesProcessor(fTempNameProposals));
-
- layouter.perform(label, text, 1);
-
- addReplaceAllCheckbox(result, layouter);
- addDeclareFinalCheckbox(result, layouter);
-
- validateTextField(text.getText());
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_TEMP_WIZARD_PAGE);
- }
-
- private void loadSettings() {
- fSettings= getDialogSettings().getSection(ExtractTempWizard.DIALOG_SETTING_SECTION);
- if (fSettings == null) {
- fSettings= getDialogSettings().addNewSection(ExtractTempWizard.DIALOG_SETTING_SECTION);
- fSettings.put(DECLARE_FINAL, false);
- fSettings.put(REPLACE_ALL, true);
- }
- getExtractTempRefactoring().setDeclareFinal(fSettings.getBoolean(DECLARE_FINAL));
- getExtractTempRefactoring().setReplaceAllOccurrences(fSettings.getBoolean(REPLACE_ALL));
- }
-
- private void addReplaceAllCheckbox(Composite result, RowLayouter layouter) {
- String title= RefactoringMessages.ExtractTempInputPage_replace_all;
- boolean defaultValue= getExtractTempRefactoring().replaceAllOccurrences();
- final Button checkBox= createCheckbox(result, title, defaultValue, layouter);
- getExtractTempRefactoring().setReplaceAllOccurrences(checkBox.getSelection());
- checkBox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- fSettings.put(REPLACE_ALL, checkBox.getSelection());
- getExtractTempRefactoring().setReplaceAllOccurrences(checkBox.getSelection());
- }
- });
- }
-
- private void addDeclareFinalCheckbox(Composite result, RowLayouter layouter) {
- String title= RefactoringMessages.ExtractTempInputPage_declare_final;
- boolean defaultValue= getExtractTempRefactoring().declareFinal();
- final Button checkBox= createCheckbox(result, title, defaultValue, layouter);
- getExtractTempRefactoring().setDeclareFinal(checkBox.getSelection());
- checkBox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- fSettings.put(DECLARE_FINAL, checkBox.getSelection());
- getExtractTempRefactoring().setDeclareFinal(checkBox.getSelection());
- }
- });
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#textModified(java.lang.String)
- */
- protected void textModified(String text) {
- getExtractTempRefactoring().setTempName(text);
- super.textModified(text);
- }
-
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#validateTextField(String)
- */
- protected RefactoringStatus validateTextField(String text) {
- return getExtractTempRefactoring().checkTempName(text);
- }
-
- private ExtractTempRefactoring getExtractTempRefactoring(){
- return (ExtractTempRefactoring)getRefactoring();
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value, RowLayouter layouter){
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- layouter.perform(checkBox);
- return checkBox;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#isInitialInputValid()
- */
- protected boolean isInitialInputValid() {
- return fInitialValid;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IExceptionListChangeListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IExceptionListChangeListener.java
deleted file mode 100644
index 26367053..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IExceptionListChangeListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-
-public interface IExceptionListChangeListener {
-
- /**
- * Gets fired if the exception list got modified by adding or removing exceptions
- */
- public void exceptionListChanged();
-
-
-// /**
-// * Gets fired when the given parameter has changed
-// * @param parameter the parameter that has changed.
-// */
-// public void exceptionChanged(ExceptionInfo exception);
-//
-// /**
-// * Gets fired when the given exception has been added
-// * @param exception the exception that has been added.
-// */
-// public void exceptionAdded(ExceptionInfo exception);
-//
-//
-// /**
-// * Gets fired if the exception list got modified by reordering or removing
-// * exceptions (note that adding is handled by <code>exceptionAdded</code>))
-// */
-// public void exceptionListChanged();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IParameterListChangeListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IParameterListChangeListener.java
deleted file mode 100644
index 2b9fd878..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IParameterListChangeListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-
-public interface IParameterListChangeListener {
-
- /**
- * Gets fired when the given parameter has changed
- * @param parameter the parameter that has changed.
- */
- public void parameterChanged(ParameterInfo parameter);
-
- /**
- * Gets fired when the given parameter has been added
- * @param parameter the parameter that has been added.
- */
- public void parameterAdded(ParameterInfo parameter);
-
-
- /**
- * Gets fired if the parameter list got modified by reordering or removing
- * parameters (note that adding is handled by <code>parameterAdded</code>))
- */
- public void parameterListChanged();
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IScheduledRefactoring.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IScheduledRefactoring.java
deleted file mode 100644
index c6acaeeb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IScheduledRefactoring.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-public interface IScheduledRefactoring {
-
- /**
- * The scheduling rule used to perform the
- * refactoring.
- *
- * @return {@link ISchedulingRule} not null
- */
- public ISchedulingRule getSchedulingRule();
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IVisibilityChangeListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IVisibilityChangeListener.java
deleted file mode 100644
index 7f0ec5f8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IVisibilityChangeListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-public interface IVisibilityChangeListener{
- void visibilityChanged(int newVisibility);
- void modifierChanged(int modifier, boolean isChecked);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InferTypeArgumentsWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InferTypeArgumentsWizard.java
deleted file mode 100644
index 9aed7b35..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InferTypeArgumentsWizard.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public class InferTypeArgumentsWizard extends RefactoringWizard {
-
- public InferTypeArgumentsWizard(Refactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.InferTypeArgumentsWizard_defaultPageTitle);
- }
-
- /*
- * @see org.eclipse.ltk.ui.refactoring.RefactoringWizard#addUserInputPages()
- */
- protected void addUserInputPages() {
- addPage(new InferTypeArgumentsInputPage());
- }
-
- private static class InferTypeArgumentsInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "InferTypeArgumentsInputPage"; //$NON-NLS-1$
-
- private static final String DESCRIPTION= RefactoringMessages.InferTypeArgumentsInputPage_description;
-
- private static final String DIALOG_SETTING_SECTION= "InferTypeArguments"; //$NON-NLS-1$
- private static final String ASSUME_CLONE_RETURNS_SAME_TYPE= "assumeCloneReturnsSameType"; //$NON-NLS-1$
- private static final String LEAVE_UNCONSTRAINED_RAW= "leaveUnconstrainedRaw"; //$NON-NLS-1$
-
- IDialogSettings fSettings;
-
- private InferTypeArgumentsRefactoring fRefactoring;
-
-
- public InferTypeArgumentsInputPage() {
- super(PAGE_NAME);
- setDescription(DESCRIPTION);
- }
-
- public void createControl(Composite parent) {
- fRefactoring= (InferTypeArgumentsRefactoring) getRefactoring();
- loadSettings();
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- result.setLayout(layout);
-
- Label doit= new Label(result, SWT.WRAP);
- doit.setText(RefactoringMessages.InferTypeArgumentsWizard_lengthyDescription);
- doit.setLayoutData(new GridData());
-
- Label separator= new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- Button cloneCheckBox= new Button(result, SWT.CHECK);
- cloneCheckBox.setText(RefactoringMessages.InferTypeArgumentsWizard_assumeCloneSameType);
- boolean assumeCloneValue= fSettings.getBoolean(ASSUME_CLONE_RETURNS_SAME_TYPE);
- fRefactoring.setAssumeCloneReturnsSameType(assumeCloneValue);
- cloneCheckBox.setSelection(assumeCloneValue);
- cloneCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setAssumeCloseReturnsSameType(((Button)e.widget).getSelection());
- }
- });
-
- Button leaveRawCheckBox= new Button(result, SWT.CHECK);
- leaveRawCheckBox.setText(RefactoringMessages.InferTypeArgumentsWizard_leaveUnconstrainedRaw);
- boolean leaveRawValue= fSettings.getBoolean(LEAVE_UNCONSTRAINED_RAW);
- fRefactoring.setLeaveUnconstrainedRaw(leaveRawValue);
- leaveRawCheckBox.setSelection(leaveRawValue);
- leaveRawCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setLeaveUnconstrainedRaw(((Button)e.widget).getSelection());
- }
- });
-
- updateStatus();
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INFER_TYPE_ARGUMENTS_WIZARD_PAGE);
- }
-
- private void setAssumeCloseReturnsSameType(boolean selection) {
- fSettings.put(ASSUME_CLONE_RETURNS_SAME_TYPE, selection);
- fRefactoring.setAssumeCloneReturnsSameType(selection);
- }
-
- private void setLeaveUnconstrainedRaw(boolean selection) {
- fSettings.put(LEAVE_UNCONSTRAINED_RAW, selection);
- fRefactoring.setLeaveUnconstrainedRaw(selection);
- }
-
- private void updateStatus() {
- setPageComplete(true);
- }
-
- private void loadSettings() {
- fSettings= getDialogSettings().getSection(DIALOG_SETTING_SECTION);
- if (fSettings == null) {
- fSettings= getDialogSettings().addNewSection(DIALOG_SETTING_SECTION);
- fSettings.put(ASSUME_CLONE_RETURNS_SAME_TYPE, true);
- fSettings.put(LEAVE_UNCONSTRAINED_RAW, true);
- }
- fRefactoring.setAssumeCloneReturnsSameType(fSettings.getBoolean(ASSUME_CLONE_RETURNS_SAME_TYPE));
- fRefactoring.setLeaveUnconstrainedRaw(fSettings.getBoolean(LEAVE_UNCONSTRAINED_RAW));
- }
-
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineConstantWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineConstantWizard.java
deleted file mode 100644
index 83e6ddf2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineConstantWizard.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.InlineConstantRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public class InlineConstantWizard extends RefactoringWizard {
-
- private static final String MESSAGE = RefactoringMessages.InlineConstantWizard_message;
-
- public InlineConstantWizard(InlineConstantRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.InlineConstantWizard_Inline_Constant);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
-
- String message= null;
- int messageType= IMessageProvider.NONE;
- if(!getInlineConstantRefactoring().isInitializerAllStaticFinal()) {
- message= RefactoringMessages.InlineConstantWizard_initializer_refers_to_fields;
- messageType= IMessageProvider.INFORMATION;
- } else {
- message= MESSAGE;
- messageType= IMessageProvider.NONE;
- }
-
- addPage(new InlineConstantInputPage(message, messageType));
- }
-
- private InlineConstantRefactoring getInlineConstantRefactoring(){
- return (InlineConstantRefactoring)getRefactoring();
- }
-
- private static class InlineConstantInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "InlineConstantInputPage";//$NON-NLS-1$
-
- private InlineConstantRefactoring fRefactoring;
- private Group fInlineMode;
- private Button fRemove;
-
- private final int fOriginalMessageType;
- private final String fOriginalMessage;
-
- public InlineConstantInputPage(String description, int messageType) {
- super(PAGE_NAME);
- fOriginalMessage= description;
- fOriginalMessageType= messageType;
- setDescription(description);
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- fRefactoring= (InlineConstantRefactoring)getRefactoring();
- fRefactoring.setReplaceAllReferences(fRefactoring.isDeclarationSelected());
- fRefactoring.setRemoveDeclaration(true);
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
- GridData gd= null;
-
- fInlineMode= new Group(result, SWT.NONE);
- fInlineMode.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fInlineMode.setLayout(new GridLayout());
- fInlineMode.setText(RefactoringMessages.InlineConstantInputPage_Inline);
-
- final Button all= new Button(fInlineMode, SWT.RADIO);
- all.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- all.setText(RefactoringMessages.InlineConstantInputPage_All_references);
- all.setSelection(fRefactoring.getReplaceAllReferences());
- all.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRefactoring.setReplaceAllReferences(true);
- fRemove.setEnabled(true);
- }
- });
-
- fRemove= new Button(fInlineMode, SWT.CHECK);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent= convertWidthInCharsToPixels(3);
- fRemove.setLayoutData(gd);
- fRemove.setText(RefactoringMessages.InlineConstantInputPage_Delete_constant);
- fRemove.setEnabled(all.getSelection());
- fRemove.setSelection(fRefactoring.getRemoveDeclaration());
- fRemove.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setRemoveDeclaration(fRemove.getSelection());
- }
- });
-
-
- final Button onlySelected= new Button(fInlineMode, SWT.RADIO);
- onlySelected.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- onlySelected.setText(RefactoringMessages.InlineConstantInputPage_Only_selected);
- onlySelected.setSelection(!fRefactoring.getReplaceAllReferences());
- onlySelected.setEnabled(!fRefactoring.isDeclarationSelected());
- onlySelected.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRefactoring.setReplaceAllReferences(false);
- fRemove.setEnabled(false);
- }
- });
- Dialog.applyDialogFont(result);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INLINE_CONSTANT_WIZARD_PAGE);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#restoreMessage()
- */
- protected void restoreMessage() {
- setMessage(fOriginalMessage, fOriginalMessageType);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineTempWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineTempWizard.java
deleted file mode 100644
index c829cd5a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/InlineTempWizard.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.InlineTempRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public class InlineTempWizard extends RefactoringWizard {
-
- public InlineTempWizard(InlineTempRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
- setDefaultPageTitle(RefactoringMessages.InlineTempWizard_defaultPageTitle);
- }
-
- protected void addUserInputPages() {
- addPage(new InlineTempInputPage());
- }
-
- public int getMessageLineWidthInChars() {
- return 0;
- }
-
- private static class InlineTempInputPage extends MessageWizardPage {
-
- public static final String PAGE_NAME= "InlineTempInputPage"; //$NON-NLS-1$
-
- public InlineTempInputPage() {
- super(PAGE_NAME, true, MessageWizardPage.STYLE_QUESTION);
- }
-
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INLINE_TEMP_WIZARD_PAGE);
- }
-
- protected String getMessageString() {
- InlineTempRefactoring refactoring= (InlineTempRefactoring) getRefactoring();
- int occurrences= refactoring.getReferences().length;
- final String identifier= refactoring.getVariableDeclaration().getName().getIdentifier();
- switch (occurrences) {
- case 0:
- return Messages.format(
- RefactoringMessages.InlineTempInputPage_message_zero,
- identifier);
-
- case 1:
- return Messages.format(RefactoringMessages.InlineTempInputPage_message_one, identifier);
-
- default:
- return Messages.format(RefactoringMessages.InlineTempInputPage_message_multi, new Object[] {
- new Integer(occurrences), identifier });
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryInputPage.java
deleted file mode 100644
index 20624b1e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryInputPage.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.IntroduceFactoryRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-/**
- * @author rfuhrer
- */
-public class IntroduceFactoryInputPage extends UserInputWizardPage {
- /**
- * The name of the factory method to be created.
- */
- private Text fMethodName;
-
- private RefactoringStatus fMethodNameStatus;
- private RefactoringStatus fDestinationStatus;
-
- /**
- * Constructor for IntroduceFactoryInputPage.
- * @param name the name of the page
- */
- public IntroduceFactoryInputPage(String name) {
- super(name);
- }
-
- private Text createTextInputField(Composite result) {
- final Text textField = new Text(result, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
- textField.selectAll();
- TextFieldNavigationHandler.install(textField);
- return textField;
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite result = new Composite(parent, SWT.NONE);
-
- setControl(result);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- result.setLayout(layout);
-
- Label methNameLabel= new Label(result, SWT.NONE);
- methNameLabel.setText(RefactoringMessages.IntroduceFactoryInputPage_method_name);
-
- fMethodName= createTextInputField(result);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- fMethodName.setLayoutData(gd);
- fMethodName.setText(getUseFactoryRefactoring().getNewMethodName());
-
- final Label factoryTypeLabel= new Label(result, SWT.NONE);
- factoryTypeLabel.setText(RefactoringMessages.IntroduceFactoryInputPage_factoryClassLabel);
-
- Composite inner= new Composite(result, SWT.NONE);
- GridLayout innerLayout= new GridLayout();
- innerLayout.marginHeight= 0; innerLayout.marginWidth= 0;
- innerLayout.numColumns= 2;
- inner.setLayout(innerLayout);
- inner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Text factoryTypeName= createTextInputField(inner);
- factoryTypeName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Button browseTypes= new Button(inner, SWT.PUSH);
- browseTypes.setText(RefactoringMessages.IntroduceFactoryInputPage_browseLabel);
- gd= new GridData();
- gd.horizontalAlignment= GridData.END;
- gd.widthHint = SWTUtil.getButtonWidthHint(browseTypes);
- browseTypes.setLayoutData(gd);
-
- final Button protectCtorCB= new Button(result, SWT.CHECK);
- protectCtorCB.setText(RefactoringMessages.IntroduceFactoryInputPage_protectConstructorLabel);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- protectCtorCB.setLayoutData(gd);
-
- fMethodName.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- fMethodNameStatus = getUseFactoryRefactoring().setNewMethodName(fMethodName.getText());
- validateInput(true);
- /*
- boolean nameOk= status.isOK();
-
- if (status.hasFatalError()) {
- IntroduceFactoryInputPage.this.setPageComplete(false);
-
- }
- IntroduceFactoryInputPage.this.setPageComplete(!status.hasFatalError());
- IntroduceFactoryInputPage.this.setErrorMessage(nameOk ?
- "" : //$NON-NLS-1$
- status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
- */
- }
- });
- protectCtorCB.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean isChecked = protectCtorCB.getSelection();
-
- getUseFactoryRefactoring().setProtectConstructor(isChecked);
- }
- });
-
- factoryTypeName.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- fDestinationStatus= getUseFactoryRefactoring().setFactoryClass(factoryTypeName.getText());
- validateInput(false);
- /*
- boolean nameOk= status.isOK();
-
- IntroduceFactoryInputPage.this.setPageComplete(nameOk);
- IntroduceFactoryInputPage.this.setErrorMessage(nameOk ? "" : //$NON-NLS-1$
- status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
- */
- }
- });
- browseTypes.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IType factoryType= chooseFactoryClass();
-
- if (factoryType == null)
- return;
-
- RefactoringStatus status= getUseFactoryRefactoring().setFactoryClass(factoryType.getFullyQualifiedName());
- boolean nameOk= status.isOK();
-
- factoryTypeName.setText(factoryType.getFullyQualifiedName());
- IntroduceFactoryInputPage.this.setPageComplete(nameOk);
- IntroduceFactoryInputPage.this.setErrorMessage(nameOk ? "" : //$NON-NLS-1$
- status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
- }
- });
-
- // Set up the initial state of the various dialog options.
- if (getUseFactoryRefactoring().canProtectConstructor())
- protectCtorCB.setSelection(true);
- else {
- protectCtorCB.setSelection(false);
- protectCtorCB.setEnabled(false);
- getUseFactoryRefactoring().setProtectConstructor(false);
- }
- factoryTypeName.setText(getUseFactoryRefactoring().getFactoryClassName());
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INTRODUCE_FACTORY_WIZARD_PAGE);
- }
-
- private IType chooseFactoryClass() {
- IJavaScriptProject proj= getUseFactoryRefactoring().getProject();
-
- if (proj == null)
- return null;
-
- IJavaScriptElement[] elements= new IJavaScriptElement[] { proj };
- IJavaScriptSearchScope scope= SearchEngine.createJavaSearchScope(elements);
-
- FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(
- getShell(), false, getWizard().getContainer(), scope, IJavaScriptSearchConstants.CLASS);
-
- dialog.setTitle(RefactoringMessages.IntroduceFactoryInputPage_chooseFactoryClass_title);
- dialog.setMessage(RefactoringMessages.IntroduceFactoryInputPage_chooseFactoryClass_message);
-
- if (dialog.open() == Window.OK) {
- return (IType) dialog.getFirstResult();
- }
- return null;
- }
-
- private IntroduceFactoryRefactoring getUseFactoryRefactoring() {
- return (IntroduceFactoryRefactoring) getRefactoring();
- }
-
- private void validateInput(boolean methodName) {
- RefactoringStatus merged= new RefactoringStatus();
- if (fMethodNameStatus != null && (methodName || fMethodNameStatus.hasError()))
- merged.merge(fMethodNameStatus);
- if (fDestinationStatus != null && (!methodName || fDestinationStatus.hasError()))
- merged.merge(fDestinationStatus);
-
- setPageComplete(!merged.hasError());
- int severity= merged.getSeverity();
- String message= merged.getMessageMatchingSeverity(severity);
- if (severity >= RefactoringStatus.INFO) {
- setMessage(message, severity);
- } else {
- setMessage("", NONE); //$NON-NLS-1$
- }
- }
- }
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryWizard.java
deleted file mode 100644
index 850ec44f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceFactoryWizard.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.IntroduceFactoryRefactoring;
-
-/**
- * @author rfuhrer@watson.ibm.com
- */
-public class IntroduceFactoryWizard extends RefactoringWizard {
- /**
- * Constructor for IntroduceFactoryWizard.
- * @param ref the refactoring
- * @param pageTitle the page title
- */
- public IntroduceFactoryWizard(IntroduceFactoryRefactoring ref, String pageTitle) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(pageTitle);
- }
-
- /**
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- String message= RefactoringMessages.IntroduceFactoryInputPage_name_factory;
-
- IntroduceFactoryInputPage page= new IntroduceFactoryInputPage(message);
-
- addPage(page);
- }
-
- public IntroduceFactoryRefactoring getIntroduceFactoryRefactoring() {
- return (IntroduceFactoryRefactoring) getRefactoring();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionInputPage.java
deleted file mode 100644
index 8d0dea24..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionInputPage.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.IntroduceIndirectionRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-/**
- *
- */
-public class IntroduceIndirectionInputPage extends UserInputWizardPage {
-
- /**
- * The name of the intermediary method to be created.
- */
- private Text fIntermediaryMethodName;
-
- private Combo fIntermediaryTypeName;
- private static final int INTERMEDIARY_TYPE_COUNT= 10;
- private static List fgIntermediaryTypes= new ArrayList(INTERMEDIARY_TYPE_COUNT);
-
- /**
- * Constructor for IntroduceIndirectionInputPage.
- * @param name the name of the page
- */
- public IntroduceIndirectionInputPage(String name) {
- super(name);
- }
-
- private Text createIntermediaryNameCombo(Composite result) {
- final Text textField= new Text(result, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
- textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- TextFieldNavigationHandler.install(textField);
- return textField;
- }
-
- private Combo createIntermediaryTypeCombo(Composite composite) {
- final Combo textCombo= new Combo(composite, SWT.SINGLE | SWT.BORDER);
- textCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- textCombo.setItems((String[]) fgIntermediaryTypes.toArray(new String[fgIntermediaryTypes.size()]));
- textCombo.setVisibleItemCount(INTERMEDIARY_TYPE_COUNT);
-
- JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(false, false, true);
- processor.setPackageFragment(getIntroduceIndirectionRefactoring().getInvocationPackage());
- ControlContentAssistHelper.createComboContentAssistant(textCombo, processor);
- TextFieldNavigationHandler.install(textCombo);
- return textCombo;
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
-
- setControl(result);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- result.setLayout(layout);
-
- Label methNameLabel= new Label(result, SWT.NONE);
- methNameLabel.setText(RefactoringMessages.IntroduceIndirectionInputPage_new_method_name);
-
- fIntermediaryMethodName= createIntermediaryNameCombo(result);
-
- final Label intermediaryTypeLabel= new Label(result, SWT.NONE);
- intermediaryTypeLabel.setText(RefactoringMessages.IntroduceIndirectionInputPage_declaring_class);
-
- Composite inner= new Composite(result, SWT.NONE);
- GridLayout innerLayout= new GridLayout();
- innerLayout.marginHeight= 0;
- innerLayout.marginWidth= 0;
- innerLayout.numColumns= 2;
- inner.setLayout(innerLayout);
- inner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fIntermediaryTypeName= createIntermediaryTypeCombo(inner);
- fIntermediaryTypeName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Button browseTypes= new Button(inner, SWT.PUSH);
- browseTypes.setText(RefactoringMessages.IntroduceIndirectionInputPage_browse);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.END;
- gd.widthHint= SWTUtil.getButtonWidthHint(browseTypes);
- browseTypes.setLayoutData(gd);
-
- final Button enableReferencesCheckBox= new Button(result, SWT.CHECK);
- enableReferencesCheckBox.setText(RefactoringMessages.IntroduceIndirectionInputPage_update_references);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- gd.verticalIndent= 2;
- enableReferencesCheckBox.setLayoutData(gd);
-
- fIntermediaryMethodName.setText(getIntroduceIndirectionRefactoring().getIntermediaryMethodName());
- fIntermediaryTypeName.setText(getIntroduceIndirectionRefactoring().getIntermediaryClassName());
-
- fIntermediaryMethodName.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
- });
-
- enableReferencesCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getIntroduceIndirectionRefactoring().setEnableUpdateReferences(enableReferencesCheckBox.getSelection());
- }
- });
-
- fIntermediaryTypeName.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
- });
-
- browseTypes.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IType intermediaryType= chooseIntermediaryClass();
-
- if (intermediaryType == null)
- return;
-
- fIntermediaryTypeName.setText(intermediaryType.getFullyQualifiedName());
- }
- });
-
- if (getIntroduceIndirectionRefactoring().canEnableUpdateReferences())
- enableReferencesCheckBox.setSelection(true);
- else {
- enableReferencesCheckBox.setSelection(false);
- enableReferencesCheckBox.setEnabled(false);
- getIntroduceIndirectionRefactoring().setEnableUpdateReferences(false);
- }
-
- fIntermediaryMethodName.setFocus();
- fIntermediaryMethodName.selectAll();
- validateInput();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INTRODUCE_INDIRECTION_WIZARD_PAGE);
- }
-
- private IType chooseIntermediaryClass() {
- IJavaScriptProject proj= getIntroduceIndirectionRefactoring().getProject();
-
- if (proj == null)
- return null;
-
- IJavaScriptElement[] elements= new IJavaScriptElement[] { proj };
- IJavaScriptSearchScope scope= SearchEngine.createJavaSearchScope(elements);
-
- FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, IJavaScriptSearchConstants.CLASS);
-
- dialog.setTitle(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class);
- dialog.setMessage(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class_long);
-
- if (dialog.open() == Window.OK) {
- return (IType) dialog.getFirstResult();
- }
- return null;
- }
-
- private IntroduceIndirectionRefactoring getIntroduceIndirectionRefactoring() {
- return (IntroduceIndirectionRefactoring) getRefactoring();
- }
-
- private void validateInput() {
- RefactoringStatus merged= new RefactoringStatus();
- merged.merge(getIntroduceIndirectionRefactoring().setIntermediaryClassName(fIntermediaryTypeName.getText()));
- merged.merge(getIntroduceIndirectionRefactoring().setIntermediaryMethodName(fIntermediaryMethodName.getText()));
-
- setPageComplete(!merged.hasError());
- int severity= merged.getSeverity();
- String message= merged.getMessageMatchingSeverity(severity);
- if (severity >= RefactoringStatus.INFO) {
- setMessage(message, severity);
- } else {
- setMessage("", NONE); //$NON-NLS-1$
- }
- }
-
- protected boolean performFinish() {
- storeIntermediaryTypeName();
- return super.performFinish();
- }
-
- public IWizardPage getNextPage() {
- storeIntermediaryTypeName();
- return super.getNextPage();
- }
-
- private void storeIntermediaryTypeName() {
- String destination= fIntermediaryTypeName.getText();
- if (!fgIntermediaryTypes.remove(destination) && fgIntermediaryTypes.size() >= INTERMEDIARY_TYPE_COUNT)
- fgIntermediaryTypes.remove(fgIntermediaryTypes.size() - 1);
- fgIntermediaryTypes.add(0, destination);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionWizard.java
deleted file mode 100644
index f020cb21..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceIndirectionWizard.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.IntroduceIndirectionRefactoring;
-
-/**
- *
- */
-public class IntroduceIndirectionWizard extends RefactoringWizard {
-
- /**
- * Constructor for IntroduceIndirectionWizard.
- * @param ref the refactoring
- * @param pageTitle the page title
- */
- public IntroduceIndirectionWizard(IntroduceIndirectionRefactoring ref, String pageTitle) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(pageTitle);
- }
-
- /**
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- IntroduceIndirectionInputPage page= new IntroduceIndirectionInputPage("IntroduceIndirectionInputPage"); //$NON-NLS-1$
- addPage(page);
- }
-
- public IntroduceIndirectionRefactoring getIntroduceIndirectionRefactoring() {
- return (IntroduceIndirectionRefactoring) getRefactoring();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceParameterWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceParameterWizard.java
deleted file mode 100644
index 02f38fc8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/IntroduceParameterWizard.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.IntroduceParameterRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-public class IntroduceParameterWizard extends RefactoringWizard {
-
- public IntroduceParameterWizard(IntroduceParameterRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.IntroduceParameterWizard_defaultPageTitle);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new IntroduceParameterInputPage(getIntroduceParameterRefactoring().guessParameterNames()));
- }
-
- private IntroduceParameterRefactoring getIntroduceParameterRefactoring(){
- return (IntroduceParameterRefactoring)getRefactoring();
- }
-
- private static class IntroduceParameterInputPage extends UserInputWizardPage {
-
- private static final String DESCRIPTION = RefactoringMessages.IntroduceParameterInputPage_description;
- public static final String PAGE_NAME= "IntroduceParameterInputPage";//$NON-NLS-1$
- private String[] fParamNameProposals;
-
- private JavaSourceViewer fSignaturePreview;
- private Document fSignaturePreviewDocument;
- private Button fLeaveDelegateCheckBox;
- private Button fDeprecateDelegateCheckBox;
-
- public IntroduceParameterInputPage(String[] tempNameProposals) {
- super(PAGE_NAME);
- setDescription(DESCRIPTION);
- Assert.isNotNull(tempNameProposals);
- fParamNameProposals= tempNameProposals;
- fSignaturePreviewDocument= new Document();
- }
-
- private IntroduceParameterRefactoring getIntroduceParameterRefactoring(){
- return (IntroduceParameterRefactoring)getRefactoring();
- }
-
- public void createControl(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
-
- createParameterTableControl(result);
- fLeaveDelegateCheckBox= DelegateUIHelper.generateLeaveDelegateCheckbox(result, getRefactoring(), false);
- if (fLeaveDelegateCheckBox != null) {
- fDeprecateDelegateCheckBox= new Button(result, SWT.CHECK);
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.horizontalIndent= (layout.marginWidth + fDeprecateDelegateCheckBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- fDeprecateDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox.setText(DelegateUIHelper.getDeprecateDelegateCheckBoxTitle());
- final IntroduceParameterRefactoring refactoring= getIntroduceParameterRefactoring();
- fDeprecateDelegateCheckBox.setSelection(DelegateUIHelper.loadDeprecateDelegateSetting(refactoring));
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- fDeprecateDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- }
- });
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
- Label sep= new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
- sep.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- createSignaturePreview(result);
-
- update(false);
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INTRODUCE_PARAMETER_WIZARD_PAGE);
- }
-
- private ChangeParametersControl createParameterTableControl(Composite composite) {
- String labelText= RefactoringMessages.IntroduceParameterWizard_parameters;
- ChangeParametersControl cp= new ChangeParametersControl(composite, SWT.NONE, labelText, new IParameterListChangeListener() {
- public void parameterChanged(ParameterInfo parameter) {
- update(true);
- }
- public void parameterListChanged() {
- update(true);
- }
- public void parameterAdded(ParameterInfo parameter) {
- update(true);
- }
- }, ChangeParametersControl.Mode.INTRODUCE_PARAMETER, fParamNameProposals);
- cp.setLayoutData(new GridData(GridData.FILL_BOTH));
- cp.setInput(getIntroduceParameterRefactoring().getParameterInfos());
- cp.editParameter(getIntroduceParameterRefactoring().getAddedParameterInfo());
- return cp;
- }
-
- public void dispose() {
- DelegateUIHelper.saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
- DelegateUIHelper.saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
- super.dispose();
- }
-
- private void createSignaturePreview(Composite composite) {
- Label previewLabel= new Label(composite, SWT.NONE);
- previewLabel.setText(RefactoringMessages.ChangeSignatureInputPage_method_Signature_Preview);
-
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSignaturePreview= new JavaSourceViewer(composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store);
- fSignaturePreview.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- fSignaturePreview.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- fSignaturePreview.getTextWidget().setBackground(composite.getBackground());
- fSignaturePreview.setDocument(fSignaturePreviewDocument);
- fSignaturePreview.setEditable(false);
-
- //Layouting problems with wrapped text: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866
- Control signaturePreviewControl= fSignaturePreview.getControl();
- PixelConverter pixelConverter= new PixelConverter(signaturePreviewControl);
- GridData gdata= new GridData(GridData.FILL_BOTH);
- gdata.widthHint= pixelConverter.convertWidthInCharsToPixels(50);
- gdata.heightHint= pixelConverter.convertHeightInCharsToPixels(2);
- signaturePreviewControl.setLayoutData(gdata);
- }
-
- private void update(boolean displayErrorMessage){
- updateStatus(displayErrorMessage);
- updateSignaturePreview();
- }
-
- private void updateStatus(boolean displayErrorMessage) {
- RefactoringStatus nameCheck= getIntroduceParameterRefactoring().validateInput();
- if (displayErrorMessage) {
- setPageComplete(nameCheck);
- } else {
- setErrorMessage(null);
- setPageComplete(true);
- }
- }
-
- private void updateSignaturePreview() {
- try{
- int top= fSignaturePreview.getTextWidget().getTopPixel();
- fSignaturePreviewDocument.set(getIntroduceParameterRefactoring().getMethodSignaturePreview());
- fSignaturePreview.getTextWidget().setTopPixel(top);
- } catch (JavaScriptModelException e){
- ExceptionHandler.handle(e, RefactoringMessages.IntroduceParameterWizard_defaultPageTitle, RefactoringMessages.ChangeSignatureInputPage_exception);
- }
- }
-
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/JavaStatusContextViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/JavaStatusContextViewer.java
deleted file mode 100644
index eda3e04a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/JavaStatusContextViewer.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
-import org.eclipse.ltk.ui.refactoring.TextStatusContextViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.base.JavaStatusContext;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.base.JavaStringStatusContext;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.InternalClassFileEditorInput;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public class JavaStatusContextViewer extends TextStatusContextViewer {
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.IStatusContextViewer#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- final SourceViewer viewer= getSourceViewer();
- viewer.unconfigure();
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- viewer.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- viewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- }
-
- protected SourceViewer createSourceViewer(Composite parent) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- return new JavaSourceViewer(parent, null, null, false, SWT.LEFT_TO_RIGHT | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, store);
- }
-
- private IPackageFragmentRoot getPackageFragmentRoot(IClassFile file) {
-
- IJavaScriptElement element= file.getParent();
- while (element != null && element.getElementType() != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT)
- element= element.getParent();
-
- return (IPackageFragmentRoot) element;
- }
-
- public void setInput(RefactoringStatusContext context) {
- if (context instanceof JavaStatusContext) {
- JavaStatusContext jsc= (JavaStatusContext)context;
- IDocument document= null;
- if (jsc.isBinary()) {
- IClassFile file= jsc.getClassFile();
- IEditorInput editorInput= new InternalClassFileEditorInput(file);
- document= getDocument(JavaScriptPlugin.getDefault().getClassFileDocumentProvider(), editorInput);
- if (document.getLength() == 0)
- document= new Document(Messages.format(RefactoringMessages.JavaStatusContextViewer_no_source_found0, getPackageFragmentRoot(file).getElementName()));
- updateTitle(file);
- } else {
- IJavaScriptUnit cunit= jsc.getCompilationUnit();
- if (cunit.isWorkingCopy()) {
- try {
- document= newJavaDocument(cunit.getSource());
- } catch (JavaScriptModelException e) {
- // document is null which is a valid input.
- }
- } else {
- IEditorInput editorInput= new FileEditorInput((IFile)cunit.getResource());
- document= getDocument(JavaScriptPlugin.getDefault().getCompilationUnitDocumentProvider(), editorInput);
- }
- if (document == null)
- document= new Document(RefactoringMessages.JavaStatusContextViewer_no_source_available);
- updateTitle(cunit);
- }
- setInput(document, createRegion(jsc.getSourceRange()));
- } else if (context instanceof JavaStringStatusContext) {
- updateTitle(null);
- JavaStringStatusContext sc= (JavaStringStatusContext)context;
- setInput(newJavaDocument(sc.getSource()), createRegion(sc.getSourceRange()));
- }
- }
-
- private IDocument newJavaDocument(String source) {
- IDocument result= new Document(source);
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- textTools.setupJavaDocumentPartitioner(result);
- return result;
- }
-
- private static IRegion createRegion(ISourceRange range) {
- return new Region(range.getOffset(), range.getLength());
- }
-
- private IDocument getDocument(IDocumentProvider provider, IEditorInput input) {
- if (input == null)
- return null;
- IDocument result= null;
- try {
- provider.connect(input);
- result= provider.getDocument(input);
- } catch (CoreException e) {
- } finally {
- provider.disconnect(input);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MessageWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MessageWizardPage.java
deleted file mode 100644
index 6a319194..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MessageWizardPage.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-
-public abstract class MessageWizardPage extends UserInputWizardPage {
-
- public static final int STYLE_NONE= 0;
- public static final int STYLE_INFORMATION= 1;
- public static final int STYLE_QUESTION= 2;
- public static final int STYLE_ERROR= 3;
- public static final int STYLE_WARNING= 4;
-
- private final int fStyle;
-
- public MessageWizardPage(String pageName, boolean isLastUserPage, int style) {
- super(pageName);
- fStyle= style;
- }
-
- protected abstract String getMessageString();
-
- protected Image getMessageImage() {
- switch (fStyle) {
- case STYLE_ERROR :
- return Display.getCurrent().getSystemImage(SWT.ICON_ERROR);
- case STYLE_WARNING :
- return Display.getCurrent().getSystemImage(SWT.ICON_WARNING);
- case STYLE_INFORMATION :
- return Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION);
- case STYLE_QUESTION :
- return Display.getCurrent().getSystemImage(SWT.ICON_QUESTION);
- default :
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN) * 3 / 2;
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING) * 2;
- layout.numColumns= 2;
- result.setLayout(layout);
-
- Image image= getMessageImage();
- if (image != null) {
- Label label= new Label(result, SWT.NULL);
- image.setBackground(label.getBackground());
- label.setImage(image);
- label.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
- }
-
- String message= getMessageString();
- if (message != null) {
- Label messageLabel= new Label(result, SWT.WRAP);
- messageLabel.setText(message);
- GridData data= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
- data.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- messageLabel.setLayoutData(data);
- messageLabel.setFont(result.getFont());
- }
- Dialog.applyDialogFont(result);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInnerToTopWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInnerToTopWizard.java
deleted file mode 100644
index 0f1b985c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInnerToTopWizard.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-
-public class MoveInnerToTopWizard extends RefactoringWizard {
-
- private class MoveInnerToToplnputPage extends TextInputWizardPage {
-
- private Text fFieldNameEntryText;
-
- private Label fFieldNameLabel;
-
- private Button fFinalCheckBox;
-
- private final boolean fInitialInputValid;
-
- public MoveInnerToToplnputPage(String initialValue) {
- super(RefactoringMessages.MoveInnerToToplnputPage_description, true, initialValue);
- final MoveInnerToTopRefactoring refactoring= getMoveRefactoring();
- final boolean mandatory= refactoring.isCreatingInstanceFieldMandatory();
- fInitialInputValid= (!initialValue.equals("")) || !mandatory; //$NON-NLS-1$
- if (!mandatory)
- refactoring.setCreateInstanceField(false);
- }
-
- private void addFieldNameEntry(Composite newControl) {
- fFieldNameLabel= new Label(newControl, SWT.NONE);
- if (getMoveRefactoring().isCreatingInstanceFieldMandatory())
- fFieldNameLabel.setText(RefactoringMessages.MoveInnerToToplnputPage_enter_name_mandatory);
- else
- fFieldNameLabel.setText(RefactoringMessages.MoveInnerToToplnputPage_enter_name);
- fFieldNameLabel.setLayoutData(new GridData());
-
- fFieldNameEntryText= createTextInputField(newControl);
- fFieldNameEntryText.selectAll();
- fFieldNameEntryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- private void addFinalCheckBox(Composite newControl) {
- fFinalCheckBox= new Button(newControl, SWT.CHECK);
- fFinalCheckBox.setText(RefactoringMessages.MoveInnerToToplnputPage_instance_final);
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan= 2;
- fFinalCheckBox.setLayoutData(data);
- fFinalCheckBox.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- getMoveRefactoring().setMarkInstanceFieldAsFinal(fFinalCheckBox.getSelection());
- }
- });
- fFieldNameEntryText.addModifyListener(new ModifyListener() {
-
- public final void modifyText(ModifyEvent event) {
- final String text= fFieldNameEntryText.getText();
- final MoveInnerToTopRefactoring refactoring= getMoveRefactoring();
- if (refactoring.isCreatingInstanceFieldMandatory())
- setPageComplete(validateTextField(text));
- final boolean empty= text.length() == 0;
- if (refactoring.isCreatingInstanceFieldMandatory()) {
- // Do nothing
- } else if (refactoring.isCreatingInstanceFieldPossible()) {
- fFinalCheckBox.setEnabled(!empty);
- }
- if (!refactoring.isCreatingInstanceFieldMandatory())
- refactoring.setCreateInstanceField(!empty);
- }
- });
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- Composite newControl= new Composite(parent, SWT.NONE);
- setControl(newControl);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newControl, IJavaHelpContextIds.MOVE_INNER_TO_TOP_WIZARD_PAGE);
- newControl.setLayout(new GridLayout());
- Dialog.applyDialogFont(newControl);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- newControl.setLayout(layout);
-
- addFieldNameEntry(newControl);
- addFinalCheckBox(newControl);
-
- if (getMoveRefactoring().isCreatingInstanceFieldPossible()) {
- fFinalCheckBox.setSelection(getMoveRefactoring().isInstanceFieldMarkedFinal());
- fFinalCheckBox.setEnabled(true);
- } else {
- fFinalCheckBox.setSelection(false);
- fFinalCheckBox.setEnabled(false);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#isEmptyInputValid()
- */
- protected boolean isEmptyInputValid() {
- return !getMoveRefactoring().isCreatingInstanceFieldMandatory();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#isInitialInputValid()
- */
- protected boolean isInitialInputValid() {
- return fInitialInputValid;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- String message= getMoveRefactoring().isCreatingInstanceFieldMandatory() ? RefactoringMessages.MoveInnerToToplnputPage_mandatory_info : RefactoringMessages.MoveInnerToToplnputPage_optional_info;
- setPageComplete(RefactoringStatus.createInfoStatus(message));
- } else {
- setPageComplete(new RefactoringStatus());
- getContainer().updateMessage();
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage#validateTextField(String)
- */
- protected RefactoringStatus validateTextField(String text) {
- final MoveInnerToTopRefactoring refactoring= getMoveRefactoring();
- refactoring.setEnclosingInstanceName(text);
- if (refactoring.isCreatingInstanceFieldMandatory())
- return refactoring.checkEnclosingInstanceName(text);
- else if (!text.equals("")) //$NON-NLS-1$
- return refactoring.checkEnclosingInstanceName(text);
- else
- return new RefactoringStatus();
- }
- }
-
- public MoveInnerToTopWizard(Refactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.MoveInnerToTopWizard_Move_Inner);
- }
-
- /*
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- final MoveInnerToTopRefactoring refactoring= getMoveRefactoring();
- if (refactoring.isCreatingInstanceFieldPossible())
- addPage(new MoveInnerToToplnputPage(refactoring.isCreatingInstanceFieldMandatory() ? refactoring.getEnclosingInstanceName() : "")); //$NON-NLS-1$
- else
- setChangeCreationCancelable(false);
- }
-
- private MoveInnerToTopRefactoring getMoveRefactoring() {
- return (MoveInnerToTopRefactoring) getRefactoring();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInstanceMethodWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInstanceMethodWizard.java
deleted file mode 100644
index 28c73ccd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveInstanceMethodWizard.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.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.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.MoveInstanceMethodRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TableLayoutComposite;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.BindingLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-/**
- * Refactoring wizard for the 'move instance method' refactoring.
- */
-public final class MoveInstanceMethodWizard extends RefactoringWizard {
-
- /**
- * The input wizard page of the 'move instance method' refactoring.
- */
- public final class MoveInstanceMethodPage extends UserInputWizardPage {
-
- /** The page name */
- protected static final String PAGE_NAME= "MoveInstanceMethodPage"; //$NON-NLS-1$
-
- /** The "leave delegate" checkbox */
- protected Button fLeaveDelegateCheckBox= null;
-
- /** The "deprecate delegate" checkbox */
- protected Button fDeprecateDelegateCheckBox= null;
-
- /** The method name text field */
- protected Text fMethodNameField= null;
-
- /** The current method name status */
- protected RefactoringStatus fMethodNameStatus= new RefactoringStatus();
-
- /** The target name text field */
- protected Text fTargetNameField= null;
-
- /** The target name label */
- protected Label fTargetNameLabel= null;
-
- /** The current target name status */
- protected RefactoringStatus fTargetNameStatus= new RefactoringStatus();
-
- /** The current target type status */
- protected RefactoringStatus fTargetTypeStatus= new RefactoringStatus();
-
- /**
- * Creates a new move instance method page.
- */
- public MoveInstanceMethodPage() {
- super(PAGE_NAME);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(final Composite parent) {
- Assert.isNotNull(parent);
- final Composite control= new Composite(parent, SWT.NONE);
- setControl(control);
-
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- control.setLayout(layout);
-
- Label label= new Label(control, SWT.SINGLE);
- label.setText(Messages.format(RefactoringMessages.MoveInstanceMethodPage_New_receiver, JavaScriptElementLabels.getElementLabel(fProcessor.getMethod(), JavaScriptElementLabels.ALL_DEFAULT | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PRE_TYPE_PARAMETERS | JavaScriptElementLabels.M_PARAMETER_NAMES)));
-
- GridData data= new GridData();
- data.horizontalSpan= 2;
- label.setLayoutData(data);
-
- final TableLayoutComposite composite= new TableLayoutComposite(control, SWT.NULL);
- composite.addColumnData(new ColumnWeightData(40, true));
- composite.addColumnData(new ColumnWeightData(60, true));
-
- final Table table= new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
- table.setHeaderVisible(true);
- table.setLinesVisible(false);
-
- TableColumn column= new TableColumn(table, SWT.NONE);
- column.setText(RefactoringMessages.MoveInstanceMethodPage_Name);
- column.setResizable(true);
-
- column= new TableColumn(table, SWT.NONE);
- column.setText(RefactoringMessages.MoveInstanceMethodPage_Type);
- column.setResizable(true);
-
- final TableViewer viewer= new TableViewer(table);
- viewer.setContentProvider(new ArrayContentProvider());
- viewer.setLabelProvider(new TargetLabelProvider());
-
- final IVariableBinding[] candidateTargets= fProcessor.getCandidateTargets();
- viewer.setInput(candidateTargets);
- final IVariableBinding[] possibleTargets= fProcessor.getPossibleTargets();
- viewer.setSelection(new StructuredSelection(new Object[] { possibleTargets[0]}));
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public final void selectionChanged(final SelectionChangedEvent event) {
- final Object element= ((IStructuredSelection) event.getSelection()).getFirstElement();
- if (element instanceof IVariableBinding) {
- final IVariableBinding target= (IVariableBinding) element;
- final IVariableBinding[] targets= fProcessor.getPossibleTargets();
- boolean success= false;
- for (int index= 0; index < targets.length; index++) {
- if (Bindings.equals(target, targets[index])) {
- handleTargetChanged(target);
- success= true;
- break;
- }
- }
- if (!success)
- fTargetTypeStatus= RefactoringStatus.createWarningStatus(Messages.format(RefactoringMessages.MoveInstanceMethodPage_invalid_target, target.getName()));
- else
- fTargetTypeStatus= new RefactoringStatus();
- handleStatusChanged();
- }
- }
- });
-
- data= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- data.heightHint= SWTUtil.getTableHeightHint(table, 7);
- data.horizontalSpan= 2;
- composite.setLayoutData(data);
-
- label= new Label(control, SWT.SINGLE);
- label.setText(RefactoringMessages.MoveInstanceMethodPage_Method_name);
- label.setLayoutData(new GridData());
-
- fMethodNameField= new Text(control, SWT.SINGLE | SWT.BORDER);
- fMethodNameField.setText(fProcessor.getMethodName());
- fMethodNameField.selectAll();
- fMethodNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fMethodNameField.setFocus();
- fMethodNameField.addModifyListener(new ModifyListener() {
-
- public final void modifyText(final ModifyEvent event) {
- fMethodNameStatus= fProcessor.setMethodName(fMethodNameField.getText());
- handleStatusChanged();
- }
- });
- TextFieldNavigationHandler.install(fMethodNameField);
-
- fTargetNameLabel= new Label(control, SWT.SINGLE);
- fTargetNameLabel.setText(RefactoringMessages.MoveInstanceMethodPage_Target_name);
- fTargetNameLabel.setLayoutData(new GridData());
-
- fTargetNameField= new Text(control, SWT.SINGLE | SWT.BORDER);
- final String name= fProcessor.getTargetName();
- if (name != null && name.length() > 0)
- fTargetNameField.setText(fProcessor.getTargetName());
- else {
- setPageComplete(RefactoringStatus.createInfoStatus(RefactoringCoreMessages.Checks_Choose_name));
- setPageComplete(false);
- }
- fTargetNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fTargetNameField.addModifyListener(new ModifyListener() {
-
- public final void modifyText(final ModifyEvent event) {
- fTargetNameStatus= fProcessor.setTargetName(fTargetNameField.getText());
- handleStatusChanged();
- }
- });
- TextFieldNavigationHandler.install(fTargetNameField);
-
- label= new Label(control, SWT.NONE);
-
- data= new GridData();
- data.horizontalSpan= 2;
- label.setLayoutData(data);
-
- fLeaveDelegateCheckBox= DelegateUIHelper.generateLeaveDelegateCheckbox(control, getRefactoring(), false);
- if (fLeaveDelegateCheckBox != null) {
- fDeprecateDelegateCheckBox= new Button(control, SWT.CHECK);
- data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.horizontalIndent= (layout.marginWidth + fDeprecateDelegateCheckBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- data.horizontalSpan= 2;
- fDeprecateDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox.setText(DelegateUIHelper.getDeprecateDelegateCheckBoxTitle());
- fDeprecateDelegateCheckBox.setSelection(DelegateUIHelper.loadDeprecateDelegateSetting(fProcessor));
- fProcessor.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- fDeprecateDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fProcessor.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- }
- });
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
-
- fProcessor.setInlineDelegator(!fLeaveDelegateCheckBox.getSelection());
- fProcessor.setRemoveDelegator(!fLeaveDelegateCheckBox.getSelection());
-
- handleTargetChanged(possibleTargets[0]);
-
- Dialog.applyDialogFont(control);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.MOVE_MEMBERS_WIZARD_PAGE);
- }
-
- public void dispose() {
- DelegateUIHelper.saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
- DelegateUIHelper.saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
- super.dispose();
- }
-
- /**
- * Handles the status changed event.
- */
- protected final void handleStatusChanged() {
- final RefactoringStatus status= new RefactoringStatus();
- status.merge(fMethodNameStatus);
- status.merge(fTargetNameStatus);
- status.merge(fTargetTypeStatus);
- if (!fTargetTypeStatus.isOK())
- setPageComplete(false);
- else
- setPageComplete(status);
- }
-
- /**
- * Handles the target changed event.
- *
- * @param target the changed target
- */
- protected final void handleTargetChanged(final IVariableBinding target) {
- Assert.isNotNull(target);
- fProcessor.setTarget(target);
- fTargetNameField.setEnabled(fProcessor.needsTargetNode());
- fTargetNameLabel.setEnabled(fProcessor.needsTargetNode());
- }
- }
-
- /**
- * Table label provider for the target selection table.
- */
- public static class TargetLabelProvider extends BindingLabelProvider implements ITableLabelProvider {
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(final Object element, final int column) {
- if (column == 0)
- return getImage(element);
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(final Object element, final int column) {
- final IVariableBinding binding= (IVariableBinding) element;
- switch (column) {
- case 0:
- return getText(binding);
- case 1:
- return getText(binding.getType());
- default:
- return null;
- }
- }
- }
-
- /** The default create delegator setting */
- protected static boolean DEFAULT_CREATE_DELEGATOR_SETTING= false;
-
- /** The default deprecate delegator setting */
- protected static boolean DEFAULT_DEPRECATE_DELEGATOR_SETTING= false;
-
- /** The associated move instance method processor */
- protected final MoveInstanceMethodProcessor fProcessor;
-
- /**
- * Creates a new move instance method wizard.
- *
- * @param refactoring the refactoring to host
- */
- public MoveInstanceMethodWizard(final MoveInstanceMethodRefactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- fProcessor= refactoring.getMoveMethodProcessor();
- setDefaultPageTitle(RefactoringMessages.MoveInstanceMethodWizard_Move_Method);
- }
-
- /*
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- addPage(new MoveInstanceMethodPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveMembersWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveMembersWizard.java
deleted file mode 100644
index 60b73633..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/MoveMembersWizard.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.MoveStaticMembersProcessor;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class MoveMembersWizard extends RefactoringWizard {
-
- public MoveMembersWizard(MoveRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.MoveMembersWizard_page_title);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new MoveMembersInputPage());
- }
-
- private static class MoveMembersInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "MoveMembersInputPage"; //$NON-NLS-1$
- private static final long LABEL_FLAGS= JavaScriptElementLabels.ALL_DEFAULT;
-
- private Combo fDestinationField;
- private Button fLeaveDelegateCheckBox;
- private Button fDeprecateDelegateCheckBox;
- private static final int MRU_COUNT= 10;
- private static List fgMruDestinations= new ArrayList(MRU_COUNT);
-
- public MoveMembersInputPage() {
- super(PAGE_NAME);
- }
-
- public void setVisible(boolean visible){
- if (visible){
- String message= Messages.format(RefactoringMessages.MoveMembersInputPage_descriptionKey,
- new String[]{new Integer(getMoveProcessor().getMembersToMove().length).toString(),
- JavaModelUtil.getFullyQualifiedName(getMoveProcessor().getDeclaringType())});
- setDescription(message);
- }
- super.setVisible(visible);
- }
-
- public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- addLabel(composite);
- addDestinationControls(composite);
- fLeaveDelegateCheckBox= DelegateUIHelper.generateLeaveDelegateCheckbox(composite, getRefactoring(), getMoveProcessor().getMembersToMove().length > 1);
- GridData data= new GridData();
- data.horizontalSpan= 2;
- if (fLeaveDelegateCheckBox != null) {
- fLeaveDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox= new Button(composite, SWT.CHECK);
- data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.horizontalIndent= (layout.marginWidth + fDeprecateDelegateCheckBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- data.horizontalSpan= 2;
- fDeprecateDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox.setText(DelegateUIHelper.getDeprecateDelegateCheckBoxTitle());
- fDeprecateDelegateCheckBox.setSelection(DelegateUIHelper.loadDeprecateDelegateSetting(getMoveProcessor()));
- getMoveProcessor().setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- fDeprecateDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getMoveProcessor().setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- }
- });
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
- setControl(composite);
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.MOVE_MEMBERS_WIZARD_PAGE);
- }
-
- public void dispose() {
- DelegateUIHelper.saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
- DelegateUIHelper.saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
- super.dispose();
- }
-
- private void addLabel(Composite parent) {
- Label label= new Label(parent, SWT.NONE);
- IMember[] members= getMoveProcessor().getMembersToMove();
- if (members.length == 1) {
- label.setText(Messages.format(
- RefactoringMessages.MoveMembersInputPage_destination_single,
- JavaScriptElementLabels.getElementLabel(members[0], LABEL_FLAGS)));
- } else {
- label.setText(Messages.format(
- RefactoringMessages.MoveMembersInputPage_destination_multi,
- String.valueOf(members.length)));
- }
- GridData gd= new GridData();
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
- }
-
- private void addDestinationControls(Composite composite) {
- fDestinationField= new Combo(composite, SWT.SINGLE | SWT.BORDER);
- fDestinationField.setFocus();
- fDestinationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fDestinationField.setItems((String[]) fgMruDestinations.toArray(new String[fgMruDestinations.size()]));
- fDestinationField.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- handleDestinationChanged();
- }
- private void handleDestinationChanged() {
- IStatus status= JavaScriptConventions.validateJavaScriptTypeName(fDestinationField.getText());
- if (status.getSeverity() == IStatus.ERROR){
- error(status.getMessage());
- } else {
- try {
- final IType declaring= getMoveProcessor().getDeclaringType();
- IType resolvedType= declaring.getJavaScriptProject().findType(fDestinationField.getText());
- if (resolvedType == null)
- resolvedType= declaring.getJavaScriptProject().findType(declaring.getPackageFragment().getElementName(), fDestinationField.getText());
- IStatus validationStatus= validateDestinationType(resolvedType, fDestinationField.getText());
- if (validationStatus.isOK()){
- setErrorMessage(null);
- setPageComplete(true);
- } else {
- error(validationStatus.getMessage());
- }
- } catch(JavaScriptModelException ex) {
- JavaScriptPlugin.log(ex); //no ui here
- error(RefactoringMessages.MoveMembersInputPage_invalid_name);
- }
- }
- }
- private void error(String message){
- setErrorMessage(message);
- setPageComplete(false);
- }
- });
- if (fgMruDestinations.size() > 0) {
- fDestinationField.select(0);
- } else {
- setPageComplete(false);
- }
- JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(false, false, true);
- IPackageFragment context= (IPackageFragment) getMoveProcessor().getDeclaringType().getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT);
- processor.setPackageFragment(context);
- ControlContentAssistHelper.createComboContentAssistant(fDestinationField, processor);
- TextFieldNavigationHandler.install(fDestinationField);
-
- Button button= new Button(composite, SWT.PUSH);
- button.setText(RefactoringMessages.MoveMembersInputPage_browse);
- button.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- openTypeSelectionDialog();
- }
- });
- }
-
- protected boolean performFinish() {
- initializeRefactoring();
- return super.performFinish();
- }
-
- public IWizardPage getNextPage() {
- initializeRefactoring();
- return super.getNextPage();
- }
-
- private void initializeRefactoring() {
- try {
- String destination= fDestinationField.getText();
- if (!fgMruDestinations.remove(destination) && fgMruDestinations.size() >= MRU_COUNT)
- fgMruDestinations.remove(fgMruDestinations.size() - 1);
- fgMruDestinations.add(0, destination);
-
- getMoveProcessor().setDestinationTypeFullyQualifiedName(destination);
- } catch(JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.MoveMembersInputPage_move_Member, RefactoringMessages.MoveMembersInputPage_exception);
- }
- }
-
- private IJavaScriptSearchScope createWorkspaceSourceScope(){
- IJavaScriptElement[] project= new IJavaScriptElement[] { getMoveProcessor().getDeclaringType().getJavaScriptProject() };
- return SearchEngine.createJavaSearchScope(project, IJavaScriptSearchScope.REFERENCED_PROJECTS | IJavaScriptSearchScope.SOURCES);
- }
-
- private void openTypeSelectionDialog(){
- int elementKinds= IJavaScriptSearchConstants.TYPE;
- final IJavaScriptSearchScope scope= createWorkspaceSourceScope();
- FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
- getWizard().getContainer(), scope, elementKinds);
- dialog.setTitle(RefactoringMessages.MoveMembersInputPage_choose_Type);
- dialog.setMessage(RefactoringMessages.MoveMembersInputPage_dialogMessage);
- dialog.setValidator(new ISelectionStatusValidator(){
- public IStatus validate(Object[] selection) {
- Assert.isTrue(selection.length <= 1);
- if (selection.length == 0)
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
- Object element= selection[0];
- if (! (element instanceof IType))
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
- IType type= (IType)element;
- return validateDestinationType(type, type.getElementName());
- }
- });
- dialog.setInitialPattern(createInitialFilter());
- if (dialog.open() == Window.CANCEL)
- return;
- IType firstResult= (IType)dialog.getFirstResult();
- fDestinationField.setText(JavaModelUtil.getFullyQualifiedName(firstResult));
- }
-
- private String createInitialFilter() {
- if (! fDestinationField.getText().trim().equals("")) //$NON-NLS-1$
- return fDestinationField.getText();
- else
- return getMoveProcessor().getDeclaringType().getElementName();
- }
-
- private static IStatus validateDestinationType(IType type, String typeName){
- if (type == null || ! type.exists())
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, Messages.format(RefactoringMessages.MoveMembersInputPage_not_found, typeName), null);
- if (type.isBinary())
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_no_binary, null);
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
-
- private MoveStaticMembersProcessor getMoveProcessor() {
- return (MoveStaticMembersProcessor)getRefactoring().getAdapter(MoveStaticMembersProcessor.class);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ParameterEditDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ParameterEditDialog.java
deleted file mode 100644
index 5a5f07e7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/ParameterEditDialog.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-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.layout.GridLayout;
-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.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.Checks;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.StubTypeContext;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.TypeContextChecker;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-
-public class ParameterEditDialog extends StatusDialog {
-
- private final ParameterInfo fParameter;
- private final boolean fEditType;
- private final boolean fEditDefault;
- private final StubTypeContext fContext;
- private Text fType;
- private Text fName;
- private Text fDefaultValue;
-
- /**
- * @param context the <code>IPackageFragment</code> for type ContentAssist.
- * Can be <code>null</code> if <code>canEditType</code> is <code>false</code>.
- */
- public ParameterEditDialog(Shell parentShell, ParameterInfo parameter, boolean canEditType, boolean canEditDefault, StubTypeContext context) {
- super(parentShell);
- fParameter= parameter;
- fEditType= canEditType;
- fEditDefault= canEditDefault;
- fContext= context;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(RefactoringMessages.ParameterEditDialog_title);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite result= (Composite)super.createDialogArea(parent);
- GridLayout layout= (GridLayout)result.getLayout();
- layout.numColumns= 2;
- Label label;
- GridData gd;
-
- label= new Label(result, SWT.NONE);
- String newName = fParameter.getNewName();
- if (newName.length() == 0)
- label.setText(RefactoringMessages.ParameterEditDialog_message_new);
- else
- label.setText(Messages.format(RefactoringMessages.ParameterEditDialog_message, newName));
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
-
- if (fEditType) {
- label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ParameterEditDialog_type);
- fType= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- fType.setLayoutData(gd);
- fType.setText(fParameter.getNewTypeName());
- fType.addModifyListener(
- new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate((Text)e.widget);
- }
- });
- TextFieldNavigationHandler.install(fType);
- JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(true, false);
- processor.setCompletionContext(fContext.getCuHandle(), fContext.getBeforeString(), fContext.getAfterString());
- ControlContentAssistHelper.createTextContentAssistant(fType, processor);
- }
-
- label= new Label(result, SWT.NONE);
- fName= new Text(result, SWT.BORDER);
- initializeDialogUnits(fName);
- label.setText(RefactoringMessages.ParameterEditDialog_name);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(45);
- fName.setLayoutData(gd);
- fName.setText(newName);
- fName.addModifyListener(
- new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate((Text)e.widget);
- }
- });
- TextFieldNavigationHandler.install(fName);
-
- if (fEditDefault && fParameter.isAdded()) {
- label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ParameterEditDialog_defaultValue);
- fDefaultValue= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- fDefaultValue.setLayoutData(gd);
- fDefaultValue.setText(fParameter.getDefaultValue());
- fDefaultValue.addModifyListener(
- new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate((Text)e.widget);
- }
- });
- TextFieldNavigationHandler.install(fDefaultValue);
- }
- applyDialogFont(result);
- return result;
- }
-
- protected void okPressed() {
- if (fType != null) {
- fParameter.setNewTypeName(fType.getText());
- }
- fParameter.setNewName(fName.getText());
- if (fDefaultValue != null) {
- fParameter.setDefaultValue(fDefaultValue.getText());
- }
- super.okPressed();
- }
-
- private void validate(Text first) {
- IStatus[] result= new IStatus[3];
- if (first == fType) {
- result[0]= validateType();
- result[1]= validateName();
- result[2]= validateDefaultValue();
- } else if (first == fName) {
- result[0]= validateName();
- result[1]= validateType();
- result[2]= validateDefaultValue();
- } else {
- result[0]= validateDefaultValue();
- result[1]= validateName();
- result[2]= validateType();
- }
- for (int i= 0; i < result.length; i++) {
- IStatus status= result[i];
- if (status != null && !status.isOK()) {
- updateStatus(status);
- return;
- }
- }
- updateStatus(createOkStatus());
- }
-
- private IStatus validateType() {
- if (fType == null)
- return null;
- String type= fType.getText();
-
- RefactoringStatus status= TypeContextChecker.checkParameterTypeSyntax(type, fContext.getCuHandle().getJavaScriptProject());
- if (status == null || status.isOK())
- return createOkStatus();
- if (status.hasError())
- return createErrorStatus(status.getEntryWithHighestSeverity().getMessage());
- else
- return createWarningStatus(status.getEntryWithHighestSeverity().getMessage());
- }
-
- private IStatus validateName() {
- if (fName == null)
- return null;
- String text= fName.getText();
- if (text.length() == 0)
- return createErrorStatus(RefactoringMessages.ParameterEditDialog_name_error);
- IStatus status= JavaScriptConventions.validateFieldName(text);
- if (status.matches(IStatus.ERROR))
- return status;
- if (! Checks.startsWithLowerCase(text))
- return createWarningStatus(RefactoringCoreMessages.ExtractTempRefactoring_convention);
- return createOkStatus();
- }
-
- private IStatus validateDefaultValue() {
- if (fDefaultValue == null)
- return null;
- String defaultValue= fDefaultValue.getText();
- if (defaultValue.length() == 0)
- return createErrorStatus(RefactoringMessages.ParameterEditDialog_defaultValue_error);
- if (ChangeSignatureRefactoring.isValidExpression(defaultValue))
- return createOkStatus();
- String msg= Messages.format(RefactoringMessages.ParameterEditDialog_defaultValue_invalid, new String[]{defaultValue});
- return createErrorStatus(msg);
-
- }
-
- private Status createOkStatus() {
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- }
-
- private Status createWarningStatus(String message) {
- return new Status(IStatus.WARNING, JavaScriptPlugin.getPluginId(), IStatus.WARNING, message, null);
- }
-
- private Status createErrorStatus(String message) {
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), IStatus.ERROR, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PromoteTempWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PromoteTempWizard.java
deleted file mode 100644
index ee588069..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PromoteTempWizard.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.FieldNameProcessor;
-
-public class PromoteTempWizard extends RefactoringWizard {
-
- public PromoteTempWizard(PromoteTempToFieldRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.ConvertLocalToField_title);
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages(){
- addPage(new PromoteTempInputPage());
- }
-
- private static class PromoteTempInputPage extends UserInputWizardPage {
-
- private static final String DESCRIPTION = RefactoringMessages.PromoteTempInputPage_description;
- public static final String PAGE_NAME= "PromoteTempInputPage";//$NON-NLS-1$
- private static final String[] RADIO_BUTTON_LABELS= {
- RefactoringMessages.PromoteTempInputPage_Field_declaration,
- RefactoringMessages.PromoteTempInputPage_Current_method,
- RefactoringMessages.PromoteTempInputPage_constructors};
- private static final Integer[] RADIO_BUTTON_DATA= {
- new Integer(PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD),
- new Integer(PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD),
- new Integer(PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR)};
- private Button fDeclareStaticCheckbox;
- private Button fDeclareFinalCheckbox;
- private Button[] fInitializeInRadioButtons;
- private Text fNameField;
-
- public PromoteTempInputPage() {
- super(PAGE_NAME);
- setDescription(DESCRIPTION);
- }
-
- public void createControl(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- result.setLayout(layout);
-
- addFieldNameField(result);
- addVisibilityControl(result);
- addInitizeInRadioButtonGroup(result);
- addDeclareStaticCheckbox(result);
- addDeclareFinalCheckbox(result);
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROMOTE_TEMP_TO_FIELD_WIZARD_PAGE);
- }
-
- private void addFieldNameField(Composite result) {
- Label nameLabel= new Label(result, SWT.NONE);
- nameLabel.setText(RefactoringMessages.PromoteTempInputPage_Field_name);
- nameLabel.setLayoutData(new GridData());
-
- String[] guessedFieldNames= getPromoteTempRefactoring().guessFieldNames();
-
- fNameField = new Text(result, SWT.BORDER | SWT.SINGLE);
- fNameField.setText(guessedFieldNames[0]);
- fNameField.selectAll();
- fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fNameField.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- PromoteTempInputPage.this.getPromoteTempRefactoring().setFieldName(fNameField.getText());
- PromoteTempInputPage.this.updateStatus();
- }
- });
- IContentAssistProcessor processor= new FieldNameProcessor(guessedFieldNames, getPromoteTempRefactoring());
- ControlContentAssistHelper.createTextContentAssistant(fNameField, processor);
- TextFieldNavigationHandler.install(fNameField);
- }
-
- private void updateStatus() {
- setPageComplete(getPromoteTempRefactoring().validateInput());
- }
-
- private void addInitizeInRadioButtonGroup(Composite result) {
- GridData gd;
- Group initializeIn= new Group(result, SWT.NONE);
- initializeIn.setText(RefactoringMessages.PromoteTempInputPage_Initialize);
- initializeIn.setLayout(new GridLayout());
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- initializeIn.setLayoutData(gd);
-
- Assert.isTrue(RADIO_BUTTON_LABELS.length == RADIO_BUTTON_DATA.length);
- fInitializeInRadioButtons= new Button[RADIO_BUTTON_LABELS.length];
- for (int i= 0; i < RADIO_BUTTON_LABELS.length; i++) {
- Integer dataItem= RADIO_BUTTON_DATA[i];
- fInitializeInRadioButtons[i]= new Button(initializeIn, SWT.RADIO);
- fInitializeInRadioButtons[i].setEnabled(canEnable(dataItem.intValue()));
- fInitializeInRadioButtons[i].setText(RADIO_BUTTON_LABELS[i]);
- fInitializeInRadioButtons[i].setSelection(dataItem.intValue() == getPromoteTempRefactoring().getInitializeIn());
- fInitializeInRadioButtons[i].setLayoutData(new GridData());
- fInitializeInRadioButtons[i].setData(dataItem);
- final int j= i;
- fInitializeInRadioButtons[i].addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getPromoteTempRefactoring().setInitializeIn(getDataAsInt(fInitializeInRadioButtons[j]));
- updateButtonsEnablement();
- }
- });
- }
- }
-
- private void updateButtonsEnablement() {
- fDeclareFinalCheckbox.setEnabled(getPromoteTempRefactoring().canEnableSettingFinal());
- fDeclareStaticCheckbox.setEnabled(getPromoteTempRefactoring().canEnableSettingStatic());
- for (int i= 0; i < fInitializeInRadioButtons.length; i++) {
- fInitializeInRadioButtons[i].setEnabled(canEnable(getDataAsInt(fInitializeInRadioButtons[i])));
- }
- }
-
- private static int getDataAsInt(Button button){
- return ((Integer)button.getData()).intValue();
- }
-
- private boolean canEnable(int initializeIn){
- switch(initializeIn){
- case PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR:
- return getPromoteTempRefactoring().canEnableSettingDeclareInConstructors();
- case PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD:
- return getPromoteTempRefactoring().canEnableSettingDeclareInFieldDeclaration();
- case PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD:
- return getPromoteTempRefactoring().canEnableSettingDeclareInMethod();
- default: Assert.isTrue(false); return false;
- }
- }
-
- public void addDeclareStaticCheckbox(Composite result) {
- GridData gd;
- fDeclareStaticCheckbox= new Button(result, SWT.CHECK);
- fDeclareStaticCheckbox.setEnabled(getPromoteTempRefactoring().canEnableSettingStatic());
- fDeclareStaticCheckbox.setSelection(getPromoteTempRefactoring().getDeclareStatic());
- fDeclareStaticCheckbox.setText(RefactoringMessages.PromoteTempInputPage_declare_static);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- fDeclareStaticCheckbox.setLayoutData(gd);
- fDeclareStaticCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getPromoteTempRefactoring().setDeclareStatic(fDeclareStaticCheckbox.getSelection());
- updateButtonsEnablement();
- }
- });
- }
-
- private void addDeclareFinalCheckbox(Composite result) {
- GridData gd;
- fDeclareFinalCheckbox= new Button(result, SWT.CHECK);
- fDeclareFinalCheckbox.setEnabled(getPromoteTempRefactoring().canEnableSettingFinal());
- fDeclareFinalCheckbox.setSelection(getPromoteTempRefactoring().getDeclareFinal());
- fDeclareFinalCheckbox.setText(RefactoringMessages.PromoteTempInputPage_declare_final);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- fDeclareFinalCheckbox.setLayoutData(gd);
- fDeclareFinalCheckbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getPromoteTempRefactoring().setDeclareFinal(fDeclareFinalCheckbox.getSelection());
- updateButtonsEnablement();
- }
- });
- }
-
- private void addVisibilityControl(Composite result) {
- int[] availableVisibilities= getPromoteTempRefactoring().getAvailableVisibilities();
- int currectVisibility= getPromoteTempRefactoring().getVisibility();
- IVisibilityChangeListener visibilityChangeListener= new IVisibilityChangeListener(){
- public void visibilityChanged(int newVisibility) {
- getPromoteTempRefactoring().setVisibility(newVisibility);
- }
-
- public void modifierChanged(int modifier, boolean isChecked) {
- }
- };
- Composite visibilityComposite= VisibilityControlUtil.createVisibilityControl(result, visibilityChangeListener, availableVisibilities, currectVisibility);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- visibilityComposite.setLayoutData(gd);
- }
-
- private PromoteTempToFieldRefactoring getPromoteTempRefactoring(){
- return (PromoteTempToFieldRefactoring)getRefactoring();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible && fNameField != null)
- fNameField.setFocus();
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullPushCheckboxTableViewer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullPushCheckboxTableViewer.java
deleted file mode 100644
index 6bee6fb0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullPushCheckboxTableViewer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.IMemberActionInfo;
-
-class PullPushCheckboxTableViewer extends CheckboxTableViewer{
- public PullPushCheckboxTableViewer(Table table) {
- super(table);
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean)
- */
- protected void doUpdateItem(Widget widget, Object element, boolean fullMap) {
- super.doUpdateItem(widget, element, fullMap);
- if (! (widget instanceof TableItem))
- return;
- TableItem item= (TableItem)widget;
- IMemberActionInfo info= (IMemberActionInfo)element;
- item.setChecked(PullPushCheckboxTableViewer.getCheckState(info));
- Assert.isTrue(item.getChecked() == PullPushCheckboxTableViewer.getCheckState(info));
- }
-
- /*
- * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, java.lang.Object)
- */
- protected void inputChanged(Object input, Object oldInput) {
- super.inputChanged(input, oldInput);
- // XXX workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=9390
- setCheckState((IMemberActionInfo[])input);
- }
-
- private void setCheckState(IMemberActionInfo[] infos) {
- if (infos == null)
- return;
- for (int i= 0; i < infos.length; i++) {
- IMemberActionInfo info= infos[i];
- setChecked(info, PullPushCheckboxTableViewer.getCheckState(info));
- }
- }
-
- private static boolean getCheckState(IMemberActionInfo info) {
- return info.isActive();
- }
-
- /*
- * @see org.eclipse.jface.viewers.Viewer#refresh()
- */
- public void refresh() {
- int topIndex = getTable().getTopIndex();
- super.refresh();
- // XXX workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=9390
- setCheckState((IMemberActionInfo[])getInput());
- if (topIndex < getTable().getItemCount())
- getTable().setTopIndex(topIndex); //see bug 31645
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMemberPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMemberPage.java
deleted file mode 100644
index c651575f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMemberPage.java
+++ /dev/null
@@ -1,978 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ICheckStateListener;
-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.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.HierarchyProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.IMemberActionInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PullUpRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TableLayoutComposite;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-/**
- * Wizard page for pull up refactoring wizards which allows to specify the
- * actions on the members to pull up.
- *
- *
- */
-public class PullUpMemberPage extends UserInputWizardPage {
-
- private class MemberActionCellModifier implements ICellModifier {
-
- public boolean canModify(final Object element, final String property) {
- if (!ACTION_PROPERTY.equals(property))
- return false;
- return ((MemberActionInfo) element).isEditable();
- }
-
- public Object getValue(final Object element, final String property) {
- if (!ACTION_PROPERTY.equals(property))
- return null;
- final MemberActionInfo info= (MemberActionInfo) element;
- return new Integer(info.getAction());
- }
-
- public void modify(final Object element, final String property, final Object value) {
- if (!ACTION_PROPERTY.equals(property))
- return;
- final int action= ((Integer) value).intValue();
- MemberActionInfo info;
- if (element instanceof Item) {
- info= (MemberActionInfo) ((Item) element).getData();
- } else
- info= (MemberActionInfo) element;
- if (!canModify(info, property))
- return;
- Assert.isTrue(info.isMethodInfo());
- info.setAction(action);
- updateWizardPage(null, true);
- }
- }
-
- private class MemberActionInfo implements IMemberActionInfo {
-
- private static final int NO_ACTION= 2;
-
- private int fAction;
-
- private final IMember fMember;
-
- public MemberActionInfo(final IMember member, final int action) {
- Assert.isTrue((member instanceof IFunction) || (member instanceof IField) || (member instanceof IType));
- assertAction(member, action);
- fMember= member;
- fAction= action;
- }
-
- private void assertAction(final IMember member, final int action) {
- if (member instanceof IFunction) {
- try {
- Assert.isTrue(action != DECLARE_ABSTRACT_ACTION || !JdtFlags.isStatic(member));
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- Assert.isTrue(action == NO_ACTION || action == DECLARE_ABSTRACT_ACTION || action == PULL_UP_ACTION);
- } else {
- Assert.isTrue(action == NO_ACTION || action == PULL_UP_ACTION);
- }
- }
-
- public int getAction() {
- return fAction;
- }
-
- public String getActionLabel() {
- switch (fAction) {
- case PULL_UP_ACTION:
- return getPullUpActionLabel();
- case DECLARE_ABSTRACT_ACTION:
- return getDeclareAbstractActionLabel();
- case NO_ACTION:
- return ""; //$NON-NLS-1$
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
- public String[] getAllowedLabels() {
- if (isFieldInfo())
- return new String[] { ""}; //$NON-NLS-1$
- else if (isMethodInfo())
- return METHOD_LABELS;
- else if (isTypeInfo())
- return TYPE_LABELS;
- else {
- Assert.isTrue(false);
- return null;
- }
- }
-
- public IMember getMember() {
- return fMember;
- }
-
- public boolean isActive() {
- return getAction() != NO_ACTION;
- }
-
- public boolean isEditable() {
- if (fAction == NO_ACTION)
- return false;
- if (!isMethodInfo())
- return false;
- final IFunction method= (IFunction) fMember;
- try {
- return !JdtFlags.isStatic(method);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return false;
- }
- }
-
- public boolean isFieldInfo() {
- return getMember() instanceof IField;
- }
-
- public boolean isMethodInfo() {
- return getMember() instanceof IFunction;
- }
-
- public boolean isTypeInfo() {
- return getMember() instanceof IType;
- }
-
- public void setAction(final int action) {
- assertAction(fMember, action);
- fAction= action;
- }
- }
-
- private static class MemberActionInfoLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- private final ILabelProvider fLabelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT | JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
-
- public void dispose() {
- super.dispose();
- fLabelProvider.dispose();
- }
-
- public Image getColumnImage(final Object element, final int columnIndex) {
- final MemberActionInfo info= (MemberActionInfo) element;
- switch (columnIndex) {
- case MEMBER_COLUMN:
- return fLabelProvider.getImage(info.getMember());
- case ACTION_COLUMN:
- return null;
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
- public String getColumnText(final Object element, final int columnIndex) {
- final MemberActionInfo info= (MemberActionInfo) element;
- switch (columnIndex) {
- case MEMBER_COLUMN:
- return fLabelProvider.getText(info.getMember());
- case ACTION_COLUMN:
- return info.getActionLabel();
- default:
- Assert.isTrue(false);
- return null;
- }
- }
- }
-
- private static final int ACTION_COLUMN= 1;
-
- private static final String ACTION_PROPERTY= "action"; //$NON-NLS-1$
-
- protected static final int DECLARE_ABSTRACT_ACTION= 1;
-
- private static final int MEMBER_COLUMN= 0;
-
- private static final String MEMBER_PROPERTY= "member"; //$NON-NLS-1$
-
- protected static final int PULL_UP_ACTION= 0;
-
- private static final String SETTING_INSTANCEOF= "InstanceOf"; //$NON-NLS-1$
-
- private static final String SETTING_REPLACE= "Replace"; //$NON-NLS-1$
-
- private static int getEditableCount(final MemberActionInfo[] infos) {
- int result= 0;
- for (int i= 0; i < infos.length; i++) {
- final MemberActionInfo info= infos[i];
- if (info.isEditable())
- result++;
- }
- return result;
- }
-
- private static void putToStringMapping(final Map result, final String[] actionLabels, final int actionIndex) {
- result.put(actionLabels[actionIndex], new Integer(actionIndex));
- }
-
- private static void setActionForInfos(final MemberActionInfo[] infos, final int action) {
- for (int i= 0; i < infos.length; i++) {
- infos[i].setAction(action);
- }
- }
-
- private Button fAddButton;
-
- protected IType[] fCandidateTypes= {};
-
- private Button fCreateStubsButton;
-
- private Button fDeselectAllButton;
-
- private Button fEditButton;
-
- private Button fInstanceofButton;
-
- private Label fLabel;
-
- private Button fReplaceButton;
-
- private Button fSelectAllButton;
-
- private Label fStatusLine;
-
- protected final PullUpMethodPage fSuccessorPage;
-
- private Combo fSuperTypesCombo;
-
- private CheckboxTableViewer fTableViewer;
-
- protected final String[] METHOD_LABELS;
-
- protected final String[] TYPE_LABELS;
-
- public PullUpMemberPage(final String name, final PullUpMethodPage page) {
- super(name);
- fSuccessorPage= page;
- setDescription(RefactoringMessages.PullUpInputPage1_page_message);
- METHOD_LABELS= new String[2];
- METHOD_LABELS[PULL_UP_ACTION]= RefactoringMessages.PullUpInputPage1_pull_up;
- METHOD_LABELS[DECLARE_ABSTRACT_ACTION]= RefactoringMessages.PullUpInputPage1_declare_abstract;
-
- TYPE_LABELS= new String[1];
- TYPE_LABELS[PULL_UP_ACTION]= RefactoringMessages.PullUpInputPage1_pull_up;
- }
-
- private boolean areAllMembersMarkedAsPullUp() {
- return getMembersForAction(PULL_UP_ACTION).length == getTableInput().length;
- }
-
- protected boolean areAllMembersMarkedAsWithNoAction() {
- return getMembersForAction(MemberActionInfo.NO_ACTION).length == getTableInput().length;
- }
-
- private MemberActionInfo[] asMemberActionInfos() {
- final PullUpRefactoringProcessor processor= getPullUpRefactoring().getPullUpProcessor();
- final List toPullUp= Arrays.asList(processor.getMembersToMove());
- final IMember[] members= processor.getPullableMembersOfDeclaringType();
- final MemberActionInfo[] result= new MemberActionInfo[members.length];
- for (int i= 0; i < members.length; i++) {
- final IMember member= members[i];
- if (toPullUp.contains(member))
- result[i]= new MemberActionInfo(member, PULL_UP_ACTION);
- else
- result[i]= new MemberActionInfo(member, MemberActionInfo.NO_ACTION);
- }
- return result;
- }
-
- public boolean canFlipToNextPage() {
- if (getMethodsForAction(PULL_UP_ACTION).length == 0)
- return isPageComplete();
- return super.canFlipToNextPage();
- }
-
- private void checkAdditionalRequired() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, false, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor pm) throws InvocationTargetException {
- try {
- checkPullUp(getPullUpRefactoring().getPullUpProcessor().getAdditionalRequiredMembersToPullUp(pm), true);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.PullUpInputPage_pull_Up, RefactoringMessages.PullUpInputPage_exception);
- } catch (InterruptedException e) {
- Assert.isTrue(false);
- }
- }
-
- protected void checkPageCompletionStatus(final boolean displayErrors) {
- if (areAllMembersMarkedAsWithNoAction()) {
- if (displayErrors)
- setErrorMessage(getNoMembersMessage());
- setPageComplete(false);
- } else {
- setErrorMessage(null);
- setPageComplete(true);
- }
- fSuccessorPage.fireSettingsChanged();
- }
-
- private void checkPullUp(final IMember[] elements, final boolean displayErrors) {
- setActionForMembers(elements, PULL_UP_ACTION);
- updateWizardPage(null, displayErrors);
- }
-
- private void createButtonComposite(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- final GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- composite.setLayout(gl);
-
- fSelectAllButton= new Button(composite, SWT.PUSH);
- fSelectAllButton.setText(RefactoringMessages.PullUpWizard_select_all_label);
- fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fSelectAllButton.setEnabled(true);
- SWTUtil.setButtonDimensionHint(fSelectAllButton);
- fSelectAllButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- final IMember[] members= getMembers();
- setActionForMembers(members, PULL_UP_ACTION);
- updateWizardPage(null, true);
- }
- });
-
- fDeselectAllButton= new Button(composite, SWT.PUSH);
- fDeselectAllButton.setText(RefactoringMessages.PullUpWizard_deselect_all_label);
- fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fDeselectAllButton.setEnabled(false);
- SWTUtil.setButtonDimensionHint(fDeselectAllButton);
- fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- final IMember[] members= getMembers();
- setActionForMembers(members, MemberActionInfo.NO_ACTION);
- updateWizardPage(null, true);
- }
- });
-
- fEditButton= new Button(composite, SWT.PUSH);
- fEditButton.setText(RefactoringMessages.PullUpInputPage1_Edit);
-
- final GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.verticalIndent= new PixelConverter(parent).convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- fEditButton.setLayoutData(data);
- fEditButton.setEnabled(false);
- SWTUtil.setButtonDimensionHint(fEditButton);
- fEditButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- editSelectedMembers();
- }
- });
-
- fAddButton= new Button(composite, SWT.PUSH);
- fAddButton.setText(RefactoringMessages.PullUpInputPage1_Add_Required);
- fAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(fAddButton);
- fAddButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- checkAdditionalRequired();
- }
- });
- }
-
- public void createControl(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- createSuperTypeControl(composite);
- createSpacer(composite);
- createSuperTypeCheckbox(composite);
- createInstanceOfCheckbox(composite, layout.marginWidth);
- createStubCheckbox(composite);
- createSpacer(composite);
- createMemberTableLabel(composite);
- createMemberTableComposite(composite);
- createStatusLine(composite);
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- initializeEnablement();
- initializeCheckboxes();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PULL_UP_WIZARD_PAGE);
- }
-
- protected void createInstanceOfCheckbox(final Composite result, final int margin) {
- final HierarchyProcessor processor= getPullUpRefactoring().getPullUpProcessor();
- fInstanceofButton= new Button(result, SWT.CHECK);
- fInstanceofButton.setSelection(false);
- final GridData gd= new GridData();
- gd.horizontalIndent= (margin + fInstanceofButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- gd.horizontalSpan= 2;
- fInstanceofButton.setLayoutData(gd);
- fInstanceofButton.setText(getInstanceofButtonLabel());
- processor.setInstanceOf(fInstanceofButton.getSelection());
- fInstanceofButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent e) {
- processor.setInstanceOf(fInstanceofButton.getSelection());
- }
- });
- fReplaceButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent e) {
- fInstanceofButton.setEnabled(fReplaceButton.getSelection());
- }
- });
- }
-
- private void createMemberTable(final Composite parent) {
- final TableLayoutComposite layouter= new TableLayoutComposite(parent, SWT.NONE);
- layouter.addColumnData(new ColumnWeightData(60, true));
- layouter.addColumnData(new ColumnWeightData(40, true));
-
- final Table table= new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- final GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= SWTUtil.getTableHeightHint(table, getTableRowCount());
- gd.widthHint= convertWidthInCharsToPixels(30);
- layouter.setLayoutData(gd);
-
- final TableLayout tableLayout= new TableLayout();
- table.setLayout(tableLayout);
-
- final TableColumn column0= new TableColumn(table, SWT.NONE);
- column0.setText(RefactoringMessages.PullUpInputPage1_Member);
-
- final TableColumn column1= new TableColumn(table, SWT.NONE);
- column1.setText(RefactoringMessages.PullUpInputPage1_Action);
-
- fTableViewer= new PullPushCheckboxTableViewer(table);
- fTableViewer.setUseHashlookup(true);
- fTableViewer.setContentProvider(new ArrayContentProvider());
- fTableViewer.setLabelProvider(new MemberActionInfoLabelProvider());
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- updateButtonEnablement(event.getSelection());
- }
- });
- fTableViewer.addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(final CheckStateChangedEvent event) {
- final boolean checked= event.getChecked();
- final MemberActionInfo info= (MemberActionInfo) event.getElement();
- if (checked)
- info.setAction(PULL_UP_ACTION);
- else
- info.setAction(MemberActionInfo.NO_ACTION);
- updateWizardPage(null, true);
- }
- });
- fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(final DoubleClickEvent event) {
- editSelectedMembers();
- }
- });
-
- setTableInput();
- checkPullUp(getPullUpRefactoring().getPullUpProcessor().getMembersToMove(), false);
- setupCellEditors(table);
- }
-
- protected void createMemberTableComposite(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- final GridData data= new GridData(GridData.FILL_BOTH);
- data.horizontalSpan= 2;
- composite.setLayoutData(data);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createMemberTable(composite);
- createButtonComposite(composite);
- }
-
- protected void createMemberTableLabel(final Composite parent) {
- fLabel= new Label(parent, SWT.NONE);
- fLabel.setText(RefactoringMessages.PullUpInputPage1_Specify_actions);
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- fLabel.setLayoutData(data);
- }
-
- protected void createSpacer(final Composite parent) {
- final Label label= new Label(parent, SWT.NONE);
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- data.heightHint= convertHeightInCharsToPixels(1) / 2;
- label.setLayoutData(data);
- }
-
- protected void createStatusLine(final Composite composite) {
- fStatusLine= new Label(composite, SWT.NONE);
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- updateStatusLine();
- fStatusLine.setLayoutData(data);
- }
-
- // String -> Integer
- private Map createStringMappingForSelectedMembers() {
- final Map result= new HashMap();
- putToStringMapping(result, METHOD_LABELS, PULL_UP_ACTION);
- putToStringMapping(result, METHOD_LABELS, DECLARE_ABSTRACT_ACTION);
- return result;
- }
-
- protected void createStubCheckbox(final Composite parent) {
- fCreateStubsButton= new Button(parent, SWT.CHECK);
- fCreateStubsButton.setText(getCreateStubsButtonLabel());
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- fCreateStubsButton.setLayoutData(data);
- fCreateStubsButton.setEnabled(false);
- fCreateStubsButton.setSelection(getPullUpRefactoring().getPullUpProcessor().getCreateMethodStubs());
- }
-
- protected void createSuperTypeCheckbox(final Composite parent) {
- fReplaceButton= new Button(parent, SWT.CHECK);
- fReplaceButton.setText(getReplaceButtonLabel());
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- fReplaceButton.setLayoutData(data);
- fReplaceButton.setEnabled(true);
- fReplaceButton.setSelection(getPullUpRefactoring().getPullUpProcessor().isReplace());
- }
-
- private void createSuperTypeCombo(final IProgressMonitor pm, final Composite parent) throws JavaScriptModelException {
- final Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.PullUpInputPage1_Select_destination);
- label.setLayoutData(new GridData());
-
- fSuperTypesCombo= new Combo(parent, SWT.READ_ONLY);
- fCandidateTypes= getPullUpRefactoring().getPullUpProcessor().getCandidateTypes(new RefactoringStatus(), pm);
- if (fCandidateTypes.length > 0) {
- for (int i= 0; i < fCandidateTypes.length; i++) {
- final String comboLabel= JavaModelUtil.getFullyQualifiedName(fCandidateTypes[i]);
- fSuperTypesCombo.add(comboLabel);
- }
- fSuperTypesCombo.select(fCandidateTypes.length - 1);
- fSuperTypesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- }
-
- protected void createSuperTypeControl(final Composite parent) {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, false, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor monitor) throws InvocationTargetException {
- try {
- createSuperTypeCombo(monitor, parent);
- } catch (JavaScriptModelException exception) {
- throw new InvocationTargetException(exception);
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException exception) {
- ExceptionHandler.handle(exception, getShell(), RefactoringMessages.PullUpInputPage_pull_Up, RefactoringMessages.PullUpInputPage_exception);
- } catch (InterruptedException exception) {
- Assert.isTrue(false);
- }
- }
-
- public void dispose() {
- fInstanceofButton= null;
- fReplaceButton= null;
- fTableViewer= null;
- super.dispose();
- }
-
- private void editSelectedMembers() {
- if (!fEditButton.isEnabled())
- return;
-
- final ISelection preserved= fTableViewer.getSelection();
- try {
- final String shellTitle= RefactoringMessages.PullUpInputPage1_Edit_members;
- final String labelText= RefactoringMessages.PullUpInputPage1_Mark_selected_members;
- final Map stringMapping= createStringMappingForSelectedMembers();
- final String[] keys= (String[]) stringMapping.keySet().toArray(new String[stringMapping.keySet().size()]);
- Arrays.sort(keys);
- final int initialSelectionIndex= getInitialSelectionIndexForEditDialog(stringMapping, keys);
- final ComboSelectionDialog dialog= new ComboSelectionDialog(getShell(), shellTitle, labelText, keys, initialSelectionIndex);
- dialog.setBlockOnOpen(true);
- if (dialog.open() == Window.CANCEL)
- return;
- final int action= ((Integer) stringMapping.get(dialog.getSelectedString())).intValue();
- setActionForInfos(getSelectedMembers(), action);
- } finally {
- updateWizardPage(preserved, true);
- }
- }
-
- private boolean enableEditButton(final IStructuredSelection ss) {
- if (ss.isEmpty() || ss.size() == 0)
- return false;
- return ss.size() == getEditableCount(getSelectedMembers());
- }
-
- private MemberActionInfo[] getActiveInfos() {
- final MemberActionInfo[] infos= getTableInput();
- final List result= new ArrayList(infos.length);
- for (int i= 0; i < infos.length; i++) {
- final MemberActionInfo info= infos[i];
- if (info.isActive())
- result.add(info);
- }
- return (MemberActionInfo[]) result.toArray(new MemberActionInfo[result.size()]);
- }
-
- private int getCommonActionCodeForSelectedInfos() {
- final MemberActionInfo[] infos= getSelectedMembers();
- if (infos.length == 0)
- return -1;
-
- final int code= infos[0].getAction();
- for (int i= 0; i < infos.length; i++) {
- if (code != infos[i].getAction())
- return -1;
- }
- return code;
- }
-
- protected String getCreateStubsButtonLabel() {
- return RefactoringMessages.PullUpInputPage1_Create_stubs;
- }
-
- protected String getDeclareAbstractActionLabel() {
- return RefactoringMessages.PullUpInputPage1_declare_abstract;
- }
-
- public IType getDestinationType() {
- final int index= fSuperTypesCombo.getSelectionIndex();
- if (index >= 0)
- return fCandidateTypes[index];
- return null;
- }
-
- private int getInitialSelectionIndexForEditDialog(final Map stringMapping, final String[] keys) {
- final int commonActionCode= getCommonActionCodeForSelectedInfos();
- if (commonActionCode == -1)
- return 0;
- for (final Iterator iter= stringMapping.keySet().iterator(); iter.hasNext();) {
- final String key= (String) iter.next();
- final int action= ((Integer) stringMapping.get(key)).intValue();
- if (commonActionCode == action) {
- for (int i= 0; i < keys.length; i++) {
- if (key.equals(keys[i]))
- return i;
- }
- Assert.isTrue(false);
- }
- }
- return 0;
- }
-
- protected String getInstanceofButtonLabel() {
- return RefactoringMessages.PullUpInputPage1_label_use_in_instanceof;
- }
-
- private IMember[] getMembers() {
- final MemberActionInfo[] infos= getTableInput();
- final List result= new ArrayList(infos.length);
- for (int index= 0; index < infos.length; index++) {
- result.add(infos[index].getMember());
- }
- return (IMember[]) result.toArray(new IMember[result.size()]);
- }
-
- private IMember[] getMembersForAction(final int action) {
- final MemberActionInfo[] infos= getTableInput();
- final List result= new ArrayList(infos.length);
- for (int index= 0; index < infos.length; index++) {
- if (infos[index].getAction() == action)
- result.add(infos[index].getMember());
- }
- return (IMember[]) result.toArray(new IMember[result.size()]);
- }
-
- private IFunction[] getMethodsForAction(final int action) {
- final MemberActionInfo[] infos= getTableInput();
- final List list= new ArrayList(infos.length);
- for (int index= 0; index < infos.length; index++) {
- if (infos[index].isMethodInfo() && infos[index].getAction() == action) {
- list.add(infos[index].getMember());
- }
- }
- return (IFunction[]) list.toArray(new IFunction[list.size()]);
- }
-
- public IWizardPage getNextPage() {
- initializeRefactoring();
- storeDialogSettings();
- if (getMethodsForAction(PULL_UP_ACTION).length == 0)
- return computeSuccessorPage();
- try {
- final IType destination= getDestinationType();
- if (destination != null && destination.isInterface())
- return computeSuccessorPage();
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- return super.getNextPage();
- }
-
- protected String getNoMembersMessage() {
- return RefactoringMessages.PullUpInputPage1_Select_members_to_pull_up;
- }
-
- protected String getPullUpActionLabel() {
- return RefactoringMessages.PullUpInputPage1_pull_up;
- }
-
- private PullUpRefactoring getPullUpRefactoring() {
- return (PullUpRefactoring) getRefactoring();
- }
-
- protected String getReplaceButtonLabel() {
- return RefactoringMessages.PullUpInputPage1_label_use_destination;
- }
-
- private MemberActionInfo[] getSelectedMembers() {
- Assert.isTrue(fTableViewer.getSelection() instanceof IStructuredSelection);
- final IStructuredSelection structured= (IStructuredSelection) fTableViewer.getSelection();
- final List result= structured.toList();
- return (MemberActionInfo[]) result.toArray(new MemberActionInfo[result.size()]);
- }
-
- private MemberActionInfo[] getTableInput() {
- return (MemberActionInfo[]) fTableViewer.getInput();
- }
-
- protected int getTableRowCount() {
- return 10;
- }
-
- private void initializeCheckBox(final Button checkbox, final String property, final boolean def) {
- final String s= JavaScriptPlugin.getDefault().getDialogSettings().get(property);
- if (s != null)
- checkbox.setSelection(new Boolean(s).booleanValue());
- else
- checkbox.setSelection(def);
- }
-
- protected void initializeCheckboxes() {
- initializeCheckBox(fReplaceButton, SETTING_REPLACE, true);
- initializeCheckBox(fInstanceofButton, SETTING_INSTANCEOF, false);
- }
-
- protected void initializeEnablement() {
- MemberActionInfo[] infos= asMemberActionInfos();
- final boolean enabled= infos.length > 0;
- fTableViewer.getTable().setEnabled(enabled);
- fStatusLine.setEnabled(enabled);
- fAddButton.setEnabled(enabled);
- fLabel.setEnabled(enabled);
- }
-
- private void initializeRefactoring() {
- final PullUpRefactoringProcessor processor= getPullUpRefactoring().getPullUpProcessor();
- processor.setMembersToMove(getMembersForAction(PULL_UP_ACTION));
- processor.setAbstractMethods(getMethodsForAction(DECLARE_ABSTRACT_ACTION));
- final IType destination= getDestinationType();
- if (destination != null)
- processor.setDestinationType(destination);
- processor.setCreateMethodStubs(fCreateStubsButton.getSelection());
- processor.setReplace(fReplaceButton.getSelection());
- processor.setInstanceOf(fInstanceofButton.getSelection());
- processor.setDeletedMethods(getMethodsForAction(PULL_UP_ACTION));
- }
-
- protected boolean performFinish() {
- initializeRefactoring();
- storeDialogSettings();
- return super.performFinish();
- }
-
- private void setActionForMembers(final IMember[] members, final int action) {
- final MemberActionInfo[] infos= getTableInput();
- for (int i= 0; i < members.length; i++) {
- for (int j= 0; j < infos.length; j++) {
- if (infos[j].getMember().equals(members[i]))
- infos[j].setAction(action);
- }
- }
- }
-
- private void setTableInput() {
- fTableViewer.setInput(asMemberActionInfos());
- }
-
- private void setupCellEditors(final Table table) {
- final ComboBoxCellEditor editor= new ComboBoxCellEditor();
- editor.setStyle(SWT.READ_ONLY);
- fTableViewer.setCellEditors(new CellEditor[] { null, editor});
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- if (editor.getControl() == null & !table.isDisposed())
- editor.create(table);
- final ISelection sel= event.getSelection();
- if (!(sel instanceof IStructuredSelection))
- return;
- final IStructuredSelection structured= (IStructuredSelection) sel;
- if (structured.size() != 1)
- return;
- final MemberActionInfo info= (MemberActionInfo) structured.getFirstElement();
- editor.setItems(info.getAllowedLabels());
- editor.setValue(new Integer(info.getAction()));
- }
- });
-
- final ICellModifier cellModifier= new MemberActionCellModifier();
- fTableViewer.setCellModifier(cellModifier);
- fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY});
- }
-
- public void setVisible(final boolean visible) {
- super.setVisible(visible);
- if (visible) {
- try {
- getPullUpRefactoring().getPullUpProcessor().resetEnvironment();
- } finally {
- fTableViewer.setSelection(new StructuredSelection(getActiveInfos()), true);
- fTableViewer.getControl().setFocus();
- }
- }
- }
-
- private void storeDialogSettings() {
- final IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings();
- settings.put(SETTING_REPLACE, fReplaceButton.getSelection());
- settings.put(SETTING_INSTANCEOF, fInstanceofButton.getSelection());
- }
-
- private void updateButtonEnablement(final ISelection selection) {
- if (fEditButton != null)
- fEditButton.setEnabled(enableEditButton((IStructuredSelection) selection));
- fCreateStubsButton.setEnabled(getMethodsForAction(DECLARE_ABSTRACT_ACTION).length != 0);
- fInstanceofButton.setEnabled(fReplaceButton.getSelection());
- if (fSelectAllButton != null)
- fSelectAllButton.setEnabled(!areAllMembersMarkedAsPullUp());
- if (fDeselectAllButton != null)
- fDeselectAllButton.setEnabled(!areAllMembersMarkedAsWithNoAction());
- }
-
- private void updateStatusLine() {
- if (fStatusLine == null)
- return;
- final int selected= fTableViewer.getCheckedElements().length;
- final String[] keys= { String.valueOf(selected)};
- final String msg= Messages.format(RefactoringMessages.PullUpInputPage1_status_line, keys);
- fStatusLine.setText(msg);
- }
-
- private void updateWizardPage(final ISelection selection, final boolean displayErrors) {
- fTableViewer.refresh();
- if (selection != null) {
- fTableViewer.getControl().setFocus();
- fTableViewer.setSelection(selection);
- }
- checkPageCompletionStatus(displayErrors);
- updateButtonEnablement(fTableViewer.getSelection());
- updateStatusLine();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMethodPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMethodPage.java
deleted file mode 100644
index 3f4e3a0d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpMethodPage.java
+++ /dev/null
@@ -1,562 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeHierarchy;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.HierarchyProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PullUpRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.Strings;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-/**
- * Wizard page for pull up refactoring wizards which allows to specify the
- * methods to be deleted in subtypes after pull up.
- *
- *
- */
-public class PullUpMethodPage extends UserInputWizardPage {
-
- private static class PullUpFilter extends ViewerFilter {
-
- private static boolean anySubtypeCanBeShown(final IType type, final Map typeToMemberArray, final ITypeHierarchy hierarchy) {
- final IType[] subTypes= hierarchy.getSubtypes(type);
- for (int i= 0; i < subTypes.length; i++) {
- if (canBeShown(subTypes[i], typeToMemberArray, hierarchy))
- return true;
- }
- return false;
- }
-
- private static boolean canBeShown(final IType type, final Map typeToMemberArray, final ITypeHierarchy hierarchy) {
- if (typeToMemberArray.containsKey(type))
- return true;
- return anySubtypeCanBeShown(type, typeToMemberArray, hierarchy);
- }
-
- private static Set computeShowableSubtypesOfMainType(final ITypeHierarchy hierarchy, final Map typeToMemberArray) {
- final Set result= new HashSet();
- final IType[] subtypes= hierarchy.getAllSubtypes(hierarchy.getType());
- for (int i= 0; i < subtypes.length; i++) {
- final IType subtype= subtypes[i];
- if (canBeShown(subtype, typeToMemberArray, hierarchy))
- result.add(subtype);
- }
- return result;
- }
-
- private static Set computeTypesToShow(final ITypeHierarchy hierarchy, final Map typeToMemberArray) {
- final Set typesToShow= new HashSet();
- typesToShow.add(hierarchy.getType());
- typesToShow.addAll(computeShowableSubtypesOfMainType(hierarchy, typeToMemberArray));
- return typesToShow;
- }
-
- private final Set fTypesToShow;
-
- public PullUpFilter(final ITypeHierarchy hierarchy, final IMember[] members) {
- // IType -> IMember[]
- final Map map= PullUpMethodPage.createTypeToMemberArrayMapping(members);
- fTypesToShow= computeTypesToShow(hierarchy, map);
- }
-
- public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
- if (element instanceof IFunction)
- return true;
- return fTypesToShow.contains(element);
- }
- }
-
- private static class PullUpHierarchyContentProvider implements ITreeContentProvider {
-
- private IType fDeclaringType;
-
- private ITypeHierarchy fHierarchy;
-
- private Map fTypeToMemberArray; // IType -> IMember[]
-
- public PullUpHierarchyContentProvider(final IType declaringType, final IMember[] members) {
- fDeclaringType= declaringType;
- fTypeToMemberArray= PullUpMethodPage.createTypeToMemberArrayMapping(members);
- }
-
- public void dispose() {
- fHierarchy= null;
- fTypeToMemberArray.clear();
- fTypeToMemberArray= null;
- fDeclaringType= null;
- }
-
- public Object[] getChildren(final Object parentElement) {
- if (parentElement instanceof IType)
- return getSubclassesAndMembers((IType) parentElement);
- else
- return new Object[0];
- }
-
- public Object[] getElements(final Object inputElement) {
- Assert.isTrue(inputElement == null || inputElement instanceof ITypeHierarchy);
- return new IType[] { fHierarchy.getType()};
- }
-
- private IMember[] getMembers(final IType type) {
- if (fTypeToMemberArray.containsKey(type))
- return (IMember[]) (fTypeToMemberArray.get(type));
- else
- return new IMember[0];
- }
-
- public Object getParent(final Object element) {
- if (element instanceof IType)
- return fHierarchy.getSuperclass((IType) element);
- if (element instanceof IMember)
- return ((IMember) element).getDeclaringType();
- Assert.isTrue(false, "Should not get here"); //$NON-NLS-1$
- return null;
- }
-
- private IType[] getSubclasses(final IType type) {
- if (type.equals(fDeclaringType))
- return new IType[0];
- return fHierarchy.getSubclasses(type);
- }
-
- private Object[] getSubclassesAndMembers(final IType type) {
- final Set set= new HashSet();
- set.addAll(Arrays.asList(getSubclasses(type)));
- set.addAll(Arrays.asList(getMembers(type)));
- return set.toArray();
- }
-
- public boolean hasChildren(final Object element) {
- if (!(element instanceof IType))
- return false;
- final IType type= (IType) element;
- return (fHierarchy.getAllSubtypes(type).length > 0) || fTypeToMemberArray.containsKey(type);
- }
-
- public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
- Assert.isTrue(newInput == null || newInput instanceof ITypeHierarchy);
- fHierarchy= (ITypeHierarchy) newInput;
- }
- }
-
- private static final String PAGE_NAME= "PullUpMethodPage"; //$NON-NLS-1$
-
- // IType -> IMember[]
- private static Map createTypeToMemberArrayMapping(final IMember[] members) {
- final Map typeToMemberSet= createTypeToMemberSetMapping(members);
-
- final Map typeToMemberArray= new HashMap();
- for (final Iterator iter= typeToMemberSet.keySet().iterator(); iter.hasNext();) {
- final IType type= (IType) iter.next();
- final Set memberSet= (Set) typeToMemberSet.get(type);
- final IMember[] memberArray= (IMember[]) memberSet.toArray(new IMember[memberSet.size()]);
- typeToMemberArray.put(type, memberArray);
- }
- return typeToMemberArray;
- }
-
- // IType -> Set of IMember
- private static Map createTypeToMemberSetMapping(final IMember[] members) {
- final Map typeToMemberSet= new HashMap();
- for (int i= 0; i < members.length; i++) {
- final IMember member= members[i];
- final IType type= member.getDeclaringType();
- if (!typeToMemberSet.containsKey(type))
- typeToMemberSet.put(type, new HashSet());
- ((Set) typeToMemberSet.get(type)).add(member);
- }
- return typeToMemberSet;
- }
-
- private boolean fChangedSettings= true;
-
- private Label fSelectionLabel;
-
- private SourceViewer fSourceViewer;
-
- private ContainerCheckedTreeViewer fTreeViewer;
-
- private Label fTypeHierarchyLabel;
-
- public PullUpMethodPage() {
- super(PAGE_NAME);
- setMessage(RefactoringMessages.PullUpInputPage_select_methods);
- }
-
- private void checkAllParents(final IType parent) {
- final ITypeHierarchy th= getTreeInput();
- final IType root= getTreeInput().getType();
- IType type= parent;
- while (!root.equals(type)) {
- fTreeViewer.setChecked(type, true);
- type= th.getSuperclass(type);
- }
- fTreeViewer.setChecked(root, true);
- }
-
- public void checkPulledUp() {
- uncheckAll();
- final HierarchyProcessor processor= getPullUpRefactoring().getPullUpProcessor();
- fTreeViewer.setCheckedElements(processor.getMembersToMove());
- final IType parent= processor.getDeclaringType();
- fTreeViewer.setChecked(parent, true);
- checkAllParents(parent);
- }
-
- private void createButtonComposite(final Composite superComposite) {
- final Composite buttonComposite= new Composite(superComposite, SWT.NONE);
- buttonComposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
- final GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- buttonComposite.setLayout(layout);
-
- fSelectionLabel= new Label(buttonComposite, SWT.LEFT | SWT.WRAP | SWT.HORIZONTAL);
- GridData data= new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false);
- data.widthHint= convertWidthInCharsToPixels(32);
- fSelectionLabel.setLayoutData(data);
-
- final Button button= new Button(buttonComposite, SWT.PUSH);
- button.setText(RefactoringMessages.PullUpInputPage2_Select);
- button.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent e) {
- checkPulledUp();
- updateSelectionLabel();
- }
- });
- }
-
- public void createControl(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
-
- createTreeAndSourceViewer(composite);
- createButtonComposite(composite);
- setControl(composite);
-
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PULL_UP_WIZARD_PAGE);
- }
-
- private void createHierarchyTreeComposite(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- final GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- layout.horizontalSpacing= 1;
- layout.verticalSpacing= 1;
- composite.setLayout(layout);
-
- createTypeHierarchyLabel(composite);
- createTreeViewer(composite);
- }
-
- private void createSourceViewer(final Composite c) {
- final IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSourceViewer= new JavaSourceViewer(c, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store);
- fSourceViewer.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- fSourceViewer.setEditable(false);
- fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- }
-
- private void createSourceViewerComposite(final Composite parent) {
- final Composite c= new Composite(parent, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- final GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- layout.horizontalSpacing= 1;
- layout.verticalSpacing= 1;
- c.setLayout(layout);
-
- createSourceViewerLabel(c);
- createSourceViewer(c);
- }
-
- private void createSourceViewerLabel(final Composite c) {
- final Label label= new Label(c, SWT.WRAP);
- final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- label.setText(RefactoringMessages.PullUpInputPage2_Source);
- label.setLayoutData(gd);
- }
-
- private void createTreeAndSourceViewer(final Composite superComposite) {
- final SashForm composite= new SashForm(superComposite, SWT.HORIZONTAL);
- initializeDialogUnits(superComposite);
- final GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(20);
- gd.widthHint= convertWidthInCharsToPixels(10);
- composite.setLayoutData(gd);
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- layout.horizontalSpacing= 1;
- layout.verticalSpacing= 1;
- composite.setLayout(layout);
-
- createHierarchyTreeComposite(composite);
- createSourceViewerComposite(composite);
- composite.setWeights(new int[] { 50, 50});
- }
-
- private void createTreeViewer(final Composite composite) {
- final Tree tree= new Tree(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- fTreeViewer= new ContainerCheckedTreeViewer(tree);
- fTreeViewer.setLabelProvider(new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT | JavaScriptElementLabelProvider.SHOW_SMALL_ICONS));
- fTreeViewer.setUseHashlookup(true);
- fTreeViewer.setComparator(new JavaScriptElementComparator());
- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- treeViewerSelectionChanged(event);
- }
- });
- fTreeViewer.addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(final CheckStateChangedEvent event) {
- updateSelectionLabel();
- }
- });
- }
-
- private void createTypeHierarchyLabel(final Composite composite) {
- fTypeHierarchyLabel= new Label(composite, SWT.WRAP);
- final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- fTypeHierarchyLabel.setLayoutData(gd);
- }
-
- public void fireSettingsChanged() {
- fChangedSettings= true;
- }
-
- private IFunction[] getCheckedMethods() {
- final Object[] checked= fTreeViewer.getCheckedElements();
- final List members= new ArrayList(checked.length);
- for (int i= 0; i < checked.length; i++) {
- if (checked[i] instanceof IFunction)
- members.add(checked[i]);
- }
- return (IFunction[]) members.toArray(new IFunction[members.size()]);
- }
-
- private ISourceReference getFirstSelectedSourceReference(final SelectionChangedEvent event) {
- final ISelection s= event.getSelection();
- if (!(s instanceof IStructuredSelection))
- return null;
- final IStructuredSelection ss= (IStructuredSelection) s;
- if (ss.size() != 1)
- return null;
- final Object first= ss.getFirstElement();
- if (!(first instanceof ISourceReference))
- return null;
- return (ISourceReference) first;
- }
-
- public IWizardPage getNextPage() {
- initializeRefactoring();
- return super.getNextPage();
- }
-
- private PullUpRefactoring getPullUpRefactoring() {
- return (PullUpRefactoring) getRefactoring();
- }
-
- private String getSupertypeSignature() {
- return JavaElementUtil.createSignature(getPullUpRefactoring().getPullUpProcessor().getDestinationType());
- }
-
- private ITypeHierarchy getTreeInput() {
- return (ITypeHierarchy) fTreeViewer.getInput();
- }
-
- private void initializeRefactoring() {
- getPullUpRefactoring().getPullUpProcessor().setDeletedMethods(getCheckedMethods());
- }
-
- private void initializeTreeViewer() {
- try {
- getContainer().run(false, false, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor pm) {
- try {
- initializeTreeViewer(pm);
- } finally {
- pm.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.PullUpInputPage_pull_Up, RefactoringMessages.PullUpInputPage_exception);
- } catch (InterruptedException e) {
- Assert.isTrue(false);
- }
- }
-
- private void initializeTreeViewer(final IProgressMonitor pm) {
- try {
- pm.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 2);
- final PullUpRefactoringProcessor processor= getPullUpRefactoring().getPullUpProcessor();
- final IMember[] matchingMethods= processor.getMatchingElements(new SubProgressMonitor(pm, 1), false);
- final ITypeHierarchy hierarchy= processor.getDestinationTypeHierarchy(new SubProgressMonitor(pm, 1));
- removeAllTreeViewFilters();
- fTreeViewer.addFilter(new PullUpFilter(hierarchy, matchingMethods));
- fTreeViewer.setContentProvider(new PullUpHierarchyContentProvider(processor.getDeclaringType(), matchingMethods));
- fTreeViewer.setInput(hierarchy);
- precheckElements(fTreeViewer);
- fTreeViewer.expandAll();
- updateSelectionLabel();
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.PullUpInputPage_pull_up1, RefactoringMessages.PullUpInputPage_exception);
- fTreeViewer.setInput(null);
- } finally {
- pm.done();
- }
- }
-
- protected boolean performFinish() {
- initializeRefactoring();
- return super.performFinish();
- }
-
- private void precheckElements(final ContainerCheckedTreeViewer treeViewer) {
- final IMember[] members= getPullUpRefactoring().getPullUpProcessor().getMembersToMove();
- for (int i= 0; i < members.length; i++) {
- treeViewer.setChecked(members[i], true);
- }
- }
-
- private void removeAllTreeViewFilters() {
- final ViewerFilter[] filters= fTreeViewer.getFilters();
- for (int i= 0; i < filters.length; i++) {
- fTreeViewer.removeFilter(filters[i]);
- }
- }
-
- private void setHierarchyLabelText() {
- final String message= Messages.format(RefactoringMessages.PullUpInputPage_subtypes, getSupertypeSignature());
- fTypeHierarchyLabel.setText(message);
- }
-
- private void setSourceViewerContents(String contents) {
- if (contents != null) {
- final IJavaScriptProject project= getPullUpRefactoring().getPullUpProcessor().getDestinationType().getJavaScriptProject();
- final String[] lines= Strings.convertIntoLines(contents);
- if (lines.length > 0) {
- final int indent= Strings.computeIndentUnits(lines[lines.length - 1], project);
- contents= Strings.changeIndent(contents, indent, project, "", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- final IDocument document= (contents == null) ? new Document() : new Document(contents);
- JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document);
- fSourceViewer.setDocument(document);
- }
-
- public void setVisible(final boolean visible) {
- if (visible && fChangedSettings) {
- fChangedSettings= false;
- initializeTreeViewer();
- setHierarchyLabelText();
- }
- super.setVisible(visible);
- }
-
- private void showInSourceViewer(final ISourceReference selected) throws JavaScriptModelException {
- if (selected == null)
- setSourceViewerContents(null);
- else
- setSourceViewerContents(selected.getSource());
- }
-
- private void treeViewerSelectionChanged(final SelectionChangedEvent event) {
- try {
- showInSourceViewer(getFirstSelectedSourceReference(event));
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.PullUpInputPage_pull_up1, RefactoringMessages.PullUpInputPage_see_log);
- }
- }
-
- private void uncheckAll() {
- final IType root= getTreeInput().getType();
- fTreeViewer.setChecked(root, false);
- }
-
- private void updateSelectionLabel() {
- fSelectionLabel.setText(Messages.format(RefactoringMessages.PullUpInputPage_hierarchyLabal, String.valueOf(getCheckedMethods().length)));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpWizard.java
deleted file mode 100644
index ac13d488..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PullUpWizard.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PullUpRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * Refactoring wizard for the pull up refactoring.
- */
-public final class PullUpWizard extends RefactoringWizard {
-
- /** The page name */
- private static final String PAGE_NAME= "PullUpMemberPage"; //$NON-NLS-1$
-
- /**
- * Creates a new pull up wizard.
- *
- * @param refactoring
- * the pull up refactoring
- */
- public PullUpWizard(final PullUpRefactoring refactoring) {
- super(refactoring, WIZARD_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.PullUpWizard_defaultPageTitle);
- setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_REFACTOR_PULL_UP);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void addUserInputPages() {
- final PullUpMethodPage page= new PullUpMethodPage();
- addPage(new PullUpMemberPage(PullUpWizard.PAGE_NAME, page));
- addPage(page);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PushDownWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PushDownWizard.java
deleted file mode 100644
index 48d43c17..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/PushDownWizard.java
+++ /dev/null
@@ -1,599 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ICheckStateListener;
-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.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.window.Window;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Item;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PushDownRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor.MemberActionInfo;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.util.TableLayoutComposite;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public final class PushDownWizard extends RefactoringWizard {
-
- private static class PushDownInputPage extends UserInputWizardPage {
-
- private static class MemberActionInfoLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- private static String getActionLabel(final int action) {
- switch (action) {
- case MemberActionInfo.NO_ACTION:
- return ""; //$NON-NLS-1$
- case MemberActionInfo.PUSH_ABSTRACT_ACTION:
- return RefactoringMessages.PushDownInputPage_leave_abstract;
- case MemberActionInfo.PUSH_DOWN_ACTION:
- return RefactoringMessages.PushDownInputPage_push_down;
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
- private static String[] getAvailableActionLabels(final MemberActionInfo info) {
- final int[] actions= info.getAvailableActions();
- final String[] result= new String[actions.length];
- for (int index= 0; index < actions.length; index++) {
- result[index]= getActionLabel(actions[index]);
- }
- return result;
- }
-
- private final ILabelProvider fLabelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT | JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
-
- public void dispose() {
- fLabelProvider.dispose();
- super.dispose();
- }
-
- public Image getColumnImage(final Object element, final int index) {
- final MemberActionInfo info= (MemberActionInfo) element;
- switch (index) {
- case MEMBER_COLUMN:
- return fLabelProvider.getImage(info.getMember());
- case ACTION_COLUMN:
- return null;
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
- public String getColumnText(final Object element, final int index) {
- final MemberActionInfo info= (MemberActionInfo) element;
- switch (index) {
- case MEMBER_COLUMN:
- return fLabelProvider.getText(info.getMember());
- case ACTION_COLUMN:
- return getActionLabel(info.getAction());
- default:
- Assert.isTrue(false);
- return null;
- }
- }
- }
-
- private class PushDownCellModifier implements ICellModifier {
-
- public boolean canModify(final Object element, final String property) {
- if (!ACTION_PROPERTY.equals(property))
- return false;
- return ((MemberActionInfo) element).isEditable();
- }
-
- public Object getValue(final Object element, final String property) {
- if (!ACTION_PROPERTY.equals(property))
- return null;
-
- final MemberActionInfo info= (MemberActionInfo) element;
- return new Integer(info.getAction());
- }
-
- public void modify(final Object element, final String property, final Object value) {
- if (!ACTION_PROPERTY.equals(property))
- return;
-
- final int action= ((Integer) value).intValue();
- MemberActionInfo info;
- if (element instanceof Item) {
- info= (MemberActionInfo) ((Item) element).getData();
- } else
- info= (MemberActionInfo) element;
- if (!canModify(info, property))
- return;
- info.setAction(action);
- PushDownInputPage.this.updateWizardPage(null, true);
- }
- }
-
- private static final int ACTION_COLUMN= 1;
-
- private final static String ACTION_PROPERTY= "action"; //$NON-NLS-1$
-
- private static final int MEMBER_COLUMN= 0;
-
- private final static String MEMBER_PROPERTY= "member"; //$NON-NLS-1$
-
- private static final String PAGE_NAME= "PushDownInputPage"; //$NON-NLS-1$
-
- private static final int ROW_COUNT= 10;
-
- private static int countEditableInfos(final MemberActionInfo[] infos) {
- int result= 0;
- for (int index= 0; index < infos.length; index++) {
- if (infos[index].isEditable())
- result++;
- }
- return result;
- }
-
- private static void setInfoAction(final MemberActionInfo[] infos, final int action) {
- for (int index= 0; index < infos.length; index++) {
- infos[index].setAction(action);
- }
- }
-
- private Button fDeselectAllButton;
-
- private Button fEditButton;
-
- private Button fSelectAllButton;
-
- private Label fStatusLine;
-
- private PullPushCheckboxTableViewer fTableViewer;
-
- public PushDownInputPage() {
- super(PAGE_NAME);
- }
-
- private boolean areAllElementsMarkedAsNoAction() {
- return countInfosForAction(MemberActionInfo.NO_ACTION) == ((MemberActionInfo[]) fTableViewer.getInput()).length;
- }
-
- private boolean areAllElementsMarkedAsPushDownAction() {
- return countInfosForAction(MemberActionInfo.PUSH_DOWN_ACTION) == ((MemberActionInfo[]) fTableViewer.getInput()).length;
- }
-
- private void checkPageCompletionStatus(final boolean displayErrorMessage) {
- if (areAllElementsMarkedAsNoAction()) {
- if (displayErrorMessage)
- setErrorMessage(RefactoringMessages.PushDownInputPage_Select_members_to_push_down);
- setPageComplete(false);
- } else {
- setErrorMessage(null);
- setPageComplete(true);
- }
- }
-
- private int countInfosForAction(final int action) {
- final MemberActionInfo[] infos= (MemberActionInfo[]) fTableViewer.getInput();
- int count= 0;
- for (int index= 0; index < infos.length; index++) {
- final MemberActionInfo info= infos[index];
- if (info.getAction() == action)
- count++;
- }
- return count;
- }
-
- private void createButtonComposite(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- final GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- fSelectAllButton= new Button(composite, SWT.PUSH);
- fSelectAllButton.setText(RefactoringMessages.PullUpWizard_select_all_label);
- fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fSelectAllButton.setEnabled(true);
- SWTUtil.setButtonDimensionHint(fSelectAllButton);
- fSelectAllButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- final IMember[] members= getMembers();
- setActionForMembers(members, MemberActionInfo.PUSH_DOWN_ACTION);
- updateWizardPage(null, true);
- }
- });
-
- fDeselectAllButton= new Button(composite, SWT.PUSH);
- fDeselectAllButton.setText(RefactoringMessages.PullUpWizard_deselect_all_label);
- fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fDeselectAllButton.setEnabled(false);
- SWTUtil.setButtonDimensionHint(fDeselectAllButton);
- fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- final IMember[] members= getMembers();
- setActionForMembers(members, MemberActionInfo.NO_ACTION);
- updateWizardPage(null, true);
- }
- });
-
- fEditButton= new Button(composite, SWT.PUSH);
- fEditButton.setText(RefactoringMessages.PushDownInputPage_Edit);
- final GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.verticalIndent= new PixelConverter(parent).convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- fEditButton.setLayoutData(data);
- fEditButton.setEnabled(false);
- SWTUtil.setButtonDimensionHint(fEditButton);
- fEditButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- PushDownInputPage.this.editSelectedMembers();
- }
- });
-
- final Button addButton= new Button(composite, SWT.PUSH);
- addButton.setText(RefactoringMessages.PushDownInputPage_Add_Required);
- addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(addButton);
- addButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(final SelectionEvent event) {
- PushDownInputPage.this.markAdditionalRequiredMembersAsMembersToPushDown();
- }
- });
- }
-
- public void createControl(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
-
- createMemberTableLabel(composite);
- createMemberTableComposite(composite);
- createStatusLine(composite);
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PUSH_DOWN_WIZARD_PAGE);
- }
-
- private void createMemberTable(final Composite parent) {
- final TableLayoutComposite layouter= new TableLayoutComposite(parent, SWT.NONE);
- layouter.addColumnData(new ColumnWeightData(60, true));
- layouter.addColumnData(new ColumnWeightData(40, true));
-
- final Table table= new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- final GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= SWTUtil.getTableHeightHint(table, ROW_COUNT);
- data.widthHint= convertWidthInCharsToPixels(30);
- layouter.setLayoutData(data);
-
- final TableLayout layout= new TableLayout();
- table.setLayout(layout);
-
- final TableColumn first= new TableColumn(table, SWT.NONE);
- first.setText(RefactoringMessages.PushDownInputPage_Member);
-
- final TableColumn second= new TableColumn(table, SWT.NONE);
- second.setText(RefactoringMessages.PushDownInputPage_Action);
-
- fTableViewer= new PullPushCheckboxTableViewer(table);
- fTableViewer.setUseHashlookup(true);
- fTableViewer.setContentProvider(new ArrayContentProvider());
- fTableViewer.setLabelProvider(new MemberActionInfoLabelProvider());
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- PushDownInputPage.this.updateButtonEnablementState((IStructuredSelection) event.getSelection());
- }
- });
- fTableViewer.addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(final CheckStateChangedEvent event) {
- final boolean checked= event.getChecked();
- final MemberActionInfo info= (MemberActionInfo) event.getElement();
- if (checked)
- info.setAction(MemberActionInfo.PUSH_DOWN_ACTION);
- else
- info.setAction(MemberActionInfo.NO_ACTION);
- updateWizardPage(null, true);
- }
- });
- fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(final DoubleClickEvent event) {
- PushDownInputPage.this.editSelectedMembers();
- }
- });
-
- fTableViewer.setInput(getPushDownRefactoring().getPushDownProcessor().getMemberActionInfos());
- updateWizardPage(null, false);
- setupCellEditors(table);
- }
-
- private void createMemberTableComposite(final Composite parent) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- final GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createMemberTable(composite);
- createButtonComposite(composite);
- }
-
- private void createMemberTableLabel(final Composite parent) {
- final Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.PushDownInputPage_Specify_actions);
- label.setLayoutData(new GridData());
- }
-
- private void createStatusLine(final Composite composite) {
- fStatusLine= new Label(composite, SWT.NONE);
- final GridData data= new GridData();
- data.horizontalSpan= 2;
- updateStatusLine();
- fStatusLine.setLayoutData(data);
- }
-
- // String -> Integer
- private Map createStringMappingForSelectedElements() {
- final Map result= new HashMap();
- int action= MemberActionInfo.PUSH_DOWN_ACTION;
- result.put(MemberActionInfoLabelProvider.getActionLabel(action), new Integer(action));
- int action1= MemberActionInfo.PUSH_ABSTRACT_ACTION;
- result.put(MemberActionInfoLabelProvider.getActionLabel(action1), new Integer(action1));
- return result;
- }
-
- private void editSelectedMembers() {
- if (!fEditButton.isEnabled())
- return;
- final ISelection preserved= fTableViewer.getSelection();
- try {
- final Map stringMapping= createStringMappingForSelectedElements();
- final String[] keys= (String[]) stringMapping.keySet().toArray(new String[stringMapping.keySet().size()]);
- Arrays.sort(keys);
- final int initialSelectionIndex= getInitialSelectionIndexForEditDialog(stringMapping, keys);
-
- final ComboSelectionDialog dialog= new ComboSelectionDialog(getShell(), RefactoringMessages.PushDownInputPage_Edit_members, RefactoringMessages.PushDownInputPage_Mark_selected_members, keys, initialSelectionIndex);
- dialog.setBlockOnOpen(true);
- if (dialog.open() == Window.CANCEL)
- return;
- final int action= ((Integer) stringMapping.get(dialog.getSelectedString())).intValue();
- setInfoAction(getSelectedMemberActionInfos(), action);
- } finally {
- updateWizardPage(preserved, true);
- }
- }
-
- private boolean enableEditButton(final IStructuredSelection selection) {
- if (selection.isEmpty() || selection.size() == 0)
- return false;
- return selection.size() == countEditableInfos(getSelectedMemberActionInfos());
- }
-
- private MemberActionInfo[] getActiveInfos() {
- final MemberActionInfo[] infos= getPushDownRefactoring().getPushDownProcessor().getMemberActionInfos();
- final List result= new ArrayList(infos.length);
- for (int index= 0; index < infos.length; index++) {
- final MemberActionInfo info= infos[index];
- if (info.isActive())
- result.add(info);
- }
- return (MemberActionInfo[]) result.toArray(new MemberActionInfo[result.size()]);
- }
-
- private int getCommonActionCodeForSelectedInfos() {
- final MemberActionInfo[] infos= getSelectedMemberActionInfos();
- if (infos.length == 0)
- return -1;
-
- final int code= infos[0].getAction();
- for (int index= 0; index < infos.length; index++) {
- if (code != infos[index].getAction())
- return -1;
- }
- return code;
- }
-
- private int getInitialSelectionIndexForEditDialog(final Map mapping, final String[] keys) {
- final int commonActionCode= getCommonActionCodeForSelectedInfos();
- if (commonActionCode == -1)
- return 0;
- for (final Iterator iterator= mapping.keySet().iterator(); iterator.hasNext();) {
- final String key= (String) iterator.next();
- final int action= ((Integer) mapping.get(key)).intValue();
- if (commonActionCode == action) {
- for (int index= 0; index < keys.length; index++) {
- if (key.equals(keys[index]))
- return index;
- }
- Assert.isTrue(false);// there's no way
- }
- }
- return 0;
- }
-
- private IMember[] getMembers() {
- final MemberActionInfo[] infos= (MemberActionInfo[]) fTableViewer.getInput();
- final List result= new ArrayList(infos.length);
- for (int index= 0; index < infos.length; index++) {
- result.add(infos[index].getMember());
- }
- return (IMember[]) result.toArray(new IMember[result.size()]);
- }
-
- private PushDownRefactoring getPushDownRefactoring() {
- return (PushDownRefactoring) getRefactoring();
- }
-
- private MemberActionInfo[] getSelectedMemberActionInfos() {
- Assert.isTrue(fTableViewer.getSelection() instanceof IStructuredSelection);
- final List result= ((IStructuredSelection) fTableViewer.getSelection()).toList();
- return (MemberActionInfo[]) result.toArray(new MemberActionInfo[result.size()]);
- }
-
- public void markAdditionalRequiredMembersAsMembersToPushDown() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, false, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor pm) throws InvocationTargetException {
- try {
- getPushDownRefactoring().getPushDownProcessor().computeAdditionalRequiredMembersToPushDown(pm);
- updateWizardPage(null, true);
- } catch (final JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
- });
- } catch (final InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.PushDownInputPage_Push_Down, RefactoringMessages.PushDownInputPage_Internal_Error);
- } catch (final InterruptedException e) {
- Assert.isTrue(false);// not cancelable
- }
- }
-
- private void setActionForMembers(final IMember[] members, final int action) {
- final MemberActionInfo[] infos= (MemberActionInfo[]) fTableViewer.getInput();
- for (int offset= 0; offset < members.length; offset++) {
- for (int index= 0; index < infos.length; index++) {
- if (infos[index].getMember().equals(members[offset]))
- infos[index].setAction(action);
- }
- }
- }
-
- private void setupCellEditors(final Table table) {
- final ComboBoxCellEditor comboBoxCellEditor= new ComboBoxCellEditor();
- comboBoxCellEditor.setStyle(SWT.READ_ONLY);
- fTableViewer.setCellEditors(new CellEditor[] { null, comboBoxCellEditor});
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(final SelectionChangedEvent event) {
- if (comboBoxCellEditor.getControl() == null & !table.isDisposed())
- comboBoxCellEditor.create(table);
- Assert.isTrue(event.getSelection() instanceof IStructuredSelection);
- final IStructuredSelection ss= (IStructuredSelection) event.getSelection();
- if (ss.size() != 1)
- return;
- final MemberActionInfo mac= (MemberActionInfo) ss.getFirstElement();
- comboBoxCellEditor.setItems(MemberActionInfoLabelProvider.getAvailableActionLabels(mac));
- comboBoxCellEditor.setValue(new Integer(mac.getAction()));
- }
- });
-
- final ICellModifier cellModifier= new PushDownCellModifier();
- fTableViewer.setCellModifier(cellModifier);
- fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY});
- }
-
- public void setVisible(final boolean visible) {
- super.setVisible(visible);
- if (visible) {
- fTableViewer.setSelection(new StructuredSelection(getActiveInfos()), true);
- fTableViewer.getControl().setFocus();
- }
- }
-
- private void updateButtonEnablementState(final IStructuredSelection tableSelection) {
- if (tableSelection == null || fEditButton == null)
- return;
- fEditButton.setEnabled(enableEditButton(tableSelection));
- if (fSelectAllButton != null)
- fSelectAllButton.setEnabled(!areAllElementsMarkedAsPushDownAction());
- if (fDeselectAllButton != null)
- fDeselectAllButton.setEnabled(!areAllElementsMarkedAsNoAction());
- }
-
- private void updateStatusLine() {
- if (fStatusLine == null)
- return;
- final int selected= fTableViewer.getCheckedElements().length;
- final String[] keys= { String.valueOf(selected)};
- final String msg= Messages.format(RefactoringMessages.PushDownInputPage_status_line, keys);
- fStatusLine.setText(msg);
- }
-
- private void updateWizardPage(final ISelection preserved, final boolean displayErrorMessage) {
- fTableViewer.refresh();
- if (preserved != null) {
- fTableViewer.getControl().setFocus();
- fTableViewer.setSelection(preserved);
- }
- checkPageCompletionStatus(displayErrorMessage);
- updateButtonEnablementState(((IStructuredSelection) fTableViewer.getSelection()));
- updateStatusLine();
- }
- }
-
- public PushDownWizard(final PushDownRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.PushDownWizard_defaultPageTitle);
- }
-
- protected void addUserInputPages() {
- addPage(new PushDownInputPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/QualifiedNameComponent.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/QualifiedNameComponent.java
deleted file mode 100644
index f0d9a161..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/QualifiedNameComponent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-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.layout.GridLayout;
-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.wst.jsdt.internal.corext.refactoring.tagging.IQualifiedNameUpdating;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.RenameRefactoringWizard;
-
-public class QualifiedNameComponent extends Composite {
-
- private Text fPatterns;
-
- public QualifiedNameComponent(Composite parent, int style, final IQualifiedNameUpdating refactoring, IDialogSettings settings) {
- super(parent, style);
- GridLayout layout= new GridLayout();
- layout.marginWidth=0; layout.marginHeight= 0;
- layout.numColumns= 2;
- setLayout(layout);
- Label label= new Label(this, SWT.NONE);
- label.setText(RefactoringMessages.QualifiedNameComponent_patterns_label);
- fPatterns= new Text(this, SWT.BORDER);
- fPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- label= new Label(this, SWT.NONE);
- label.setText(RefactoringMessages.QualifiedNameComponent_patterns_description);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- label.setLayoutData(gd);
- String text= refactoring.getFilePatterns();
- if (text == null)
- text= settings.get(RenameRefactoringWizard.QUALIFIED_NAMES_PATTERNS);
- if (text != null) {
- fPatterns.setText(text);
- refactoring.setFilePatterns(text);
- }
- fPatterns.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- refactoring.setFilePatterns(fPatterns.getText());
- }
- });
- }
-
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- children[i].setEnabled(enabled);
- }
- }
-
- public void savePatterns(IDialogSettings settings) {
- settings.put(RenameRefactoringWizard.QUALIFIED_NAMES_PATTERNS, fPatterns.getText());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringAdapterFactory.java
deleted file mode 100644
index 3a715b2e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringAdapterFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
- package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.ltk.core.refactoring.TextEditBasedChange;
-import org.eclipse.ltk.ui.refactoring.TextEditChangeNode;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.CompilationUnitChange;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.MultiStateCompilationUnitChange;
-
-public class RefactoringAdapterFactory implements IAdapterFactory {
-
- private static final Class[] ADAPTER_LIST= new Class[] {
- TextEditChangeNode.class
- };
-
- public Class[] getAdapterList() {
- return ADAPTER_LIST;
- }
-
- public Object getAdapter(Object object, Class key) {
- if (!TextEditChangeNode.class.equals(key))
- return null;
- if (!(object instanceof CompilationUnitChange) && !(object instanceof MultiStateCompilationUnitChange))
- return null;
- return new CompilationUnitChangeNode((TextEditBasedChange)object);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringExecutionHelper.java
deleted file mode 100644
index 6f531f13..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringExecutionHelper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IThreadListener;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringUI;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
-
-/**
- * A helper class to execute a refactoring. The class takes care of pushing the
- * undo change onto the undo stack and folding editor edits into one editor
- * undo object.
- */
-public class RefactoringExecutionHelper {
-
- private final Refactoring fRefactoring;
- private final Shell fParent;
- private final IRunnableContext fExecContext;
- private final int fStopSeverity;
- private final int fSaveMode;
-
- private class Operation implements IWorkspaceRunnable {
- public Change fChange;
- public PerformChangeOperation fPerformChangeOperation;
- private final boolean fForked;
-
- public Operation(boolean forked) {
- fForked= forked;
- }
-
- public void run(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask("", fForked ? 7 : 11); //$NON-NLS-1$
- pm.subTask(""); //$NON-NLS-1$
-
- final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- if (status.getSeverity() >= fStopSeverity) {
- final boolean[] canceled= { false };
- if (fForked) {
- fParent.getDisplay().syncExec(new Runnable() {
- public void run() {
- canceled[0]= showStatusDialog(status);
- }
- });
- } else {
- canceled[0]= showStatusDialog(status);
- }
- if (canceled[0]) {
- throw new OperationCanceledException();
- }
- }
-
- fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
-
- fPerformChangeOperation= RefactoringUI.createUIAwareChangeOperation(fChange);
- fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName());
- if (fRefactoring instanceof IScheduledRefactoring)
- fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring)fRefactoring).getSchedulingRule());
-
- if (! fForked)
- fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- } finally {
- pm.done();
- }
- }
-
- /**
- * @param status the status to show
- * @return <code>true</code> iff the operation should be cancelled
- */
- private boolean showStatusDialog(RefactoringStatus status) {
- Dialog dialog= RefactoringUI.createRefactoringStatusDialog(status, fParent, fRefactoring.getName(), false);
- return dialog.open() == IDialogConstants.CANCEL_ID;
- }
- }
-
- /**
- * @param refactoring
- * @param stopSeverity a refactoring status constant from {@link RefactoringStatus}
- * @param saveMode a save mode from {@link RefactoringSaveHelper}
- * @param parent
- * @param context
- */
- public RefactoringExecutionHelper(Refactoring refactoring, int stopSeverity, int saveMode, Shell parent, IRunnableContext context) {
- super();
- Assert.isNotNull(refactoring);
- Assert.isNotNull(parent);
- Assert.isNotNull(context);
- fRefactoring= refactoring;
- fStopSeverity= stopSeverity;
- fParent= parent;
- fExecContext= context;
- fSaveMode= saveMode;
- }
-
- /**
- * Must be called in the UI thread.
- * @param fork if set, the operation will be forked
- * @param cancelable if set, the operation will be cancellable
- * @throws InterruptedException thrown when the operation is cancelled
- * @throws InvocationTargetException thrown when the operation failed to execute
- */
- public void perform(boolean fork, boolean cancelable) throws InterruptedException, InvocationTargetException {
- Assert.isTrue(Display.getCurrent() != null);
- final IJobManager manager= Job.getJobManager();
- final ISchedulingRule rule;
- if (fRefactoring instanceof IScheduledRefactoring) {
- rule= ((IScheduledRefactoring)fRefactoring).getSchedulingRule();
- } else {
- rule= ResourcesPlugin.getWorkspace().getRoot();
- }
- class OperationRunner extends WorkbenchRunnableAdapter implements IThreadListener {
- public OperationRunner(IWorkspaceRunnable runnable, ISchedulingRule schedulingRule) {
- super(runnable, schedulingRule);
- }
- public void threadChange(Thread thread) {
- manager.transferRule(getSchedulingRule(), thread);
- }
- }
- try {
- try {
- Runnable r= new Runnable() {
- public void run() {
- manager.beginRule(rule, null);
- }
- };
- BusyIndicator.showWhile(fParent.getDisplay(), r);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- }
-
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(fSaveMode);
- if (!saveHelper.saveEditors(fParent))
- throw new InterruptedException();
- final Operation op= new Operation(fork);
- fRefactoring.setValidationContext(fParent);
- try{
- fExecContext.run(fork, cancelable, new OperationRunner(op, rule));
- if (fork && op.fPerformChangeOperation != null)
- fExecContext.run(false, false, new OperationRunner(op.fPerformChangeOperation, rule));
-
- if (op.fPerformChangeOperation != null) {
- RefactoringStatus validationStatus= op.fPerformChangeOperation.getValidationStatus();
- if (validationStatus != null && validationStatus.hasFatalError()) {
- MessageDialog.openError(fParent, fRefactoring.getName(),
- Messages.format(
- RefactoringMessages.RefactoringExecutionHelper_cannot_execute,
- validationStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL)));
- return;
- }
- }
- } catch (InvocationTargetException e) {
- PerformChangeOperation pco= op.fPerformChangeOperation;
- if (pco != null && pco.changeExecutionFailed()) {
- ChangeExceptionHandler handler= new ChangeExceptionHandler(fParent, fRefactoring);
- Throwable inner= e.getTargetException();
- if (inner instanceof RuntimeException) {
- handler.handle(pco.getChange(), (RuntimeException)inner);
- } else if (inner instanceof CoreException) {
- handler.handle(pco.getChange(), (CoreException)inner);
- } else {
- throw e;
- }
- } else {
- throw e;
- }
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- } finally {
- saveHelper.triggerBuild();
- }
- } finally {
- manager.endRule(rule);
- fRefactoring.setValidationContext(null);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringMessages.java
deleted file mode 100644
index b4a8cbc3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringMessages.java
+++ /dev/null
@@ -1,968 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class RefactoringMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.refactoring.refactoringui";//$NON-NLS-1$
-
- public static String ChangeExceptionHandler_abort_button;
-
- public static String ChangeExceptionHandler_dialog_message;
-
- public static String ChangeExceptionHandler_dialog_title;
-
- public static String ChangeExceptionHandler_message;
-
- public static String ChangeExceptionHandler_status_without_detail;
-
- public static String ChangeExceptionHandler_undo_button;
-
- public static String ChangeExceptionHandler_undo_dialog_message;
-
- public static String ChangeExceptionHandler_undo_dialog_title;
-
- public static String ChangeExceptionsControl_buttons_add;
-
- public static String ChangeExceptionsControl_buttons_remove;
-
- public static String ChangeExceptionsControl_choose_message;
-
- public static String ChangeExceptionsControl_choose_title;
-
- public static String ChangeExceptionsControl_not_exception;
-
- public static String ChangeParametersControl_buttons_add;
-
- public static String ChangeParametersControl_buttons_edit;
-
- public static String ChangeParametersControl_buttons_move_down;
-
- public static String ChangeParametersControl_buttons_move_up;
-
- public static String ChangeParametersControl_buttons_remove;
-
- public static String ChangeParametersControl_default;
-
- public static String ChangeParametersControl_new;
-
- public static String ChangeParametersControl_new_parameter_default_name;
-
- public static String ChangeParametersControl_table_defaultValue;
-
- public static String ChangeParametersControl_table_name;
-
- public static String ChangeParametersControl_table_type;
-
- public static String ChangeParametersControl_type;
-
- public static String ChangeSignatureInputPage_access_modifier;
-
- public static String ChangeSignatureInputPage_change;
-
- public static String ChangeSignatureInputPage_Change_Signature;
-
- public static String ChangeSignatureInputPage_default;
-
- public static String ChangeSignatureInputPage_exception;
-
- public static String ChangeSignatureInputPage_exceptions;
-
- public static String ChangeSignatureInputPage_Internal_Error;
-
- public static String ChangeSignatureInputPage_method_name;
-
- public static String ChangeSignatureInputPage_method_Signature_Preview;
-
- public static String ChangeSignatureInputPage_parameters;
-
- public static String ChangeSignatureInputPage_return_type;
-
- public static String ChangeSignatureInputPage_unchanged;
-
- public static String ChangeSignatureRefactoring_modify_Parameters;
-
- public static String ChangeTypeAction_description;
-
- public static String ChangeTypeAction_dialog_title;
-
- public static String ChangeTypeAction_exception;
-
- public static String ChangeTypeAction_label;
-
- public static String ChangeTypeAction_tooltipText;
-
- public static String ChangeTypeInputPage_Select_Type;
-
- public static String ChangeTypeWizard_analyzing;
-
- public static String ChangeTypeWizard_computationInterrupted;
-
- public static String ChangeTypeWizard_declCannotBeChanged;
-
- public static String ChangeTypeWizard_grayed_types;
-
- public static String ChangeTypeWizard_internalError;
-
- public static String ChangeTypeWizard_pleaseChooseType;
-
- public static String ChangeTypeWizard_title;
-
- public static String ChangeTypeWizard_with_itself;
-
- public static String ConvertAnonymousToNestedAction_Convert_Anonymous;
-
- public static String ConvertAnonymousToNestedAction_dialog_title;
-
- public static String ConvertAnonymousToNestedAction_wizard_title;
-
- public static String ConvertAnonymousToNestedInputPage_class_name;
-
- public static String ConvertAnonymousToNestedInputPage_declare_final;
-
- public static String ConvertAnonymousToNestedInputPage_declare_static;
-
- public static String ConvertAnonymousToNestedInputPage_description;
-
- public static String ConvertLocalToField_label;
-
- public static String ConvertLocalToField_title;
-
- public static String ConvertNestedToTopAction_Convert;
-
- public static String ConvertNestedToTopAction_not_possible;
-
- public static String ConvertNestedToTopAction_Refactoring;
-
- public static String ConvertNestedToTopAction_To_activate;
-
- public static String DelegateCreator_deprecate_delegates;
-
- public static String DeleteWizard_1;
-
- public static String DeleteWizard_10;
-
- public static String DeleteWizard_11;
-
- public static String DeleteWizard_12;
-
- public static String DeleteWizard_2;
-
- public static String DeleteWizard_3;
-
- public static String DeleteWizard_4;
-
- public static String DeleteWizard_5;
-
- public static String DeleteWizard_6;
-
- public static String DeleteWizard_7;
-
- public static String DeleteWizard_8;
-
- public static String DeleteWizard_9;
-
- public static String DeleteWizard_also_delete_sub_packages;
-
- public static String ExtractConstantAction_extract_constant;
-
- public static String ExtractConstantAction_label;
-
- public static String ExtractConstantInputPage_access_modifiers;
-
- public static String ExtractConstantInputPage_constant_name;
-
- public static String ExtractConstantInputPage_enter_name;
-
- public static String ExtractConstantInputPage_exception;
-
- public static String ExtractConstantInputPage_Internal_Error;
-
- public static String ExtractConstantInputPage_qualify_constant_references_with_class_name;
-
- public static String ExtractConstantInputPage_replace_all;
-
- public static String ExtractConstantInputPage_selection_refers_to_nonfinal_fields;
-
- public static String ExtractConstantInputPage_signature_preview;
-
- public static String ExtractConstantWizard_defaultPageTitle;
-
- public static String ExtractInterfaceAction_Extract_Interface;
-
- public static String ExtractInterfaceAction_not_possible;
-
- public static String ExtractInterfaceAction_Refactoring;
-
- public static String ExtractInterfaceAction_To_activate;
-
- public static String ExtractInterfaceInputPage_change_references;
-
- public static String ExtractInterfaceInputPage_description;
-
- public static String ExtractInterfaceInputPage_Deselect_All;
-
- public static String ExtractInterfaceInputPage_Extract_Interface;
-
- public static String ExtractInterfaceInputPage_Interface_name;
-
- public static String ExtractInterfaceInputPage_Internal_Error;
-
- public static String ExtractInterfaceInputPage_Members;
-
- public static String ExtractInterfaceInputPage_Select_All;
-
- public static String ExtractInterfaceWizard_12;
-
- public static String ExtractInterfaceWizard_abstract_label;
-
- public static String ExtractInterfaceWizard_Extract_Interface;
-
- public static String ExtractInterfaceWizard_generate_comments;
-
- public static String ExtractInterfaceWizard_public_label;
-
- public static String ExtractInterfaceWizard_use_supertype;
-
- public static String ExtractMethodAction_dialog_title;
-
- public static String ExtractMethodAction_label;
-
- public static String ExtractMethodInputPage_access_Modifiers;
-
- public static String ExtractMethodInputPage_anonymous_type_label;
-
- public static String ExtractMethodInputPage_default;
-
- public static String ExtractMethodInputPage_description;
-
- public static String ExtractMethodInputPage_destination_type;
-
- public static String ExtractMethodInputPage_duplicates_multi;
-
- public static String ExtractMethodInputPage_duplicates_none;
-
- public static String ExtractMethodInputPage_duplicates_single;
-
- public static String ExtractMethodInputPage_generateJavadocComment;
-
- public static String ExtractMethodInputPage_label_text;
-
- public static String ExtractMethodInputPage_parameters;
-
- public static String ExtractMethodInputPage_private;
-
- public static String ExtractMethodInputPage_protected;
-
- public static String ExtractMethodInputPage_public;
-
- public static String ExtractMethodInputPage_signature_preview;
-
- public static String ExtractMethodInputPage_throwRuntimeExceptions;
-
- public static String ExtractMethodInputPage_validation_emptyMethodName;
-
- public static String ExtractMethodInputPage_validation_emptyParameterName;
-
- public static String ExtractMethodWizard_extract_method;
-
- public static String ExtractSuperTypeAction_label;
-
- public static String ExtractSuperTypeAction_unavailable;
-
- public static String ExtractSupertypeMemberPage_add_button_label;
-
- public static String ExtractSupertypeMemberPage_choose_type_caption;
-
- public static String ExtractSupertypeMemberPage_choose_type_message;
-
- public static String ExtractSupertypeMemberPage_create_stubs_label;
-
- public static String ExtractSupertypeMemberPage_declare_abstract;
-
- public static String ExtractSupertypeMemberPage_extract;
-
- public static String ExtractSupertypeMemberPage_extract_supertype;
-
- public static String ExtractSupertypeMemberPage_name_label;
-
- public static String ExtractSupertypeMemberPage_no_members_selected;
-
- public static String ExtractSupertypeMemberPage_page_title;
-
- public static String ExtractSupertypeMemberPage_remove_button_label;
-
- public static String ExtractSupertypeMemberPage_types_list_caption;
-
- public static String ExtractSupertypeMemberPage_use_instanceof_label;
-
- public static String ExtractSupertypeMemberPage_use_supertype_label;
-
- public static String ExtractSupertypeWizard_defaultPageTitle;
-
- public static String ExtractTempAction_extract_temp;
-
- public static String ExtractTempAction_label;
-
- public static String ExtractTempInputPage_declare_final;
-
- public static String ExtractTempInputPage_enter_name;
-
- public static String ExtractTempInputPage_exception;
-
- public static String ExtractTempInputPage_extract_local;
-
- public static String ExtractTempInputPage_replace_all;
-
- public static String ExtractTempInputPage_signature_preview;
-
- public static String ExtractTempInputPage_variable_name;
-
- public static String ExtractTempWizard_defaultPageTitle;
-
- public static String InferTypeArgumentsAction_dialog_title;
-
- public static String InferTypeArgumentsAction_label;
-
- public static String InferTypeArgumentsAction_unavailable;
-
- public static String InferTypeArgumentsInputPage_description;
-
- public static String InferTypeArgumentsWizard_assumeCloneSameType;
-
- public static String InferTypeArgumentsWizard_defaultPageTitle;
-
- public static String InferTypeArgumentsWizard_leaveUnconstrainedRaw;
-
- public static String InferTypeArgumentsWizard_lengthyDescription;
-
- public static String InlineAction_dialog_title;
-
- public static String InlineAction_Inline;
-
- public static String InlineAction_select;
-
- public static String InlineConstantAction_dialog_title;
-
- public static String InlineConstantAction_inline_Constant;
-
- public static String InlineConstantAction_no_constant_reference_or_declaration;
-
- public static String InlineConstantAction_unexpected_exception;
-
- public static String InlineConstantInputPage_All_references;
-
- public static String InlineConstantInputPage_Delete_constant;
-
- public static String InlineConstantInputPage_Inline;
-
- public static String InlineConstantInputPage_Only_selected;
-
- public static String InlineConstantWizard_initializer_refers_to_fields;
-
- public static String InlineConstantWizard_Inline_Constant;
-
- public static String InlineConstantWizard_message;
-
- public static String InlineMethodAction_dialog_title;
-
- public static String InlineMethodAction_inline_Method;
-
- public static String InlineMethodAction_no_method_invocation_or_declaration_selected;
-
- public static String InlineMethodAction_unexpected_exception;
-
- public static String InlineMethodInputPage_all_invocations;
-
- public static String InlineMethodInputPage_delete_declaration;
-
- public static String InlineMethodInputPage_description;
-
- public static String InlineMethodInputPage_inline;
-
- public static String InlineMethodInputPage_only_selected;
-
- public static String InlineMethodWizard_page_title;
-
- public static String InlineTempAction_inline_temp;
-
- public static String InlineTempAction_label;
-
- public static String InlineTempInputPage_message_multi;
-
- public static String InlineTempInputPage_message_one;
-
- public static String InlineTempInputPage_message_zero;
-
- public static String InlineTempWizard_defaultPageTitle;
-
- public static String IntroduceFactoryAction_description;
-
- public static String IntroduceFactoryAction_dialog_title;
-
- public static String IntroduceFactoryAction_exception;
-
- public static String IntroduceFactoryAction_label;
-
- public static String IntroduceFactoryAction_tooltipText;
-
- public static String IntroduceFactoryAction_use_factory;
-
- public static String IntroduceFactoryInputPage_browseLabel;
-
- public static String IntroduceFactoryInputPage_chooseFactoryClass_message;
-
- public static String IntroduceFactoryInputPage_chooseFactoryClass_title;
-
- public static String IntroduceFactoryInputPage_factoryClassLabel;
-
- public static String IntroduceFactoryInputPage_method_name;
-
- public static String IntroduceFactoryInputPage_name_factory;
-
- public static String IntroduceFactoryInputPage_protectConstructorLabel;
-
- public static String IntroduceIndirectionAction_description;
-
- public static String IntroduceIndirectionAction_dialog_title;
-
- public static String IntroduceIndirectionAction_title;
-
- public static String IntroduceIndirectionAction_tooltip;
-
- public static String IntroduceIndirectionAction_unknown_exception;
-
- public static String IntroduceIndirectionInputPage_browse;
-
- public static String IntroduceIndirectionInputPage_declaring_class;
-
- public static String IntroduceIndirectionInputPage_dialog_choose_declaring_class;
-
- public static String IntroduceIndirectionInputPage_dialog_choose_declaring_class_long;
-
- public static String IntroduceIndirectionInputPage_new_method_name;
-
- public static String IntroduceIndirectionInputPage_select_declaring_class;
-
- public static String IntroduceIndirectionInputPage_update_references;
-
- public static String IntroduceParameterAction_dialog_title;
-
- public static String IntroduceParameterAction_label;
-
- public static String IntroduceParameterInputPage_description;
-
- public static String IntroduceParameterWizard_defaultPageTitle;
-
- public static String IntroduceParameterWizard_parameters;
-
- public static String JavaStatusContextViewer_no_source_available;
-
- public static String JavaStatusContextViewer_no_source_found0;
-
- public static String JavaTypeCompletionProcessor_no_completion;
-
- public static String ModifyParametersAction_unavailable;
-
- public static String MoveAction_Move;
-
- public static String MoveAction_select;
-
- public static String MoveAction_text;
-
- public static String MoveInnerToToplnputPage_description;
-
- public static String MoveInnerToToplnputPage_enter_name;
-
- public static String MoveInnerToToplnputPage_enter_name_mandatory;
-
- public static String MoveInnerToToplnputPage_instance_final;
-
- public static String MoveInnerToToplnputPage_mandatory_info;
-
- public static String MoveInnerToToplnputPage_optional_info;
-
- public static String MoveInnerToTopWizard_Move_Inner;
-
- public static String MoveInstanceMethodAction_dialog_title;
-
- public static String MoveInstanceMethodAction_Move_Method;
-
- public static String MoveInstanceMethodAction_No_reference_or_declaration;
-
- public static String MoveInstanceMethodAction_unexpected_exception;
-
- public static String MoveInstanceMethodPage_Create_button_name;
-
- public static String MoveInstanceMethodPage_Deprecate_button_name;
-
- public static String MoveInstanceMethodPage_invalid_target;
-
- public static String MoveInstanceMethodPage_Method_name;
-
- public static String MoveInstanceMethodPage_Name;
-
- public static String MoveInstanceMethodPage_New_receiver;
-
- public static String MoveInstanceMethodPage_Target_name;
-
- public static String MoveInstanceMethodPage_Type;
-
- public static String MoveInstanceMethodWizard_Move_Method;
-
- public static String MoveMembersAction_error_message;
-
- public static String MoveMembersAction_error_title;
-
- public static String MoveMembersAction_unavailable;
-
- public static String MoveMembersInputPage_browse;
-
- public static String MoveMembersInputPage_choose_Type;
-
- public static String MoveMembersInputPage_descriptionKey;
-
- public static String MoveMembersInputPage_destination_multi;
-
- public static String MoveMembersInputPage_destination_single;
-
- public static String MoveMembersInputPage_dialogMessage;
-
- public static String MoveMembersInputPage_exception;
-
- public static String MoveMembersInputPage_internal_error;
-
- public static String MoveMembersInputPage_invalid_name;
-
- public static String MoveMembersInputPage_Invalid_selection;
-
- public static String MoveMembersInputPage_lowerListLabel;
-
- public static String MoveMembersInputPage_move;
-
- public static String MoveMembersInputPage_move_Member;
-
- public static String MoveMembersInputPage_no_binary;
-
- public static String MoveMembersInputPage_not_found;
-
- public static String MoveMembersInputPage_upperListLabel;
-
- public static String MoveMembersWizard_page_title;
-
- public static String NewTextRefactoringAction_exception;
-
- public static String OpenRefactoringWizardAction_exception;
-
- public static String OpenRefactoringWizardAction_refactoring;
-
- public static String OpenRefactoringWizardAction_unavailable;
-
- public static String ParameterEditDialog_defaultValue;
-
- public static String ParameterEditDialog_defaultValue_error;
-
- public static String ParameterEditDialog_defaultValue_invalid;
-
- public static String ParameterEditDialog_message;
-
- public static String ParameterEditDialog_message_new;
-
- public static String ParameterEditDialog_name;
-
- public static String ParameterEditDialog_name_error;
-
- public static String ParameterEditDialog_title;
-
- public static String ParameterEditDialog_type;
-
- public static String ParameterEditDialog_type_error;
-
- public static String ParameterEditDialog_type_invalid;
-
- public static String PromoteTempInputPage_constructors;
-
- public static String PromoteTempInputPage_Current_method;
-
- public static String PromoteTempInputPage_declare_final;
-
- public static String PromoteTempInputPage_declare_static;
-
- public static String PromoteTempInputPage_description;
-
- public static String PromoteTempInputPage_Field_declaration;
-
- public static String PromoteTempInputPage_Field_name;
-
- public static String PromoteTempInputPage_Initialize;
-
- public static String PullUpAction_unavailable;
-
- public static String PullUpInputPage_exception;
-
- public static String PullUpInputPage_hierarchyLabal;
-
- public static String PullUpInputPage_pull_Up;
-
- public static String PullUpInputPage_pull_up1;
-
- public static String PullUpInputPage_see_log;
-
- public static String PullUpInputPage_select_methods;
-
- public static String PullUpInputPage_subtypes;
-
- public static String PullUpInputPage1_Action;
-
- public static String PullUpInputPage1_Add_Required;
-
- public static String PullUpInputPage1_Create_stubs;
-
- public static String PullUpInputPage1_declare_abstract;
-
- public static String PullUpInputPage1_Edit;
-
- public static String PullUpInputPage1_Edit_members;
-
- public static String PullUpInputPage1_label_use_destination;
-
- public static String PullUpInputPage1_label_use_in_instanceof;
-
- public static String PullUpInputPage1_Mark_selected_members;
-
- public static String PullUpInputPage1_Member;
-
- public static String PullUpInputPage1_page_message;
-
- public static String PullUpInputPage1_pull_up;
-
- public static String PullUpInputPage1_Select_destination;
-
- public static String PullUpInputPage1_Select_members_to_pull_up;
-
- public static String PullUpInputPage1_Specify_actions;
-
- public static String PullUpInputPage1_status_line;
-
- public static String PullUpInputPage2_Select;
-
- public static String PullUpInputPage2_Source;
-
- public static String PullUpWizard_defaultPageTitle;
-
- public static String PullUpWizard_deselect_all_label;
-
- public static String PullUpWizard_select_all_label;
-
- public static String PushDownAction_not_possible;
-
- public static String PushDownAction_Push_Down;
-
- public static String PushDownAction_Refactoring;
-
- public static String PushDownAction_To_activate;
-
- public static String PushDownInputPage_Action;
-
- public static String PushDownInputPage_Add_Required;
-
- public static String PushDownInputPage_Edit;
-
- public static String PushDownInputPage_Edit_members;
-
- public static String PushDownInputPage_Internal_Error;
-
- public static String PushDownInputPage_leave_abstract;
-
- public static String PushDownInputPage_Mark_selected_members;
-
- public static String PushDownInputPage_Member;
-
- public static String PushDownInputPage_push_down;
-
- public static String PushDownInputPage_Push_Down;
-
- public static String PushDownInputPage_Select_members_to_push_down;
-
- public static String PushDownInputPage_Specify_actions;
-
- public static String PushDownInputPage_status_line;
-
- public static String PushDownWizard_defaultPageTitle;
-
- public static String QualifiedNameComponent_patterns_description;
-
- public static String QualifiedNameComponent_patterns_label;
-
- public static String RefactorActionGroup_no_refactoring_available;
-
- public static String RefactoringErrorDialogUtil_okToPerformQuestion;
-
- public static String RefactoringExecutionHelper_cannot_execute;
-
- public static String RefactoringExecutionStarter_IntroduceParameterObject_problem_description;
-
- public static String RefactoringExecutionStarter_IntroduceParameterObject_problem_title;
-
- public static String RefactoringGroup_modify_Parameters_label;
-
- public static String RefactoringGroup_move_label;
-
- public static String RefactoringGroup_pull_Up_label;
-
- public static String RefactoringStarter_always_save;
-
- public static String RefactoringStarter_must_save;
-
- public static String RefactoringStarter_save_all_resources;
-
- public static String RefactoringStarter_saving;
-
- public static String RefactoringStarter_unexpected_exception;
-
- public static String RenameAction_rename;
-
- public static String RenameAction_text;
-
- public static String RenameAction_unavailable;
-
- public static String RenameCuWizard_defaultPageTitle;
-
- public static String RenameCuWizard_inputPage_description;
-
- public static String RenameEnumConstWizard_defaultPageTitle;
-
- public static String RenameEnumConstWizard_inputPage_description;
-
- public static String RenameFieldInputWizardPage_getter_label;
-
- public static String RenameFieldInputWizardPage_rename_getter;
-
- public static String RenameFieldInputWizardPage_rename_getter_to;
-
- public static String RenameFieldInputWizardPage_rename_setter;
-
- public static String RenameFieldInputWizardPage_rename_setter_to;
-
- public static String RenameFieldInputWizardPage_setter_label;
-
- public static String RenameFieldWizard_defaultPageTitle;
-
- public static String RenameFieldWizard_inputPage_description;
-
- public static String RenameInputWizardPage_new_name;
-
- public static String RenameInputWizardPage_update_qualified_names;
-
- public static String RenameInputWizardPage_update_references;
-
- public static String RenameInputWizardPage_update_textual_matches;
-
- public static String RenameJavaElementAction_exception;
-
- public static String RenameJavaElementAction_name;
-
- public static String RenameJavaElementAction_not_available;
-
- public static String RenameJavaProject_defaultPageTitle;
-
- public static String RenameJavaProject_inputPage_description;
-
- public static String RenameLocalVariableWizard_defaultPageTitle;
-
- public static String RenameLocalVariableWizard_inputPage_description;
-
- public static String RenameMethodWizard_defaultPageTitle;
-
- public static String RenameMethodWizard_inputPage_description;
-
- public static String RenamePackageWizard_defaultPageTitle;
-
- public static String RenamePackageWizard_inputPage_description;
-
- public static String RenamePackageWizard_rename_subpackages;
-
- public static String RenameRefactoringWizard_internal_error;
-
- public static String RenameResourceWizard_defaultPageTitle;
-
- public static String RenameResourceWizard_inputPage_description;
-
- public static String RenameSourceFolder_defaultPageTitle;
-
- public static String RenameSourceFolder_inputPage_description;
-
- public static String RenameTempAction_exception;
-
- public static String RenameTypeParameterWizard_defaultPageTitle;
-
- public static String RenameTypeParameterWizard_inputPage_description;
-
- public static String RenameTypeWizard_defaultPageTitle;
-
- public static String RenameTypeWizard_unexpected_exception;
-
- public static String RenameTypeWizardInputPage_description;
-
- public static String RenameTypeWizardInputPage_update_similar_elements;
-
- public static String RenameTypeWizardInputPage_update_similar_elements_configure;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_select_strategy;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_strategy_1;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_strategy_2;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_strategy_3;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_title;
-
- public static String RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names;
-
- public static String RenameTypeWizardSimilarElementsPage_change_element_name;
-
- public static String RenameTypeWizardSimilarElementsPage_change_name;
-
- public static String RenameTypeWizardSimilarElementsPage_enter_new_name;
-
- public static String RenameTypeWizardSimilarElementsPage_field_exists;
-
- public static String RenameTypeWizardSimilarElementsPage_method_exists;
-
- public static String RenameTypeWizardSimilarElementsPage_name_empty;
-
- public static String RenameTypeWizardSimilarElementsPage_name_should_start_lowercase;
-
- public static String RenameTypeWizardSimilarElementsPage_rename_to;
-
- public static String RenameTypeWizardSimilarElementsPage_restore_defaults;
-
- public static String RenameTypeWizardSimilarElementsPage_review_similar_elements;
-
- public static String RenameTypeWizardSimilarElementsPage_select_element_to_view_source;
-
- public static String ReplaceInvocationsAction_dialog_title;
-
- public static String ReplaceInvocationsAction_label;
-
- public static String ReplaceInvocationsAction_unavailable;
-
- public static String ReplaceInvocationsInputPage_replaceAll;
-
- public static String ReplaceInvocationsInputPage_replaceInvocationsBy;
-
- public static String ReplaceInvocationsWizard_title;
-
- public static String SelfEncapsulateField_field_access;
-
- public static String SelfEncapsulateField_keep_references;
-
- public static String SelfEncapsulateField_sef;
-
- public static String SelfEncapsulateField_use_setter_getter;
-
- public static String SelfEncapsulateFieldInputPage_access_Modifiers;
-
- public static String SelfEncapsulateFieldInputPage_default;
-
- public static String SelfEncapsulateFieldInputPage_description;
-
- public static String SelfEncapsulateFieldInputPage_first_method;
-
- public static String SelfEncapsulateFieldInputPage_generateJavadocComment;
-
- public static String SelfEncapsulateFieldInputPage_getter_name;
-
- public static String SelfEncapsulateFieldInputPage_insert_after;
-
- public static String SelfEncapsulateFieldInputPage_private;
-
- public static String SelfEncapsulateFieldInputPage_protected;
-
- public static String SelfEncapsulateFieldInputPage_public;
-
- public static String SelfEncapsulateFieldInputPage_setter_name;
-
- public static String SelfEncapsulateFieldInputPage_usenewgetter_label;
-
- public static String SelfEncapsulateFieldInputPage_usenewsetter_label;
-
- public static String SurroundWithTryCatchAction_dialog_title;
-
- public static String SurroundWithTryCatchAction_exception;
-
- public static String SurroundWithTryCatchAction_label;
-
- public static String SurroundWithTryCatchAction_no_exceptions;
-
- public static String UseSupertypeAction_not_possible;
-
- public static String UseSupertypeAction_Refactoring;
-
- public static String UseSupertypeAction_to_activate;
-
- public static String UseSupertypeAction_use_Supertype;
-
- public static String UseSupertypeInputPage_Internal_Error;
-
- public static String UseSupertypeInputPage_no_possible_updates;
-
- public static String UseSupertypeInputPage_No_updates;
-
- public static String UseSupertypeInputPage_Select_supertype;
-
- public static String UseSupertypeInputPage_Select_supertype_to_use;
-
- public static String UseSupertypeInputPage_updates_possible_in_file;
-
- public static String UseSupertypeInputPage_updates_possible_in_files;
-
- public static String UseSupertypeInputPage_Use_in_instanceof;
-
- public static String UseSupertypeInputPage_Use_Supertype;
-
- public static String UseSupertypeWizard_10;
-
- public static String UseSupertypeWizard_Use_Super_Type_Where_Possible;
-
- public static String VisibilityControlUtil_Access_modifier;
-
- public static String VisibilityControlUtil_defa_ult_4;
-
- public static String VisibilityControlUtil_final;
-
- public static String VisibilityControlUtil_synchronized;
-
- public static String SelfEncapsulateFieldInputPage_useexistingsetter_label;
-
- public static String SelfEncapsulateFieldInputPage_useexistinggetter_label;
-
- public static String JarImportWizard_prepare_import;
- public static String JarImportWizard_error_shared_jar;
- public static String BinaryRefactoringHistoryWizard_error_missing_source_attachment;
- public static String JarImportWizard_cleanup_import;
-
-
- static {
- reloadMessages();
- }
-
- public static void reloadMessages() {
- NLS.initializeMessages(BUNDLE_NAME, RefactoringMessages.class);
- }
-
- private RefactoringMessages() {
- // Do not instantiate
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSaveHelper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSaveHelper.java
deleted file mode 100644
index 74c88fc9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSaveHelper.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-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.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.GlobalBuildAction;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.actions.ListDialog;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-public class RefactoringSaveHelper {
-
- private boolean fFilesSaved;
- private final int fSaveMode;
-
- /**
- * Save mode to save all dirty editors (always ask).
- */
- public static final int SAVE_ALL_ALWAYS_ASK= 1;
-
- /**
- * Save mode to save all dirty editors.
- */
- public static final int SAVE_ALL= 2;
-
- /**
- * Save mode to save all unknown editors, i.e. those that don't work on
- * resources, don't use file buffers, or are otherwise suspect.
- *
- * Used for refactorings with participants or qualified name updating.
- */
- public static final int SAVE_NON_JAVA_UPDATES= 3;
-
- /**
- * Save mode to save only dirty editors on compilation units that are not in
- * working copy mode.
- *
- * Used for refactorings without participants or qualified name updating.
- */
- public static final int SAVE_JAVA_ONLY_UPDATES= 4;
-
- /**
- * Save mode to not save save any editors.
- */
- public static final int SAVE_NOTHING= 5;
-
- /**
- * @param saveMode one of the SAVE_* constants
- */
- public RefactoringSaveHelper(int saveMode) {
- Assert.isTrue(saveMode == SAVE_ALL_ALWAYS_ASK
- || saveMode == SAVE_ALL
- || saveMode == SAVE_NON_JAVA_UPDATES
- || saveMode == SAVE_JAVA_ONLY_UPDATES
- || saveMode == SAVE_NOTHING);
- fSaveMode= saveMode;
- }
-
- /**
- * @param shell
- * @return <code>true</code> if save was successful and refactoring can proceed;
- * false if the refactoring must be cancelled
- */
- public boolean saveEditors(Shell shell) {
- final IEditorPart[] dirtyEditors;
- switch (fSaveMode) {
- case SAVE_ALL_ALWAYS_ASK:
- case SAVE_ALL:
- dirtyEditors= EditorUtility.getDirtyEditors();
- break;
-
- case SAVE_NON_JAVA_UPDATES:
- dirtyEditors= EditorUtility.getDirtyEditorsToSave(false); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=175495
- break;
-
- case SAVE_JAVA_ONLY_UPDATES:
- dirtyEditors= EditorUtility.getDirtyEditorsToSave(false);
- break;
-
- case SAVE_NOTHING:
- return true;
-
- default:
- throw new IllegalStateException(Integer.toString(fSaveMode));
- }
- if (dirtyEditors.length == 0)
- return true;
- if (! askSaveAllDirtyEditors(shell, dirtyEditors))
- return false;
- try {
- // Save isn't cancelable.
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IWorkspaceDescription description= workspace.getDescription();
- boolean autoBuild= description.isAutoBuilding();
- description.setAutoBuilding(false);
- workspace.setDescription(description);
- try {
- if (fSaveMode == SAVE_ALL_ALWAYS_ASK || fSaveMode == SAVE_ALL
- || RefactoringSavePreferences.getSaveAllEditors()) {
- if (!JavaScriptPlugin.getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false))
- return false;
- } else {
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InterruptedException {
- int count= dirtyEditors.length;
- pm.beginTask("", count); //$NON-NLS-1$
- for (int i= 0; i < count; i++) {
- IEditorPart editor= dirtyEditors[i];
- editor.doSave(new SubProgressMonitor(pm, 1));
- if (pm.isCanceled())
- throw new InterruptedException();
- }
- pm.done();
- }
- };
- try {
- PlatformUI.getWorkbench().getProgressService().runInUI(JavaScriptPlugin.getActiveWorkbenchWindow(), runnable, null);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, shell,
- RefactoringMessages.RefactoringStarter_saving, RefactoringMessages.RefactoringStarter_unexpected_exception);
- return false;
- }
- }
- fFilesSaved= true;
- } finally {
- description.setAutoBuilding(autoBuild);
- workspace.setDescription(description);
- }
- return true;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, shell,
- RefactoringMessages.RefactoringStarter_saving, RefactoringMessages.RefactoringStarter_unexpected_exception);
- return false;
- }
- }
-
- public void triggerBuild() {
- if (fFilesSaved && ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
- new GlobalBuildAction(JavaScriptPlugin.getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
- }
- }
-
- private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) {
- final boolean canSaveAutomatically= fSaveMode != SAVE_ALL_ALWAYS_ASK;
- if (canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors()) //must save everything
- return true;
- ListDialog dialog= new ListDialog(shell) {
- {
- setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
- }
- protected Control createDialogArea(Composite parent) {
- Composite result= (Composite) super.createDialogArea(parent);
- if (canSaveAutomatically) {
- final Button check= new Button(result, SWT.CHECK);
- check.setText(RefactoringMessages.RefactoringStarter_always_save);
- check.setSelection(RefactoringSavePreferences.getSaveAllEditors());
- check.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- RefactoringSavePreferences.setSaveAllEditors(check.getSelection());
- }
- });
- applyDialogFont(result);
- }
- return result;
- }
- };
- dialog.setTitle(RefactoringMessages.RefactoringStarter_save_all_resources);
- dialog.setAddCancelButton(true);
- dialog.setLabelProvider(createDialogLabelProvider());
- dialog.setMessage(RefactoringMessages.RefactoringStarter_must_save);
- dialog.setContentProvider(new ArrayContentProvider());
- dialog.setInput(Arrays.asList(dirtyEditors));
- return dialog.open() == Window.OK;
- }
-
- public boolean hasFilesSaved() {
- return fFilesSaved;
- }
-
- private ILabelProvider createDialogLabelProvider() {
- return new LabelProvider() {
- public Image getImage(Object element) {
- return ((IEditorPart) element).getTitleImage();
- }
- public String getText(Object element) {
- return ((IEditorPart) element).getTitle();
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSavePreferences.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSavePreferences.java
deleted file mode 100644
index 2545a1d5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/RefactoringSavePreferences.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-
-public class RefactoringSavePreferences {
-
- public static final String PREF_SAVE_ALL_EDITORS= PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS;
-
- public static boolean getSaveAllEditors() {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(PREF_SAVE_ALL_EDITORS);
- }
-
- public static void setSaveAllEditors(boolean save) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- store.setValue(PREF_SAVE_ALL_EDITORS, save);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/TextInputWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/TextInputWizardPage.java
deleted file mode 100644
index 7e7e694c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/TextInputWizardPage.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-
-/**
- * A TextInputWizardPage is a simple UserInputWizardPage with facilities
- * to create a text input field and validate its contents.
- * The text is assumed to be a java identifier, hence CamelCase word jumping is installed.
- */
-public abstract class TextInputWizardPage extends UserInputWizardPage{
-
- private String fInitialValue;
- private Text fTextField;
-
- public static final String PAGE_NAME= "TextInputPage";//$NON-NLS-1$
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage <code>true</code> if this page is the wizard's last
- * user input page. Otherwise <code>false</code>.
- */
- public TextInputWizardPage(String description, boolean isLastUserPage) {
- this(description, isLastUserPage, ""); //$NON-NLS-1$
- }
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage <code>true</code> if this page is the wizard's last
- * user input page. Otherwise <code>false</code>
- * @param initialValue the initial value
- */
- public TextInputWizardPage(String description, boolean isLastUserPage, String initialValue) {
- super(PAGE_NAME);
- Assert.isNotNull(initialValue);
- setDescription(description);
- fInitialValue= initialValue;
- }
-
- /**
- * Returns whether the initial input is valid. Typically it is not, because the
- * user is required to provide some information e.g. a new type name etc.
- *
- * @return <code>true</code> iff the input provided at initialization is valid
- */
- protected boolean isInitialInputValid(){
- return false;
- }
-
- /**
- * Returns whether an empty string is a valid input. Typically it is not, because
- * the user is required to provide some information e.g. a new type name etc.
- *
- * @return <code>true</code> iff an empty string is valid
- */
- protected boolean isEmptyInputValid(){
- return false;
- }
-
- /**
- * Returns the content of the text input field.
- *
- * @return the content of the text input field. Returns <code>null</code> if
- * not text input field has been created
- */
- protected String getText() {
- if (fTextField == null)
- return null;
- return fTextField.getText();
- }
-
- /**
- * Sets the new text for the text field. Does nothing if the text field has not been created.
- * @param text the new value
- */
- protected void setText(String text) {
- if (fTextField == null)
- return;
- fTextField.setText(text);
- }
-
- /**
- * Returns the text entry field
- *
- * @return the text entry field
- */
- protected Text getTextField() {
- return fTextField;
- }
-
- /**
- * Returns the initial value.
- *
- * @return the initial value
- */
- public String getInitialValue() {
- return fInitialValue;
- }
-
- /**
- * Performs input validation. Returns a <code>RefactoringStatus</code> which
- * describes the result of input validation. <code>Null<code> is interpreted
- * as no error.
- */
- protected RefactoringStatus validateTextField(String text){
- return null;
- }
-
- protected Text createTextInputField(Composite parent) {
- return createTextInputField(parent, SWT.BORDER);
- }
-
- protected Text createTextInputField(Composite parent, int style) {
- fTextField= new Text(parent, style);
- fTextField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textModified(getText());
- }
- });
- fTextField.setText(fInitialValue);
- TextFieldNavigationHandler.install(fTextField);
- return fTextField;
- }
-
- /**
- * Checks the page's state and issues a corresponding error message. The page validation
- * is computed by calling <code>validatePage</code>.
- */
- protected void textModified(String text) {
- if (! isEmptyInputValid() && "".equals(text)){ //$NON-NLS-1$
- setPageComplete(false);
- setErrorMessage(null);
- restoreMessage();
- return;
- }
- if ((! isInitialInputValid()) && fInitialValue.equals(text)){
- setPageComplete(false);
- setErrorMessage(null);
- restoreMessage();
- return;
- }
-
- RefactoringStatus status= validateTextField(text);
- if (status == null)
- status= new RefactoringStatus();
- setPageComplete(status);
- }
-
- /**
- * Subclasses can override if they want to restore the message differently.
- * This implementation calls <code>setMessage(null)</code>, which clears the message
- * thus exposing the description.
- */
- protected void restoreMessage(){
- setMessage(null);
- }
-
- /* (non-Javadoc)
- * Method declared in IDialogPage
- */
- public void dispose() {
- fTextField= null;
- }
-
- /* (non-Javadoc)
- * Method declared in WizardPage
- */
- public void setVisible(boolean visible) {
- if (visible) {
- textModified(getText());
- }
- super.setVisible(visible);
- if (visible && fTextField != null) {
- fTextField.setFocus();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UseSupertypeWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UseSupertypeWizard.java
deleted file mode 100644
index 719e3212..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UseSupertypeWizard.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeHierarchy;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.UseSuperTypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.UseSuperTypeRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class UseSupertypeWizard extends RefactoringWizard{
-
- /* package */ static final String DIALOG_SETTING_SECTION= "UseSupertypeWizard"; //$NON-NLS-1$
-
- public UseSupertypeWizard(UseSuperTypeRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.UseSupertypeWizard_Use_Super_Type_Where_Possible);
- }
-
- protected void addUserInputPages(){
- addPage(new UseSupertypeInputPage());
- }
-
- private static class UseSupertypeInputPage extends UserInputWizardPage{
-
- private class UseSupertypeContentProvider implements ITreeContentProvider {
-
- private ITypeHierarchy fHierarchy;
-
- public Object[] getChildren(Object element) {
- if (element instanceof ITypeHierarchy)
- return getElements(element);
- return getDirectSuperTypes((IType)element).toArray();
- }
-
- public Set/*<IType>*/ getDirectSuperTypes(IType type){
- Set/*<IType>*/ result= new HashSet();
- final IType superclass= fHierarchy.getSuperclass(type);
- if (superclass != null) {
- result.add(superclass);
- }
- IType[] superInterface= fHierarchy.getSuperInterfaces(type);
- for (int i=0; i < superInterface.length; i++){
- result.add(superInterface[i]);
- }
- try {
- if (type.isInterface()) {
- IType found= type.getJavaScriptProject().findType("java.lang.Object"); //$NON-NLS-1$
- result.add(found);
- }
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- return result;
- }
-
- public Object[] getElements(Object element) {
- if (element instanceof ITypeHierarchy)
- return getChildren(((ITypeHierarchy) element).getType());
- return new Object[0];
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public void dispose() {
- // Do nothing
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof ITypeHierarchy)
- fHierarchy= (ITypeHierarchy) newInput;
- else
- fHierarchy= null;
- }
- }
-
- private static final String REWRITE_INSTANCEOF= "rewriteInstanceOf"; //$NON-NLS-1$
- public static final String PAGE_NAME= "UseSupertypeInputPage";//$NON-NLS-1$
- private TreeViewer fTreeViewer;
- private final Map fFileCount; //IType -> Integer
- private final static String MESSAGE= RefactoringMessages.UseSupertypeInputPage_Select_supertype;
- private JavaScriptElementLabelProvider fLabelProvider;
- private IDialogSettings fSettings;
-
- public UseSupertypeInputPage() {
- super(PAGE_NAME);
- fFileCount= new HashMap(2);
- setMessage(MESSAGE);
- }
-
- private void loadSettings() {
- fSettings= getDialogSettings().getSection(UseSupertypeWizard.DIALOG_SETTING_SECTION);
- if (fSettings == null) {
- fSettings= getDialogSettings().addNewSection(UseSupertypeWizard.DIALOG_SETTING_SECTION);
- fSettings.put(REWRITE_INSTANCEOF, false);
- }
- getUseSupertypeProcessor().setInstanceOf(fSettings.getBoolean(REWRITE_INSTANCEOF));
- }
-
- private UseSuperTypeProcessor getUseSupertypeProcessor() {
- return getUseSupertypeRefactoring().getUseSuperTypeProcessor();
- }
-
- private UseSuperTypeRefactoring getUseSupertypeRefactoring() {
- return ((UseSuperTypeRefactoring)getRefactoring());
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- loadSettings();
- Composite composite= new Composite(parent, SWT.NONE);
- setControl(composite);
- composite.setLayout(new GridLayout());
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(Messages.format(
- RefactoringMessages.UseSupertypeInputPage_Select_supertype_to_use,
- JavaScriptElementLabels.getElementLabel(getUseSupertypeProcessor().getSubType(), JavaScriptElementLabels.T_FULLY_QUALIFIED)));
- label.setLayoutData(new GridData());
-
- addTreeViewer(composite);
-
- final Button checkbox= new Button(composite, SWT.CHECK);
- checkbox.setText(RefactoringMessages.UseSupertypeInputPage_Use_in_instanceof);
- checkbox.setLayoutData(new GridData());
- checkbox.setSelection(getUseSupertypeProcessor().isInstanceOf());
- checkbox.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getUseSupertypeProcessor().setInstanceOf(checkbox.getSelection());
- fSettings.put(REWRITE_INSTANCEOF, checkbox.getSelection());
- setMessage(MESSAGE);
- setPageComplete(true);
- fFileCount.clear();
- fTreeViewer.refresh();
- }
- });
-
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.USE_SUPERTYPE_WIZARD_PAGE);
- }
-
- private void addTreeViewer(Composite composite) {
- fTreeViewer= new TreeViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- final Tree tree= fTreeViewer.getTree();
- final GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= convertHeightInCharsToPixels(12);
- tree.setLayoutData(data);
- fLabelProvider= new UseSupertypeLabelProvider(fFileCount);
- fTreeViewer.setLabelProvider(fLabelProvider);
- fTreeViewer.setContentProvider(new UseSupertypeContentProvider());
- fTreeViewer.setComparator(new ViewerComparator() {
-
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
-
- public int compare(Viewer viewer, Object first, Object second) {
- final IType type1= (IType)first;
- final IType type2= (IType)second;
- try {
- final int kind1= type1.isInterface() ? 1 : 0;
- final int kind2= type2.isInterface() ? 1 : 0;
- if (kind1 - kind2 != 0)
- return kind1 - kind2;
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- return getComparator().compare(type1.getElementName(), type2.getElementName());
- }
- });
- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection ss= (IStructuredSelection)event.getSelection();
- if (new Integer(0).equals(fFileCount.get(ss.getFirstElement()))){
- setMessage(RefactoringMessages.UseSupertypeInputPage_No_updates, IMessageProvider.INFORMATION);
- setPageComplete(false);
- } else {
- setMessage(MESSAGE);
- setPageComplete(true);
- }
- fTreeViewer.refresh();
- }
- });
- try {
- fTreeViewer.setInput(SuperTypeHierarchyCache.getTypeHierarchy(getUseSupertypeProcessor().getSubType()));
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- fTreeViewer.expandAll();
- final TreeItem[] items= tree.getItems();
- if (items.length > 0)
- tree.setSelection(new TreeItem[] {items[0]});
- }
-
- public IWizardPage getNextPage() {
- initializeRefactoring();
- IWizardPage nextPage= super.getNextPage();
- updateUpdateLabels();
- return nextPage;
- }
-
- private void updateUpdateLabels() {
- IType selectedType= getSelectedSupertype();
- final int count= getUseSupertypeProcessor().getChanges();
- fFileCount.put(selectedType, new Integer(count));
- if (count == 0) {
- setMessage(RefactoringMessages.UseSupertypeInputPage_No_updates, IMessageProvider.INFORMATION);
- setPageComplete(false);
- }
- fTreeViewer.refresh();
- if (noSupertypeCanBeUsed()){
- setMessage(RefactoringMessages.UseSupertypeWizard_10, IMessageProvider.INFORMATION);
- setPageComplete(false);
- }
- }
-
- private boolean noSupertypeCanBeUsed() {
- return fTreeViewer.getTree().getItemCount() == countFilesWithValue(0);
- }
-
- private int countFilesWithValue(int i) {
- int count= 0;
- for (Iterator iter= fFileCount.keySet().iterator(); iter.hasNext();) {
- if (((Integer)fFileCount.get(iter.next())).intValue() == i)
- count++;
- }
- return count;
- }
-
- private IType getSelectedSupertype() {
- IStructuredSelection ss= (IStructuredSelection)fTreeViewer.getSelection();
- return (IType)ss.getFirstElement();
- }
-
- public boolean performFinish(){
- initializeRefactoring();
- boolean superFinish= super.performFinish();
- if (! superFinish)
- return false;
- final int count= getUseSupertypeProcessor().getChanges();
- if (count == 0) {
- updateUpdateLabels();
- return false;
- }
- return superFinish;
- }
-
- private void initializeRefactoring() {
- IStructuredSelection ss= (IStructuredSelection)fTreeViewer.getSelection();
- getUseSupertypeProcessor().setSuperType((IType)ss.getFirstElement());
- }
-
- public void dispose() {
- fTreeViewer= null;
- fFileCount.clear();
- fLabelProvider= null;
- super.dispose();
- }
-
- private static class UseSupertypeLabelProvider extends JavaScriptElementLabelProvider{
- private final Map fFileCount;
- private UseSupertypeLabelProvider(Map fileCount){
- fFileCount= fileCount;
- }
- public String getText(Object element) {
- String superText= super.getText(element);
- if (! fFileCount.containsKey(element))
- return superText;
- int count= ((Integer)fFileCount.get(element)).intValue();
- if (count == 0){
- String[] keys= {superText};
- return Messages.format(RefactoringMessages.UseSupertypeInputPage_no_possible_updates, keys);
- } else if (count == 1){
- String [] keys= {superText};
- return Messages.format(RefactoringMessages.UseSupertypeInputPage_updates_possible_in_file, keys);
- } else {
- String[] keys= {superText, String.valueOf(count)};
- return Messages.format(RefactoringMessages.UseSupertypeInputPage_updates_possible_in_files, keys);
- }
- }
- }
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible && fTreeViewer != null)
- fTreeViewer.getTree().setFocus();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceManager.java
deleted file mode 100644
index cbe5c37c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceManager.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-
-public class UserInterfaceManager {
-
- private Map fMap= new HashMap();
-
- private static class Tuple {
- private Class starter;
- private Class wizard;
- public Tuple(Class s, Class w) {
- starter= s;
- wizard= w;
- }
- }
-
- protected void put(Class processor, Class starter, Class wizard) {
- fMap.put(processor, new Tuple(starter, wizard));
- }
-
-
- public UserInterfaceStarter getStarter(Refactoring refactoring) {
- RefactoringProcessor processor= (RefactoringProcessor)refactoring.getAdapter(RefactoringProcessor.class);
- if (processor == null)
- return null;
- Tuple tuple= (Tuple)fMap.get(processor.getClass());
- if (tuple == null)
- return null;
- try {
- UserInterfaceStarter starter= (UserInterfaceStarter)tuple.starter.newInstance();
- Class wizardClass= tuple.wizard;
- Constructor constructor= wizardClass.getConstructor(new Class[] {Refactoring.class});
- RefactoringWizard wizard= (RefactoringWizard)constructor.newInstance(new Object[] {refactoring});
- starter.initialize(wizard);
- return starter;
- } catch (NoSuchMethodException e) {
- return null;
- } catch (IllegalAccessException e) {
- return null;
- } catch (InstantiationException e) {
- return null;
- } catch (IllegalArgumentException e) {
- return null;
- } catch (InvocationTargetException e) {
- return null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceStarter.java
deleted file mode 100644
index fdeb0dc4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/UserInterfaceStarter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.actions.RefactoringStarter;
-
-/**
- * Opens the user interface for a given refactoring.
- */
-public class UserInterfaceStarter {
-
- private RefactoringWizard fWizard;
-
- /**
- * Initializes this user interface starter with the given
- * wizard.
- *
- * @param wizard the refactoring wizard to use
- */
- public void initialize(RefactoringWizard wizard) {
- fWizard= wizard;
- }
-
- /**
- * Actually activates the user interface. This default implementation
- * assumes that the configuration element passed to <code>initialize
- * </code> has an attribute wizard denoting the wizard class to be
- * used for the given refactoring.
- * <p>
- * Subclasses may override to open a different user interface
- *
- * @param refactoring the refactoring for which the user interface
- * should be opened
- * @param parent the parent shell to be used
- * @param saveMode a save mode from {@link RefactoringSaveHelper}
- * @return <code>true</code> iff the refactoring was executed,
- * <code>false</code> otherwise
- *
- * @exception CoreException if the user interface can't be activated
- */
- public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
- String title= fWizard.getDefaultPageTitle();
- if (title == null)
- title= ""; //$NON-NLS-1$
- return new RefactoringStarter().activate(refactoring, fWizard, parent, title, saveMode);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/VisibilityControlUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/VisibilityControlUtil.java
deleted file mode 100644
index acd43112..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/VisibilityControlUtil.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-
-public class VisibilityControlUtil {
- private VisibilityControlUtil(){}
-
- public static Composite createVisibilityControl(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) {
- List allowedVisibilities= convertToIntegerList(availableVisibilities);
- if (allowedVisibilities.size() == 1)
- return null;
-
- Group group= new Group(parent, SWT.NONE);
- group.setText(RefactoringMessages.VisibilityControlUtil_Access_modifier);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- group.setLayoutData(gd);
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= 4;
- group.setLayout(layout);
-
- String[] labels= new String[] {
- "&public", //$NON-NLS-1$
- "pro&tected", //$NON-NLS-1$
- RefactoringMessages.VisibilityControlUtil_defa_ult_4,
- "pri&vate" //$NON-NLS-1$
- };
- Integer[] data= new Integer[] {
- new Integer(Modifier.PUBLIC),
- new Integer(Modifier.PROTECTED),
- new Integer(Modifier.NONE),
- new Integer(Modifier.PRIVATE)};
- Integer initialVisibility= new Integer(correctVisibility);
- for (int i= 0; i < labels.length; i++) {
- Button radio= new Button(group, SWT.RADIO);
- Integer visibilityCode= data[i];
- radio.setText(labels[i]);
- radio.setData(visibilityCode);
- radio.setSelection(visibilityCode.equals(initialVisibility));
- radio.setEnabled(allowedVisibilities.contains(visibilityCode));
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- visibilityChangeListener.visibilityChanged(((Integer)event.widget.getData()).intValue());
- }
- });
- }
- group.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
- return group;
- }
-
- private static List convertToIntegerList(int[] array) {
- List result= new ArrayList(array.length);
- for (int i= 0; i < array.length; i++) {
- result.add(new Integer(array[i]));
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ApplyRefactoringScriptAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ApplyRefactoringScriptAction.java
deleted file mode 100644
index 4b542f42..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ApplyRefactoringScriptAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Action to apply a refactoring script to the workspace.
- *
- * TODO: remove once bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=131746 is fixed
- */
-public final class ApplyRefactoringScriptAction implements IWorkbenchWindowActionDelegate {
-
- /** The workbench window, or <code>null</code> */
- private IWorkbenchWindow fWindow= null;
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- // Do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(final IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final IAction a) {
- if (fWindow != null) {
- org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction action= new org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction();
- action.init(fWindow);
- action.run(a);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final IAction action, final ISelection selection) {
- // Do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/CreateRefactoringScriptAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/CreateRefactoringScriptAction.java
deleted file mode 100644
index 910e0109..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/CreateRefactoringScriptAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Action to create a refactoring script from the refactoring history.
- *
- * TODO: remove once bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=131746 is fixed
- */
-public final class CreateRefactoringScriptAction implements IWorkbenchWindowActionDelegate {
-
- /** The workbench window, or <code>null</code> */
- private IWorkbenchWindow fWindow= null;
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- // Do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(final IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final IAction a) {
- if (fWindow != null) {
- org.eclipse.ltk.ui.refactoring.actions.CreateRefactoringScriptAction action= new org.eclipse.ltk.ui.refactoring.actions.CreateRefactoringScriptAction();
- action.init(fWindow);
- action.run(a);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final IAction action, final ISelection selection) {
- // Do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineConstantAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineConstantAction.java
deleted file mode 100644
index 2f66db6e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineConstantAction.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.RefactoringASTParser;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-/**
- * Inlines a constant.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- */
-public class InlineConstantAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- *
- * @param editor the java editor
- */
- public InlineConstantAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- public InlineConstantAction(IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.InlineConstantAction_inline_Constant);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.INLINE_ACTION);
- }
-
- //---- structured selection ---------------------------------------------
-
- /*
- * @see SelectionDispatchAction#selectionChanged(IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isInlineConstantAvailable(selection));
- } catch (JavaScriptModelException e) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);//no ui
- }
- }
-
- /*
- * @see SelectionDispatchAction#run(IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- try {
- Assert.isTrue(RefactoringAvailabilityTester.isInlineConstantAvailable(selection));
-
- Object first= selection.getFirstElement();
- Assert.isTrue(first instanceof IField);
-
- IField field= (IField) first;
- run(field.getNameRange().getOffset(), field.getNameRange().getLength(), field.getJavaScriptUnit());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception);
- }
- }
-
- //---- text selection -----------------------------------------------
-
- /*
- * @see SelectionDispatchAction#selectionChanged(ITextSelection)
- */
- public void selectionChanged(ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- * @param selection
- */
- public void selectionChanged(JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isInlineConstantAvailable(selection));
- } catch (JavaScriptModelException e) {
- setEnabled(false);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction
- */
- public void run(ITextSelection selection) {
- run(selection.getOffset(), selection.getLength(), SelectionConverter.getInputAsCompilationUnit(fEditor));
- }
-
- private void run(int offset, int length, IJavaScriptUnit cu) {
- Assert.isNotNull(cu);
- Assert.isTrue(offset >= 0);
- Assert.isTrue(length >= 0);
- if (!ActionUtil.isEditable(fEditor, getShell(), cu))
- return;
- try {
- JavaScriptUnit node= RefactoringASTParser.parseWithASTProvider(cu, true, null);
- if (! RefactoringExecutionStarter.startInlineConstantRefactoring(cu, node, offset, length, getShell())) {
- MessageDialog.openInformation(getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_no_constant_reference_or_declaration);
- }
-
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception);
- }
- }
-
- public boolean tryInlineConstant(IJavaScriptUnit unit, JavaScriptUnit node, ITextSelection selection, Shell shell) {
- try {
- if (RefactoringExecutionStarter.startInlineConstantRefactoring(unit, node, selection.getOffset(), selection.getLength(), shell)) {
- return true;
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception);
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineMethodAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineMethodAction.java
deleted file mode 100644
index b65f2285..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/InlineMethodAction.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.RefactoringASTParser;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-/**
- * Inlines a method.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- */
-public class InlineMethodAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- * @param editor the java editor
- */
- public InlineMethodAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- public InlineMethodAction(IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.InlineMethodAction_inline_Method);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.INLINE_ACTION);
- }
-
- //---- structured selection ----------------------------------------------
-
- /*
- * @see SelectionDispatchAction#selectionChanged(IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isInlineMethodAvailable(selection));
- } catch (JavaScriptModelException e) {
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- }
- }
-
- /*
- * @see SelectionDispatchAction#run(IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- try {
- Assert.isTrue(RefactoringAvailabilityTester.isInlineMethodAvailable(selection));
- IFunction method= (IFunction) selection.getFirstElement();
- ISourceRange nameRange= method.getNameRange();
- run(nameRange.getOffset(), nameRange.getLength(), method.getTypeRoot());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineMethodAction_dialog_title, RefactoringMessages.InlineMethodAction_unexpected_exception);
- }
- }
-
- /*
- * @see SelectionDispatchAction#selectionChanged(ITextSelection)
- */
- public void selectionChanged(ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- * @param selection
- */
- public void selectionChanged(JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isInlineMethodAvailable(selection));
- } catch (JavaScriptModelException e) {
- setEnabled(false);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction
- */
- public void run(ITextSelection selection) {
- ITypeRoot typeRoot= SelectionConverter.getInputAsTypeRoot(fEditor);
- if (typeRoot == null)
- return;
- if (! JavaElementUtil.isSourceAvailable(typeRoot))
- return;
- run(selection.getOffset(), selection.getLength(), typeRoot);
- }
-
- private void run(int offset, int length, ITypeRoot typeRoot) {
- if (!ActionUtil.isEditable(fEditor, getShell(), typeRoot))
- return;
- try {
- JavaScriptUnit compilationUnit= RefactoringASTParser.parseWithASTProvider(typeRoot, true, null);
- if (! RefactoringExecutionStarter.startInlineMethodRefactoring(typeRoot, compilationUnit, offset, length, getShell())) {
- MessageDialog.openInformation(getShell(), RefactoringMessages.InlineMethodAction_dialog_title, RefactoringMessages.InlineMethodAction_no_method_invocation_or_declaration_selected);
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineMethodAction_dialog_title, RefactoringMessages.InlineMethodAction_unexpected_exception);
- }
- }
-
- public boolean tryInlineMethod(ITypeRoot typeRoot, JavaScriptUnit node, ITextSelection selection, Shell shell) {
- try {
- if (RefactoringExecutionStarter.startInlineMethodRefactoring(typeRoot, node, selection.getOffset(), selection.getLength(), shell)) {
- return true;
- }
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ListDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ListDialog.java
deleted file mode 100644
index 3756ef59..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ListDialog.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-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.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-public class ListDialog extends SelectionDialog {
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fTableViewer;
- private boolean fAddCancelButton;
-
- public ListDialog(Shell parent) {
- super(parent);
- fAddCancelButton= false;
- }
-
- public void setInput(Object input) {
- fInput= input;
- }
-
- public void setContentProvider(IStructuredContentProvider sp){
- fContentProvider= sp;
- }
-
- public void setLabelProvider(ILabelProvider lp){
- fLabelProvider= lp;
- }
-
- public void setAddCancelButton(boolean addCancelButton) {
- fAddCancelButton= addCancelButton;
- }
-
- public TableViewer getTableViewer(){
- return fTableViewer;
- }
-
- public boolean hasFilters(){
- return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0;
- }
-
- public void create() {
- setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
- super.create();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fAddCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fTableViewer= new TableViewer(parent, getTableStyle());
- fTableViewer.setContentProvider(fContentProvider);
- Table table= fTableViewer.getTable();
- fTableViewer.setLabelProvider(fLabelProvider);
- fTableViewer.setInput(fInput);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(15);
- gd.widthHint= convertWidthInCharsToPixels(55);
- table.setLayoutData(gd);
- applyDialogFont(parent);
- return parent;
- }
-
- protected int getTableStyle() {
- return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveInstanceMethodAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveInstanceMethodAction.java
deleted file mode 100644
index 56a16808..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveInstanceMethodAction.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public final class MoveInstanceMethodAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- * @param editor the java editor
- */
- public MoveInstanceMethodAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- public MoveInstanceMethodAction(IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.MoveInstanceMethodAction_Move_Method);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.MOVE_ACTION);
- }
-
- /*
- * @see SelectionDispatchAction#selectionChanged(IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isMoveMethodAvailable(selection));
- } catch (JavaScriptModelException e) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);//no ui
- }
- }
-
- public void selectionChanged(ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- */
- public void selectionChanged(JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isMoveMethodAvailable(selection));
- } catch (CoreException e) {
- setEnabled(false);
- }
- }
-
- private static IFunction getSingleSelectedMethod(IStructuredSelection selection) {
- if (selection.isEmpty() || selection.size() != 1)
- return null;
-
- Object first= selection.getFirstElement();
- if (! (first instanceof IFunction))
- return null;
- return (IFunction) first;
- }
- /*
- * @see SelectionDispatchAction#run(IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- try {
- Assert.isTrue(RefactoringAvailabilityTester.isMoveMethodAvailable(selection));
- IFunction method= getSingleSelectedMethod(selection);
- Assert.isNotNull(method);
- if (!ActionUtil.isEditable(fEditor, getShell(), method))
- return;
- RefactoringExecutionStarter.startMoveMethodRefactoring(method, getShell());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringMessages.MoveInstanceMethodAction_unexpected_exception);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction
- */
- public void run(ITextSelection selection) {
- try {
- run(selection, SelectionConverter.getInputAsCompilationUnit(fEditor));
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringMessages.MoveInstanceMethodAction_unexpected_exception);
- }
- }
-
- private void run(ITextSelection selection, IJavaScriptUnit cu) throws JavaScriptModelException {
- Assert.isNotNull(cu);
- Assert.isTrue(selection.getOffset() >= 0);
- Assert.isTrue(selection.getLength() >= 0);
-
- if (!ActionUtil.isEditable(fEditor, getShell(), cu))
- return;
-
- IFunction method= getMethod(cu, selection);
- if (method != null) {
- RefactoringExecutionStarter.startMoveMethodRefactoring(method, getShell());
- } else {
- MessageDialog.openInformation(getShell(), RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringMessages.MoveInstanceMethodAction_No_reference_or_declaration);
- }
- }
-
- private static IFunction getMethod(IJavaScriptUnit cu, ITextSelection selection) throws JavaScriptModelException {
- IJavaScriptElement element= SelectionConverter.getElementAtOffset(cu, selection);
- if (element instanceof IFunction)
- return (IFunction) element;
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveStaticMembersAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveStaticMembersAction.java
deleted file mode 100644
index e53a6197..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/MoveStaticMembersAction.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class MoveStaticMembersAction extends SelectionDispatchAction{
-
- private JavaEditor fEditor;
-
- public MoveStaticMembersAction(IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.RefactoringGroup_move_label);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.MOVE_ACTION);
- }
-
- public MoveStaticMembersAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isMoveStaticMembersAvailable(getSelectedMembers(selection)));
- } catch (JavaScriptModelException e) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);//no ui
- }
- }
-
- public void selectionChanged(ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- */
- public void selectionChanged(JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isMoveStaticAvailable(selection));
- } catch (JavaScriptModelException e) {
- setEnabled(false);
- }
- }
-
- public void run(IStructuredSelection selection) {
- try {
- IMember[] members= getSelectedMembers(selection);
- for (int index= 0; index < members.length; index++) {
- if (!ActionUtil.isEditable(getShell(), members[index]))
- return;
- }
- if (RefactoringAvailabilityTester.isMoveStaticMembersAvailable(members))
- RefactoringExecutionStarter.startMoveStaticMembersRefactoring(members, getShell());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-
- public void run(ITextSelection selection) {
- try {
- IMember member= getSelectedMemberFromEditor();
- if (!ActionUtil.isEditable(fEditor, getShell(), member))
- return;
- IMember[] array= new IMember[]{member};
- if (member != null && RefactoringAvailabilityTester.isMoveStaticMembersAvailable(array)){
- RefactoringExecutionStarter.startMoveStaticMembersRefactoring(array, getShell());
- } else {
- MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.MoveMembersAction_unavailable);
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-
- private static IMember[] getSelectedMembers(IStructuredSelection selection){
- if (selection.isEmpty())
- return null;
-
- for (final Iterator iterator= selection.iterator(); iterator.hasNext(); ) {
- if (! (iterator.next() instanceof IMember))
- return null;
- }
- Set memberSet= new HashSet();
- memberSet.addAll(Arrays.asList(selection.toArray()));
- return (IMember[]) memberSet.toArray(new IMember[memberSet.size()]);
- }
-
- private IMember getSelectedMemberFromEditor() throws JavaScriptModelException{
- IJavaScriptElement element= SelectionConverter.getElementAtOffset(fEditor);
- if (element == null || ! (element instanceof IMember))
- return null;
- return (IMember)element;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringActions.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringActions.java
deleted file mode 100644
index 01bfd832..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringActions.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-
-/**
- * Helper class for refactoring actions
- */
-public class RefactoringActions {
-
- /**
- * Converts the given selection into a type using the following rules:
- * <ul>
- * <li>if the selection is enclosed by a type than that type is returned.</li>
- * <li>if the selection is inside a compilation unit or class file than the
- * primary type is returned.</li>
- * <li>otherwise <code>null</code> is returned.
- * </ul>
- */
- public static IType getEnclosingOrPrimaryType(JavaTextSelection selection) throws JavaScriptModelException {
- final IJavaScriptElement element= selection.resolveEnclosingElement();
- if (element != null)
- return convertToEnclosingOrPrimaryType(element);
- return null;
- }
- public static IType getEnclosingOrPrimaryType(JavaEditor editor) throws JavaScriptModelException {
- return convertToEnclosingOrPrimaryType(SelectionConverter.resolveEnclosingElement(
- editor, (ITextSelection)editor.getSelectionProvider().getSelection()));
- }
-
- private static IType convertToEnclosingOrPrimaryType(IJavaScriptElement element) throws JavaScriptModelException {
- if (element instanceof IType)
- return (IType)element;
- IType result= (IType)element.getAncestor(IJavaScriptElement.TYPE);
- if (result != null)
- return result;
- if (element instanceof IJavaScriptUnit)
- return ((IJavaScriptUnit)element).findPrimaryType();
- if (element instanceof IClassFile)
- return ((IClassFile)element).getType();
- return null;
- }
-
- /**
- * Converts the given selection into a type using the following rules:
- * <ul>
- * <li>if the selection is enclosed by a type than that type is returned.</li>
- * <li>otherwise <code>null</code> is returned.
- * </ul>
- */
- public static IType getEnclosingType(JavaTextSelection selection) throws JavaScriptModelException {
- return convertToEnclosingType(selection.resolveEnclosingElement());
- }
- public static IType getEnclosingType(JavaEditor editor) throws JavaScriptModelException {
- return convertToEnclosingType(SelectionConverter.resolveEnclosingElement(
- editor, (ITextSelection)editor.getSelectionProvider().getSelection()));
- }
-
- private static IType convertToEnclosingType(IJavaScriptElement element) {
- if (element == null)
- return null;
- if (! (element instanceof IType))
- element= element.getAncestor(IJavaScriptElement.TYPE);
- return (IType)element;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringStarter.java
deleted file mode 100644
index 4e7cae34..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RefactoringStarter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSaveHelper;
-
-/**
- * A helper class to activate the UI of a refactoring
- */
-public class RefactoringStarter {
-
- private RefactoringStatus fStatus;
-
- /**
- * @param refactoring
- * @param wizard
- * @param parent
- * @param dialogTitle
- * @param saveMode a save mode from {@link RefactoringSaveHelper}
- * @return <code>true</code> if the refactoring was executed, <code>false</code> otherwise
- * @throws JavaScriptModelException
- */
- public boolean activate(Refactoring refactoring, RefactoringWizard wizard, Shell parent, String dialogTitle, int saveMode) throws JavaScriptModelException {
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(saveMode);
- if (! canActivate(saveHelper, parent))
- return false;
-
- try {
- RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
- int result= op.run(parent, dialogTitle);
- fStatus= op.getInitialConditionCheckingStatus();
- if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
- saveHelper.triggerBuild();
- return false;
- } else {
- return true;
- }
- } catch (InterruptedException e) {
- return false; // User action got cancelled
- }
- }
-
- public RefactoringStatus getInitialConditionCheckingStatus() {
- return fStatus;
- }
-
- private boolean canActivate(RefactoringSaveHelper saveHelper, Shell shell) {
- return saveHelper.saveEditors(shell);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameJavaElementAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameJavaElementAction.java
deleted file mode 100644
index 35b94b3e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameJavaElementAction.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeParameter;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.ActionUtil;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.RenameLinkedMode;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class RenameJavaElementAction extends SelectionDispatchAction {
-
- private JavaEditor fEditor;
-
- public RenameJavaElementAction(IWorkbenchSite site) {
- super(site);
- }
-
- public RenameJavaElementAction(JavaEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- //---- Structured selection ------------------------------------------------
-
- public void selectionChanged(IStructuredSelection selection) {
- try {
- if (selection.size() == 1) {
- setEnabled(canEnable(selection));
- return;
- }
- } catch (JavaScriptModelException e) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- setEnabled(false);
- }
-
- private static boolean canEnable(IStructuredSelection selection) throws CoreException {
- IJavaScriptElement element= getJavaElement(selection);
- if (element == null)
- return false;
- return isRenameAvailable(element);
- }
-
- private static IJavaScriptElement getJavaElement(IStructuredSelection selection) {
- if (selection.size() != 1)
- return null;
- Object first= selection.getFirstElement();
- if (! (first instanceof IJavaScriptElement))
- return null;
- return (IJavaScriptElement)first;
- }
-
- public void run(IStructuredSelection selection) {
- IJavaScriptElement element= getJavaElement(selection);
- if (element == null)
- return;
- try {
- run(element, false);
- } catch (CoreException e){
- ExceptionHandler.handle(e, RefactoringMessages.RenameJavaElementAction_name, RefactoringMessages.RenameJavaElementAction_exception);
- }
- }
-
- //---- text selection ------------------------------------------------------------
-
- public void selectionChanged(ITextSelection selection) {
- if (selection instanceof JavaTextSelection) {
- try {
- IJavaScriptElement[] elements= ((JavaTextSelection)selection).resolveElementAtOffset();
- if (elements.length == 1) {
- setEnabled(isRenameAvailable(elements[0]));
- } else {
- setEnabled(false);
- }
- } catch (CoreException e) {
- setEnabled(false);
- }
- } else {
- setEnabled(true);
- }
- }
-
- public void run(ITextSelection selection) {
- RenameLinkedMode activeLinkedMode= RenameLinkedMode.getActiveLinkedMode();
- if (activeLinkedMode != null) {
- if (activeLinkedMode.isCaretInLinkedPosition()) {
- activeLinkedMode.startFullDialog();
- return;
- } else {
- activeLinkedMode.cancel();
- }
- }
-
- try {
- IJavaScriptElement element= getJavaElementFromEditor();
- if (element != null && isRenameAvailable(element)) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
- run(element, store.getBoolean(PreferenceConstants.REFACTOR_LIGHTWEIGHT));
- return;
- }
- } catch (CoreException e) {
- ExceptionHandler.handle(e, RefactoringMessages.RenameJavaElementAction_name, RefactoringMessages.RenameJavaElementAction_exception);
- }
- MessageDialog.openInformation(getShell(), RefactoringMessages.RenameJavaElementAction_name, RefactoringMessages.RenameJavaElementAction_not_available);
- }
-
- public boolean canRunInEditor() {
- if (RenameLinkedMode.getActiveLinkedMode() != null)
- return true;
-
- try {
- IJavaScriptElement element= getJavaElementFromEditor();
- if (element == null)
- return false;
-
- return isRenameAvailable(element);
- } catch (JavaScriptModelException e) {
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- return false;
- }
-
- private IJavaScriptElement getJavaElementFromEditor() throws JavaScriptModelException {
- IJavaScriptElement[] elements= SelectionConverter.codeResolve(fEditor);
- if (elements == null || elements.length != 1)
- return null;
- return elements[0];
- }
-
- //---- helper methods -------------------------------------------------------------------
-
- private void run(IJavaScriptElement element, boolean lightweight) throws CoreException {
- // Work around for http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
- if (! ActionUtil.isEditable(fEditor, getShell(), element))
- return;
- //XXX workaround bug 31998
- if (ActionUtil.mustDisableJavaModelAction(getShell(), element))
- return;
-
- if (lightweight && fEditor instanceof CompilationUnitEditor && ! (element instanceof IPackageFragment)) {
- new RenameLinkedMode(element, (CompilationUnitEditor) fEditor).start();
- } else {
- RefactoringExecutionStarter.startRenameRefactoring(element, getShell());
- }
- }
-
- private static boolean isRenameAvailable(IJavaScriptElement element) throws CoreException {
- switch (element.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- return RefactoringAvailabilityTester.isRenameAvailable((IJavaScriptProject) element);
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- return RefactoringAvailabilityTester.isRenameAvailable((IPackageFragmentRoot) element);
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- return RefactoringAvailabilityTester.isRenameAvailable((IPackageFragment) element);
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- return RefactoringAvailabilityTester.isRenameAvailable((IJavaScriptUnit) element);
- case IJavaScriptElement.TYPE:
- return RefactoringAvailabilityTester.isRenameAvailable((IType) element);
- case IJavaScriptElement.METHOD:
- final IFunction method= (IFunction) element;
- if (method.isConstructor())
- return RefactoringAvailabilityTester.isRenameAvailable(method.getDeclaringType());
- else
- return RefactoringAvailabilityTester.isRenameAvailable(method);
- case IJavaScriptElement.FIELD:
- final IField field= (IField) element;
- if (Flags.isEnum(field.getFlags()))
- return RefactoringAvailabilityTester.isRenameEnumConstAvailable(field);
- else
- return RefactoringAvailabilityTester.isRenameFieldAvailable(field);
- case IJavaScriptElement.TYPE_PARAMETER:
- return RefactoringAvailabilityTester.isRenameAvailable((ITypeParameter) element);
- case IJavaScriptElement.LOCAL_VARIABLE:
- return RefactoringAvailabilityTester.isRenameAvailable((ILocalVariable) element);
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameResourceAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameResourceAction.java
deleted file mode 100644
index 1402689b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/RenameResourceAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class RenameResourceAction extends SelectionDispatchAction {
-
- public RenameResourceAction(IWorkbenchSite site) {
- super(site);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- IResource element= getResource(selection);
- if (element == null)
- setEnabled(false);
- else
- setEnabled(RefactoringAvailabilityTester.isRenameAvailable(element));
- }
-
- public void run(IStructuredSelection selection) {
- IResource resource = getResource(selection);
- if (!RefactoringAvailabilityTester.isRenameAvailable(resource))
- return;
- try {
- RefactoringExecutionStarter.startRenameResourceRefactoring(resource, getShell());
- } catch (CoreException e) {
- ExceptionHandler.handle(e, RefactoringMessages.RenameJavaElementAction_name, RefactoringMessages.RenameJavaElementAction_exception);
- }
- }
-
- private static IResource getResource(IStructuredSelection selection) {
- if (selection.size() != 1)
- return null;
- Object first= selection.getFirstElement();
- if (! (first instanceof IResource))
- return null;
- return (IResource)first;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ShowRefactoringHistoryAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ShowRefactoringHistoryAction.java
deleted file mode 100644
index 05a91524..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/actions/ShowRefactoringHistoryAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Action to show the global refactoring history.
- *
- * TODO: remove once bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=131746 is fixed
- */
-public final class ShowRefactoringHistoryAction implements IWorkbenchWindowActionDelegate {
-
- /** The workbench window, or <code>null</code> */
- private IWorkbenchWindow fWindow= null;
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- // Do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(final IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final IAction a) {
- if (fWindow != null) {
- org.eclipse.ltk.ui.refactoring.actions.ShowRefactoringHistoryAction action= new org.eclipse.ltk.ui.refactoring.actions.ShowRefactoringHistoryAction();
- action.init(fWindow);
- action.run(a);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(final IAction action, final ISelection selection) {
- // Do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/binary/BinaryRefactoringHistoryWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/binary/BinaryRefactoringHistoryWizard.java
deleted file mode 100644
index 2d0b9e71..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/binary/BinaryRefactoringHistoryWizard.java
+++ /dev/null
@@ -1,731 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.binary;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.jar.JarFile;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-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.SubProgressMonitor;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringContribution;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
-import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
-import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
-import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryWizard;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.refactoring.descriptors.JavaScriptRefactoringDescriptor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.JDTRefactoringContribution;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.JDTRefactoringDescriptor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.JavaRefactoringArguments;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.base.JavaStatusContext;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.binary.SourceCreationOperation;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.binary.StubCreationOperation;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.CoreUtility;
-
-/**
- * Partial implementation of a refactoring history wizard which creates stubs
- * from a binary package fragment root while refactoring.
- *
- *
- */
-public abstract class BinaryRefactoringHistoryWizard extends RefactoringHistoryWizard {
-
- /** The meta-inf fragment */
- private static final String META_INF_FRAGMENT= JarFile.MANIFEST_NAME.substring(0, JarFile.MANIFEST_NAME.indexOf('/'));
-
- /** The temporary linked source folder */
- private static final String SOURCE_FOLDER= ".src"; //$NON-NLS-1$
-
- /** The temporary stubs folder */
- private static final String STUB_FOLDER= ".stubs"; //$NON-NLS-1$
-
- /**
- * Updates the new classpath with exclusion patterns for the specified path.
- *
- * @param entries
- * the classpath entries
- * @param path
- * the path
- */
- private static void addExclusionPatterns(final List entries, final IPath path) {
- for (int index= 0; index < entries.size(); index++) {
- final IIncludePathEntry entry= (IIncludePathEntry) entries.get(index);
- if (entry.getEntryKind() == IIncludePathEntry.CPE_SOURCE && entry.getPath().isPrefixOf(path)) {
- final IPath[] patterns= entry.getExclusionPatterns();
- if (!JavaModelUtil.isExcludedPath(path, patterns)) {
- final IPath[] filters= new IPath[patterns.length + 1];
- System.arraycopy(patterns, 0, filters, 0, patterns.length);
- filters[patterns.length]= path.removeFirstSegments(entry.getPath().segmentCount()).addTrailingSeparator();
- entries.set(index, JavaScriptCore.newSourceEntry(entry.getPath(), filters, entry.getOutputLocation()));
- }
- }
- }
- }
-
- /**
- * Checks whether the archive referenced by the package fragment root is not
- * shared with multiple java projects in the workspace.
- *
- * @param root
- * the package fragment root
- * @param monitor
- * the progress monitor to use
- * @return the status of the operation
- */
- private static RefactoringStatus checkPackageFragmentRoots(final IPackageFragmentRoot root, final IProgressMonitor monitor) {
- final RefactoringStatus status= new RefactoringStatus();
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 100);
- final IWorkspaceRoot workspace= ResourcesPlugin.getWorkspace().getRoot();
- if (workspace != null) {
- final IJavaScriptModel model= JavaScriptCore.create(workspace);
- if (model != null) {
- try {
- final URI uri= getLocationURI(root.getRawIncludepathEntry());
- if (uri != null) {
- final IJavaScriptProject[] projects= model.getJavaScriptProjects();
- final IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
- try {
- subMonitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, projects.length * 100);
- for (int index= 0; index < projects.length; index++) {
- final IPackageFragmentRoot[] roots= projects[index].getPackageFragmentRoots();
- final IProgressMonitor subsubMonitor= new SubProgressMonitor(subMonitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
- try {
- subsubMonitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, roots.length);
- for (int offset= 0; offset < roots.length; offset++) {
- final IPackageFragmentRoot current= roots[offset];
- if (!current.equals(root) && current.getKind() == IPackageFragmentRoot.K_BINARY) {
- final IIncludePathEntry entry= current.getRawIncludepathEntry();
- if (entry.getEntryKind() == IIncludePathEntry.CPE_LIBRARY) {
- final URI location= getLocationURI(entry);
- if (uri.equals(location))
- status.addFatalError(Messages.format(RefactoringMessages.JarImportWizard_error_shared_jar, new String[] { current.getJavaScriptProject().getElementName() }));
- }
- }
- subsubMonitor.worked(1);
- }
- } finally {
- subsubMonitor.done();
- }
- }
- } finally {
- subMonitor.done();
- }
- }
- } catch (CoreException exception) {
- status.addError(exception.getLocalizedMessage());
- }
- }
- }
- } finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * Configures the classpath of the project before refactoring.
- *
- * @param project
- * the java project
- * @param root
- * the package fragment root to refactor
- * @param folder
- * the temporary source folder
- * @param monitor
- * the progress monitor to use
- * @throws IllegalStateException
- * if the plugin state location does not exist
- * @throws CoreException
- * if an error occurs while configuring the class path
- */
- private static void configureClasspath(final IJavaScriptProject project, final IPackageFragmentRoot root, final IFolder folder, final IProgressMonitor monitor) throws IllegalStateException, CoreException {
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 200);
- final IIncludePathEntry entry= root.getRawIncludepathEntry();
- final IIncludePathEntry[] entries= project.getRawIncludepath();
- final List list= new ArrayList();
- list.addAll(Arrays.asList(entries));
- final IFileStore store= EFS.getLocalFileSystem().getStore(JavaScriptPlugin.getDefault().getStateLocation().append(STUB_FOLDER).append(project.getElementName()));
- if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
- store.delete(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- store.mkdir(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- folder.createLink(store.toURI(), IResource.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- addExclusionPatterns(list, folder.getFullPath());
- for (int index= 0; index < entries.length; index++) {
- if (entries[index].equals(entry))
- list.add(index, JavaScriptCore.newSourceEntry(folder.getFullPath()));
- }
- project.setRawIncludepath((IIncludePathEntry[]) list.toArray(new IIncludePathEntry[list.size()]), false, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Returns the location URI of the classpath entry
- *
- * @param entry
- * the classpath entry
- * @return the location URI
- */
- public static URI getLocationURI(final IIncludePathEntry entry) {
- IPath path= null;
- if (entry.getEntryKind() == IIncludePathEntry.CPE_VARIABLE)
- path= JavaScriptCore.getResolvedVariablePath(entry.getPath());
- else
- path= entry.getPath();
- final IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- URI location= null;
- if (root.exists(path)) {
- location= root.getFile(path).getRawLocationURI();
- } else
- location= URIUtil.toURI(path);
- return location;
- }
-
- /** Is auto build enabled? */
- protected boolean fAutoBuild= true;
-
- /** Has the wizard been cancelled? */
- protected boolean fCancelled= false;
-
- /** The current refactoring arguments, or <code>null</code> */
- protected RefactoringArguments fCurrentArguments= null;
-
- /** The current refactoring to be initialized, or <code>null</code> */
- protected IScriptableRefactoring fCurrentRefactoring= null;
-
- /** The java project or <code>null</code> */
- protected IJavaScriptProject fJavaProject= null;
-
- /**
- * The packages which already have been processed (element type:
- * &lt;IPackageFragment&gt;)
- */
- protected final Collection fProcessedFragments= new HashSet();
-
- /** The temporary source folder, or <code>null</code> */
- protected IFolder fSourceFolder= null;
-
- /**
- * Creates a new stub refactoring history wizard.
- *
- * @param overview
- * <code>true</code> to show an overview of the refactorings,
- * <code>false</code> otherwise
- * @param caption
- * the wizard caption
- * @param title
- * the wizard title
- * @param description
- * the wizard description
- */
- protected BinaryRefactoringHistoryWizard(final boolean overview, final String caption, final String title, final String description) {
- super(overview, caption, title, description);
- }
-
- /**
- * Creates a new stub refactoring history wizard.
- *
- * @param caption
- * the wizard caption
- * @param title
- * the wizard title
- * @param description
- * the wizard description
- */
- protected BinaryRefactoringHistoryWizard(final String caption, final String title, final String description) {
- super(caption, title, description);
- }
-
- /**
- * {@inheritDoc}
- */
- protected RefactoringStatus aboutToPerformHistory(final IProgressMonitor monitor) {
- final RefactoringStatus status= new RefactoringStatus();
- try {
- fJavaProject= null;
- fSourceFolder= null;
- fProcessedFragments.clear();
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 520);
- status.merge(super.aboutToPerformHistory(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
- if (!status.hasFatalError()) {
- final IPackageFragmentRoot root= getPackageFragmentRoot();
- if (root != null) {
- status.merge(checkPackageFragmentRoots(root, new SubProgressMonitor(monitor, 90, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
- if (!status.hasFatalError()) {
- status.merge(checkSourceAttachmentRefactorings(new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
- if (!status.hasFatalError()) {
- final IJavaScriptProject project= root.getJavaScriptProject();
- if (project != null) {
- final IFolder folder= project.getProject().getFolder(SOURCE_FOLDER + String.valueOf(System.currentTimeMillis()));
- try {
- fAutoBuild= CoreUtility.enableAutoBuild(false);
- final RefactoringHistory history= getRefactoringHistory();
- if (history != null && !history.isEmpty())
- configureClasspath(project, root, folder, new SubProgressMonitor(monitor, 300, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } catch (CoreException exception) {
- status.merge(RefactoringStatus.createFatalErrorStatus(exception.getLocalizedMessage()));
- try {
- project.setRawIncludepath(project.readRawIncludepath(), false, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } catch (CoreException throwable) {
- JavaScriptPlugin.log(throwable);
- }
- } finally {
- if (!status.hasFatalError()) {
- fJavaProject= project;
- fSourceFolder= folder;
- }
- }
- }
- }
- }
- }
- }
- } finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * {@inheritDoc}
- */
- protected RefactoringStatus aboutToPerformRefactoring(final Refactoring refactoring, final RefactoringDescriptor descriptor, final IProgressMonitor monitor) {
- final RefactoringStatus status= new RefactoringStatus();
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 100);
- status.merge(createNecessarySourceCode(refactoring, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
- if (!status.hasFatalError()) {
- if (fCurrentRefactoring != null && fCurrentArguments != null)
- status.merge(fCurrentRefactoring.initialize(fCurrentArguments));
- }
- } finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * Can this wizard use the source attachment of the package fragment root if
- * necessary?
- *
- * @return <code>true</code> to use the source attachment,
- * <code>false</code> otherwise
- */
- protected boolean canUseSourceAttachment() {
- final IPackageFragmentRoot root= getPackageFragmentRoot();
- if (root != null) {
- try {
- return root.getSourceAttachmentPath() != null;
- } catch (JavaScriptModelException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- return false;
- }
-
- /**
- * Checks whether there are any refactorings to be executed which need a
- * source attachment, but none exists.
- *
- * @param monitor
- * the progress monitor
- * @return a status describing the outcome of the check
- */
- protected RefactoringStatus checkSourceAttachmentRefactorings(final IProgressMonitor monitor) {
- final RefactoringStatus status= new RefactoringStatus();
- try {
- if (!canUseSourceAttachment()) {
- final RefactoringDescriptorProxy[] proxies= getRefactoringHistory().getDescriptors();
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, proxies.length * 100);
- for (int index= 0; index < proxies.length; index++) {
- final RefactoringDescriptor descriptor= proxies[index].requestDescriptor(new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- if (descriptor != null) {
- final int flags= descriptor.getFlags();
- if ((flags & JavaScriptRefactoringDescriptor.JAR_SOURCE_ATTACHMENT) != 0)
- status.merge(RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringMessages.BinaryRefactoringHistoryWizard_error_missing_source_attachment, descriptor.getDescription())));
- }
- }
- } else
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 1);
- } finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * Creates the necessary source code for the refactoring.
- *
- * @param refactoring
- * the refactoring to create the source code for
- * @param monitor
- * the progress monitor to use
- */
- private RefactoringStatus createNecessarySourceCode(final Refactoring refactoring, final IProgressMonitor monitor) {
- final RefactoringStatus status= new RefactoringStatus();
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, 240);
- final IPackageFragmentRoot root= getPackageFragmentRoot();
- if (root != null && fSourceFolder != null && fJavaProject != null) {
- try {
- final SubProgressMonitor subMonitor= new SubProgressMonitor(monitor, 40, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
- final IJavaScriptElement[] elements= root.getChildren();
- final List list= new ArrayList(elements.length);
- try {
- subMonitor.beginTask(RefactoringMessages.JarImportWizard_prepare_import, elements.length);
- for (int index= 0; index < elements.length; index++) {
- final IJavaScriptElement element= elements[index];
- if (!fProcessedFragments.contains(element) && !element.getElementName().equals(META_INF_FRAGMENT))
- list.add(element);
- subMonitor.worked(1);
- }
- } finally {
- subMonitor.done();
- }
- if (!list.isEmpty()) {
- fProcessedFragments.addAll(list);
- final URI uri= fSourceFolder.getRawLocationURI();
- if (uri != null) {
- final IPackageFragmentRoot sourceFolder= fJavaProject.getPackageFragmentRoot(fSourceFolder);
- IWorkspaceRunnable runnable= null;
- if (canUseSourceAttachment()) {
- runnable= new SourceCreationOperation(uri, list) {
-
- private IPackageFragment fFragment= null;
-
- protected final void createCompilationUnit(final IFileStore store, final String name, final String content, final IProgressMonitor pm) throws CoreException {
- fFragment.createCompilationUnit(name, content, true, pm);
- }
-
- protected final void createPackageFragment(final IFileStore store, final String name, final IProgressMonitor pm) throws CoreException {
- fFragment= sourceFolder.createPackageFragment(name, true, pm);
- }
- };
- } else {
- runnable= new StubCreationOperation(uri, list, true) {
-
- private IPackageFragment fFragment= null;
-
- protected final void createCompilationUnit(final IFileStore store, final String name, final String content, final IProgressMonitor pm) throws CoreException {
- fFragment.createCompilationUnit(name, content, true, pm);
- }
-
- protected final void createPackageFragment(final IFileStore store, final String name, final IProgressMonitor pm) throws CoreException {
- fFragment= sourceFolder.createPackageFragment(name, true, pm);
- }
- };
- }
- try {
- runnable.run(new SubProgressMonitor(monitor, 150, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } finally {
- fSourceFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 50, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- }
- }
- }
- } catch (CoreException exception) {
- status.addFatalError(exception.getLocalizedMessage());
- }
- }
- } finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Refactoring createRefactoring(final RefactoringDescriptor descriptor, final RefactoringStatus status) throws CoreException {
- Assert.isNotNull(descriptor);
- Refactoring refactoring= null;
- if (descriptor instanceof JDTRefactoringDescriptor) {
- final JDTRefactoringDescriptor javaDescriptor= (JDTRefactoringDescriptor) descriptor;
- final RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());
- if (contribution instanceof JDTRefactoringContribution) {
- final JDTRefactoringContribution extended= (JDTRefactoringContribution) contribution;
- refactoring= extended.createRefactoring(descriptor);
- }
- if (refactoring != null) {
- final RefactoringArguments arguments= javaDescriptor.createArguments();
- if (arguments instanceof JavaRefactoringArguments) {
- final JavaRefactoringArguments extended= (JavaRefactoringArguments) arguments;
- if (fJavaProject != null) {
- final String name= fJavaProject.getElementName();
- extended.setProject(name);
- String handle= extended.getAttribute(JDTRefactoringDescriptor.ATTRIBUTE_INPUT);
- if (handle != null && !"".equals(handle)) //$NON-NLS-1$
- extended.setAttribute(JDTRefactoringDescriptor.ATTRIBUTE_INPUT, getTransformedHandle(name, handle));
- int count= 1;
- String attribute= JDTRefactoringDescriptor.ATTRIBUTE_ELEMENT + count;
- while ((handle= extended.getAttribute(attribute)) != null) {
- if (!"".equals(handle)) //$NON-NLS-1$
- extended.setAttribute(attribute, getTransformedHandle(name, handle));
- count++;
- attribute= JDTRefactoringDescriptor.ATTRIBUTE_ELEMENT + count;
- }
- }
- } else
- status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
- if (refactoring instanceof IScriptableRefactoring) {
- fCurrentRefactoring= (IScriptableRefactoring) refactoring;
- fCurrentArguments= arguments;
- } else
- status.merge(RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_initialization_error, javaDescriptor.getID())));
- }
- return refactoring;
- }
- return null;
- }
-
- /**
- * Deconfigures the classpath after all refactoring have been performed.
- *
- * @param entries
- * the classpath entries to reset the project to
- * @param monitor
- * the progress monitor to use
- * @return <code>true</code> if the classpath has been changed,
- * <code>false</code> otherwise
- * @throws CoreException
- * if an error occurs while deconfiguring the classpath
- */
- protected boolean deconfigureClasspath(IIncludePathEntry[] entries, IProgressMonitor monitor) throws CoreException {
- return false;
- }
-
- /**
- * Deconfigures the classpath of the project after refactoring.
- *
- * @param monitor
- * the progress monitor to use
- * @throws CoreException
- * if an error occurs while deconfiguring the classpath
- */
- private void deconfigureClasspath(final IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_cleanup_import, 300);
- if (fJavaProject != null) {
- final IIncludePathEntry[] entries= fJavaProject.readRawIncludepath();
- final boolean changed= deconfigureClasspath(entries, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- final RefactoringHistory history= getRefactoringHistory();
- final boolean valid= history != null && !history.isEmpty();
- if (valid)
- RefactoringCore.getUndoManager().flush();
- if (valid || changed)
- fJavaProject.setRawIncludepath(entries, changed, new SubProgressMonitor(monitor, 60, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- }
- if (fSourceFolder != null) {
- final IFileStore store= EFS.getStore(fSourceFolder.getRawLocationURI());
- if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
- store.delete(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- fSourceFolder.delete(true, false, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- fSourceFolder.clearHistory(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- fSourceFolder= null;
- }
- if (fJavaProject != null) {
- try {
- fJavaProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } catch (CoreException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- } finally {
- fJavaProject= null;
- monitor.done();
- }
- }
-
- /**
- * Returns the package fragment root to stub.
- *
- * @return the package fragment root to stub, or <code>null</code>
- */
- protected abstract IPackageFragmentRoot getPackageFragmentRoot();
-
- /**
- * Returns the refactoring history to perform.
- *
- * @return the refactoring history to perform, or the empty history
- */
- protected abstract RefactoringHistory getRefactoringHistory();
-
- /**
- * Returns the transformed handle corresponding to the specified input
- * handle.
- *
- * @param project
- * the project, or <code>null</code> for the workspace
- * @param handle
- * the handle to transform
- * @return the transformed handle, or the original one if nothing needed to
- * be transformed
- */
- private String getTransformedHandle(final String project, final String handle) {
- if (fSourceFolder != null) {
- final IJavaScriptElement target= JavaScriptCore.create(fSourceFolder);
- if (target instanceof IPackageFragmentRoot) {
- final IPackageFragmentRoot extended= (IPackageFragmentRoot) target;
- String sourceIdentifier= null;
- final IJavaScriptElement element= JDTRefactoringDescriptor.handleToElement(project, handle, false);
- if (element != null) {
- final IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (root != null)
- sourceIdentifier= root.getHandleIdentifier();
- else {
- final IJavaScriptProject javaProject= element.getJavaScriptProject();
- if (javaProject != null)
- sourceIdentifier= javaProject.getHandleIdentifier();
- }
- if (sourceIdentifier != null) {
- final IJavaScriptElement result= JavaScriptCore.create(extended.getHandleIdentifier() + element.getHandleIdentifier().substring(sourceIdentifier.length()));
- if (result != null)
- return JDTRefactoringDescriptor.elementToHandle(project, result);
- }
- }
- }
- }
- return handle;
- }
-
- /**
- * {@inheritDoc}
- */
- protected RefactoringStatus historyPerformed(final IProgressMonitor monitor) {
- try {
- monitor.beginTask(RefactoringMessages.JarImportWizard_cleanup_import, 100);
- final RefactoringStatus status= super.historyPerformed(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- if (!status.hasFatalError()) {
- try {
- deconfigureClasspath(new SubProgressMonitor(monitor, 90, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } catch (CoreException exception) {
- status.addError(exception.getLocalizedMessage());
- } finally {
- try {
- CoreUtility.enableAutoBuild(fAutoBuild);
- } catch (CoreException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- }
- return status;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean performCancel() {
- fCancelled= true;
- return super.performCancel();
- }
-
- /**
- * {@inheritDoc}
- */
- protected RefactoringStatus refactoringPerformed(final Refactoring refactoring, final IProgressMonitor monitor) {
- try {
- monitor.beginTask("", 120); //$NON-NLS-1$
- final RefactoringStatus status= super.refactoringPerformed(refactoring, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- if (!status.hasFatalError()) {
- if (fSourceFolder != null) {
- try {
- fSourceFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- } catch (CoreException exception) {
- JavaScriptPlugin.log(exception);
- }
- }
- }
- return status;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean selectPreviewChange(final Change change) {
- if (fSourceFolder != null) {
- final IPath source= fSourceFolder.getFullPath();
- final Object element= change.getModifiedElement();
- if (element instanceof IAdaptable) {
- final IAdaptable adaptable= (IAdaptable) element;
- final IResource resource= (IResource) adaptable.getAdapter(IResource.class);
- if (resource != null && source.isPrefixOf(resource.getFullPath()))
- return false;
- }
- }
- return super.selectPreviewChange(change);
- }
-
- /**
- * {@inheritDoc}
- */
- protected boolean selectStatusEntry(final RefactoringStatusEntry entry) {
- if (fSourceFolder != null) {
- final IPath source= fSourceFolder.getFullPath();
- final RefactoringStatusContext context= entry.getContext();
- if (context instanceof JavaStatusContext) {
- final JavaStatusContext extended= (JavaStatusContext) context;
- final IJavaScriptUnit unit= extended.getCompilationUnit();
- if (unit != null) {
- final IResource resource= unit.getResource();
- if (resource != null && source.isPrefixOf(resource.getFullPath()))
- return false;
- }
- }
- }
- return super.selectStatusEntry(entry);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodInputPage.java
deleted file mode 100644
index 0423bf35..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodInputPage.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.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.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.ParameterInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ExtractMethodRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.ChangeParametersControl;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.IParameterListChangeListener;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-public class ExtractMethodInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "ExtractMethodInputPage";//$NON-NLS-1$
-
- private ExtractMethodRefactoring fRefactoring;
- private Text fTextField;
- private boolean fFirstTime;
- private JavaSourceViewer fSignaturePreview;
- private Document fSignaturePreviewDocument;
- private IDialogSettings fSettings;
-
- private static final String DESCRIPTION = RefactoringMessages.ExtractMethodInputPage_description;
- private static final String THROW_RUNTIME_EXCEPTIONS= "ThrowRuntimeExceptions"; //$NON-NLS-1$
- private static final String GENERATE_JAVADOC= "GenerateJavadoc"; //$NON-NLS-1$
-
- public ExtractMethodInputPage() {
- super(PAGE_NAME);
- setImageDescriptor(JavaPluginImages.DESC_WIZBAN_REFACTOR_CU);
- setDescription(DESCRIPTION);
- fFirstTime= true;
- fSignaturePreviewDocument= new Document();
- }
-
- public void createControl(Composite parent) {
- fRefactoring= (ExtractMethodRefactoring)getRefactoring();
- loadSettings();
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- result.setLayout(layout);
- RowLayouter layouter= new RowLayouter(2);
- GridData gd= null;
-
- initializeDialogUnits(result);
-
- Label label= new Label(result, SWT.NONE);
- label.setText(getLabelText());
-
- fTextField= createTextInputField(result, SWT.BORDER);
- fTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- layouter.perform(label, fTextField, 1);
-
- ASTNode[] destinations= fRefactoring.getDestinations();
- if (destinations.length > 1) {
- label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.ExtractMethodInputPage_destination_type);
- final Combo combo= new Combo(result, SWT.READ_ONLY | SWT.DROP_DOWN);
- for (int i= 0; i < destinations.length; i++) {
- ASTNode declaration= destinations[i];
- combo.add(getLabel(declaration));
- }
- combo.select(0);
- combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- combo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setDestination(combo.getSelectionIndex());
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- // nothing
- }
- });
- }
-
-// label= new Label(result, SWT.NONE);
-// label.setText(RefactoringMessages.ExtractMethodInputPage_access_Modifiers);
-//
-// Composite group= new Composite(result, SWT.NONE);
-// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-// layout= new GridLayout();
-// layout.numColumns= 4; layout.marginWidth= 0;
-// group.setLayout(layout);
-//
-// String[] labels= new String[] {
-// RefactoringMessages.ExtractMethodInputPage_public,
-// RefactoringMessages.ExtractMethodInputPage_protected,
-// RefactoringMessages.ExtractMethodInputPage_default,
-// RefactoringMessages.ExtractMethodInputPage_private
-// };
-// Integer[] data= new Integer[] {new Integer(Modifier.PUBLIC), new Integer(Modifier.PROTECTED), new Integer(Modifier.NONE), new Integer(Modifier.PRIVATE)};
-// Integer visibility= new Integer(fRefactoring.getVisibility());
-// for (int i= 0; i < labels.length; i++) {
-// Button radio= new Button(group, SWT.RADIO);
-// radio.setText(labels[i]);
-// radio.setData(data[i]);
-// if (data[i].equals(visibility))
-// radio.setSelection(true);
-// radio.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent event) {
-// setVisibility((Integer)event.widget.getData());
-// }
-// });
-// }
-// layouter.perform(label, group, 1);
-
- if (!fRefactoring.getParameterInfos().isEmpty()) {
- ChangeParametersControl cp= new ChangeParametersControl(result, SWT.NONE,
- RefactoringMessages.ExtractMethodInputPage_parameters,
- new IParameterListChangeListener() {
- public void parameterChanged(ParameterInfo parameter) {
- parameterModified();
- }
- public void parameterListChanged() {
- parameterModified();
- }
- public void parameterAdded(ParameterInfo parameter) {
- updatePreview(getText());
- }
- }, ChangeParametersControl.Mode.EXTRACT_METHOD);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
- cp.setLayoutData(gd);
- cp.setInput(fRefactoring.getParameterInfos());
- }
-
-// Button checkBox= new Button(result, SWT.CHECK);
-// checkBox.setText(RefactoringMessages.ExtractMethodInputPage_throwRuntimeExceptions);
-// checkBox.setSelection(fSettings.getBoolean(THROW_RUNTIME_EXCEPTIONS));
-// checkBox.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// setRethrowRuntimeException(((Button)e.widget).getSelection());
-// }
-// });
-// layouter.perform(checkBox);
-//
- Button checkBox= new Button(result, SWT.CHECK);
- checkBox.setText(RefactoringMessages.ExtractMethodInputPage_generateJavadocComment);
- boolean generate= computeGenerateJavadoc();
- setGenerateJavadoc(generate);
- checkBox.setSelection(generate);
- checkBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setGenerateJavadoc(((Button)e.widget).getSelection());
- }
- });
- layouter.perform(checkBox);
-
- int duplicates= fRefactoring.getNumberOfDuplicates();
- checkBox= new Button(result, SWT.CHECK);
- if (duplicates == 0) {
- checkBox.setText(RefactoringMessages.ExtractMethodInputPage_duplicates_none);
- } else if (duplicates == 1) {
- checkBox.setText(RefactoringMessages.ExtractMethodInputPage_duplicates_single);
- } else {
- checkBox.setText(Messages.format(
- RefactoringMessages.ExtractMethodInputPage_duplicates_multi,
- new Integer(duplicates)));
- }
- checkBox.setSelection(fRefactoring.getReplaceDuplicates());
- checkBox.setEnabled(duplicates > 0);
- checkBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setReplaceDuplicates(((Button)e.widget).getSelection());
- }
- });
- layouter.perform(checkBox);
-
- label= new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layouter.perform(label);
-
- createSignaturePreview(result, layouter);
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_METHOD_WIZARD_PAGE);
- }
-
- private String getLabel(ASTNode node) {
- if (node instanceof AbstractTypeDeclaration) {
- return ((AbstractTypeDeclaration)node).getName().getIdentifier();
- } else if (node instanceof AnonymousClassDeclaration) {
- if (node.getLocationInParent() == ClassInstanceCreation.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
- ClassInstanceCreation creation= (ClassInstanceCreation)node.getParent();
- return Messages.format(
- RefactoringMessages.ExtractMethodInputPage_anonymous_type_label,
- ASTNodes.asString(creation.getType()));
- }
- }
- return "UNKNOWN"; //$NON-NLS-1$
- }
-
- private Text createTextInputField(Composite parent, int style) {
- Text result= new Text(parent, style);
- result.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textModified(getText());
- }
- });
- TextFieldNavigationHandler.install(result);
- return result;
- }
-
- private String getText() {
- if (fTextField == null)
- return null;
- return fTextField.getText();
- }
-
- private String getLabelText(){
- return RefactoringMessages.ExtractMethodInputPage_label_text;
- }
-
-// private void setVisibility(Integer visibility) {
-// fRefactoring.setVisibility(visibility.intValue());
-// updatePreview(getText());
-// }
-//
-// private void setRethrowRuntimeException(boolean value) {
-// fSettings.put(THROW_RUNTIME_EXCEPTIONS, value);
-// fRefactoring.setThrowRuntimeExceptions(value);
-// updatePreview(getText());
-// }
-
- private boolean computeGenerateJavadoc() {
- boolean result= fRefactoring.getGenerateJavadoc();
- if (result)
- return result;
- return fSettings.getBoolean(GENERATE_JAVADOC);
- }
-
- private void setGenerateJavadoc(boolean value) {
- fSettings.put(GENERATE_JAVADOC, value);
- fRefactoring.setGenerateJavadoc(value);
- }
-
- private void createSignaturePreview(Composite composite, RowLayouter layouter) {
- Label previewLabel= new Label(composite, SWT.NONE);
- previewLabel.setText(RefactoringMessages.ExtractMethodInputPage_signature_preview);
- layouter.perform(previewLabel);
-
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSignaturePreview= new JavaSourceViewer(composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store);
- fSignaturePreview.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- fSignaturePreview.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- fSignaturePreview.getTextWidget().setBackground(composite.getBackground());
- fSignaturePreview.setDocument(fSignaturePreviewDocument);
- fSignaturePreview.setEditable(false);
-
- //Layouting problems with wrapped text: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866
- Control signaturePreviewControl= fSignaturePreview.getControl();
- PixelConverter pixelConverter= new PixelConverter(signaturePreviewControl);
- GridData gdata= new GridData(GridData.FILL_BOTH);
- gdata.widthHint= pixelConverter.convertWidthInCharsToPixels(50);
- gdata.heightHint= pixelConverter.convertHeightInCharsToPixels(2);
- signaturePreviewControl.setLayoutData(gdata);
- layouter.perform(signaturePreviewControl);
- }
-
- private void updatePreview(String text) {
- if (fSignaturePreview == null)
- return;
-
- if (text.length() == 0)
- text= "someMethodName"; //$NON-NLS-1$
-
- int top= fSignaturePreview.getTextWidget().getTopPixel();
- String signature;
- try {
- signature= fRefactoring.getSignature(text);
- } catch (IllegalArgumentException e) {
- signature= ""; //$NON-NLS-1$
- }
- fSignaturePreviewDocument.set(signature);
- fSignaturePreview.getTextWidget().setTopPixel(top);
- }
-
- private void loadSettings() {
- fSettings= getDialogSettings().getSection(ExtractMethodWizard.DIALOG_SETTING_SECTION);
- if (fSettings == null) {
- fSettings= getDialogSettings().addNewSection(ExtractMethodWizard.DIALOG_SETTING_SECTION);
- fSettings.put(THROW_RUNTIME_EXCEPTIONS, false);
- fSettings.put(GENERATE_JAVADOC, JavaPreferencesSettings.getCodeGenerationSettings(fRefactoring.getCompilationUnit().getJavaScriptProject()).createComments);
- }
- fRefactoring.setThrowRuntimeExceptions(fSettings.getBoolean(THROW_RUNTIME_EXCEPTIONS));
- }
-
- //---- Input validation ------------------------------------------------------
-
- public void setVisible(boolean visible) {
- if (visible) {
- if (fFirstTime) {
- fFirstTime= false;
- setPageComplete(false);
- updatePreview(getText());
- fTextField.setFocus();
- } else {
- setPageComplete(validatePage(true));
- }
- }
- super.setVisible(visible);
- }
-
- private void textModified(String text) {
- fRefactoring.setMethodName(text);
- RefactoringStatus status= validatePage(true);
- if (!status.hasFatalError()) {
- updatePreview(text);
- } else {
- fSignaturePreviewDocument.set(""); //$NON-NLS-1$
- }
- setPageComplete(status);
- }
-
- private void parameterModified() {
- updatePreview(getText());
- setPageComplete(validatePage(false));
- }
-
- private RefactoringStatus validatePage(boolean text) {
- RefactoringStatus result= new RefactoringStatus();
- if (text) {
- result.merge(validateMethodName());
- result.merge(validateParameters());
- } else {
- result.merge(validateParameters());
- result.merge(validateMethodName());
- }
- return result;
- }
-
- private RefactoringStatus validateMethodName() {
- RefactoringStatus result= new RefactoringStatus();
- String text= getText();
- if ("".equals(text)) { //$NON-NLS-1$
- result.addFatalError(RefactoringMessages.ExtractMethodInputPage_validation_emptyMethodName);
- return result;
- }
- result.merge(fRefactoring.checkMethodName());
- return result;
- }
-
- private RefactoringStatus validateParameters() {
- RefactoringStatus result= new RefactoringStatus();
- List parameters= fRefactoring.getParameterInfos();
- for (Iterator iter= parameters.iterator(); iter.hasNext();) {
- ParameterInfo info= (ParameterInfo) iter.next();
- if ("".equals(info.getNewName())) { //$NON-NLS-1$
- result.addFatalError(RefactoringMessages.ExtractMethodInputPage_validation_emptyParameterName);
- return result;
- }
- }
- result.merge(fRefactoring.checkParameterNames());
- result.merge(fRefactoring.checkVarargOrder());
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodWizard.java
deleted file mode 100644
index a0040094..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ExtractMethodWizard.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ExtractMethodRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class ExtractMethodWizard extends RefactoringWizard {
-
- /* package */ static final String DIALOG_SETTING_SECTION= "ExtractMethodWizard"; //$NON-NLS-1$
-
- public ExtractMethodWizard(ExtractMethodRefactoring ref){
- super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
- setDefaultPageTitle(RefactoringMessages.ExtractMethodWizard_extract_method);
- setDialogSettings(JavaScriptPlugin.getDefault().getDialogSettings());
- }
-
- public Change createChange(){
- // creating the change is cheap. So we don't need to show progress.
- try {
- return getRefactoring().createChange(new NullProgressMonitor());
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return null;
- }
- }
-
- protected void addUserInputPages(){
- addPage(new ExtractMethodInputPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodInputPage.java
deleted file mode 100644
index 9bae4687..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodInputPage.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.InlineMethodRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class InlineMethodInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "InlineMethodInputPage";//$NON-NLS-1$
- private static final String DESCRIPTION = RefactoringMessages.InlineMethodInputPage_description;
-
- private InlineMethodRefactoring fRefactoring;
- private Group fInlineMode;
- private Button fRemove;
-
- public InlineMethodInputPage() {
- super(PAGE_NAME);
- setImageDescriptor(JavaPluginImages.DESC_WIZBAN_REFACTOR_CU);
- setDescription(DESCRIPTION);
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- fRefactoring= (InlineMethodRefactoring)getRefactoring();
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
- GridData gd= null;
-
- boolean all= fRefactoring.getInitialMode() == InlineMethodRefactoring.Mode.INLINE_ALL;
- fInlineMode= new Group(result, SWT.NONE);
- fInlineMode.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fInlineMode.setLayout(new GridLayout());
- fInlineMode.setText(RefactoringMessages.InlineMethodInputPage_inline);
-
- Button radio= new Button(fInlineMode, SWT.RADIO);
- radio.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- radio.setText(RefactoringMessages.InlineMethodInputPage_all_invocations);
- radio.setSelection(all);
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRemove.setEnabled(fRefactoring.canEnableDeleteSource());
- if (((Button)event.widget).getSelection())
- changeRefactoring(InlineMethodRefactoring.Mode.INLINE_ALL);
- }
- });
-
- fRemove= new Button(fInlineMode, SWT.CHECK);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent= convertWidthInCharsToPixels(3);
- fRemove.setLayoutData(gd);
- fRemove.setText(RefactoringMessages.InlineMethodInputPage_delete_declaration);
- fRemove.setEnabled(all && fRefactoring.canEnableDeleteSource());
- fRemove.setSelection(fRefactoring.canEnableDeleteSource());
- fRefactoring.setDeleteSource(fRefactoring.canEnableDeleteSource());
- fRemove.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setDeleteSource(((Button)e.widget).getSelection());
- }
- });
-
-
- radio= new Button(fInlineMode, SWT.RADIO);
- radio.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- radio.setText(RefactoringMessages.InlineMethodInputPage_only_selected);
- radio.setSelection(!all);
- if (all) {
- radio.setEnabled(false);
- }
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRemove.setEnabled(false);
- if (((Button)event.widget).getSelection())
- changeRefactoring(InlineMethodRefactoring.Mode.INLINE_SINGLE);
- }
- });
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INLINE_METHOD_WIZARD_PAGE);
- }
-
- private void changeRefactoring(InlineMethodRefactoring.Mode mode) {
- RefactoringStatus status;
- try {
- status= fRefactoring.setCurrentMode(mode);
- } catch (JavaScriptModelException e) {
- status= RefactoringStatus.createFatalErrorStatus(e.getMessage());
- }
- setPageComplete(status);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodWizard.java
deleted file mode 100644
index 83c21aeb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/InlineMethodWizard.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.InlineMethodRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class InlineMethodWizard extends RefactoringWizard {
-
- /* package */ static final String DIALOG_SETTING_SECTION= "InlineMethodWizard"; //$NON-NLS-1$
-
- public InlineMethodWizard(InlineMethodRefactoring ref){
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.InlineMethodWizard_page_title);
- setDialogSettings(JavaScriptPlugin.getDefault().getDialogSettings());
- }
-
- protected void addUserInputPages(){
- addPage(new InlineMethodInputPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsInputPage.java
deleted file mode 100644
index f93e5bce..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsInputPage.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ReplaceInvocationsRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-
-public class ReplaceInvocationsInputPage extends UserInputWizardPage {
-
- public static final String PAGE_NAME= "ReplaceInvocationsInputPage";//$NON-NLS-1$
-
- private ReplaceInvocationsRefactoring fRefactoring;
-
- private static final long LABEL_FLAGS= JavaScriptElementLabels.M_PRE_TYPE_PARAMETERS | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_EXCEPTIONS;
-
- public ReplaceInvocationsInputPage() {
- super(PAGE_NAME);
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- fRefactoring= (ReplaceInvocationsRefactoring) getRefactoring();
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
-
- createMethodSignature(result);
-
- Label separator= new Label(parent, SWT.NONE);
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, false, false);
- gridData.heightHint= 5;
- separator.setLayoutData(gridData);
-
- Label bodyLabel= new Label(result, SWT.NONE);
- bodyLabel.setText(RefactoringMessages.ReplaceInvocationsInputPage_replaceInvocationsBy);
-
- createBody(result);
-
- Button replaceAll= new Button(result, SWT.CHECK);
- replaceAll.setText(RefactoringMessages.ReplaceInvocationsInputPage_replaceAll);
- boolean canSingle= fRefactoring.canReplaceSingle();
-// replaceAll.setEnabled(canSingle);
- replaceAll.setEnabled(false); // does not work for now...
- replaceAll.setSelection(! canSingle);
- replaceAll.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- boolean all= ((Button) event.widget).getSelection();
- changeMode(all ? ReplaceInvocationsRefactoring.Mode.REPLACE_ALL : ReplaceInvocationsRefactoring.Mode.REPLACE_SINGLE);
- }
- });
-
- Dialog.applyDialogFont(result);
- }
-
- private void createMethodSignature(Composite parent) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- JavaSourceViewer signatureViewer= new JavaSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.WRAP /*| SWT.BORDER*/, store);
- signatureViewer.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- signatureViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- signatureViewer.getTextWidget().setBackground(parent.getBackground());
- String signatureLabel= JavaScriptElementLabels.getElementLabel(fRefactoring.getMethod(), LABEL_FLAGS);
- signatureViewer.setDocument(new Document(signatureLabel));
- signatureViewer.setEditable(false);
-
- Control signatureControl= signatureViewer.getControl();
- PixelConverter pixelConverter= new PixelConverter(signatureControl);
- GridData gdata= new GridData(GridData.FILL_HORIZONTAL);
- gdata.widthHint= pixelConverter.convertWidthInCharsToPixels(50);
- signatureControl.setLayoutData(gdata);
- }
-
- private void createBody(Composite parent) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- JavaSourceViewer bodyEditor= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER, store);
- bodyEditor.configure(new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
- bodyEditor.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- Document bodyDocument= new Document(getInitialBody());
- bodyEditor.setDocument(bodyDocument);
- bodyEditor.setEditable(true);
-
- Control bodyControl= bodyEditor.getControl();
- PixelConverter pixelConverter= new PixelConverter(bodyControl);
- GridData gdata= new GridData(GridData.FILL_BOTH);
- gdata.widthHint= pixelConverter.convertWidthInCharsToPixels(50);
- gdata.minimumHeight= pixelConverter.convertHeightInCharsToPixels(5);
- bodyControl.setLayoutData(gdata);
- bodyControl.setFocus();
-
- bodyDocument.addDocumentListener(new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
- public void documentChanged(DocumentEvent event) {
- try {
- fRefactoring.setBody(event.getDocument().get(), fRefactoring.getMethod().getParameterNames());
- } catch (JavaScriptModelException ex) {
- // TODO Auto-generated catch block
- JavaScriptPlugin.log(ex);
- }
- }
- });
- }
-
- private String getInitialBody() {
- //TODO
- return ""; //$NON-NLS-1$
-
- }
-
- private void changeMode(ReplaceInvocationsRefactoring.Mode mode) {
- RefactoringStatus status;
- try {
- status= fRefactoring.setCurrentMode(mode);
- } catch (JavaScriptModelException e) {
- status= RefactoringStatus.createFatalErrorStatus(e.getMessage());
- }
- setPageComplete(status);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsWizard.java
deleted file mode 100644
index bf18dca8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/code/ReplaceInvocationsWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.code;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.ReplaceInvocationsRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class ReplaceInvocationsWizard extends RefactoringWizard {
-
- public ReplaceInvocationsWizard(ReplaceInvocationsRefactoring ref){
- super(ref, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.ReplaceInvocationsWizard_title);
- }
-
- protected void addUserInputPages(){
- addPage(new ReplaceInvocationsInputPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CUPositionCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CUPositionCompletionProcessor.java
deleted file mode 100644
index 4d99c8e0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CUPositionCompletionProcessor.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.CompletionRequestor;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.StubTypeContext;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaTypeCompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
-
-
-public class CUPositionCompletionProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
-
- private static final ImageDescriptorRegistry IMAGE_DESC_REGISTRY= JavaScriptPlugin.getImageDescriptorRegistry();
-
- private String fErrorMessage;
- private char[] fProposalAutoActivationSet;
- private CompletionProposalComparator fComparator;
-
- private CompletionContextRequestor fCompletionContextRequestor;
-
- private CUPositionCompletionRequestor fCompletionRequestor;
-
- /**
- * Creates a <code>CUPositionCompletionProcessor</code>.
- * The completion context must be set via {@link #setCompletionContext(IJavaScriptUnit,String,String)}.
- * @param completionRequestor the completion requestor
- */
- public CUPositionCompletionProcessor(CUPositionCompletionRequestor completionRequestor) {
- fCompletionRequestor= completionRequestor;
-
- fComparator= new CompletionProposalComparator();
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- fProposalAutoActivationSet = triggers.toCharArray();
- }
-
- /**
- * @param cuHandle the {@link IJavaScriptUnit} in whose context codeComplete will be invoked.
- * The given cu doesn't have to exist (and if it exists, it will not be modified).
- * An independent working copy consisting of
- * <code>beforeString</code> + ${current_input} + <code>afterString</code> will be used.
- * @param beforeString the string before the input position
- * @param afterString the string after the input position
- */
- public void setCompletionContext(final IJavaScriptUnit cuHandle, final String beforeString, final String afterString) {
- fCompletionContextRequestor= new CompletionContextRequestor() {
- final StubTypeContext fStubTypeContext= new StubTypeContext(cuHandle, beforeString, afterString);
- public StubTypeContext getStubTypeContext() {
- return fStubTypeContext;
- }
- };
- if (cuHandle != null)
- fCompletionRequestor.setJavaProject(cuHandle.getJavaScriptProject());
- }
-
- public void setCompletionContextRequestor(CompletionContextRequestor completionContextRequestor) {
- fCompletionContextRequestor= completionContextRequestor;
- }
-
- /**
- * Computing proposals on a <code>ITextViewer</code> is not supported.
- * @see #computeCompletionProposals(IContentAssistSubjectControl, int)
- * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /**
- * Computing context information on a <code>ITextViewer</code> is not supported.
- * @see #computeContextInformation(IContentAssistSubjectControl, int)
- * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null; //no context
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeContextInformation(IContentAssistSubjectControl, int)
- */
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
- return null;
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeCompletionProposals(IContentAssistSubjectControl, int)
- */
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
- if (fCompletionContextRequestor.getOriginalCu() == null)
- return null;
- String input= contentAssistSubjectControl.getDocument().get();
- if (documentOffset == 0)
- return null;
- ICompletionProposal[] proposals= internalComputeCompletionProposals(documentOffset, input);
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- private ICompletionProposal[] internalComputeCompletionProposals(int documentOffset, String input) {
- String cuString= fCompletionContextRequestor.getBeforeString() + input + fCompletionContextRequestor.getAfterString();
- IJavaScriptUnit cu= null;
- try {
- /*
- * Explicitly create a new non-shared working copy.
- *
- * The WorkingCopy cannot easily be shared between calls, since IContentAssistProcessor
- * has no dispose() lifecycle method. A workaround could be to pass in a WorkingCopyOwner
- * and dispose the owner's working copies from the caller's dispose().
- */
- cu= fCompletionContextRequestor.getOriginalCu().getWorkingCopy(new WorkingCopyOwner() {/*subclass*/}, null, new NullProgressMonitor());
- cu.getBuffer().setContents(cuString);
- int cuPrefixLength= fCompletionContextRequestor.getBeforeString().length();
- fCompletionRequestor.setOffsetReduction(cuPrefixLength);
- cu.codeComplete(cuPrefixLength + documentOffset, fCompletionRequestor);
-
- JavaCompletionProposal[] proposals= fCompletionRequestor.getResults();
- if (proposals.length == 0) {
- String errorMsg= fCompletionRequestor.getErrorMessage();
- if (errorMsg == null || errorMsg.trim().length() == 0)
- errorMsg= RefactoringMessages.JavaTypeCompletionProcessor_no_completion;
- fErrorMessage= errorMsg;
- } else {
- fErrorMessage= fCompletionRequestor.getErrorMessage();
- }
- return proposals;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return null;
- } finally {
- try {
- if (cu != null)
- cu.discardWorkingCopy();
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- }
-
- protected abstract static class CUPositionCompletionRequestor extends CompletionRequestor {
- public static final char[] TRIGGER_CHARACTERS= new char[] { '.' };
-
- private int fOffsetReduction;
- private IJavaScriptProject fJavaProject;
-
- private List fProposals;
- private String fErrorMessage2;
-
- public IJavaScriptProject getJavaProject() {
- return fJavaProject;
- }
-
- private void setJavaProject(IJavaScriptProject javaProject) {
- fJavaProject= javaProject;
- }
-
- private void setOffsetReduction(int offsetReduction) {
- fOffsetReduction= offsetReduction;
- fProposals= new ArrayList();
- }
-
- public final void completionFailure(IProblem error) {
- fErrorMessage2= error.getMessage();
- }
-
- public final JavaCompletionProposal[] getResults() {
- return (JavaCompletionProposal[]) fProposals.toArray(new JavaCompletionProposal[fProposals.size()]);
- }
-
- public final String getErrorMessage() {
- return fErrorMessage2;
- }
-
- protected final void addAdjustedCompletion(String name, String completion,
- int start, int end, int relevance, ImageDescriptor descriptor) {
- JavaCompletionProposal javaCompletionProposal= new JavaCompletionProposal(completion, start - fOffsetReduction, end - start,
- getImage(descriptor), name, relevance);
- javaCompletionProposal.setTriggerCharacters(TRIGGER_CHARACTERS);
- fProposals.add(javaCompletionProposal);
- }
-
- protected final void addAdjustedTypeCompletion(String name, String completion,
- int start, int end, int relevance, ImageDescriptor descriptor, String fullyQualifiedName) {
- JavaTypeCompletionProposal javaCompletionProposal= new JavaTypeCompletionProposal(
- fullyQualifiedName == null ? completion : fullyQualifiedName, null,
- fullyQualifiedName == null ? start - fOffsetReduction : 0,
- end - start, getImage(descriptor), name, relevance, completion);
- javaCompletionProposal.setTriggerCharacters(TRIGGER_CHARACTERS);
- fProposals.add(javaCompletionProposal);
- }
-
- private static Image getImage(ImageDescriptor descriptor) {
- return (descriptor == null) ? null : CUPositionCompletionProcessor.IMAGE_DESC_REGISTRY.get(descriptor);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CompletionContextRequestor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CompletionContextRequestor.java
deleted file mode 100644
index b42eaa13..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/CompletionContextRequestor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.StubTypeContext;
-
-
-public abstract class CompletionContextRequestor {
-
- public abstract StubTypeContext getStubTypeContext();
-
- public IJavaScriptUnit getOriginalCu() {
- return getStubTypeContext().getCuHandle();
- }
-
- public String getBeforeString() {
- return getStubTypeContext().getBeforeString();
- }
-
- public String getAfterString() {
- return getStubTypeContext().getAfterString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java
deleted file mode 100644
index 562ed501..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
-import org.eclipse.wst.jsdt.internal.ui.text.html.HTMLTextPresenter;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.contentassist.ContentAssistHandler;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.ContentAssistPreference;
-
-
-/**
- *
- */
-public class ControlContentAssistHelper {
-
- /**
- * @param text the text field to install ContentAssist
- * @param processor the <code>IContentAssistProcessor</code>
- */
- public static void createTextContentAssistant(final Text text, IContentAssistProcessor processor) {
- ContentAssistHandler.createHandlerForText(text, createJavaContentAssistant(processor));
- }
-
- /**
- * @param combo the text field to install ContentAssist
- * @param processor the <code>IContentAssistProcessor</code>
- */
- public static void createComboContentAssistant(final Combo combo, IContentAssistProcessor processor) {
- ContentAssistHandler.createHandlerForCombo(combo, createJavaContentAssistant(processor));
- }
-
- public static SubjectControlContentAssistant createJavaContentAssistant(IContentAssistProcessor processor) {
- final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant();
-
- contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
-
- ContentAssistPreference.configure(contentAssistant, JavaScriptPlugin.getDefault().getPreferenceStore());
- contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
- }
- });
-
- return contentAssistant;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/FieldNameProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/FieldNameProcessor.java
deleted file mode 100644
index 3bb4692d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/FieldNameProcessor.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.resource.ImageDescriptor;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-
-public class FieldNameProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
-
- private String[] fFieldNameProposals;
- private String fErrorMessage;
- private ImageDescriptorRegistry fImageRegistry= JavaScriptPlugin.getImageDescriptorRegistry();
- private PromoteTempToFieldRefactoring fRefactoring;
-
- public FieldNameProcessor(String[] guessedFieldNames, PromoteTempToFieldRefactoring refactoring) {
- fRefactoring= refactoring;
- fFieldNameProposals= refactoring.guessFieldNames();
- Arrays.sort(fFieldNameProposals);
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.contentassist.IContentAssistProcessorExtension#computeContextInformation(org.eclipse.jface.contentassist.IContentAssistSubject, int)
- */
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.contentassist.IContentAssistProcessorExtension#computeCompletionProposals(org.eclipse.jface.contentassist.IContentAssistSubject, int)
- */
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- if (fFieldNameProposals.length == 0)
- return null;
- String input= contentAssistSubject.getDocument().get();
-
- ArrayList proposals= new ArrayList();
- String prefix= input.substring(0, documentOffset);
- ImageDescriptor imageDescriptor= JavaElementImageProvider.getFieldImageDescriptor(false, fRefactoring.getVisibility());
- Image image= fImageRegistry.get(imageDescriptor);
- for (int i= 0; i < fFieldNameProposals.length; i++) {
- String tempName= fFieldNameProposals[i];
- if (tempName.length() == 0 || ! tempName.startsWith(prefix))
- continue;
- JavaCompletionProposal proposal= new JavaCompletionProposal(tempName, 0, input.length(), image, tempName, 0);
- proposals.add(proposal);
- }
- fErrorMessage= proposals.size() > 0 ? null : JavaUIMessages.JavaEditor_codeassist_noCompletions;
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageCompletionProcessor.java
deleted file mode 100644
index b5fb39e0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageCompletionProcessor.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.preference.IPreferenceStore;
-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;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
-
-public class JavaPackageCompletionProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
-
- private IPackageFragmentRoot fPackageFragmentRoot;
- private CompletionProposalComparator fComparator;
- private ILabelProvider fLabelProvider;
-
- private char[] fProposalAutoActivationSet;
-
- /**
- * Creates a <code>JavaPackageCompletionProcessor</code>.
- * The completion context must be set via {@link #setPackageFragmentRoot(IPackageFragmentRoot)}.
- */
- public JavaPackageCompletionProcessor() {
- this(new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_SMALL_ICONS));
- }
-
- /**
- * Creates a <code>JavaPackageCompletionProcessor</code>.
- * The Processor uses the given <code>ILabelProvider</code> to show text and icons for the
- * possible completions.
- * @param labelProvider Used for the popups.
- */
- public JavaPackageCompletionProcessor(ILabelProvider labelProvider) {
- fComparator= new CompletionProposalComparator();
- fLabelProvider= labelProvider;
-
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- fProposalAutoActivationSet = triggers.toCharArray();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null; //no context
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeContextInformation(IContentAssistSubjectControl, int)
- */
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl,
- int documentOffset) {
- return null;
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeCompletionProposals(IContentAssistSubjectControl, int)
- */
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
- if (fPackageFragmentRoot == null)
- return null;
- String input= contentAssistSubjectControl.getDocument().get();
- ICompletionProposal[] proposals= createPackagesProposals(documentOffset, input);
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- public void setPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot) {
- fPackageFragmentRoot= packageFragmentRoot;
- }
-
- private ICompletionProposal[] createPackagesProposals(int documentOffset, String input) {
- ArrayList proposals= new ArrayList();
- String prefix= input.substring(0, documentOffset);
- try {
- IJavaScriptElement[] packageFragments= fPackageFragmentRoot.getChildren();
- for (int i= 0; i < packageFragments.length; i++) {
- IPackageFragment pack= (IPackageFragment) packageFragments[i];
- String packName= pack.getElementName();
- if (packName.length() == 0 || ! packName.startsWith(prefix))
- continue;
- Image image= fLabelProvider.getImage(pack);
- JavaCompletionProposal proposal= new JavaCompletionProposal(packName, 0, input.length(), image, fLabelProvider.getText(pack), 0);
- proposals.add(proposal);
- }
- } catch (JavaScriptModelException e) {
- //fPackageFragmentRoot is not a proper root -> no proposals
- }
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageFragmentRootCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageFragmentRootCompletionProcessor.java
deleted file mode 100644
index 9b2b12d8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaPackageFragmentRootCompletionProcessor.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
-
-/**
- * TODO: this class is not used anywhere yet.
- * (ContentAssist should be added to all source folder dialog fields.)
- */
-public class JavaPackageFragmentRootCompletionProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
- private static final ImageDescriptorRegistry IMAGE_DESC_REGISTRY= JavaScriptPlugin.getImageDescriptorRegistry();
-
- private IPackageFragmentRoot fPackageFragmentRoot;
- private CompletionProposalComparator fComparator;
-
- private char[] fProposalAutoActivationSet;
-
- /**
- * Creates a <code>JavaPackageCompletionProcessor</code> to complete existing packages
- * in the context of <code>packageFragmentRoot</code>.
- *
- * @param packageFragmentRoot the context for package completion
- */
- public JavaPackageFragmentRootCompletionProcessor(IPackageFragmentRoot packageFragmentRoot) {
- fPackageFragmentRoot= packageFragmentRoot;
- fComparator= new CompletionProposalComparator();
-
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- fProposalAutoActivationSet = triggers.toCharArray();
- }
-
- /*(non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null; //no context
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeContextInformation(IContentAssistSubjectControl, int)
- */
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubject,
- int documentOffset) {
- return null;
- }
-
- /*
- * @see ISubjectControlContentAssistProcessor#computeCompletionProposals(IContentAssistSubjectControl, int)
- */
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
- String input= contentAssistSubjectControl.getDocument().get();
- ICompletionProposal[] proposals= createPackagesProposals(documentOffset, input);
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- private ICompletionProposal[] createPackagesProposals(int documentOffset, String input) {
- ArrayList proposals= new ArrayList();
- String prefix= input.substring(0, documentOffset);
- try {
- IJavaScriptElement[] packageFragments= fPackageFragmentRoot.getChildren();
- for (int i= 0; i < packageFragments.length; i++) {
- IPackageFragment pack= (IPackageFragment) packageFragments[i];
- String packName= pack.getElementName();
- if (packName.length() == 0 || ! packName.startsWith(prefix))
- continue;
- Image image= getImage(JavaPluginImages.DESC_OBJS_PACKAGE);
- JavaCompletionProposal proposal= new JavaCompletionProposal(packName, 0, input.length(), image, packName, 0);
- proposals.add(proposal);
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- private static Image getImage(ImageDescriptor descriptor) {
- return (descriptor == null) ? null : JavaPackageFragmentRootCompletionProcessor.IMAGE_DESC_REGISTRY.get(descriptor);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaSourcePackageFragmentRootCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaSourcePackageFragmentRootCompletionProcessor.java
deleted file mode 100644
index 5d142ab1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaSourcePackageFragmentRootCompletionProcessor.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.preference.IPreferenceStore;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
-
-/**
- * Simple completion processor that completes package fragment roots that are source
- * folders.
- */
-public class JavaSourcePackageFragmentRootCompletionProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
-
- private char[] fProposalAutoActivationSet;
- private IJavaScriptModel fRoot;
- private CompletionProposalComparator fComparator;
- private JavaScriptElementLabelProvider fLabelProvider;
-
- public JavaSourcePackageFragmentRootCompletionProcessor() {
- fRoot= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot());
- IPreferenceStore preferenceStore= JavaScriptPlugin.getDefault().getPreferenceStore();
- String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- fProposalAutoActivationSet= triggers.toCharArray();
- fComparator= new CompletionProposalComparator();
- fLabelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- public String getErrorMessage() {
- return null;
- }
-
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- if (fRoot == null) {
- return null;
- }
-
- String input= contentAssistSubject.getDocument().get();
- String prefix= input.substring(0, documentOffset);
-
- ICompletionProposal[] proposals= createSourcePackageFragmentRootProposals(prefix, input.length());
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- /**
- * @param prefix prefixString with thatthe sourcepackagefragmentroots must begin
- * @param replacementLength length of the text to replace
- * @return array with sourcepackagefragmentroots
- */
- private ICompletionProposal[] createSourcePackageFragmentRootProposals(String prefix, int replacementLength) {
- List proposals= new ArrayList();
- try {
- IJavaScriptProject[] projects= fRoot.getJavaScriptProjects();
- for (int i= 0; i < projects.length; i++) {
- IJavaScriptProject project= projects[i];
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- for (int j= 0; j < roots.length; j++) {
- IPackageFragmentRoot root= roots[j];
- if (root.exists() && (root.getKind() == IPackageFragmentRoot.K_SOURCE)) {
- String name= root.getPath().toString();
- if (name.length() > 1) {
- name= name.substring(1);
- }
- if (name.startsWith(prefix)) {
- Image image= fLabelProvider.getImage(root);
- JavaCompletionProposal proposal= new JavaCompletionProposal(name, 0, replacementLength, image,
- name, 0);
- proposals.add(proposal);
- }
- }
- }
- }
- } catch (JavaScriptModelException e) {
- // nothing to do
- }
-
- return (ICompletionProposal[])proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java
deleted file mode 100644
index 78ce7591..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.wst.jsdt.core.CompletionProposal;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.TypeFilter;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-
-public class JavaTypeCompletionProcessor extends CUPositionCompletionProcessor {
-
- public static final String DUMMY_CLASS_NAME= "$$__$$"; //$NON-NLS-1$
-
- /**
- * The CU name to be used if no parent IJavaScriptUnit is available.
- * The main type of this class will be filtered out from the proposals list.
- */
- public static final String DUMMY_CU_NAME= DUMMY_CLASS_NAME + JavaModelUtil.DEFAULT_CU_SUFFIX;
-
- /**
- * Creates a <code>JavaTypeCompletionProcessor</code>.
- * The completion context must be set via {@link #setPackageFragment(IPackageFragment)}.
- *
- * @param enableBaseTypes complete java base types iff <code>true</code>
- * @param enableVoid complete <code>void</code> base type iff <code>true</code>
- */
- public JavaTypeCompletionProcessor(boolean enableBaseTypes, boolean enableVoid) {
- this(enableBaseTypes, enableVoid, false);
- }
-
- /**
- * Creates a <code>JavaTypeCompletionProcessor</code>.
- * The completion context must be set via {@link #setPackageFragment(IPackageFragment)}.
- *
- * @param enableBaseTypes complete java base types iff <code>true</code>
- * @param enableVoid complete <code>void</code> base type iff <code>true</code>
- * @param fullyQualify always complete to fully qualifies type iff <code>true</code>
- */
- public JavaTypeCompletionProcessor(boolean enableBaseTypes, boolean enableVoid, boolean fullyQualify) {
- super(new TypeCompletionRequestor(enableBaseTypes, enableVoid, fullyQualify));
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- // disable auto activation in dialog fields, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89476
- return null;
- }
-
- /**
- * @param packageFragment the new completion context
- */
- public void setPackageFragment(IPackageFragment packageFragment) {
- //TODO: Some callers have a better completion context and should include imports
- // and nested classes of their declaring CU in WC's source.
- if (packageFragment == null) {
- setCompletionContext(null, null, null);
- } else {
- String before= "public class " + DUMMY_CLASS_NAME + " { "; //$NON-NLS-1$//$NON-NLS-2$
- String after= " }"; //$NON-NLS-1$
- setCompletionContext(packageFragment.getJavaScriptUnit(DUMMY_CU_NAME), before, after);
- }
- }
-
- public void setExtendsCompletionContext(IJavaScriptElement javaElement) {
- if (javaElement instanceof IPackageFragment) {
- IPackageFragment packageFragment= (IPackageFragment) javaElement;
- IJavaScriptUnit cu= packageFragment.getJavaScriptUnit(DUMMY_CU_NAME);
- setCompletionContext(cu, "public class " + DUMMY_CLASS_NAME + " extends ", " {}"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- } else if (javaElement instanceof IType) {
- // pattern: public class OuterType { public class Type extends /*caret*/ {} }
- IType type= (IType) javaElement;
- String before= "public class " + type.getElementName() + " extends "; //$NON-NLS-1$ //$NON-NLS-2$
- String after= " {}"; //$NON-NLS-1$
- IJavaScriptElement parent= type.getParent();
- while (parent instanceof IType) {
- type= (IType) parent;
- before+= "public class " + type.getElementName() + " {"; //$NON-NLS-1$ //$NON-NLS-2$
- after+= "}"; //$NON-NLS-1$
- parent= type.getParent();
- }
- IJavaScriptUnit cu= type.getJavaScriptUnit();
- setCompletionContext(cu, before, after);
- } else {
- setCompletionContext(null, null, null);
- }
- }
-
-// public void setImplementsCompletionContext(IPackageFragment packageFragment) {
-// IJavaScriptUnit cu= packageFragment.getCompilationUnit(DUMMY_CU_NAME);
-// setCompletionContext(cu, "public class " + DUMMY_CLASS_NAME + " implements ", " {}"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
-// }
-
- protected static class TypeCompletionRequestor extends CUPositionCompletionRequestor {
- private static final String VOID= "void"; //$NON-NLS-1$
- private static final List BASE_TYPES= Arrays.asList(
- new String[] {"boolean", "byte", "char", "double", "float", "int", "long", "short"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
-
- private boolean fEnableBaseTypes;
- private boolean fEnableVoid;
- private final boolean fFullyQualify;
-
- public TypeCompletionRequestor(boolean enableBaseTypes, boolean enableVoid, boolean fullyQualify) {
- fFullyQualify= fullyQualify;
- fEnableBaseTypes= enableBaseTypes;
- fEnableVoid= enableVoid;
- setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, true);
- setIgnored(CompletionProposal.FIELD_REF, true);
- setIgnored(CompletionProposal.LABEL_REF, true);
- setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, true);
- setIgnored(CompletionProposal.METHOD_DECLARATION, true);
- setIgnored(CompletionProposal.METHOD_REF, true);
- setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
- setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, true);
- setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, true);
- }
-
- public void accept(CompletionProposal proposal) {
- switch (proposal.getKind()) {
- case CompletionProposal.PACKAGE_REF :
- char[] packageName= proposal.getDeclarationSignature();
- if (TypeFilter.isFiltered(packageName))
- return;
- addAdjustedCompletion(
- new String(packageName),
- new String(proposal.getCompletion()),
- proposal.getReplaceStart(),
- proposal.getReplaceEnd(),
- proposal.getRelevance(),
- JavaPluginImages.DESC_OBJS_PACKAGE);
- return;
-
- case CompletionProposal.TYPE_REF :
- char[] fullName= Signature.toCharArray(proposal.getSignature());
- if (TypeFilter.isFiltered(fullName))
- return;
- StringBuffer buf= new StringBuffer();
- buf.append(Signature.getSimpleName(fullName));
- if (buf.length() == 0)
- return; // this is the dummy class, whose $ have been converted to dots
- char[] typeQualifier= Signature.getQualifier(fullName);
- if (typeQualifier.length > 0) {
- buf.append(" - "); //$NON-NLS-1$
- buf.append(typeQualifier);
- }
- String name= buf.toString();
-
- addAdjustedTypeCompletion(
- name,
- new String(proposal.getCompletion()),
- proposal.getReplaceStart(),
- proposal.getReplaceEnd(),
- proposal.getRelevance(),
- JavaElementImageProvider.getTypeImageDescriptor(false, false, proposal.getFlags(), false),
- fFullyQualify ? new String(fullName) : null);
- return;
-
- case CompletionProposal.KEYWORD:
- if (! fEnableBaseTypes)
- return;
- String keyword= new String(proposal.getName());
- if ( (fEnableVoid && VOID.equals(keyword)) || (fEnableBaseTypes && BASE_TYPES.contains(keyword)) )
- addAdjustedCompletion(
- keyword,
- new String(proposal.getCompletion()),
- proposal.getReplaceStart(),
- proposal.getReplaceEnd(),
- proposal.getRelevance(),
- null);
- return;
-
- default :
- return;
- }
-
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/VariableNamesProcessor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/VariableNamesProcessor.java
deleted file mode 100644
index 4e8bf03d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/contentassist/VariableNamesProcessor.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
-import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
-import org.eclipse.jface.resource.ImageDescriptor;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ImageDescriptorRegistry;
-
-public class VariableNamesProcessor implements IContentAssistProcessor, ISubjectControlContentAssistProcessor {
-
- private String fErrorMessage;
-
- private String[] fTempNameProposals;
-
- private ImageDescriptorRegistry fImageRegistry;
- private ImageDescriptor fProposalImageDescriptor;
-
- public VariableNamesProcessor(String[] tempNameProposals) {
- fTempNameProposals= (String[]) tempNameProposals.clone();
- Arrays.sort(fTempNameProposals);
- fImageRegistry= JavaScriptPlugin.getImageDescriptorRegistry();
- fProposalImageDescriptor= JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE;
-
- }
-
- public void setProposalImageDescriptor(ImageDescriptor proposalImageDescriptor) {
- fProposalImageDescriptor= proposalImageDescriptor;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.contentassist.IContentAssistProcessorExtension#computeContextInformation(org.eclipse.jface.contentassist.IContentAssistSubject, int)
- */
- public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- return null; //no context
- }
-
- /*
- * @see org.eclipse.jface.contentassist.IContentAssistProcessorExtension#computeCompletionProposals(org.eclipse.jface.contentassist.IContentAssistSubject, int)
- */
- public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
- if (fTempNameProposals.length == 0)
- return null;
- String input= contentAssistSubject.getDocument().get();
-
- ArrayList proposals= new ArrayList();
- String prefix= input.substring(0, documentOffset);
- Image image= fImageRegistry.get(fProposalImageDescriptor);
- for (int i= 0; i < fTempNameProposals.length; i++) {
- String tempName= fTempNameProposals[i];
- if (tempName.length() == 0 || ! tempName.startsWith(prefix))
- continue;
- JavaCompletionProposal proposal= new JavaCompletionProposal(tempName, 0, input.length(), image, tempName, 0);
- proposals.add(proposal);
- }
- fErrorMessage= proposals.size() > 0 ? null : JavaUIMessages.JavaEditor_codeassist_noCompletions;
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/AccessorDescription.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/AccessorDescription.java
deleted file mode 100644
index a3262996..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/AccessorDescription.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-
-/**
- *
- */
-public class AccessorDescription {
-
- private final static String KEY_ACCESSOR_NAME= "accessorName"; //$NON-NLS-1$
- private final static String KEY_ACCESSOR_PACK= "accessorPackage"; //$NON-NLS-1$
- private final static String KEY_RESOURCE_BUNDLE_NAME= "bundleName"; //$NON-NLS-1$
- private final static String KEY_RESOURCE_BUNDLE_PACK= "bundlePackage"; //$NON-NLS-1$
-
-
- private final IPackageFragment fResourceBundlePackage;
- private final String fAccessorClassName;
- private final IPackageFragment fAccessorClassPackage;
- private final String fResourceBundleName;
-
- /**
- *
- */
- public AccessorDescription(String accessorClassName, IPackageFragment accessorClassPackage, String propertyFileName, IPackageFragment propertyFilePackage) {
- super();
- fAccessorClassName= accessorClassName;
- fAccessorClassPackage= accessorClassPackage;
- fResourceBundleName= propertyFileName;
- fResourceBundlePackage= propertyFilePackage;
- }
-
- public String getLabel() {
- StringBuffer buf= new StringBuffer();
- buf.append(getAccessorClassPackage().getElementName());
- if (buf.length() > 0) {
- buf.append('.');
- }
- buf.append(getAccessorClassName());
- buf.append(JavaScriptElementLabels.CONCAT_STRING);
- IPath propertyFilePath= getResourceBundlePackage().getPath().append(getResourceBundleName());
- buf.append(propertyFilePath.makeRelative().toString());
- return buf.toString();
- }
-
- public void serialize(IDialogSettings settings) {
- settings.put(KEY_ACCESSOR_NAME, getAccessorClassName());
- settings.put(KEY_ACCESSOR_PACK, getAccessorClassPackage().getHandleIdentifier());
- settings.put(KEY_RESOURCE_BUNDLE_NAME, getResourceBundleName());
- settings.put(KEY_RESOURCE_BUNDLE_PACK, getResourceBundlePackage().getHandleIdentifier());
- }
-
- /**
- * @return Returns the accessor class name.
- */
- public String getAccessorClassName() {
- return fAccessorClassName;
- }
- /**
- * @return Returns the accessor class package.
- */
- public IPackageFragment getAccessorClassPackage() {
- return fAccessorClassPackage;
- }
- /**
- * @return Returns the resource bundle name.
- */
- public String getResourceBundleName() {
- return fResourceBundleName;
- }
- /**
- * @return Returns the resource bundle package
- */
- public IPackageFragment getResourceBundlePackage() {
- return fResourceBundlePackage;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj != null && obj.getClass().equals(getClass())) {
- AccessorDescription other= (AccessorDescription) obj;
- return other == this ||
- (other.fAccessorClassName.equals(fAccessorClassName)
- && other.fAccessorClassPackage.equals(fAccessorClassPackage)
- && other.fResourceBundleName.equals(fResourceBundleName)
- && other.fResourceBundlePackage.equals(fResourceBundlePackage));
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fAccessorClassName.hashCode() + fAccessorClassPackage.hashCode() + fResourceBundleName.hashCode() + fResourceBundlePackage.hashCode();
- }
-
- public static AccessorDescription deserialize(IDialogSettings settings) {
- String accessorName= settings.get(KEY_ACCESSOR_NAME);
- if (accessorName == null) {
- return null;
- }
-
- String accessorPackHandle= settings.get(KEY_ACCESSOR_PACK);
- if (accessorPackHandle == null) {
- return null;
- }
- IJavaScriptElement accessorPack= JavaScriptCore.create(accessorPackHandle);
- if (!(accessorPack instanceof IPackageFragment) || !accessorPack.exists()) {
- return null;
- }
-
- String bundleName= settings.get(KEY_RESOURCE_BUNDLE_NAME);
- if (bundleName == null) {
- return null;
- }
-
- String bundlePackHandle= settings.get(KEY_RESOURCE_BUNDLE_PACK);
- if (bundlePackHandle == null) {
- return null;
- }
- IJavaScriptElement bundlePack= JavaScriptCore.create(bundlePackHandle);
- if (!(bundlePack instanceof IPackageFragment) || !bundlePack.exists()) {
- return null;
- }
-
- return new AccessorDescription(accessorName, (IPackageFragment) accessorPack, bundleName, (IPackageFragment) bundlePack);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizard.java
deleted file mode 100644
index 2369c527..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizard.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-/**
- * good citizen problems - wizard is only valid after constructor (when the pages toggle
- * some values and force an validate the validate can't get a wizard)
- */
-public class ExternalizeWizard extends RefactoringWizard {
-
- public ExternalizeWizard(NLSRefactoring refactoring) {
- super(refactoring,CHECK_INITIAL_CONDITIONS_ON_OPEN | WIZARD_BASED_USER_INTERFACE);
- setDefaultPageTitle(Messages.format(NLSUIMessages.ExternalizeWizardPage_title, refactoring.getCu().getElementName()));
- setWindowTitle(NLSUIMessages.ExternalizeWizard_name);
- setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_EXTERNALIZE_STRINGS);
- }
-
- /**
- * @see RefactoringWizard#addUserInputPages()
- */
- protected void addUserInputPages() {
-
- NLSRefactoring nlsRefac= (NLSRefactoring) getRefactoring();
- ExternalizeWizardPage page= new ExternalizeWizardPage(nlsRefac);
- page.setMessage(NLSUIMessages.ExternalizeWizard_select);
- addPage(page);
-
- /*ExternalizeWizardPage2 page2= new ExternalizeWizardPage2(nlsRefac);
- page2.setMessage(NLSUIMessages.getString("wizard.select_values")); //$NON-NLS-1$
- addPage(page2);*/
- }
-
- public boolean canFinish() {
- IWizardPage page= getContainer().getCurrentPage();
- return super.canFinish() && !(page instanceof ExternalizeWizardPage);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
deleted file mode 100644
index c5d2a233..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
+++ /dev/null
@@ -1,1332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IFontProvider;
-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.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-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.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.KeyValuePair;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSSubstitution;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementImageDescriptor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-class ExternalizeWizardPage extends UserInputWizardPage {
-
- private static final String[] PROPERTIES;
- private static final String[] fgTitles;
- private static final int STATE_PROP= 0;
- private static final int VAL_PROP= 1;
- private static final int KEY_PROP= 2;
- private static final int SIZE= 3; //column counter
- private static final int ROW_COUNT= 5;
-
- public static final String PAGE_NAME= "NLSWizardPage1"; //$NON-NLS-1$
- static {
- PROPERTIES= new String[SIZE];
- PROPERTIES[STATE_PROP]= "task"; //$NON-NLS-1$
- PROPERTIES[KEY_PROP]= "key"; //$NON-NLS-1$
- PROPERTIES[VAL_PROP]= "value"; //$NON-NLS-1$
-
- fgTitles= new String[SIZE];
- fgTitles[STATE_PROP]= ""; //$NON-NLS-1$
- fgTitles[KEY_PROP]= NLSUIMessages.ExternalizeWizardPage_key;
- fgTitles[VAL_PROP]= NLSUIMessages.ExternalizeWizardPage_value;
- }
-
- private class CellModifier implements ICellModifier {
-
- /**
- * @see ICellModifier#canModify(Object, String)
- */
- public boolean canModify(Object element, String property) {
- if (property == null)
- return false;
-
- if (!(element instanceof NLSSubstitution))
- return false;
-
- NLSSubstitution subst= (NLSSubstitution) element;
- if (PROPERTIES[KEY_PROP].equals(property) && subst.getState() != NLSSubstitution.EXTERNALIZED) {
- return false;
- }
-
- return true;
- }
-
- /**
- * @see ICellModifier#getValue(Object, String)
- */
- public Object getValue(Object element, String property) {
- if (element instanceof NLSSubstitution) {
- NLSSubstitution substitution= (NLSSubstitution) element;
- String res= null;
- if (PROPERTIES[KEY_PROP].equals(property)) {
- res= substitution.getKeyWithoutPrefix();
- } else if (PROPERTIES[VAL_PROP].equals(property)) {
- res= substitution.getValue();
- } else if (PROPERTIES[STATE_PROP].equals(property)) {
- return new Integer(substitution.getState());
- }
- if (res != null) {
- return unwindEscapeChars(res);
- }
- return ""; //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * @see ICellModifier#modify(Object, String, Object)
- */
- public void modify(Object element, String property, Object value) {
- if (element instanceof TableItem) {
- Object data= ((TableItem) element).getData();
- if (data instanceof NLSSubstitution) {
- NLSSubstitution substitution= (NLSSubstitution) data;
- if (PROPERTIES[KEY_PROP].equals(property)) {
- String string = (String)value;
- string = windEscapeChars(string);
- substitution.setKey(string);
- }
- if (PROPERTIES[VAL_PROP].equals(property)) {
- String string = (String)value;
- string = windEscapeChars(string);
- substitution.setValue(string);
- }
- if (PROPERTIES[STATE_PROP].equals(property)) {
- substitution.setState(((Integer) value).intValue());
- if ((substitution.getState() == NLSSubstitution.EXTERNALIZED) && substitution.hasStateChanged()) {
- substitution.generateKey(fSubstitutions);
- }
- }
- }
- validateKeys(false);
- fTableViewer.update(data, null);
- }
- }
- }
-
- private class NLSSubstitutionLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
-
- private FontRegistry fFontRegistry;
-
- public NLSSubstitutionLabelProvider() {
- fFontRegistry= JFaceResources.getFontRegistry();
- }
-
- public String getColumnText(Object element, int columnIndex) {
- String columnText= ""; //$NON-NLS-1$
- if (element instanceof NLSSubstitution) {
- NLSSubstitution substitution= (NLSSubstitution) element;
- if (columnIndex == KEY_PROP) {
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED) {
- columnText= substitution.getKey();
- }
- } else
- if ((columnIndex == VAL_PROP) && (substitution.getValue() != null)) {
- columnText= substitution.getValue();
- }
- }
- return unwindEscapeChars(columnText);
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- if ((columnIndex == STATE_PROP) && (element instanceof NLSSubstitution)) {
- return getNLSImage((NLSSubstitution) element);
- }
-
- return null;
- }
-
- public Font getFont(Object element) {
- if (element instanceof NLSSubstitution) {
- NLSSubstitution substitution= (NLSSubstitution) element;
- if (substitution.hasPropertyFileChange() || substitution.hasSourceChange()) {
- return fFontRegistry.getBold(JFaceResources.DIALOG_FONT);
- }
- }
- return null;
- }
-
- private Image getNLSImage(NLSSubstitution sub) {
- if ((sub.getValue() == null) && (sub.getKey() != null)) {
- // Missing keys
- JavaScriptElementImageDescriptor imageDescriptor= new JavaScriptElementImageDescriptor(getNLSImageDescriptor(sub.getState()), JavaScriptElementImageDescriptor.WARNING, JavaElementImageProvider.SMALL_SIZE);
- return JavaScriptPlugin.getImageDescriptorRegistry().get(imageDescriptor);
- } else
- if (sub.isConflicting(fSubstitutions) || !isKeyValid(sub, null)) {
- JavaScriptElementImageDescriptor imageDescriptor= new JavaScriptElementImageDescriptor(getNLSImageDescriptor(sub.getState()), JavaScriptElementImageDescriptor.ERROR, JavaElementImageProvider.SMALL_SIZE);
- return JavaScriptPlugin.getImageDescriptorRegistry().get(imageDescriptor);
- } else {
- return getNLSImage(sub.getState());
- }
- }
-
- private Image getNLSImage(int task) {
- switch (task) {
- case NLSSubstitution.EXTERNALIZED :
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_TRANSLATE);
- case NLSSubstitution.IGNORED :
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
- case NLSSubstitution.INTERNALIZED :
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_SKIP);
- default :
- Assert.isTrue(false);
- return null;
- }
- }
-
- private ImageDescriptor getNLSImageDescriptor(int task) {
- switch (task) {
- case NLSSubstitution.EXTERNALIZED :
- return JavaPluginImages.DESC_OBJS_NLS_TRANSLATE;
- case NLSSubstitution.IGNORED :
- return JavaPluginImages.DESC_OBJS_NLS_NEVER_TRANSLATE;
- case NLSSubstitution.INTERNALIZED :
- return JavaPluginImages.DESC_OBJS_NLS_SKIP;
- default :
- Assert.isTrue(false);
- return null;
- }
- }
- }
-
- private static String unwindEscapeChars(String s) {
- if (s != null) {
- StringBuffer sb= new StringBuffer(s.length());
- int length= s.length();
- for (int i= 0; i < length; i++) {
- char c= s.charAt(i);
- sb.append(getUnwoundString(c));
- }
- return sb.toString();
- }
- return null;
- }
-
- private static String getUnwoundString(char c) {
- switch (c) {
- case '\b' :
- return "\\b";//$NON-NLS-1$
- case '\t' :
- return "\\t";//$NON-NLS-1$
- case '\n' :
- return "\\n";//$NON-NLS-1$
- case '\f' :
- return "\\f";//$NON-NLS-1$
- case '\r' :
- return "\\r";//$NON-NLS-1$
- case '\\' :
- return "\\\\";//$NON-NLS-1$
- }
- return String.valueOf(c);
- }
-
- private static String windEscapeChars(String s) {
- if (s == null)
- return null;
-
- char aChar;
- int len= s.length();
- StringBuffer outBuffer= new StringBuffer(len);
-
- for (int x= 0; x < len;) {
- aChar= s.charAt(x++);
- if (aChar == '\\') {
- aChar= s.charAt(x++);
- if (aChar == 'u') {
- // Read the xxxx
- int value= 0;
- for (int i= 0; i < 4; i++) {
- aChar= s.charAt(x++);
- switch (aChar) {
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- value= (value << 4) + aChar - '0';
- break;
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- value= (value << 4) + 10 + aChar - 'a';
- break;
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- value= (value << 4) + 10 + aChar - 'A';
- break;
- default:
- throw new IllegalArgumentException("Malformed \\uxxxx encoding."); //$NON-NLS-1$
- }
- }
- outBuffer.append((char) value);
- } else {
- if (aChar == 't') {
- outBuffer.append('\t');
- } else {
- if (aChar == 'r') {
- outBuffer.append('\r');
- } else {
- if (aChar == 'n') {
- outBuffer.append('\n');
- } else {
- if (aChar == 'f') {
- outBuffer.append('\f');
- } else {
- outBuffer.append(aChar);
- }
- }
- }
- }
- }
- } else
- outBuffer.append(aChar);
- }
- return outBuffer.toString();
- }
-
- private class NLSInputDialog extends StatusDialog implements IDialogFieldListener {
- private StringDialogField fKeyField;
- private StringDialogField fValueField;
- private DialogField fMessageField;
- private NLSSubstitution fSubstitution;
-
- public NLSInputDialog(Shell parent, NLSSubstitution substitution) {
- super(parent);
-
- setTitle(NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Title);
-
- fSubstitution= substitution;
-
- fMessageField= new DialogField();
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED) {
- fMessageField.setLabelText(NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_ext_Label);
- } else {
- fMessageField.setLabelText(NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Label);
- }
-
- fKeyField= new StringDialogField();
- fKeyField.setLabelText(NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Enter_key);
- fKeyField.setDialogFieldListener(this);
-
- fValueField= new StringDialogField();
- fValueField.setLabelText(NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Enter_value);
- fValueField.setDialogFieldListener(this);
-
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED) {
- fKeyField.setText(substitution.getKeyWithoutPrefix());
- } else {
- fKeyField.setText(""); //$NON-NLS-1$
- }
-
- fValueField.setText(substitution.getValueNonEmpty());
- }
-
- public KeyValuePair getResult() {
- KeyValuePair res= new KeyValuePair(fKeyField.getText(), fValueField.getText());
- return res;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setFont(composite.getFont());
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- inner.setLayout(layout);
-
- fMessageField.doFillIntoGrid(inner, 2);
-
- if (fSubstitution.getState() == NLSSubstitution.EXTERNALIZED) {
- fKeyField.doFillIntoGrid(inner, 2);
- LayoutUtil.setWidthHint(fKeyField.getTextControl(null), convertWidthInCharsToPixels(45));
- }
-
- fValueField.doFillIntoGrid(inner, 2);
- LayoutUtil.setWidthHint(fValueField.getTextControl(null), convertWidthInCharsToPixels(45));
- LayoutUtil.setHorizontalGrabbing(fValueField.getTextControl(null));
-
- fValueField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- IStatus keyStatus= validateKey(fKeyField.getText());
- //IStatus valueStatus= StatusInfo.OK_STATUS; // no validation yet
-
- //updateStatus(StatusUtil.getMoreSevere(valueStatus, keyStatus));
- updateStatus(keyStatus);
- }
-
-
- private IStatus validateKey(String val) {
- if (fSubstitution.getState() != NLSSubstitution.EXTERNALIZED) {
- return StatusInfo.OK_STATUS;
- }
-
- if (val == null || val.length() == 0) {
- return new StatusInfo(IStatus.ERROR, NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Error_empty_key);
- }
-
- if (fNLSRefactoring.isEclipseNLS()) {
- if (!Character.isJavaIdentifierStart(val.charAt(0)))
- return new StatusInfo(IStatus.ERROR, NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Error_invalid_EclipseNLS_key);
-
- for (int i= 1, length= val.length(); i < length; i++) {
- if (!Character.isJavaIdentifierPart(val.charAt(i)))
- return new StatusInfo(IStatus.ERROR, NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Error_invalid_EclipseNLS_key);
- }
- } else {
- // validation so keys don't contain spaces
- for (int i= 0; i < val.length(); i++) {
- if (Character.isWhitespace(val.charAt(i))) {
- return new StatusInfo(IStatus.ERROR, NLSUIMessages.ExternalizeWizardPage_NLSInputDialog_Error_invalid_key);
- }
- }
- }
- return StatusInfo.OK_STATUS;
- }
- }
-
- private static final String SETTINGS_NLS_ACCESSORS= "nls_accessor_history"; //$NON-NLS-1$
- private static final int SETTINGS_MAX_ENTRIES= 5;
-
- private Text fPrefixField;
- private Button fIsEclipseNLS;
- private Table fTable;
- private TableViewer fTableViewer;
- private SourceViewer fSourceViewer;
-
- private final IJavaScriptUnit fCu;
- private NLSSubstitution[] fSubstitutions;
- private Button fExternalizeButton;
- private Button fIgnoreButton;
- private Button fInternalizeButton;
- private Button fRevertButton;
- private Button fEditButton;
- private NLSRefactoring fNLSRefactoring;
- private Button fRenameButton;
- private Combo fAccessorClassField;
-
- private AccessorDescription[] fAccessorChoices;
- private Button fFilterCheckBox;
-
- public ExternalizeWizardPage(NLSRefactoring nlsRefactoring) {
- super(PAGE_NAME);
- fCu= nlsRefactoring.getCu();
- fSubstitutions= nlsRefactoring.getSubstitutions();
- fNLSRefactoring= nlsRefactoring;
- fAccessorChoices= null;
-
- setDescription(NLSUIMessages.ExternalizeWizardPage_description);
- createDefaultExternalization(fSubstitutions, nlsRefactoring.getPrefix());
- }
-
- /*
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite supercomposite= new Composite(parent, SWT.NONE);
- supercomposite.setFont(parent.getFont());
- supercomposite.setLayout(new GridLayout());
-
- createIsEclipseNLSCheckbox(supercomposite);
-
- createKeyPrefixField(supercomposite);
-
- SashForm composite= new SashForm(supercomposite, SWT.VERTICAL);
- composite.setFont(supercomposite.getFont());
-
- GridData data= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(data);
-
- createTableViewer(composite);
- createSourceViewer(composite);
-
- createAccessorInfoComposite(supercomposite);
-
- composite.setWeights(new int[]{65, 45});
-
- validateKeys(false);
- updateButtonStates(StructuredSelection.EMPTY);
-
- // promote control
- setControl(supercomposite);
- Dialog.applyDialogFont(supercomposite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(supercomposite, IJavaHelpContextIds.EXTERNALIZE_WIZARD_KEYVALUE_PAGE);
- }
-
- /**
- * @param supercomposite
- */
- private void createAccessorInfoComposite(Composite supercomposite) {
- Composite accessorComposite= new Composite(supercomposite, SWT.NONE);
- accessorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- accessorComposite.setLayout(layout);
-
- Composite composite= new Composite(accessorComposite, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- layout= new GridLayout(1, true);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
-
- Label accessorClassLabel= new Label(composite, SWT.NONE);
- accessorClassLabel.setText(NLSUIMessages.ExternalizeWizardPage_accessorclass_label);
- accessorClassLabel.setLayoutData(new GridData());
-
-
- SelectionListener listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget instanceof Button) {
- doConfigureButtonPressed();
- } else {
- doAccessorSelectionChanged();
- }
- }
- };
-
-
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= convertWidthInCharsToPixels(30);
- fAccessorClassField= new Combo(composite, SWT.READ_ONLY);
- fAccessorClassField.setLayoutData(data);
- fAccessorClassField.addSelectionListener(listener);
-
-
- //new Label(composite, SWT.NONE); // placeholder
-
- Button configure= new Button(accessorComposite, SWT.PUSH);
- configure.setText(NLSUIMessages.ExternalizeWizardPage_configure_button);
- data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END);
- data.widthHint= SWTUtil.getButtonWidthHint(configure);
- configure.setLayoutData(data);
-
- configure.addSelectionListener(listener);
-
- updateAccessorChoices();
-
- }
-
- protected void doAccessorSelectionChanged() {
- int selectionIndex= fAccessorClassField.getSelectionIndex();
- if (fAccessorChoices != null && selectionIndex < fAccessorChoices.length) {
- AccessorDescription selected= fAccessorChoices[selectionIndex];
- fNLSRefactoring.setAccessorClassName(selected.getAccessorClassName());
- fNLSRefactoring.setAccessorClassPackage(selected.getAccessorClassPackage());
- fNLSRefactoring.setResourceBundleName(selected.getResourceBundleName());
- fNLSRefactoring.setResourceBundlePackage(selected.getResourceBundlePackage());
- fNLSRefactoring.setIsEclipseNLS(fNLSRefactoring.detectIsEclipseNLS());
-
- NLSSubstitution.updateSubtitutions(fSubstitutions, getProperties(fNLSRefactoring.getPropertyFileHandle()), fNLSRefactoring.getAccessorClassName());
- if (fIsEclipseNLS != null) {
- fIsEclipseNLS.setSelection(fNLSRefactoring.isEclipseNLS());
- fIsEclipseNLS.setEnabled(willCreateAccessorClass());
- }
- validateKeys(true);
- }
- }
-
- private boolean willCreateAccessorClass() {
- try {
- return fNLSRefactoring.willCreateAccessorClass();
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
-
- private void updateAccessorChoices() {
-
- AccessorDescription configured= new AccessorDescription(
- fNLSRefactoring.getAccessorClassName(),
- fNLSRefactoring.getAccessorClassPackage(),
- fNLSRefactoring.getResourceBundleName(),
- fNLSRefactoring.getResourceBundlePackage());
-
- ArrayList currChoices= new ArrayList();
- ArrayList currLabels= new ArrayList();
-
- currChoices.add(configured);
- currLabels.add(configured.getLabel());
-
- AccessorDescription[] choices= fAccessorChoices;
- if (choices == null) {
- choices= loadAccessorDescriptions();
- }
-
- for (int i= 0; i < choices.length; i++) {
- AccessorDescription curr= choices[i];
- if (!curr.equals(configured)) {
- currChoices.add(curr);
- currLabels.add(curr.getLabel());
- }
- }
-
- String[] labels= (String[]) currLabels.toArray(new String[currLabels.size()]);
- fAccessorChoices= (AccessorDescription[]) currChoices.toArray(new AccessorDescription[currChoices.size()]);
-
- fAccessorClassField.setItems(labels);
- fAccessorClassField.select(0);
- }
-
-
- private AccessorDescription[] loadAccessorDescriptions() {
- IDialogSettings section= JavaScriptPlugin.getDefault().getDialogSettings().getSection(SETTINGS_NLS_ACCESSORS);
- if (section == null) {
- return new AccessorDescription[0];
- }
- ArrayList res= new ArrayList();
- for (int i= 0; i < SETTINGS_MAX_ENTRIES; i++) {
- IDialogSettings serializedDesc= section.getSection(String.valueOf(i));
- if (serializedDesc != null) {
- AccessorDescription accessor= AccessorDescription.deserialize(serializedDesc);
- if (accessor != null) {
- res.add(accessor);
- }
- }
- }
- return (AccessorDescription[]) res.toArray(new AccessorDescription[res.size()]);
- }
-
-
-
- private void storeAccessorDescriptions() {
- if (fAccessorChoices == null) {
- return;
- }
- IDialogSettings dialogSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- IDialogSettings nlsSection= dialogSettings.getSection(SETTINGS_NLS_ACCESSORS);
- if (nlsSection == null) {
- nlsSection= dialogSettings.addNewSection(SETTINGS_NLS_ACCESSORS);
- }
- int nEntries= Math.min(SETTINGS_MAX_ENTRIES, fAccessorChoices.length);
- for (int i= 0; i < nEntries; i++) {
- IDialogSettings serializedDesc= nlsSection.addNewSection(String.valueOf(i));
- fAccessorChoices[i].serialize(serializedDesc);
- }
- }
-
-
- private void doConfigureButtonPressed() {
- NLSAccessorConfigurationDialog dialog= new NLSAccessorConfigurationDialog(getShell(), fNLSRefactoring);
- if (dialog.open() == Window.OK) {
- NLSSubstitution.updateSubtitutions(fSubstitutions, getProperties(fNLSRefactoring.getPropertyFileHandle()), fNLSRefactoring.getAccessorClassName());
- if (fIsEclipseNLS != null) {
- fIsEclipseNLS.setSelection(fNLSRefactoring.isEclipseNLS());
- fIsEclipseNLS.setEnabled(willCreateAccessorClass());
- }
- validateKeys(true);
- updateAccessorChoices();
- }
- }
-
- private Properties getProperties(IFile propertyFile) {
- Properties props= new Properties();
- try {
- if (propertyFile.exists()) {
- InputStream is= propertyFile.getContents();
- props.load(is);
- is.close();
- }
- } catch (Exception e) {
- // sorry no property
- }
- return props;
- }
-
- private void createTableViewer(Composite composite) {
- createTableComposite(composite);
-
- /*
- * Feature of CellEditors - double click is ignored.
- * The workaround is to register my own listener and force the desired
- * behavior.
- */
- fTableViewer= new TableViewer(fTable) {
- protected void hookControl(Control control) {
- super.hookControl(control);
- ((Table) control).addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- if (getTable().getSelection().length == 0)
- return;
- TableItem item= getTable().getSelection()[0];
- if (item.getBounds(STATE_PROP).contains(e.x, e.y)) {
- List widgetSel= getSelectionFromWidget();
- if (widgetSel == null || widgetSel.size() != 1)
- return;
- NLSSubstitution substitution= (NLSSubstitution) widgetSel.get(0);
- Integer value= (Integer) getCellModifier().getValue(substitution, PROPERTIES[STATE_PROP]);
- int newValue= MultiStateCellEditor.getNextValue(NLSSubstitution.STATE_COUNT, value.intValue());
- getCellModifier().modify(item, PROPERTIES[STATE_PROP], new Integer(newValue));
- }
- }
- });
- }
- };
-
- fTableViewer.setUseHashlookup(true);
-
- final CellEditor[] editors= createCellEditors();
- fTableViewer.setCellEditors(editors);
- fTableViewer.setColumnProperties(PROPERTIES);
- fTableViewer.setCellModifier(new CellModifier());
-
- fTableViewer.setContentProvider(new IStructuredContentProvider() {
- public Object[] getElements(Object inputElement) {
- return fSubstitutions;
- }
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- });
- fTableViewer.addFilter(new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (!fFilterCheckBox.getSelection()) {
- return true;
- }
- NLSSubstitution curr= (NLSSubstitution) element;
- return (curr.getInitialState() == NLSSubstitution.INTERNALIZED) || (curr.getInitialState() == NLSSubstitution.EXTERNALIZED && curr.getInitialValue() == null);
- }
- });
-
-
- fTableViewer.setLabelProvider(new NLSSubstitutionLabelProvider());
- fTableViewer.setInput(new Object());
-
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ExternalizeWizardPage.this.selectionChanged(event);
- }
- });
- }
-
- private void createDefaultExternalization(NLSSubstitution[] substitutions, String defaultPrefix) {
- for (int i= 0; i < substitutions.length; i++) {
- NLSSubstitution substitution= substitutions[i];
- if (substitution.getState() == NLSSubstitution.INTERNALIZED) {
- substitution.setState(NLSSubstitution.EXTERNALIZED);
- substitution.generateKey(substitutions);
- }
- }
- }
-
- private CellEditor[] createCellEditors() {
- final CellEditor editors[]= new CellEditor[SIZE];
- editors[STATE_PROP]= new MultiStateCellEditor(fTable, NLSSubstitution.STATE_COUNT, NLSSubstitution.DEFAULT);
- editors[KEY_PROP]= new TextCellEditor(fTable);
- editors[VAL_PROP]= new TextCellEditor(fTable);
- return editors;
- }
-
- private void createSourceViewer(Composite parent) {
- Composite c= new Composite(parent, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- c.setLayout(gl);
-
- Label l= new Label(c, SWT.NONE);
- l.setText(NLSUIMessages.ExternalizeWizardPage_context);
- l.setLayoutData(new GridData());
-
- // source viewer
- JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
- int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSourceViewer= new JavaSourceViewer(c, null, null, false, styles, store);
- fSourceViewer.configure(new JavaScriptSourceViewerConfiguration(tools.getColorManager(), store, null, null));
- fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
-
- try {
-
- String contents= fCu.getBuffer().getContents();
- IDocument document= new Document(contents);
- tools.setupJavaDocumentPartitioner(document);
-
- fSourceViewer.setDocument(document);
- fSourceViewer.setEditable(false);
-
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(10);
- gd.widthHint= convertWidthInCharsToPixels(40);
- fSourceViewer.getControl().setLayoutData(gd);
-
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, NLSUIMessages.ExternalizeWizardPage_exception_title, NLSUIMessages.ExternalizeWizardPage_exception_message);
- }
- }
-
- private void createKeyPrefixField(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout gl= new GridLayout();
- gl.numColumns= 2;
- gl.marginWidth= 0;
- composite.setLayout(gl);
-
- Label l= new Label(composite, SWT.NONE);
- l.setText(NLSUIMessages.ExternalizeWizardPage_common_prefix);
- l.setLayoutData(new GridData());
-
- fPrefixField= new Text(composite, SWT.SINGLE | SWT.BORDER);
- fPrefixField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fPrefixField.setText(fNLSRefactoring.getPrefix());
- fPrefixField.selectAll();
-
- fPrefixField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- fNLSRefactoring.setPrefix(fPrefixField.getText());
- validateKeys(true);
- }
- });
- }
-
- private boolean isEclipseNLSAvailable() {
- if (fNLSRefactoring == null || fNLSRefactoring.getCu() == null)
- return false;
-
- IJavaScriptProject jp= fNLSRefactoring.getCu().getJavaScriptProject();
- if (jp == null || !jp.exists())
- return false;
-
- try {
- return jp.findType("org.eclipse.osgi.util.NLS") != null; //$NON-NLS-1$
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
-
- private void createIsEclipseNLSCheckbox(Composite parent) {
- if (fNLSRefactoring.isEclipseNLS() || isEclipseNLSAvailable()) {
- fIsEclipseNLS= new Button(parent, SWT.CHECK);
- fIsEclipseNLS.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fIsEclipseNLS.setText(NLSUIMessages.ExternalizeWizardPage_isEclipseNLSCheckbox);
- fIsEclipseNLS.setSelection(fNLSRefactoring.isEclipseNLS());
- fIsEclipseNLS.setEnabled(willCreateAccessorClass());
- fIsEclipseNLS.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetDefaultSelected(e);
- boolean isEclipseNLS= fIsEclipseNLS.getSelection();
- fNLSRefactoring.setIsEclipseNLS(isEclipseNLS);
- if (isEclipseNLS) {
- fNLSRefactoring.setPrefix(fNLSRefactoring.getPrefix().replace('.', '_'));
- } else {
- fNLSRefactoring.setPrefix(fNLSRefactoring.getPrefix().replace('_', '.'));
- }
- fPrefixField.setText(fNLSRefactoring.getPrefix());
- validateKeys(true);
- }
- });
- }
- }
-
- private void validateKeys(boolean refreshTable) {
- RefactoringStatus status= new RefactoringStatus();
- checkInvalidKeys(status);
- checkDuplicateKeys(status);
- checkMissingKeys(status);
- setPageComplete(status);
- if (refreshTable)
- fTableViewer.refresh(true);
- }
-
- private void checkInvalidKeys(RefactoringStatus status) {
- for (int i= 0; i < fSubstitutions.length; i++) {
- if (!isKeyValid(fSubstitutions[i], status))
- return;
- }
- }
-
- private boolean isKeyValid(NLSSubstitution substitution, RefactoringStatus status) {
- if (substitution == null)
- return false;
-
- if (substitution.getState() != NLSSubstitution.EXTERNALIZED)
- return true;
-
- String key= substitution.getKey();
-
- if (fNLSRefactoring.isEclipseNLS()) {
- if (key == null || key.length() == 0 || !Character.isJavaIdentifierStart(key.charAt(0))) {
- if (status != null)
- status.addFatalError(NLSUIMessages.ExternalizeWizardPage_warning_EclipseNLS_keyInvalid);
- return false;
- }
- for (int i= 1, length= key.length(); i < length; i++) {
- if (!Character.isJavaIdentifierPart(key.charAt(i))) {
- if (status != null)
- status.addFatalError(NLSUIMessages.ExternalizeWizardPage_warning_EclipseNLS_keyInvalid);
- return false;
- }
- }
- } else {
- if (key == null || key.length() == 0) {
- if (status != null)
- status.addFatalError(NLSUIMessages.ExternalizeWizardPage_warning_keyInvalid);
- return false;
- }
- // validation so keys don't contain spaces
- for (int i= 0; i < key.length(); i++) {
- if (Character.isWhitespace(key.charAt(i))) {
- if (status != null)
- status.addFatalError(NLSUIMessages.ExternalizeWizardPage_warning_keyInvalid);
- return false;
- }
- }
- }
-
- return true;
- }
-
- private void checkDuplicateKeys(RefactoringStatus status) {
- for (int i= 0; i < fSubstitutions.length; i++) {
- NLSSubstitution substitution= fSubstitutions[i];
- if (conflictingKeys(substitution)) {
- status.addFatalError(NLSUIMessages.ExternalizeWizardPage_warning_conflicting);
- return;
- }
- }
- }
-
- private void checkMissingKeys(RefactoringStatus status) {
- for (int i= 0; i < fSubstitutions.length; i++) {
- NLSSubstitution substitution= fSubstitutions[i];
- if ((substitution.getValue() == null) && (substitution.getKey() != null)) {
- status.addWarning(NLSUIMessages.ExternalizeWizardPage_warning_keymissing);
- return;
- }
- }
- }
-
- private boolean conflictingKeys(NLSSubstitution substitution) {
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED) {
- return substitution.isConflicting(fSubstitutions);
- }
- return false;
- }
-
- private void createTableComposite(Composite parent) {
- Composite comp= new Composite(parent, SWT.NONE);
- comp.setFont(parent.getFont());
-
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- FormLayout fl= new FormLayout();
- fl.marginWidth= 0;
- fl.marginHeight= 0;
- comp.setLayout(fl);
-
- Label l= new Label(comp, SWT.NONE);
- l.setText(NLSUIMessages.ExternalizeWizardPage_strings_to_externalize);
- FormData formData = new FormData();
- formData.left = new FormAttachment(0, 0);
- l.setLayoutData(formData);
-
- Control tableControl= createTable(comp);
- formData = new FormData();
- formData.top = new FormAttachment(l, 5);
- formData.left = new FormAttachment(0, 0);
- formData.right = new FormAttachment(100,0);
- formData.bottom = new FormAttachment(100,0);
- tableControl.setLayoutData(formData);
-
- fFilterCheckBox= new Button(comp, SWT.CHECK);
- fFilterCheckBox.setText(NLSUIMessages.ExternalizeWizardPage_filter_label);
- formData = new FormData();
- formData.right = new FormAttachment(100,0);
- fFilterCheckBox.setLayoutData(formData);
- fFilterCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- doFilterCheckBoxPressed();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- fFilterCheckBox.setSelection(hasNewOrMissingSubstitutions());
- }
-
- private boolean hasNewOrMissingSubstitutions() {
- for (int i= 0; i < fSubstitutions.length; i++) {
- NLSSubstitution curr= fSubstitutions[i];
- if (curr.getInitialState() == NLSSubstitution.INTERNALIZED) {
- return true;
- }
- if (curr.getInitialState() == NLSSubstitution.EXTERNALIZED && curr.getInitialValue() == null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- *
- */
- protected void doFilterCheckBoxPressed() {
- fTableViewer.refresh();
- }
-
- private Control createTable(Composite parent) {
- Composite c= new Composite(parent, SWT.NONE);
- GridLayout gl= new GridLayout();
- gl.numColumns= 2;
- gl.marginWidth= 0;
- gl.marginHeight= 0;
- c.setLayout(gl);
-
-
- fTable= new Table(c, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.BORDER);
- fTable.setFont(parent.getFont());
-
- GridData tableGD= new GridData(GridData.FILL_BOTH);
- tableGD.heightHint= SWTUtil.getTableHeightHint(fTable, ROW_COUNT);
- //tableGD.widthHint= 40;
- fTable.setLayoutData(tableGD);
-
- fTable.setLinesVisible(true);
-
- TableLayout layout= new TableLayout();
- fTable.setLayout(layout);
- fTable.setHeaderVisible(true);
-
- ColumnLayoutData[] columnLayoutData= new ColumnLayoutData[SIZE];
- columnLayoutData[STATE_PROP]= new ColumnPixelData(18, false, true);
- columnLayoutData[KEY_PROP]= new ColumnWeightData(40, true);
- columnLayoutData[VAL_PROP]= new ColumnWeightData(40, true);
-
- for (int i= 0; i < fgTitles.length; i++) {
- TableColumn tc= new TableColumn(fTable, SWT.NONE, i);
- tc.setText(fgTitles[i]);
- layout.addColumnData(columnLayoutData[i]);
- tc.setResizable(columnLayoutData[i].resizable);
- }
-
- createButtonComposite(c);
- return c;
- }
-
- private void createButtonComposite(Composite parent) {
- Composite buttonComp= new Composite(parent, SWT.NONE);
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
- buttonComp.setLayout(gl);
- buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
-
- SelectionAdapter adapter= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleButtonPressed(e.widget);
- }
- };
-
- fExternalizeButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Externalize_Selected, adapter);
- fIgnoreButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Ignore_Selected, adapter);
- fInternalizeButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Internalize_Selected, adapter);
-
- new Label(buttonComp, SWT.NONE); // separator
-
- fEditButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Edit_key_and_value, adapter);
- fRevertButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Revert_Selected, adapter);
- fRenameButton= createTaskButton(buttonComp, NLSUIMessages.ExternalizeWizardPage_Rename_Keys, adapter);
-
- fEditButton.setEnabled(false);
- fRenameButton.setEnabled(false);
- buttonComp.pack();
- }
-
- /**
- * @param widget
- */
- protected void handleButtonPressed(Widget widget) {
- if (widget == fExternalizeButton) {
- setSelectedTasks(NLSSubstitution.EXTERNALIZED);
- } else if (widget == fIgnoreButton) {
- setSelectedTasks(NLSSubstitution.IGNORED);
- } else if (widget == fInternalizeButton) {
- setSelectedTasks(NLSSubstitution.INTERNALIZED);
- } else if (widget == fEditButton) {
- openEditButton(fTableViewer.getSelection());
- } else if (widget == fRevertButton) {
- revertStateOfSelection();
- } else if (widget == fRenameButton) {
- openRenameDialog();
- }
- }
-
- /**
- *
- */
- private void openRenameDialog() {
- IStructuredSelection sel= (IStructuredSelection) fTableViewer.getSelection();
- List elementsToRename= getExternalizedElements(sel);
- RenameKeysDialog dialog= new RenameKeysDialog(getShell(), elementsToRename);
- if (dialog.open() == Window.OK) {
- fTableViewer.refresh();
- updateButtonStates((IStructuredSelection) fTableViewer.getSelection());
- }
- }
-
- private void revertStateOfSelection() {
- List selection= getSelectedTableEntries();
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- NLSSubstitution substitution= (NLSSubstitution) iter.next();
- substitution.revert();
- }
- fTableViewer.refresh();
- updateButtonStates((IStructuredSelection) fTableViewer.getSelection());
- }
-
- private Button createTaskButton(Composite parent, String label, SelectionAdapter adapter) {
- Button button= new Button(parent, SWT.PUSH);
- button.setText(label);
- button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- SWTUtil.setButtonDimensionHint(button);
- button.addSelectionListener(adapter);
- return button;
- }
-
- private void openEditButton(ISelection selection) {
- try {
- IStructuredSelection sel= (IStructuredSelection) fTableViewer.getSelection();
- NLSSubstitution substitution= (NLSSubstitution) sel.getFirstElement();
- if (substitution == null) {
- return;
- }
-
- NLSInputDialog dialog= new NLSInputDialog(getShell(), substitution);
- if (dialog.open() == Window.CANCEL)
- return;
- KeyValuePair kvPair= dialog.getResult();
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED) {
- substitution.setKey(kvPair.getKey());
- }
- substitution.setValue(kvPair.getValue());
- validateKeys(false);
- } finally {
- fTableViewer.refresh();
- fTableViewer.getControl().setFocus();
- fTableViewer.setSelection(selection);
- }
- }
-
- private List getSelectedTableEntries() {
- ISelection sel= fTableViewer.getSelection();
- if (sel instanceof IStructuredSelection)
- return((IStructuredSelection) sel).toList();
- else
- return Collections.EMPTY_LIST;
- }
-
- private void setSelectedTasks(int state) {
- Assert.isTrue(state == NLSSubstitution.EXTERNALIZED || state == NLSSubstitution.IGNORED || state == NLSSubstitution.INTERNALIZED);
- List selected= getSelectedTableEntries();
- String[] props= new String[]{PROPERTIES[STATE_PROP]};
- for (Iterator iter= selected.iterator(); iter.hasNext();) {
- NLSSubstitution substitution= (NLSSubstitution) iter.next();
- substitution.setState(state);
- if ((substitution.getState() == NLSSubstitution.EXTERNALIZED) && substitution.hasStateChanged()) {
- substitution.generateKey(fSubstitutions);
- }
- }
- fTableViewer.update(selected.toArray(), props);
- fTableViewer.getControl().setFocus();
- updateButtonStates((IStructuredSelection) fTableViewer.getSelection());
- }
-
- private void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection= (IStructuredSelection) event.getSelection();
- updateButtonStates(selection);
- updateSourceView(selection);
- }
-
- private void updateSourceView(IStructuredSelection selection) {
- NLSSubstitution first= (NLSSubstitution) selection.getFirstElement();
- if (first != null) {
- Region region= first.getNLSElement().getPosition();
- fSourceViewer.setSelectedRange(region.getOffset(), region.getLength());
- fSourceViewer.revealRange(region.getOffset(), region.getLength());
- }
- }
-
- private void updateButtonStates(IStructuredSelection selection) {
- fExternalizeButton.setEnabled(true);
- fIgnoreButton.setEnabled(true);
- fInternalizeButton.setEnabled(true);
- fRevertButton.setEnabled(true);
-
- if (containsOnlyElementsOfSameState(NLSSubstitution.EXTERNALIZED, selection)) {
- fExternalizeButton.setEnabled(false);
- }
-
- if (containsOnlyElementsOfSameState(NLSSubstitution.IGNORED, selection)) {
- fIgnoreButton.setEnabled(false);
- }
-
- if (containsOnlyElementsOfSameState(NLSSubstitution.INTERNALIZED, selection)) {
- fInternalizeButton.setEnabled(false);
- }
-
- if (!containsElementsWithChange(selection)) {
- fRevertButton.setEnabled(false);
- }
-
- fRenameButton.setEnabled(getExternalizedElements(selection).size() > 1);
- fEditButton.setEnabled(selection.size() == 1);
- }
-
- private boolean containsElementsWithChange(IStructuredSelection selection) {
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- NLSSubstitution substitution= (NLSSubstitution) iter.next();
- if (substitution.hasPropertyFileChange() || substitution.hasSourceChange()) {
- return true;
- }
- }
- return false;
- }
-
- private List getExternalizedElements(IStructuredSelection selection) {
- ArrayList res= new ArrayList();
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- NLSSubstitution substitution= (NLSSubstitution) iter.next();
- if (substitution.getState() == NLSSubstitution.EXTERNALIZED && !substitution.hasStateChanged()) {
- res.add(substitution);
- }
- }
- return res;
- }
-
- private boolean containsOnlyElementsOfSameState(int state, IStructuredSelection selection) {
- for (Iterator iter= selection.iterator(); iter.hasNext();) {
- NLSSubstitution substitution= (NLSSubstitution) iter.next();
- if (substitution.getState() != state) {
- return false;
- }
- }
- return true;
- }
-
- public boolean performFinish() {
- return super.performFinish();
- }
-
- public IWizardPage getNextPage() {
- return super.getNextPage();
- }
-
- public void dispose() {
- storeAccessorDescriptions();
- //widgets will be disposed. only need to null'em
- fPrefixField= null;
- fSourceViewer= null;
- fTable= null;
- fTableViewer= null;
- fEditButton= null;
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/MultiStateCellEditor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/MultiStateCellEditor.java
deleted file mode 100644
index 4bdd9430..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/MultiStateCellEditor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-public class MultiStateCellEditor extends CellEditor {
-
- private int fValue;
- private final int fStateCount;
-
- /**
- * @param stateCount must be > 1
- * @param initialValue initialValue
- */
- public MultiStateCellEditor(Composite parent, int stateCount, int initialValue) {
- super(parent);
- Assert.isTrue(stateCount > 1, "incorrect state count"); //$NON-NLS-1$
- fStateCount= stateCount;
-
- Assert.isTrue(initialValue >= 0 && initialValue < stateCount, "incorrect initial value"); //$NON-NLS-1$
- fValue= initialValue;
-
- setValueValid(true);
- }
-
- /*
- * @see org.eclipse.jface.viewers.CellEditor#activate()
- */
- public void activate() {
- fValue= getNextValue(fStateCount, fValue);
- fireApplyEditorValue();
- }
-
- public static int getNextValue(int stateCount, int currentValue){
- Assert.isTrue(stateCount > 1, "incorrect state count"); //$NON-NLS-1$
- Assert.isTrue(currentValue >= 0 && currentValue < stateCount, "incorrect initial value"); //$NON-NLS-1$
- return (currentValue + 1) % stateCount;
- }
-
- /*
- * @see org.eclipse.jface.viewers.CellEditor#createControl(org.eclipse.swt.widgets.Composite)
- */
- protected Control createControl(Composite parent) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.CellEditor#doGetValue()
- * @return the Integer value
- */
- protected Object doGetValue() {
- return new Integer(fValue);
- }
-
- /*
- * @see org.eclipse.jface.viewers.CellEditor#doSetFocus()
- */
- protected void doSetFocus() {
- // Ignore
- }
-
- /*
- * @see org.eclipse.jface.viewers.CellEditor#doSetValue(java.lang.Object)
- * @param value an Integer value
- * must be >=0 and < stateCount (value passed in the constructor)
- */
- protected void doSetValue(Object value) {
- Assert.isTrue(value instanceof Integer, "value must be Integer"); //$NON-NLS-1$
- fValue = ((Integer) value).intValue();
- Assert.isTrue(fValue >= 0 && fValue < fStateCount, "invalid value"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSAccessorConfigurationDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSAccessorConfigurationDialog.java
deleted file mode 100644
index 230d31d4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSAccessorConfigurationDialog.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridLayout;
-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.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.Separator;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class NLSAccessorConfigurationDialog extends StatusDialog {
-
-
- private SourceFirstPackageSelectionDialogField fResourceBundlePackage;
- private StringButtonDialogField fResourceBundleFile;
- private SourceFirstPackageSelectionDialogField fAccessorPackage;
- private StringDialogField fAccessorClassName;
- private StringDialogField fSubstitutionPattern;
-
- private NLSRefactoring fRefactoring;
-
- private IStatus[] fStati;
-
- private static final int IDX_ACCESSOR_CLASS= 0;
- private static final int IDX_ACCESSOR_PACKAGE= 1;
- private static final int IDX_SUBST_PATTERN= 2;
- private static final int IDX_BUNDLE_NAME= 3;
- private static final int IDX_BUNDLE_PACKAGE= 4;
-
- private class AccessorAdapter implements IDialogFieldListener, IStringButtonAdapter {
- public void dialogFieldChanged(DialogField field) {
- validateAll();
- }
-
- public void changeControlPressed(DialogField field) {
- if (field == fResourceBundleFile) {
- browseForPropertyFile();
- } else if (field == fAccessorClassName) {
- browseForAccessorClass();
- }
- }
- }
-
-
- public NLSAccessorConfigurationDialog(Shell parent, NLSRefactoring refactoring) {
- super(parent);
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- fRefactoring= refactoring;
- fStati= new IStatus[] { StatusInfo.OK_STATUS, StatusInfo.OK_STATUS, StatusInfo.OK_STATUS, StatusInfo.OK_STATUS, StatusInfo.OK_STATUS };
-
- setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_title);
-
- AccessorAdapter updateListener= new AccessorAdapter();
-
- IJavaScriptUnit cu= refactoring.getCu();
-
- fAccessorPackage= new SourceFirstPackageSelectionDialogField(NLSUIMessages.NLSAccessorConfigurationDialog_accessor_path,
- NLSUIMessages.NLSAccessorConfigurationDialog_accessor_package,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse1,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse2,
- NLSUIMessages.NLSAccessorConfigurationDialog_default_package,
- NLSUIMessages.NLSAccessorConfigurationDialog_accessor_dialog_title,
- NLSUIMessages.NLSAccessorConfigurationDialog_accessor_dialog_message,
- NLSUIMessages.NLSAccessorConfigurationDialog_accessor_dialog_emtpyMessage,
- cu, updateListener, refactoring.getAccessorClassPackage());
-
- fAccessorClassName= createStringButtonField(NLSUIMessages.NLSAccessorConfigurationDialog_className,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse6, updateListener);
- fSubstitutionPattern= createStringField(NLSUIMessages.NLSAccessorConfigurationDialog_substitutionPattern, updateListener);
-
- fResourceBundlePackage= new SourceFirstPackageSelectionDialogField(NLSUIMessages.NLSAccessorConfigurationDialog_property_path,
- NLSUIMessages.NLSAccessorConfigurationDialog_property_package,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse3,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse4,
- NLSUIMessages.NLSAccessorConfigurationDialog_default_package,
- NLSUIMessages.NLSAccessorConfigurationDialog_property_dialog_title,
- NLSUIMessages.NLSAccessorConfigurationDialog_property_dialog_message,
- NLSUIMessages.NLSAccessorConfigurationDialog_property_dialog_emptyMessage,
- cu, updateListener, fRefactoring.getResourceBundlePackage());
-
- fResourceBundleFile= createStringButtonField(NLSUIMessages.NLSAccessorConfigurationDialog_property_file_name,
- NLSUIMessages.NLSAccessorConfigurationDialog_browse5, updateListener);
-
- initFields();
- }
-
- private void initFields() {
- initAccessorClassFields();
- String resourceBundleName= fRefactoring.getResourceBundleName();
- fResourceBundleFile.setText(resourceBundleName != null ? resourceBundleName : (NLSRefactoring.DEFAULT_PROPERTY_FILENAME + NLSRefactoring.PROPERTY_FILE_EXT));
- }
-
- private void initAccessorClassFields() {
- String accessorClassName= fRefactoring.getAccessorClassName();
-
- if (accessorClassName == null) {
- accessorClassName= NLSRefactoring.DEFAULT_ACCESSOR_CLASSNAME;
- }
- fAccessorClassName.setText(accessorClassName);
-
- fSubstitutionPattern.setText(fRefactoring.getSubstitutionPattern());
- }
-
- protected Control createDialogArea(Composite ancestor) {
- Composite parent= (Composite) super.createDialogArea(ancestor);
-
- final int nOfColumns= 4;
-
- initializeDialogUnits(ancestor);
-
- GridLayout layout= (GridLayout) parent.getLayout();
- layout.numColumns= nOfColumns;
- parent.setLayout(layout);
-
- createAccessorPart(parent, nOfColumns, convertWidthInCharsToPixels(40));
-
- Separator s= new Separator(SWT.SEPARATOR | SWT.HORIZONTAL);
- s.doFillIntoGrid(parent, nOfColumns);
-
- createPropertyPart(parent, nOfColumns, convertWidthInCharsToPixels(40));
-
- Dialog.applyDialogFont(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.EXTERNALIZE_WIZARD_PROPERTIES_FILE_PAGE);
- validateAll();
- return parent;
- }
-
-
- private void createAccessorPart(Composite parent, final int nOfColumns, int textWidth) {
- createLabel(parent, NLSUIMessages.NLSAccessorConfigurationDialog_resourceBundle_title, nOfColumns);
- fAccessorPackage.createControl(parent, nOfColumns, textWidth);
-
- fAccessorClassName.doFillIntoGrid(parent, nOfColumns);
- Text accessorClassText= fAccessorClassName.getTextControl(null);
- LayoutUtil.setWidthHint(accessorClassText, convertWidthInCharsToPixels(60));
- TextFieldNavigationHandler.install(accessorClassText);
-
- fSubstitutionPattern.doFillIntoGrid(parent, nOfColumns);
- Text substitutionPatternText= fSubstitutionPattern.getTextControl(null);
- LayoutUtil.setWidthHint(substitutionPatternText, convertWidthInCharsToPixels(60));
- TextFieldNavigationHandler.install(substitutionPatternText);
-
- fSubstitutionPattern.setEnabled(!fRefactoring.isEclipseNLS());
- }
-
- private void createPropertyPart(Composite parent, final int nOfColumns, final int textWidth) {
- createLabel(parent, NLSUIMessages.NLSAccessorConfigurationDialog_property_location, nOfColumns);
- fResourceBundlePackage.createControl(parent, nOfColumns, textWidth);
-
- fResourceBundleFile.doFillIntoGrid(parent, nOfColumns);
- LayoutUtil.setWidthHint(fResourceBundleFile.getTextControl(null), convertWidthInCharsToPixels(60));
- }
-
- private void createLabel(Composite parent, final String text, final int N_OF_COLUMNS) {
- Separator label= new Separator(SWT.NONE);
- ((Label) label.getSeparator(parent)).setText(text);
- GC gc= new GC(parent);
- int height= gc.stringExtent(text).y;
- gc.dispose();
- label.doFillIntoGrid(parent, N_OF_COLUMNS, height);
- }
-
- private void browseForPropertyFile() {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaScriptElementLabelProvider());
- dialog.setIgnoreCase(false);
- dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Property_File_Selection);
- dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_property_file);
- dialog.setElements(createFileListInput());
- dialog.setFilter('*' + NLSRefactoring.PROPERTY_FILE_EXT);
- if (dialog.open() == Window.OK) {
- IFile selectedFile= (IFile) dialog.getFirstResult();
- if (selectedFile != null)
- fResourceBundleFile.setText(selectedFile.getName());
- }
- }
-
- protected void browseForAccessorClass() {
- IProgressService service= PlatformUI.getWorkbench().getProgressService();
- IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot();
-
- IJavaScriptSearchScope scope= root != null ? SearchEngine.createJavaSearchScope(new IJavaScriptElement[] { root }) : SearchEngine.createWorkspaceScope();
-
- FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog (getShell(), false,
- service, scope, IJavaScriptSearchConstants.CLASS);
- dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection);
- dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file);
- dialog.setInitialPattern("*Messages"); //$NON-NLS-1$
- if (dialog.open() == Window.OK) {
- IType selectedType= (IType) dialog.getFirstResult();
- if (selectedType != null) {
- fAccessorClassName.setText(selectedType.getElementName());
- fAccessorPackage.setSelected(selectedType.getPackageFragment());
- }
- }
-
-
- }
-
- private Object[] createFileListInput() {
- try {
-
- IPackageFragment fPkgFragment= fResourceBundlePackage.getSelected();
- if (fPkgFragment == null)
- return new Object[0];
- List result= new ArrayList(1);
- Object[] nonjava= fPkgFragment.getNonJavaScriptResources();
- for (int i= 0; i < nonjava.length; i++) {
- if (isPropertyFile(nonjava[i]))
- result.add(nonjava[i]);
- }
- return result.toArray();
-
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, NLSUIMessages.NLSAccessorConfigurationDialog_externalizing, NLSUIMessages .NLSAccessorConfigurationDialog_exception);
- return new Object[0];
- }
- }
-
- private static boolean isPropertyFile(Object o) {
- if (!(o instanceof IFile))
- return false;
- IFile file= (IFile) o;
- return (NLSRefactoring.PROPERTY_FILE_EXT.equals('.' + file.getFileExtension()));
- }
-
- /**
- * checks all entered values delegates to the specific validate methods these methods
- * update the refactoring
- */
- private void validateAll() {
- validateSubstitutionPattern();
-
- validateAccessorClassName();
- checkPackageFragment();
-
- validatePropertyFilename();
- validatePropertyPackage();
-
- updateStatus(StatusUtil.getMostSevere(fStati));
- }
-
- private void validateAccessorClassName() {
- String className= fAccessorClassName.getText();
-
- IStatus status= JavaScriptConventions.validateJavaScriptTypeName(className);
- if (status.getSeverity() == IStatus.ERROR) {
- setInvalid(IDX_ACCESSOR_CLASS, status.getMessage());
- return;
- }
-
- if (className.indexOf('.') != -1) {
- setInvalid(IDX_ACCESSOR_CLASS, NLSUIMessages.NLSAccessorConfigurationDialog_no_dot);
- return;
- }
-
- setValid(IDX_ACCESSOR_CLASS);
- }
-
- private void validatePropertyFilename() {
- String fileName= fResourceBundleFile.getText();
- if ((fileName == null) || (fileName.length() == 0)) {
- setInvalid(IDX_BUNDLE_NAME, NLSUIMessages.NLSAccessorConfigurationDialog_enter_name);
- return;
- }
-
- if (!fileName.endsWith(NLSRefactoring.PROPERTY_FILE_EXT)) {
- setInvalid(IDX_BUNDLE_NAME, Messages.format(NLSUIMessages.NLSAccessorConfigurationDialog_file_name_must_end, NLSRefactoring.PROPERTY_FILE_EXT));
- return;
- }
-
- setValid(IDX_BUNDLE_NAME);
- }
-
- private void validatePropertyPackage() {
-
- IPackageFragmentRoot root= fResourceBundlePackage.getSelectedFragmentRoot();
- if ((root == null) || !root.exists()) {
- setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_root_invalid);
- return;
- }
-
- IPackageFragment fragment= fResourceBundlePackage.getSelected();
- if ((fragment == null) || !fragment.exists()) {
- setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_invalid);
- return;
- }
-
- String pkgName= fragment.getElementName();
-
- IStatus status= JavaScriptConventions.validatePackageName(pkgName);
- if ((pkgName.length() > 0) && (status.getSeverity() == IStatus.ERROR)) {
- setInvalid(IDX_BUNDLE_PACKAGE, status.getMessage());
- return;
- }
-
- IPath pkgPath= new Path(pkgName.replace('.', IPath.SEPARATOR)).makeRelative();
-
- IJavaScriptProject project= fRefactoring.getCu().getJavaScriptProject();
- try {
- IJavaScriptElement element= project.findElement(pkgPath);
- if (element == null || !element.exists()) {
- setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_must_exist);
- return;
- }
- IPackageFragment fPkgFragment= (IPackageFragment) element;
- if (!PackageBrowseAdapter.canAddPackage(fPkgFragment)) {
- setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package);
- return;
- }
- if (!PackageBrowseAdapter.canAddPackageRoot((IPackageFragmentRoot) fPkgFragment.getParent())) {
- setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package);
- return;
- }
- } catch (JavaScriptModelException e) {
- setInvalid(IDX_BUNDLE_PACKAGE, e.getStatus().getMessage());
- return;
- }
-
- setValid(IDX_BUNDLE_PACKAGE);
- }
-
- private void checkPackageFragment() {
- IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot();
- if ((root == null) || !root.exists()) {
- setInvalid(IDX_ACCESSOR_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_accessor_package_root_invalid);
- return;
- }
-
- IPackageFragment fragment= fAccessorPackage.getSelected();
- if ((fragment == null) || !fragment.exists()) {
- setInvalid(IDX_ACCESSOR_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_accessor_package_invalid);
- return;
- }
- setValid(IDX_ACCESSOR_PACKAGE);
- }
-
- private void validateSubstitutionPattern() {
- if ((fSubstitutionPattern.getText() == null) || (fSubstitutionPattern.getText().length() == 0)) {
- setInvalid(IDX_SUBST_PATTERN, NLSUIMessages.NLSAccessorConfigurationDialog_substitution_pattern_missing);
- } else {
- setValid(IDX_SUBST_PATTERN);
- }
- }
-
- private void setInvalid(int idx, String msg) {
- fStati[idx]= new StatusInfo(IStatus.ERROR, msg);
- }
-
- private void setValid(int idx) {
- fStati[idx]= StatusInfo.OK_STATUS;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- updateRefactoring();
- super.okPressed();
- }
-
-
- void updateRefactoring() {
- fRefactoring.setAccessorClassPackage(fAccessorPackage.getSelected());
- fRefactoring.setAccessorClassName(fAccessorClassName.getText());
-
- fRefactoring.setResourceBundleName(fResourceBundleFile.getText());
- fRefactoring.setResourceBundlePackage(fResourceBundlePackage.getSelected());
-
- if (!fRefactoring.isEclipseNLS())
- fRefactoring.setSubstitutionPattern(fSubstitutionPattern.getText());
-
- fRefactoring.setIsEclipseNLS(fRefactoring.detectIsEclipseNLS());
- }
-
- private StringDialogField createStringField(String label, AccessorAdapter updateListener) {
- StringDialogField field= new StringDialogField();
- field.setDialogFieldListener(updateListener);
- field.setLabelText(label);
- return field;
- }
-
- private StringButtonDialogField createStringButtonField(String label, String button, AccessorAdapter adapter) {
- StringButtonDialogField field= new StringButtonDialogField(adapter);
- field.setDialogFieldListener(adapter);
- field.setLabelText(label);
- field.setButtonLabel(button);
- return field;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.java
deleted file mode 100644
index 2e13833f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-final class NLSUIMessages extends NLS {
-
- private static final String BUNDLE_NAME= NLSUIMessages.class.getName();
-
- private NLSUIMessages() {
- // Do not instantiate
- }
-
- public static String ExternalizeWizard_name;
- public static String ExternalizeWizard_select;
- public static String ExternalizeWizardPage_title;
- public static String ExternalizeWizardPage_description;
- public static String ExternalizeWizardPage_exception_title;
- public static String ExternalizeWizardPage_exception_message;
- public static String ExternalizeWizardPage_common_prefix;
- public static String ExternalizeWizardPage_context;
- public static String ExternalizeWizardPage_strings_to_externalize;
- public static String ExternalizeWizardPage_Externalize_Selected;
- public static String ExternalizeWizardPage_Ignore_Selected;
- public static String ExternalizeWizardPage_Internalize_Selected;
- public static String ExternalizeWizardPage_Revert_Selected;
- public static String ExternalizeWizardPage_isEclipseNLSCheckbox;
- public static String ExternalizeWizardPage_Rename_Keys;
- public static String ExternalizeWizardPage_NLSInputDialog_Label;
- public static String ExternalizeWizardPage_NLSInputDialog_Enter_key;
- public static String ExternalizeWizardPage_NLSInputDialog_ext_Label;
- public static String ExternalizeWizardPage_NLSInputDialog_Enter_value;
- public static String ExternalizeWizardPage_NLSInputDialog_Title;
- public static String ExternalizeWizardPage_NLSInputDialog_Error_empty_key;
- public static String ExternalizeWizardPage_NLSInputDialog_Error_invalid_key;
- public static String ExternalizeWizardPage_NLSInputDialog_Error_invalid_EclipseNLS_key;
- public static String NLSAccessorConfigurationDialog_browse1;
- public static String NLSAccessorConfigurationDialog_browse2;
- public static String NLSAccessorConfigurationDialog_browse3;
- public static String NLSAccessorConfigurationDialog_browse4;
- public static String NLSAccessorConfigurationDialog_browse5;
- public static String NLSAccessorConfigurationDialog_browse6;
- public static String NLSAccessorConfigurationDialog_property_file_name;
- public static String NLSAccessorConfigurationDialog_substitutionPattern;
- public static String NLSAccessorConfigurationDialog_externalizing;
- public static String NLSAccessorConfigurationDialog_exception;
- public static String NLSAccessorConfigurationDialog_must_exist;
- public static String NLSAccessorConfigurationDialog_incorrect_package;
- public static String NLSAccessorConfigurationDialog_enter_name;
- public static String NLSAccessorConfigurationDialog_file_name_must_end;
- public static String NLSAccessorConfigurationDialog_className;
- public static String NLSAccessorConfigurationDialog_no_dot;
- public static String NLSAccessorConfigurationDialog_default_package;
- public static String NLSAccessorConfigurationDialog_default;
- public static String NLSAccessorConfigurationDialog_property_location;
- public static String NLSAccessorConfigurationDialog_Choose_the_property_file;
- public static String NLSAccessorConfigurationDialog_Property_File_Selection;
- public static String NLSAccessorConfigurationDialog_Choose_the_accessor_file;
- public static String NLSAccessorConfigurationDialog_Accessor_Selection;
- public static String NLSAccessorConfigurationDialog_accessor_path;
- public static String NLSAccessorConfigurationDialog_accessor_package;
- public static String NLSAccessorConfigurationDialog_resourceBundle_title;
- public static String NLSAccessorConfigurationDialog_property_path;
- public static String NLSAccessorConfigurationDialog_property_package;
- public static String NLSAccessorConfigurationDialog_accessor_package_root_invalid;
- public static String NLSAccessorConfigurationDialog_accessor_package_invalid;
- public static String NLSAccessorConfigurationDialog_property_package_root_invalid;
- public static String NLSAccessorConfigurationDialog_property_package_invalid;
- public static String NLSAccessorConfigurationDialog_substitution_pattern_missing;
- public static String NLSAccessorConfigurationDialog_accessor_dialog_title;
- public static String NLSAccessorConfigurationDialog_accessor_dialog_message;
- public static String NLSAccessorConfigurationDialog_accessor_dialog_emtpyMessage;
- public static String NLSAccessorConfigurationDialog_property_dialog_title;
- public static String NLSAccessorConfigurationDialog_property_dialog_message;
- public static String NLSAccessorConfigurationDialog_property_dialog_emptyMessage;
- public static String ExternalizeWizardPage_key;
- public static String ExternalizeWizardPage_value;
- public static String ExternalizeWizardPage_Edit_key_and_value;
- public static String ExternalizeWizardPage_accessorclass_label;
- public static String ExternalizeWizardPage_configure_button;
- public static String ExternalizeWizardPage_warning_conflicting;
- public static String ExternalizeWizardPage_warning_keymissing;
- public static String ExternalizeWizardPage_warning_keyInvalid;
- public static String ExternalizeWizardPage_warning_EclipseNLS_keyInvalid;
- public static String ExternalizeWizardPage_filter_label;
- public static String NLSAccessorConfigurationDialog_title;
- public static String PackageBrowseAdapter_package_selection;
- public static String PackageBrowseAdapter_choose_package;
- public static String RenameKeysDialog_title;
- public static String RenameKeysDialog_description_noprefix;
- public static String RenameKeysDialog_description_withprefix;
- public static String SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_title;
- public static String SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_description;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, NLSUIMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.properties
deleted file mode 100644
index bb7f50da..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/NLSUIMessages.properties
+++ /dev/null
@@ -1,97 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-ExternalizeWizard_name=Externalize Strings
-ExternalizeWizard_select=Select strings to externalize
-
-ExternalizeWizardPage_title=Externalize Strings in ''{0}''
-ExternalizeWizardPage_description= Externalizes strings from code into a properties file. The auto-generated keys should be adjusted.
-ExternalizeWizardPage_exception_title=Externalizing Strings
-ExternalizeWizardPage_exception_message=Unexpected exception while creating UI. See log for a detailed error description.
-ExternalizeWizardPage_common_prefix=&Enter common prefix for generated keys (optional):
-ExternalizeWizardPage_context=Conte&xt:
-ExternalizeWizardPage_strings_to_externalize=St&rings to externalize:
-ExternalizeWizardPage_Externalize_Selected=Externa&lize
-ExternalizeWizardPage_Ignore_Selected=&Ignore
-ExternalizeWizardPage_Internalize_Selected=In&ternalize
-ExternalizeWizardPage_Revert_Selected=Re&vert
-ExternalizeWizardPage_isEclipseNLSCheckbox=&Use Eclipse's string externalization mechanism
-
-ExternalizeWizardPage_Rename_Keys=Rename &keys...
-ExternalizeWizardPage_NLSInputDialog_Label=Enter the new value:
-ExternalizeWizardPage_NLSInputDialog_Enter_key=New &key:
-ExternalizeWizardPage_NLSInputDialog_ext_Label=Enter the new key and value:
-ExternalizeWizardPage_NLSInputDialog_Enter_value=New &value:
-ExternalizeWizardPage_NLSInputDialog_Title=Edit Entry
-ExternalizeWizardPage_NLSInputDialog_Error_empty_key=Key cannot be empty.
-ExternalizeWizardPage_NLSInputDialog_Error_invalid_key=Key contains white spaces.
-ExternalizeWizardPage_NLSInputDialog_Error_invalid_EclipseNLS_key=Key is not a valid Java identifier.
-NLSAccessorConfigurationDialog_browse1=&Browse...
-NLSAccessorConfigurationDialog_browse2=B&rowse...
-NLSAccessorConfigurationDialog_browse3=Br&owse...
-NLSAccessorConfigurationDialog_browse4=Bro&wse...
-NLSAccessorConfigurationDialog_browse5=Brows&e...
-NLSAccessorConfigurationDialog_browse6=Brow&se...
-NLSAccessorConfigurationDialog_property_file_name=Propert&y file name:
-NLSAccessorConfigurationDialog_substitutionPattern=S&ubstitution pattern:
-
-NLSAccessorConfigurationDialog_externalizing=Externalizing Strings
-NLSAccessorConfigurationDialog_exception=Unexpected exception while creating the package list. See log for a detailed error description.
-NLSAccessorConfigurationDialog_must_exist=The package does not exist in this project.
-NLSAccessorConfigurationDialog_incorrect_package=Incorrect package.
-NLSAccessorConfigurationDialog_enter_name=The property file is invalid.
-NLSAccessorConfigurationDialog_file_name_must_end=The property file name must end with ''{0}''.
-NLSAccessorConfigurationDialog_className=&Class name:
-NLSAccessorConfigurationDialog_no_dot=Class name should not contain a dot (.).
-NLSAccessorConfigurationDialog_default_package=(default package)
-NLSAccessorConfigurationDialog_default= (default)
-NLSAccessorConfigurationDialog_property_location=Property file location and name:
-NLSAccessorConfigurationDialog_Choose_the_property_file=&Choose the property file:
-NLSAccessorConfigurationDialog_Property_File_Selection=Property File Selection
-NLSAccessorConfigurationDialog_Choose_the_accessor_file=&Choose the accessor class:
-NLSAccessorConfigurationDialog_Accessor_Selection=Accessor class selection
-NLSAccessorConfigurationDialog_accessor_path=Source fol&der:
-NLSAccessorConfigurationDialog_accessor_package=Pac&kage:
-NLSAccessorConfigurationDialog_resourceBundle_title=Resource bundle accessor class (will be created if it does not exist):
-NLSAccessorConfigurationDialog_property_path=Source fo&lder:
-NLSAccessorConfigurationDialog_property_package=P&ackage:
-NLSAccessorConfigurationDialog_accessor_package_root_invalid=The source folder for the accessor class is invalid.
-NLSAccessorConfigurationDialog_accessor_package_invalid=The package for the accessor class is invalid.
-NLSAccessorConfigurationDialog_property_package_root_invalid=The source folder for the resource bundle is invalid.
-NLSAccessorConfigurationDialog_property_package_invalid=The specified package for the resource bundle is invalid.
-NLSAccessorConfigurationDialog_substitution_pattern_missing=The substitution pattern is invalid.
-NLSAccessorConfigurationDialog_accessor_dialog_title=Package Selection
-NLSAccessorConfigurationDialog_accessor_dialog_message=&Choose the destination package:
-NLSAccessorConfigurationDialog_accessor_dialog_emtpyMessage=No packages available.
-NLSAccessorConfigurationDialog_property_dialog_title=Package Selection
-NLSAccessorConfigurationDialog_property_dialog_message=&Choose the destination package:
-NLSAccessorConfigurationDialog_property_dialog_emptyMessage=No packages available.
-
-ExternalizeWizardPage_key=Key
-ExternalizeWizardPage_value=Value
-ExternalizeWizardPage_Edit_key_and_value=E&dit...
-ExternalizeWizardPage_accessorclass_label=&Accessor class:
-ExternalizeWizardPage_configure_button=&Configure...
-ExternalizeWizardPage_warning_conflicting=Conflicting entries: Same key but different values
-ExternalizeWizardPage_warning_keymissing=Entry is missing in property file.
-ExternalizeWizardPage_warning_keyInvalid=Some keys are invalid.
-ExternalizeWizardPage_warning_EclipseNLS_keyInvalid=Some keys are not valid Java identifiers.
-ExternalizeWizardPage_filter_label=Filter all exi&sting ignored and externalized entries
-NLSAccessorConfigurationDialog_title=Configure Accessor Class
-
-PackageBrowseAdapter_package_selection=Package Selection
-PackageBrowseAdapter_choose_package=&Choose a package:
-
-RenameKeysDialog_title=Rename Keys
-RenameKeysDialog_description_noprefix=Enter new prefix: (selected entries do not share a prefix)
-RenameKeysDialog_description_withprefix=Enter replacement prefix for
-SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_title=Source Folder Selection
-SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_description=&Choose a source folder:
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageBrowseAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageBrowseAdapter.java
deleted file mode 100644
index 81445a45..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageBrowseAdapter.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-
-public class PackageBrowseAdapter implements IStringButtonAdapter {
-
- PackageSelectionDialogButtonField fReceiver;
- private IJavaScriptUnit fCu;
-
- public PackageBrowseAdapter(IJavaScriptUnit unit) {
- fCu = unit;
- }
-
- public void setReceiver(PackageSelectionDialogButtonField receiver) {
- fReceiver = receiver;
- }
-
- public void changeControlPressed(DialogField field) {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(
- Display.getCurrent().getActiveShell(), new JavaScriptElementLabelProvider());
- dialog.setIgnoreCase(false);
- dialog.setTitle(NLSUIMessages.PackageBrowseAdapter_package_selection);
- dialog.setMessage(NLSUIMessages.PackageBrowseAdapter_choose_package);
- dialog.setElements(createPackageListInput(fCu, null));
- if (dialog.open() == Window.OK) {
- IPackageFragment selectedPackage= (IPackageFragment)dialog.getFirstResult();
- if (selectedPackage != null) {
- fReceiver.setPackage(selectedPackage);
- }
- }
- }
- public static Object[] createPackageListInput(IJavaScriptUnit cu, String elementNameMatch){
- try{
- IJavaScriptProject project= cu.getJavaScriptProject();
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- List result= new ArrayList();
- HashMap entered =new HashMap();
- for (int i= 0; i < roots.length; i++){
- if (canAddPackageRoot(roots[i])){
- getValidPackages(roots[i], result, entered, elementNameMatch);
- }
- }
- return result.toArray();
- } catch (JavaScriptModelException e){
- JavaScriptPlugin.log(e);
- return new Object[0];
- }
- }
-
- static boolean canAddPackageRoot(IPackageFragmentRoot root) throws JavaScriptModelException{
- if (! root.exists())
- return false;
- if (root.isArchive())
- return false;
- if (root.isExternal())
- return false;
- if (root.isReadOnly())
- return false;
- if (! root.isStructureKnown())
- return false;
- return true;
- }
-
- static void getValidPackages(IPackageFragmentRoot root, List result, HashMap entered, String elementNameMatch) throws JavaScriptModelException {
- IJavaScriptElement[] children= null;
- try {
- children= root.getChildren();
- } catch (JavaScriptModelException e){
- return;
- }
- for (int i= 0; i < children.length; i++){
- if (children[i] instanceof IPackageFragment) {
- IPackageFragment packageFragment = (IPackageFragment)children[i];
- String packageName = packageFragment.getElementName();
-
- if ((entered != null) && (entered.containsKey(packageName)) == true) {
- continue;
- }
-
- if (canAddPackage(packageFragment)) {
- if ((elementNameMatch == null) || (elementNameMatch.equals(packageName))) {
- result.add(packageFragment);
- if (entered != null) {
- entered.put(packageName, null);
- }
- }
- }
- }
- }
- }
-
- static boolean canAddPackage(IPackageFragment p) throws JavaScriptModelException{
- if (! p.exists())
- return false;
- if (p.isReadOnly())
- return false;
- if (! p.isStructureKnown())
- return false;
- return true;
- }
-
- public static List searchAllPackages(IJavaScriptProject project, String matcher) {
- try{
- IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
- List result= new ArrayList();
- for (int i= 0; i < roots.length; i++){
- if (canAddPackageRoot(roots[i])){
- getValidPackages(roots[i], result, null, matcher);
- }
- }
- return result;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return new ArrayList(0);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageFragmentSelection.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageFragmentSelection.java
deleted file mode 100644
index ebd983b9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageFragmentSelection.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaPackageCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonStatusDialogField;
-
-class PackageFragmentSelection extends StringButtonStatusDialogField implements SourceChangeListener {
-
- private final SourceFirstPackageSelectionDialogField fDialogField;
- private JavaPackageCompletionProcessor fCurrPackageCompletionProcessor;
- private IDialogFieldListener fUpdateListener;
-
- public PackageFragmentSelection(SourceFirstPackageSelectionDialogField field, String packageLabel, String browseLabel,
- String statusHint, IStringButtonAdapter adapter) {
- super(adapter);
- fDialogField= field;
- setLabelText(packageLabel);
- setButtonLabel(browseLabel);
- setStatusWidthHint(statusHint);
- fCurrPackageCompletionProcessor= new JavaPackageCompletionProcessor();
- }
-
- public void setUpdateListener(IDialogFieldListener updateListener) {
- fUpdateListener= updateListener;
- }
-
- public Control[] doFillIntoGrid(Composite parent, int nColumns, int textWidth) {
- Control[] res= super.doFillIntoGrid(parent, nColumns);
-
- final Text text= getTextControl(null);
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateListener();
- }
- });
- LayoutUtil.setWidthHint(text, textWidth);
- LayoutUtil.setHorizontalGrabbing(text);
- ControlContentAssistHelper.createTextContentAssistant(text, fCurrPackageCompletionProcessor);
- TextFieldNavigationHandler.install(text);
-
- return res;
- }
-
- public void setPackageFragment(IPackageFragment fragment) {
- if (fragment != null) {
- setText(fragment.getElementName());
- }
-
- updateListener();
- }
-
- private void updateListener() {
- if (fUpdateListener != null) {
- fUpdateListener.dialogFieldChanged(this);
- }
- }
-
- public IPackageFragment getPackageFragment() {
- return calculateFragment(fDialogField.getSelectedFragmentRoot());
- }
-
- private IPackageFragment calculateFragment(IPackageFragmentRoot root) {
- if (root == null) {
- return null;
- } else {
- return root.getPackageFragment(getText());
- }
- }
-
- public void sourceRootChanged(IPackageFragmentRoot newRoot) {
- fCurrPackageCompletionProcessor.setPackageFragmentRoot(newRoot);
-
- setPackageFragment(calculateFragment(newRoot));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionDialogButtonField.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionDialogButtonField.java
deleted file mode 100644
index 19fb6ab8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionDialogButtonField.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaPackageCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public final class PackageSelectionDialogButtonField extends StringButtonDialogField {
-
- private IPackageFragment fPackageFragment;
-
- public PackageSelectionDialogButtonField(String label, String button, PackageBrowseAdapter adapter, IJavaScriptProject root) {
- super(adapter);
- setContentAssistProcessor(new JavaPackageCompletionProcessor(new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_ROOT)));
-
- IPackageFragmentRoot[] roots;
- try {
- roots= root.getAllPackageFragmentRoots();
- ((JavaPackageCompletionProcessor)getContentAssistProcessor()).setPackageFragmentRoot(roots[0]);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- // if exception no content assist .. but thats no problem
- }
- setLabelText(label);
- setButtonLabel(button);
- adapter.setReceiver(this);
- }
-
- public void setPackage(IPackageFragment packageFragment) {
- fPackageFragment= packageFragment;
- if (fPackageFragment != null) {
- setText(fPackageFragment.getElementName());
-
- JavaPackageCompletionProcessor contentAssist= (JavaPackageCompletionProcessor)getContentAssistProcessor();
- contentAssist.setPackageFragmentRoot((IPackageFragmentRoot)packageFragment.getParent());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionStringButtonAdapter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionStringButtonAdapter.java
deleted file mode 100644
index 921826e9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/PackageSelectionStringButtonAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-class PackageSelectionStringButtonAdapter implements IStringButtonAdapter {
-
- private final SourceFirstPackageSelectionDialogField fPackageSelectionField;
- private String fEmtpyListMessage;
- private String fMessage;
- private String fTitle;
-
- PackageSelectionStringButtonAdapter(SourceFirstPackageSelectionDialogField field, String title, String message,
- String emtpyListMessage) {
- fPackageSelectionField= field;
- fTitle= title;
- fMessage= message;
- fEmtpyListMessage= emtpyListMessage;
- }
-
- public void changeControlPressed(DialogField field) {
- IPackageFragmentRoot root= fPackageSelectionField.getSelectedFragmentRoot();
-
- IJavaScriptElement[] packages= null;
- try {
- if (root != null && root.exists()) {
- packages= root.getChildren();
- }
- } catch (JavaScriptModelException e) {
- // no need to react
- }
-
- if (packages == null) {
- packages= new IJavaScriptElement[0];
- }
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(field.getLabelControl(null).getShell(),
- new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT));
- dialog.setIgnoreCase(true);
-
- dialog.setTitle(fTitle);
- dialog.setMessage(fMessage);
- dialog.setEmptyListMessage(fEmtpyListMessage);
- dialog.setElements(packages);
-
- // TODO initial selection
- // List selection = new ArrayList();
- // selection.add(fPackageSelectionField.fPackageSelection.getPackageFragment());
- // dialog.setInitialElementSelections(selection);
-
- if (dialog.open() == Window.OK) {
- IPackageFragment fragment= (IPackageFragment)dialog.getFirstResult();
- fPackageSelectionField.setSelected(fragment);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/RenameKeysDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/RenameKeysDialog.java
deleted file mode 100644
index 6d9f9a6b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/RenameKeysDialog.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSSubstitution;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-
-/**
- *
- */
-public class RenameKeysDialog extends StatusDialog {
-
- private StringDialogField fNameField;
- private List fSelectedSubstitutions;
- private int fCommonPrefixLength;
-
- /**
- * @param parent
- */
- public RenameKeysDialog(Shell parent, List selectedSubstitutions) {
- super(parent);
- setTitle(NLSUIMessages.RenameKeysDialog_title);
-
- fSelectedSubstitutions= selectedSubstitutions;
- String prefix= getInitialPrefix(selectedSubstitutions);
- fCommonPrefixLength= prefix.length();
-
- fNameField= new StringDialogField();
- fNameField.setText(prefix);
-
- if (prefix.length() == 0) {
- fNameField.setLabelText(NLSUIMessages.RenameKeysDialog_description_noprefix);
- } else {
- fNameField.setLabelText(NLSUIMessages.RenameKeysDialog_description_withprefix + prefix + ':');
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- fNameField.doFillIntoGrid(composite, 2);
- LayoutUtil.setHorizontalGrabbing(fNameField.getTextControl(null));
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- String prefix= fNameField.getText();
- for (int i= 0; i < fSelectedSubstitutions.size(); i++) {
- NLSSubstitution sub= (NLSSubstitution) fSelectedSubstitutions.get(i);
- String newKey= prefix + sub.getKey().substring(fCommonPrefixLength);
- sub.setKey(newKey);
- }
- super.okPressed();
- }
-
- private String getInitialPrefix(List selectedSubstitutions) {
- String prefix= null;
- for (int i= 0; i < selectedSubstitutions.size(); i++) {
- NLSSubstitution sub= (NLSSubstitution) selectedSubstitutions.get(i);
- String curr= sub.getKey();
- if (prefix == null) {
- prefix= curr;
- } else if (!curr.startsWith(prefix)) {
- prefix= getCommonPrefix(prefix, curr);
- if (prefix.length() == 0) {
- return prefix;
- }
- }
- }
- return prefix;
- }
-
- private String getCommonPrefix(String a, String b) {
- String shorter= a.length() <= b.length() ? a : b;
- int len= shorter.length();
- for (int i= 0; i < len; i++) {
- if (a.charAt(i) != b.charAt(i)) {
- return a.substring(0, i);
- }
- }
- return shorter;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceChangeListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceChangeListener.java
deleted file mode 100644
index 473b0bb4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceChangeListener.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-
-public interface SourceChangeListener {
-
- public void sourceRootChanged(IPackageFragmentRoot newRoot);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceContainerDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceContainerDialog.java
deleted file mode 100644
index 42af79b7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceContainerDialog.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.wizards.NewWizardMessages;
-import org.eclipse.wst.jsdt.internal.ui.wizards.TypedElementSelectionValidator;
-import org.eclipse.wst.jsdt.internal.ui.wizards.TypedViewerFilter;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-public class SourceContainerDialog extends ElementTreeSelectionDialog {
-
- private class PackageAndProjectSelectionValidator extends TypedElementSelectionValidator {
-
- public PackageAndProjectSelectionValidator() {
- super(new Class[]{IPackageFragmentRoot.class},false);
- }
-
- public boolean isSelectedValid(Object element) {
- try {
- if (element instanceof IJavaScriptProject) {
- IJavaScriptProject jproject= (IJavaScriptProject) element;
- IPath path= jproject.getProject().getFullPath();
- return (jproject.findPackageFragmentRoot(path) != null);
- } else
- if (element instanceof IPackageFragmentRoot) {
- return (((IPackageFragmentRoot) element).getKind() == IPackageFragmentRoot.K_SOURCE);
- }
- return true;
- } catch (JavaScriptModelException e) {
- // fall through returning false
- }
- return false;
- }
- }
-
- /**
- * A TypedViewerFilter that accepts only PackageFragments and JavaProjects.
- * PackageFragments are only accepted if they are of the kind K_SOURCE.
- */
- private class JavaTypedViewerFilter extends TypedViewerFilter {
-
- public JavaTypedViewerFilter() {
- super(new Class[]{IPackageFragmentRoot.class, IJavaScriptProject.class});
- }
-
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot fragmentRoot= (IPackageFragmentRoot)element;
- try {
- return (fragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE);
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
- return super.select(viewer, parent, element);
- }
- }
-
- private SourceContainerDialog(Shell shell) {
- super(shell,new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT),new StandardJavaScriptElementContentProvider());
- setValidator(new PackageAndProjectSelectionValidator());
- setComparator(new JavaScriptElementComparator());
- setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title);
- setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description);
- addFilter(new JavaTypedViewerFilter());
- }
-
- public static IPackageFragmentRoot getSourceContainer(Shell shell, IWorkspaceRoot workspaceRoot, IJavaScriptElement initElement) {
- SourceContainerDialog dialog= new SourceContainerDialog(shell);
- dialog.setInput(JavaScriptCore.create(workspaceRoot));
- dialog.setInitialSelection(initElement);
-
- if (dialog.open() == Window.OK) {
- Object element= dialog.getFirstResult();
- if (element instanceof IJavaScriptProject) {
- IJavaScriptProject jproject= (IJavaScriptProject) element;
- return jproject.getPackageFragmentRoot(jproject.getProject());
- } else
- if (element instanceof IPackageFragmentRoot) {
- return (IPackageFragmentRoot) element;
- }
- return null;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFirstPackageSelectionDialogField.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFirstPackageSelectionDialogField.java
deleted file mode 100644
index f6be3758..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFirstPackageSelectionDialogField.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.TypedElementSelectionValidator;
-import org.eclipse.wst.jsdt.internal.ui.wizards.TypedViewerFilter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-class SourceFirstPackageSelectionDialogField {
-
- private SourceFolderSelectionDialogButtonField fSourceFolderSelection;
- private PackageFragmentSelection fPackageSelection;
- private Shell fShell;
-
- public SourceFirstPackageSelectionDialogField(String sourceLabel, String packageLabel, String browseLabel1,
- String browseLabel2, String statusHint, String dialogTitle, String dialogMessage, String dialogEmptyMessage,
- IJavaScriptUnit cu, IDialogFieldListener updateListener, IPackageFragment fragment) {
- fSourceFolderSelection= new SourceFolderSelectionDialogButtonField(sourceLabel, browseLabel1, new SFStringButtonAdapter());
-
- fPackageSelection= new PackageFragmentSelection(this, packageLabel, browseLabel2, statusHint,
- new PackageSelectionStringButtonAdapter(this, dialogTitle, dialogMessage, dialogEmptyMessage));
- fPackageSelection.setDialogFieldListener(new PackageSelectionDialogFieldListener());
-
- fSourceFolderSelection.setSourceChangeListener(fPackageSelection);
-
- setDefaults(fragment, cu);
-
- fPackageSelection.setUpdateListener(updateListener);
- fSourceFolderSelection.setUpdateListener(updateListener);
- }
-
- private void setDefaults(IPackageFragment fragment, IJavaScriptUnit cu) {
- IJavaScriptElement element= fragment;
- if (element == null) {
- element= cu;
- }
-
- fSourceFolderSelection.setRoot(searchSourcePackageFragmentRoot(element));
- fPackageSelection.setPackageFragment(searchPackageFragment(element));
- }
-
- private IPackageFragment searchPackageFragment(IJavaScriptElement jElement) {
- return (IPackageFragment)jElement.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT);
- }
-
- private IPackageFragmentRoot searchSourcePackageFragmentRoot(IJavaScriptElement jElement) {
- IJavaScriptElement parent= jElement.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (parent == null) {
- return null;
- }
-
- IPackageFragmentRoot res= (IPackageFragmentRoot)parent;
- try {
- if (res.getKind() == IPackageFragmentRoot.K_SOURCE) {
- return res;
- }
- } catch (JavaScriptModelException e) {
- // nothing to do
- }
-
- return null;
- }
-
- class PackageSelectionDialogFieldListener implements IDialogFieldListener {
-
- public void dialogFieldChanged(DialogField field) {
- String packName= fPackageSelection.getText();
- if (packName.length() == 0)
- fPackageSelection.setStatus(NLSUIMessages.NLSAccessorConfigurationDialog_default);
- else
- fPackageSelection.setStatus(""); //$NON-NLS-1$
- }
- }
-
- class SFStringButtonAdapter implements IStringButtonAdapter {
- public void changeControlPressed(DialogField field) {
-
- IPackageFragmentRoot newSourceContainer= chooseSourceContainer(fSourceFolderSelection.getRoot());
- if (newSourceContainer != null) {
- fSourceFolderSelection.setRoot(newSourceContainer);
- }
- }
- }
-
- private IPackageFragmentRoot chooseSourceContainer(IJavaScriptElement initElement) {
- Class[] acceptedClasses= new Class[] { IPackageFragmentRoot.class, IJavaScriptProject.class };
- TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) {
- public boolean isSelectedValid(Object element) {
- try {
- if (element instanceof IJavaScriptProject) {
- IJavaScriptProject jproject= (IJavaScriptProject)element;
- IPath path= jproject.getProject().getFullPath();
- return (jproject.findPackageFragmentRoot(path) != null);
- } else if (element instanceof IPackageFragmentRoot) {
- return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE);
- }
- return true;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e.getStatus()); // just log, no ui in validation
- }
- return false;
- }
- };
-
- acceptedClasses= new Class[] { IJavaScriptModel.class, IPackageFragmentRoot.class, IJavaScriptProject.class };
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses) {
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IPackageFragmentRoot) {
- try {
- return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e.getStatus()); // just log, no ui in validation
- return false;
- }
- }
- return super.select(viewer, parent, element);
- }
- };
-
- StandardJavaScriptElementContentProvider provider= new StandardJavaScriptElementContentProvider();
- ILabelProvider labelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT);
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, labelProvider, provider);
- dialog.setValidator(validator);
- dialog.setComparator(new JavaScriptElementComparator());
- dialog.setTitle(NLSUIMessages.SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_title);
- dialog.setMessage(NLSUIMessages.SourceFirstPackageSelectionDialogField_ChooseSourceContainerDialog_description);
- dialog.addFilter(filter);
- dialog.setInput(JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()));
- dialog.setInitialSelection(initElement);
-
- if (dialog.open() == Window.OK) {
- Object element= dialog.getFirstResult();
- if (element instanceof IJavaScriptProject) {
- IJavaScriptProject jproject= (IJavaScriptProject)element;
- return jproject.getPackageFragmentRoot(jproject.getProject());
- } else if (element instanceof IPackageFragmentRoot) {
- return (IPackageFragmentRoot)element;
- }
- return null;
- }
- return null;
- }
-
-
- public IPackageFragment getSelected() {
- IPackageFragment res= fPackageSelection.getPackageFragment();
- return res;
- }
-
- public IPackageFragmentRoot getSelectedFragmentRoot() {
- return fSourceFolderSelection.getRoot();
- }
-
- public void setSelected(IPackageFragment newSelection) {
- fPackageSelection.setPackageFragment(newSelection);
- fSourceFolderSelection.setRoot(searchSourcePackageFragmentRoot(newSelection));
- }
-
- public void createControl(Composite parent, int nOfColumns, int textWidth) {
- fShell= parent.getShell();
- PixelConverter converter= new PixelConverter(parent);
- fSourceFolderSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
- LayoutUtil.setWidthHint(fSourceFolderSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));
-
- fPackageSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
- LayoutUtil.setWidthHint(fPackageSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFolderSelectionDialogButtonField.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFolderSelectionDialogButtonField.java
deleted file mode 100644
index 7e3b4fd2..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/SourceFolderSelectionDialogButtonField.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.contentassist.JavaSourcePackageFragmentRootCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-
-class SourceFolderSelectionDialogButtonField extends StringButtonDialogField implements IDialogFieldListener {
-
- private IPackageFragmentRoot fRoot;
- private SourceChangeListener fListener;
- private IDialogFieldListener fUpdateListener;
-
- public SourceFolderSelectionDialogButtonField(String descriptionLabel, String browseLabel, IStringButtonAdapter adapter) {
- super(adapter);
- setContentAssistProcessor(new JavaSourcePackageFragmentRootCompletionProcessor());
- setLabelText(descriptionLabel);
- setButtonLabel(browseLabel);
- setDialogFieldListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- // propagate a textchange to the fragment root of this
- setRoot(getRootFromString(getText()));
- }
-
- public void setUpdateListener(IDialogFieldListener updateListener) {
- fUpdateListener= updateListener;
- }
-
- public Control[] doFillIntoGrid(Composite parent, int nColumns, int textWidth) {
- Control[] res= super.doFillIntoGrid(parent, nColumns);
-
- final Text text= getTextControl(null);
- LayoutUtil.setWidthHint(text, textWidth);
- LayoutUtil.setHorizontalGrabbing(text);
-
- return res;
- }
-
- public void setSourceChangeListener(SourceChangeListener listener) {
- fListener= listener;
- }
-
- /**
- * tries to build a packagefragmentroot out of a string and sets the string into this
- * packagefragmentroot.
- *
- * @param rootString
- */
- private IPackageFragmentRoot getRootFromString(String rootString) {
- if (rootString.length() == 0) {
- return null;
- }
- IPath path= new Path(rootString);
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- IResource res= workspaceRoot.findMember(path);
- if (res == null) {
- return null;
- }
- int resType= res.getType();
- if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
- IProject proj= res.getProject();
- if (!proj.isOpen()) {
- return null;
- }
- IJavaScriptProject jproject= JavaScriptCore.create(proj);
- IPackageFragmentRoot root= jproject.getPackageFragmentRoot(res);
- if (root.exists()) {
- return root;
- }
- }
- return null;
- }
-
- public void setRoot(IPackageFragmentRoot root) {
- fRoot= root;
-
- if (fRoot != null) {
- String str= getRootString();
- if (!getText().equals(str)) {
- setText(str);
- }
- } else {
- // dont ripple if the root is not a real root
- }
-
- fListener.sourceRootChanged(fRoot);
- if (fUpdateListener != null) {
- fUpdateListener.dialogFieldChanged(this);
- }
- }
-
- public IPackageFragmentRoot getRoot() {
- return fRoot;
- }
-
- private String getRootString() {
- return (fRoot == null) ? "" : fRoot.getPath().makeRelative().toString(); //$NON-NLS-1$
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/CompilationUnitEntry.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/CompilationUnitEntry.java
deleted file mode 100644
index 554a3e5c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/CompilationUnitEntry.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-
-public class CompilationUnitEntry implements IAdaptable {
-
- private final String fMessage;
- private final IJavaScriptUnit fCompilationUnit;
-
- public CompilationUnitEntry(String message, IJavaScriptUnit compilationUnit) {
- fMessage= message;
- fCompilationUnit= compilationUnit;
- }
-
- public String getMessage() {
- return fMessage;
- }
-
- public IJavaScriptUnit getCompilationUnit() {
- return fCompilationUnit;
- }
-
- public Object getAdapter(Class adapter) {
- if (IJavaScriptUnit.class.equals(adapter))
- return getCompilationUnit();
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/FileEntry.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/FileEntry.java
deleted file mode 100644
index 78efc5e6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/FileEntry.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-
-public class FileEntry implements IAdaptable {
-
- private IFile fPropertiesFile;
- private String fMessage;
-
- public FileEntry(IFile propertiesFile, String message) {
- fPropertiesFile= propertiesFile;
- fMessage= message;
- }
-
- public IFile getPropertiesFile() {
- return fPropertiesFile;
- }
-
- public String getMessage() {
- return fMessage;
- }
-
- public String toString() {
- return fMessage;
- }
-
- public Object getAdapter(Class adapter) {
- if (IResource.class.equals(adapter))
- return fPropertiesFile;
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/LineReader.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/LineReader.java
deleted file mode 100644
index b6e01ab4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/LineReader.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-
-class LineReader extends Object {
- protected static final int LF= '\n';
- protected static final int CR= '\r';
-
- private BufferedReader fReader;
-
- protected int fPushbackChar;
- protected boolean fPushback;
-
- public LineReader(InputStream in, String encoding) throws IOException {
- this(new InputStreamReader(in, encoding));
- }
-
- public LineReader(Reader reader) {
- fPushback= false;
- fReader= new BufferedReader(reader);
- }
-
- public int readLine(StringBuffer sb) throws IOException {
- int ch= -1;
- sb.setLength(0);
- if (fPushback) {
- ch= fPushbackChar;
- fPushback= false;
- } else
- ch= fReader.read();
- while (ch >= 0) {
- if (ch == LF)
- return 1;
- if (ch == CR) {
- ch= fReader.read();
- if (ch == LF)
- return 2;
- else {
- fPushbackChar= ch;
- fPushback= true;
- return 1;
- }
- }
- sb.append((char) ch);
- ch= fReader.read();
- }
- return -1;
- }
-
- public void close() throws IOException {
- fReader.close();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchEditorOpener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchEditorOpener.java
deleted file mode 100644
index 7ee03709..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchEditorOpener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchEditorOpener;
-
-/**
- */
-public class NLSSearchEditorOpener extends JavaSearchEditorOpener {
- protected Object getElementToOpen(Match match) {
- Object element= match.getElement();
- if (element instanceof IJavaScriptElement) {
- return element;
- } else if (element instanceof FileEntry) {
- FileEntry fileEntry= (FileEntry) element;
- return fileEntry.getPropertiesFile();
- } else if (element instanceof CompilationUnitEntry) {
- return ((CompilationUnitEntry)element).getCompilationUnit();
- }
- // this should not happen
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.java
deleted file mode 100644
index 3b797785..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Helper class to get NLSed messages.
- */
-final class NLSSearchMessages extends NLS {
-
- private static final String BUNDLE_NAME= NLSSearchMessages.class.getName();
-
- private NLSSearchMessages() {
- // Do not instantiate
- }
-
- public static String NLSSearchQuery_label;
- public static String NLSSearchQuery_oneProblemInScope_description;
- public static String NLSSearchQuery_propertiesNotExists;
- public static String NLSSearchQuery_wrapperNotExists;
- public static String NLSSearchQuery_xProblemsInScope_description;
-
- public static String NLSSearchResultCollector_duplicateKeys;
- public static String NLSSearchResultCollector_unusedKeys;
- public static String NLSSearchResultLabelProvider2_undefinedKeys;
- public static String NLSSearchResultRequestor_searching;
-
- public static String SearchOperation_pluralLabelPatternPostfix;
- public static String SearchOperation_singularLabelPostfix;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, NLSSearchMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.properties
deleted file mode 100644
index 194c33e7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchMessages.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-SearchOperation_singularLabelPostfix=''{0}'' - 1 problem in ''{1}''
-SearchOperation_pluralLabelPatternPostfix=''{0}'' - {1} problems in ''{2}''
-
-NLSSearchResultCollector_unusedKeys=Unused keys in: {0}
-NLSSearchResultRequestor_searching=Searching for unused properties ...
-NLSSearchResultCollector_duplicateKeys=Duplicate keys in: {0}
-NLSSearchResultLabelProvider2_undefinedKeys=Undefined keys in: {0}
-
-# ### New Search: ###
-NLSSearchQuery_label=Search for Broken NLS Keys
-NLSSearchQuery_wrapperNotExists=Resource bundle accessor class ''{0}'' does not exist.
-NLSSearchQuery_propertiesNotExists=Properties file ''{0}'' does not exist.
-NLSSearchQuery_oneProblemInScope_description=1 problem in {0}
-NLSSearchQuery_xProblemsInScope_description={0} problems in {1}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchQuery.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchQuery.java
deleted file mode 100644
index bf0a9826..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchQuery.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-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;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchParticipant;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.NLSRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.SearchUtils;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIStatus;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-
-public class NLSSearchQuery implements ISearchQuery {
-
- private NLSSearchResult fResult;
- private IJavaScriptElement[] fWrapperClass;
- private IFile[] fPropertiesFile;
- private IJavaScriptSearchScope fScope;
- private String fScopeDescription;
-
- public NLSSearchQuery(IJavaScriptElement[] wrapperClass, IFile[] propertiesFile, IJavaScriptSearchScope scope, String scopeDescription) {
- fWrapperClass= wrapperClass;
- fPropertiesFile= propertiesFile;
- fScope= scope;
- fScopeDescription= scopeDescription;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("", 5 * fWrapperClass.length); //$NON-NLS-1$
-
- try {
- final AbstractTextSearchResult textResult= (AbstractTextSearchResult) getSearchResult();
- textResult.removeAll();
- AppearanceAwareLabelProvider labelProvider= new AppearanceAwareLabelProvider(JavaScriptElementLabels.ALL_POST_QUALIFIED, 0);
-
- for (int i= 0; i < fWrapperClass.length; i++) {
- IJavaScriptElement wrapperClass= fWrapperClass[i];
- IFile propertieFile= fPropertiesFile[i];
- if (! wrapperClass.exists())
- return JavaUIStatus.createError(0, Messages.format(NLSSearchMessages.NLSSearchQuery_wrapperNotExists, wrapperClass.getElementName()), null);
- if (! wrapperClass.exists())
- return JavaUIStatus.createError(0, Messages.format(NLSSearchMessages.NLSSearchQuery_propertiesNotExists, propertieFile.getName()), null);
-
- SearchPattern pattern= SearchPattern.createPattern(wrapperClass, IJavaScriptSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
- SearchParticipant[] participants= new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
-
- NLSSearchResultRequestor requestor= new NLSSearchResultRequestor(propertieFile, fResult);
- try {
- SearchEngine engine= new SearchEngine();
- engine.search(pattern, participants, fScope, requestor, new SubProgressMonitor(monitor, 4));
- requestor.reportUnusedPropertyNames(new SubProgressMonitor(monitor, 1));
-
- IJavaScriptUnit compilationUnit= ((IType)wrapperClass).getJavaScriptUnit();
- CompilationUnitEntry groupElement= new CompilationUnitEntry(Messages.format(NLSSearchMessages.NLSSearchResultCollector_unusedKeys, labelProvider.getText(compilationUnit)), compilationUnit);
-
- boolean hasUnusedPropertie= false;
- IField[] fields= ((IType)wrapperClass).getFields();
- for (int j= 0; j < fields.length; j++) {
- IField field= fields[j];
- if (isNLSField(field)) {
- ISourceRange sourceRange= field.getSourceRange();
- if (sourceRange != null) {
- String fieldName= field.getElementName();
- if (!requestor.hasPropertyKey(fieldName)) {
- fResult.addMatch(new Match(compilationUnit, sourceRange.getOffset(), sourceRange.getLength()));
- }
- if (!requestor.isUsedPropertyKey(fieldName)) {
- hasUnusedPropertie= true;
- fResult.addMatch(new Match(groupElement, sourceRange.getOffset(), sourceRange.getLength()));
- }
- }
- }
- }
- if (hasUnusedPropertie)
- fResult.addCompilationUnitGroup(groupElement);
-
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- }
- }
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- private boolean isNLSField(IField field) throws JavaScriptModelException {
- int flags= field.getFlags();
- if (!Flags.isPublic(flags))
- return false;
-
- if (!Flags.isStatic(flags))
- return false;
-
- String fieldName= field.getElementName();
- if (NLSRefactoring.BUNDLE_NAME.equals(fieldName))
- return false;
-
- if ("RESOURCE_BUNDLE".equals(fieldName)) //$NON-NLS-1$
- return false;
-
- return true;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#getLabel()
- */
- public String getLabel() {
- return NLSSearchMessages.NLSSearchQuery_label;
- }
-
- public String getResultLabel(int nMatches) {
- if (fWrapperClass.length == 1) {
- if (nMatches == 1) {
- String[] args= new String[] {fWrapperClass[0].getElementName(), fScopeDescription};
- return Messages.format(NLSSearchMessages.SearchOperation_singularLabelPostfix, args);
- }
- String[] args= new String[] {fWrapperClass[0].getElementName(), String.valueOf(nMatches), fScopeDescription};
- return Messages.format(NLSSearchMessages.SearchOperation_pluralLabelPatternPostfix, args);
- } else {
- if (nMatches == 1) {
- return Messages.format(NLSSearchMessages.NLSSearchQuery_oneProblemInScope_description, fScopeDescription);
- }
- return Messages.format(NLSSearchMessages.NLSSearchQuery_xProblemsInScope_description, new Object[] {String.valueOf(nMatches), fScopeDescription});
- }
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#canRerun()
- */
- public boolean canRerun() {
- return true;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
- */
- public boolean canRunInBackground() {
- return true;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
- */
- public ISearchResult getSearchResult() {
- if (fResult == null)
- fResult= new NLSSearchResult(this);
- return fResult;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResult.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResult.java
deleted file mode 100644
index 135461d5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResult.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.IEditorMatchAdapter;
-import org.eclipse.search.ui.text.IFileMatchAdapter;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-
-public class NLSSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
-
- private static final Match[] NO_MATCHES= new Match[0];
-
- /*
- * Element (group key) is always IJavaScriptElement or FileEntry.
- */
- private NLSSearchQuery fQuery;
- private final List fFileEntryGroups;
- private final List fCompilationUnitGroups;
-
- public NLSSearchResult(NLSSearchQuery query) {
- fQuery= query;
- fFileEntryGroups= new ArrayList();
- fCompilationUnitGroups= new ArrayList();
- }
-
- public void addFileEntryGroup(FileEntry group) {
- fFileEntryGroups.add(group);
- }
-
- public void addCompilationUnitGroup(CompilationUnitEntry group) {
- fCompilationUnitGroups.add(group);
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.ui.IEditorPart)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
- //TODO: copied from JavaSearchResult:
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
- return computeContainedMatches(result, fileEditorInput.getFile());
- } else if (editorInput instanceof IClassFileEditorInput) {
- IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
- Set matches= new HashSet();
- collectMatches(matches, classFileEditorInput.getClassFile());
- return (Match[]) matches.toArray(new Match[matches.size()]);
- }
- return NO_MATCHES;
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.core.resources.IFile)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
- Set matches= new HashSet();
- for (Iterator iter= fFileEntryGroups.iterator(); iter.hasNext();) {
- FileEntry element= (FileEntry)iter.next();
- if (element.getPropertiesFile().equals(file)) {
- matches.addAll(Arrays.asList(getMatches(element)));
- }
- }
- if (matches.size() > 0)
- return (Match[]) matches.toArray(new Match[matches.size()]);
-
- try {
- for (Iterator iter= fCompilationUnitGroups.iterator(); iter.hasNext();) {
- CompilationUnitEntry element= (CompilationUnitEntry)iter.next();
- IJavaScriptUnit cu= element.getCompilationUnit();
- if (cu.exists() && file.equals(cu.getCorrespondingResource())) {
- matches.addAll(Arrays.asList(getMatches(element)));
- }
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return NO_MATCHES;
- }
-
- //TODO: copied from JavaSearchResult:
- IJavaScriptElement javaElement= JavaScriptCore.create(file);
- collectMatches(matches, javaElement);
- return (Match[]) matches.toArray(new Match[matches.size()]);
- }
-
- private void collectMatches(Set matches, IJavaScriptElement element) {
- //TODO: copied from JavaSearchResult:
- Match[] m= getMatches(element);
- if (m.length != 0) {
- for (int i= 0; i < m.length; i++) {
- matches.add(m[i]);
- }
- }
- if (element instanceof IParent) {
- IParent parent= (IParent) element;
- try {
- IJavaScriptElement[] children= parent.getChildren();
- for (int i= 0; i < children.length; i++) {
- collectMatches(matches, children[i]);
- }
- } catch (JavaScriptModelException e) {
- // we will not be tracking these results
- }
- }
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- if (element instanceof FileEntry) {
- return ((FileEntry) element).getPropertiesFile();
- } else {
- IJavaScriptElement javaElement= null;
- if (element instanceof CompilationUnitEntry) {
- javaElement= ((CompilationUnitEntry)element).getCompilationUnit();
- } else {
- javaElement= (IJavaScriptElement) element;
- }
- IResource resource= null;
- try {
- resource= javaElement.getCorrespondingResource();
- } catch (JavaScriptModelException e) {
- // no resource
- }
- if (resource instanceof IFile)
- return (IFile) resource;
- else
- return null;
- }
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#isShownInEditor(org.eclipse.search.ui.text.Match, org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (match.getElement() instanceof FileEntry) {
- IFile file= ((FileEntry) match.getElement()).getPropertiesFile();
- if (editorInput instanceof IFileEditorInput) {
- return ((IFileEditorInput) editorInput).getFile().equals(file);
- }
- } else if (match.getElement() instanceof IJavaScriptElement || match.getElement() instanceof CompilationUnitEntry) {
- IJavaScriptElement je= null;
- if (match.getElement() instanceof IJavaScriptElement) {
- je= (IJavaScriptElement) match.getElement();
- } else {
- je= ((CompilationUnitEntry)match.getElement()).getCompilationUnit();
- }
- if (editorInput instanceof IFileEditorInput) {
- try {
- IJavaScriptUnit cu= (IJavaScriptUnit) je.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu == null)
- return false;
- else
- return ((IFileEditorInput) editorInput).getFile().equals(cu.getCorrespondingResource());
- } catch (JavaScriptModelException e) {
- return false;
- }
- } else if (editorInput instanceof IClassFileEditorInput) {
- return ((IClassFileEditorInput) editorInput).getClassFile().equals(je.getAncestor(IJavaScriptElement.CLASS_FILE));
- }
- }
- return false;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getLabel()
- */
- public String getLabel() {
- return fQuery.getResultLabel(getMatchCount());
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getTooltip()
- */
- public String getTooltip() {
- return getLabel();
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return JavaPluginImages.DESC_OBJS_SEARCH_REF;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getQuery()
- */
- public ISearchQuery getQuery() {
- return fQuery;
- }
-
- public IFileMatchAdapter getFileMatchAdapter() {
- return this;
- }
-
- public IEditorMatchAdapter getEditorMatchAdapter() {
- return this;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultLabelProvider2.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultLabelProvider2.java
deleted file mode 100644
index 992b2ea1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultLabelProvider2.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.search.TextSearchLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-
-class NLSSearchResultLabelProvider2 extends TextSearchLabelProvider {
-
- private AppearanceAwareLabelProvider fLabelProvider;
-
- public NLSSearchResultLabelProvider2(AbstractTextSearchViewPage page) {
- super(page);
- fLabelProvider= new AppearanceAwareLabelProvider(JavaScriptElementLabels.ALL_POST_QUALIFIED, 0);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.search.TextSearchLabelProvider#doGetText(java.lang.Object)
- */
- protected String doGetText(Object element) {
- if (element instanceof FileEntry) {
- FileEntry fileEntry= (FileEntry) element;
- return fileEntry.getMessage();
- } else if (element instanceof CompilationUnitEntry) {
- return ((CompilationUnitEntry)element).getMessage();
- } else {
- return Messages.format(NLSSearchMessages.NLSSearchResultLabelProvider2_undefinedKeys, fLabelProvider.getText(element));
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (element instanceof FileEntry)
- element= ((FileEntry) element).getPropertiesFile();
- if (element instanceof CompilationUnitEntry)
- element= ((CompilationUnitEntry)element).getCompilationUnit();
-
- return fLabelProvider.getImage(element);
- }
-
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#dispose()
- */
- public void dispose() {
- fLabelProvider.dispose();
- fLabelProvider= null;
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultPage.java
deleted file mode 100644
index 4f8edaf0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultPage.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.search.JavaSearchResultPage;
-import org.eclipse.wst.jsdt.internal.ui.search.TextSearchTableContentProvider;
-
-
-public class NLSSearchResultPage extends AbstractTextSearchViewPage implements IAdaptable {
-
- private TextSearchTableContentProvider fContentProvider;
- private NLSSearchEditorOpener fEditorOpener= new NLSSearchEditorOpener();
-
- public NLSSearchResultPage() {
- super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#showMatch(org.eclipse.search.ui.text.Match,
- * int, int)
- */
- protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
- try {
- IEditorPart editor= fEditorOpener.openMatch(match);
- if (editor != null && activate)
- editor.getEditorSite().getPage().activate(editor);
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor= (ITextEditor) editor;
- textEditor.selectAndReveal(currentOffset, currentLength);
- }
- } catch (JavaScriptModelException e1) {
- throw new PartInitException(e1.getStatus());
- }
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#elementsChanged(java.lang.Object[])
- */
- protected void elementsChanged(Object[] objects) {
- if (fContentProvider != null)
- fContentProvider.elementsChanged(objects);
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#clear()
- */
- protected void clear() {
- if (fContentProvider != null)
- fContentProvider.clear();
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTreeViewer(org.eclipse.jface.viewers.TreeViewer)
- */
- protected void configureTreeViewer(TreeViewer viewer) {
- throw new IllegalStateException("Doesn't support tree mode."); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
- */
- protected void configureTableViewer(TableViewer viewer) {
- viewer.setComparator(new ViewerComparator() {
- public int category(Object element) {
- if (element instanceof FileEntry) {
- return 0;
- } else {
- return 1;
- }
- }
- });
- viewer.setLabelProvider(new NLSSearchResultLabelProvider2(this));
- fContentProvider= new TextSearchTableContentProvider();
- viewer.setContentProvider(fContentProvider);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (IShowInTargetList.class.equals(adapter)) {
- return JavaSearchResultPage.SHOW_IN_TARGET_LIST;
- }
- return null;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultRequestor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultRequestor.java
deleted file mode 100644
index b528627d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/NLSSearchResultRequestor.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.Position;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.search.SearchMatch;
-import org.eclipse.wst.jsdt.core.search.SearchRequestor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.nls.PropertyFileDocumentModel;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.StringMatcher;
-
-class NLSSearchResultRequestor extends SearchRequestor {
- /*
- * Matches are added to fResult. Element (group key) is IJavaScriptElement or FileEntry.
- */
-
- private static final StringMatcher fgGetClassNameMatcher= new StringMatcher("*.class.getName()*", false, false); //$NON-NLS-1$
-
- private NLSSearchResult fResult;
- private IFile fPropertiesFile;
- private Properties fProperties;
- private HashSet fUsedPropertyNames;
-
- public NLSSearchResultRequestor(IFile propertiesFile, NLSSearchResult result) {
- fPropertiesFile= propertiesFile;
- fResult= result;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#beginReporting()
- */
- public void beginReporting() {
- loadProperties();
- fUsedPropertyNames= new HashSet(fProperties.size());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
- */
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- if (match.getAccuracy() == SearchMatch.A_INACCURATE)
- return;
-
- int offset= match.getOffset();
- int length= match.getLength();
- if (offset == -1 || length == -1)
- return;
-
- if (! (match.getElement() instanceof IJavaScriptElement))
- return;
- IJavaScriptElement javaElement= (IJavaScriptElement) match.getElement();
-
- // ignore matches in import declarations:
- if (javaElement.getElementType() == IJavaScriptElement.IMPORT_DECLARATION)
- return;
- if (javaElement.getElementType() == IJavaScriptElement.CLASS_FILE)
- return; //matches in import statements of class files
- if (javaElement.getElementType() == IJavaScriptElement.TYPE)
- return; //classes extending the accessor class and workaround for bug 61286
-
- // heuristic: ignore matches in resource bundle name field:
- if (javaElement.getElementType() == IJavaScriptElement.FIELD) {
- IField field= (IField) javaElement;
- String source= field.getSource();
- if (source != null && fgGetClassNameMatcher.match(source))
- return;
- }
-
- if (javaElement instanceof ISourceReference) {
- String source= ((ISourceReference) javaElement).getSource();
- if (source != null) {
- if (source.indexOf("NLS.initializeMessages") != -1) //$NON-NLS-1$
- return;
- }
- }
-
- // found reference to NLS Wrapper - now check if the key is there:
- Position mutableKeyPosition= new Position(offset, length);
- //TODO: What to do if argument string not found? Currently adds a match with type name.
- String key= findKey(mutableKeyPosition, javaElement);
- if (key != null && isKeyDefined(key))
- return;
-
- IJavaScriptUnit[] allCompilationUnits= JavaModelUtil.getAllCompilationUnits(new IJavaScriptElement[] {javaElement});
- Object element= javaElement;
- if (allCompilationUnits != null && allCompilationUnits.length == 1)
- element= allCompilationUnits[0];
-
- fResult.addMatch(new Match(element, mutableKeyPosition.getOffset(), mutableKeyPosition.getLength()));
- }
-
- public void reportUnusedPropertyNames(IProgressMonitor pm) {
- //Don't use endReporting() for long running operation.
- pm.beginTask("", fProperties.size()); //$NON-NLS-1$
- boolean hasUnused= false;
- pm.setTaskName(NLSSearchMessages.NLSSearchResultRequestor_searching);
- String message= Messages.format(NLSSearchMessages.NLSSearchResultCollector_unusedKeys, getPropertiesName(fPropertiesFile));
- FileEntry groupElement= new FileEntry(fPropertiesFile, message);
-
- for (Enumeration enumeration= fProperties.propertyNames(); enumeration.hasMoreElements();) {
- String propertyName= (String) enumeration.nextElement();
- if (!fUsedPropertyNames.contains(propertyName)) {
- addMatch(groupElement, propertyName);
- hasUnused= true;
- }
- pm.worked(1);
- }
- if (hasUnused)
- fResult.addFileEntryGroup(groupElement);
- pm.done();
- }
-
- private String getPropertiesName(IFile propertiesFile) {
- String path= propertiesFile.getFullPath().removeLastSegments(1).toOSString();
- return propertiesFile.getName() + " - " + path; //$NON-NLS-1$
- }
-
- private void addMatch(FileEntry groupElement, String propertyName) {
- /*
- * TODO (bug 63794): Should read in .properties file with our own reader and not
- * with Properties.load(InputStream) . Then, we can remember start position and
- * original version (not interpreting escape characters) for each property.
- *
- * The current workaround is to escape the key again before searching in the
- * .properties file. However, this can fail if the key is escaped in a different
- * manner than what PropertyFileDocumentModel.unwindEscapeChars(.) produces.
- */
- String escapedPropertyName= PropertyFileDocumentModel.unwindEscapeChars(propertyName);
- int start= findPropertyNameStartPosition(escapedPropertyName);
- int length;
- if (start == -1) { // not found -> report at beginning
- start= 0;
- length= 0;
- } else {
- length= escapedPropertyName.length();
- }
- fResult.addMatch(new Match(groupElement, start, length));
- }
-
- /**
- * Checks if the key is defined in the property file
- * and adds it to the list of used properties.
- *
- * @param key the key
- * @return <code>true</code> if the key is defined
- */
- private boolean isKeyDefined(String key) {
- if (key == null)
- return true; // Parse error - don't check key
-
- fUsedPropertyNames.add(key);
- if (fProperties.getProperty(key) != null) {
- return true;
- }
- return false;
- }
-
- public boolean hasPropertyKey(String key) {
- return fProperties.containsKey(key);
- }
-
- public boolean isUsedPropertyKey(String key) {
- return fUsedPropertyNames.contains(key);
- }
-
- /**
- * Finds the key defined by the given match. The assumption is that
- * the key is the first argument and it is a string i.e. quoted ("...").
- *
- * @param keyPositionResult reference parameter: will be filled with the position of the found key
- * @param enclosingElement enclosing java element
- * @return a string denoting the key, null if no key can be found
- * @throws CoreException if a problem occurs while accessing the <code>enclosingElement</code>
- */
- private String findKey(Position keyPositionResult, IJavaScriptElement enclosingElement) throws CoreException {
- IJavaScriptUnit unit= (IJavaScriptUnit)enclosingElement.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (unit == null)
- return null;
-
- String source= unit.getSource();
- if (source == null)
- return null;
-
- IScanner scanner= ToolFactory.createScanner(false, false, false, false);
- scanner.setSource(source.toCharArray());
- scanner.resetTo(keyPositionResult.getOffset() + keyPositionResult.getLength(), source.length());
-
- try {
- if (scanner.getNextToken() != ITerminalSymbols.TokenNameDOT)
- return null;
-
- if (scanner.getNextToken() != ITerminalSymbols.TokenNameIdentifier)
- return null;
-
- String src= new String(scanner.getCurrentTokenSource());
- int keyStart= scanner.getCurrentTokenStartPosition();
- int keyEnd= scanner.getCurrentTokenEndPosition();
-
- if (scanner.getNextToken() == ITerminalSymbols.TokenNameLPAREN) {
- // Old school
- // next must be key string:
- if (scanner.getNextToken() != ITerminalSymbols.TokenNameStringLiteral)
- return null;
- // found it:
- keyStart= scanner.getCurrentTokenStartPosition() + 1;
- keyEnd= scanner.getCurrentTokenEndPosition();
- keyPositionResult.setOffset(keyStart);
- keyPositionResult.setLength(keyEnd - keyStart);
- return source.substring(keyStart, keyEnd);
- } else {
- keyPositionResult.setOffset(keyStart);
- keyPositionResult.setLength(keyEnd - keyStart + 1);
- return src;
- }
- } catch (InvalidInputException e) {
- return null;
- }
- }
-
- /**
- * Finds the start position in the property file. We assume that
- * the key is the first match on a line.
- *
- * @param propertyName the property name
- * @return the start position of the property name in the file, -1 if not found
- */
- private int findPropertyNameStartPosition(String propertyName) {
- // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=19319
- InputStream stream= null;
- LineReader lineReader= null;
- String encoding;
- try {
- encoding= fPropertiesFile.getCharset();
- } catch (CoreException e1) {
- encoding= "ISO-8859-1"; //$NON-NLS-1$
- }
- try {
- stream= createInputStream(fPropertiesFile);
- lineReader= new LineReader(stream, encoding);
- } catch (CoreException cex) {
- // failed to get input stream
- JavaScriptPlugin.log(cex);
- return -1;
- } catch (IOException e) {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException ce) {
- JavaScriptPlugin.log(ce);
- }
- }
- return -1;
- }
- int start= 0;
- try {
- StringBuffer buf= new StringBuffer(80);
- int eols= lineReader.readLine(buf);
- int keyLength= propertyName.length();
- while (eols > 0) {
- String line= buf.toString();
- int i= line.indexOf(propertyName);
- int charPos= i + keyLength;
- char terminatorChar= 0;
- boolean hasNoValue= (charPos >= line.length());
- if (i > -1 && !hasNoValue)
- terminatorChar= line.charAt(charPos);
- if (line.trim().startsWith(propertyName) &&
- (hasNoValue || Character.isWhitespace(terminatorChar) || terminatorChar == '=')) {
- start += line.indexOf(propertyName);
- eols= -17; // found key
- } else {
- start += line.length() + eols;
- buf.setLength(0);
- eols= lineReader.readLine(buf);
- }
- }
- if (eols != -17)
- start= -1; //key not found in file. See bug 63794. This can happen if the key contains escaped characters.
- } catch (IOException ex) {
- JavaScriptPlugin.log(ex);
- return -1;
- } finally {
- try {
- lineReader.close();
- } catch (IOException ex) {
- JavaScriptPlugin.log(ex);
- }
- }
- return start;
- }
-
- private void loadProperties() {
- Set duplicateKeys= new HashSet();
- fProperties= new Properties(duplicateKeys);
- InputStream stream;
- try {
- stream= new BufferedInputStream(createInputStream(fPropertiesFile));
- } catch (CoreException ex) {
- fProperties= new Properties();
- return;
- }
- try {
- fProperties.load(stream);
- } catch (IOException ex) {
- fProperties= new Properties();
- return;
- } finally {
- try {
- stream.close();
- } catch (IOException ex) {
- }
- reportDuplicateKeys(duplicateKeys);
- }
- }
-
- private InputStream createInputStream(IFile propertiesFile) throws CoreException {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- if (manager != null) {
- ITextFileBuffer buffer= manager.getTextFileBuffer(propertiesFile.getFullPath(), LocationKind.IFILE);
- if (buffer != null) {
- return new ByteArrayInputStream(buffer.getDocument().get().getBytes());
- }
- }
-
- return propertiesFile.getContents();
- }
-
- private void reportDuplicateKeys(Set duplicateKeys) {
- if (duplicateKeys.size() == 0)
- return;
-
- String message= Messages.format(NLSSearchMessages.NLSSearchResultCollector_duplicateKeys, getPropertiesName(fPropertiesFile));
- FileEntry groupElement= new FileEntry(fPropertiesFile, message);
- Iterator iter= duplicateKeys.iterator();
- while (iter.hasNext()) {
- String propertyName= (String) iter.next();
- addMatch(groupElement, propertyName);
- }
- fResult.addFileEntryGroup(groupElement);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/Properties.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/Properties.java
deleted file mode 100644
index b3c34344..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/Properties.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-
-
-
-class Properties extends java.util.Properties {
-
- private static final long serialVersionUID= 1L;
-
- private Set fDuplicateKeys;
-
- public Properties() {
- }
-
- public Properties(Set duplicateKeys) {
- super();
- Assert.isNotNull(duplicateKeys);
- fDuplicateKeys= duplicateKeys;
- }
-
- public Properties (Properties properties, Set duplicateKeys) {
- super(properties);
- Assert.isNotNull(duplicateKeys);
- fDuplicateKeys= duplicateKeys;
- }
- /*
- * @see java.util.Map#put(Object, Object)
- */
- public Object put(Object arg0, Object arg1) {
- if (arg0 != null && containsKey(arg0))
- fDuplicateKeys.add(arg0);
- return super.put(arg0, arg1);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java
deleted file mode 100644
index a0c43316..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.nls.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-
-
-public class SearchBrokenNLSKeysUtil {
-
- public static void search(String scopeName, IType[] accessorClasses, IFile[] propertieFiles) {
- NLSSearchQuery query= new NLSSearchQuery(accessorClasses, propertieFiles, SearchEngine.createWorkspaceScope(), scopeName);
- NewSearchUI.runQueryInBackground(query);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/refactoringui.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/refactoringui.properties
deleted file mode 100644
index db78ca79..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/refactoringui.properties
+++ /dev/null
@@ -1,618 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-#######################################
-# org.eclipse.wst.jsdt.internal.ui.refactoring
-#######################################
-
-RefactorActionGroup_no_refactoring_available= <no refactoring available>
-
-RenameInputWizardPage_new_name= New na&me:
-
-RenameRefactoringWizard_internal_error= An unexpected exception occurred. See the error log for more details.
-
-#######################################
-# org.eclipse.wst.jsdt.internal.ui.actions
-#######################################
-
-OpenRefactoringWizardAction_refactoring=Refactoring
-OpenRefactoringWizardAction_exception=An unexpected exception occurred. See the error log for more details.
-
-ExtractMethodAction_label=E&xtract Function...
-ExtractMethodAction_dialog_title=Extract Function
-
-SurroundWithTryCatchAction_label=Surround with tr&y/catch Block
-SurroundWithTryCatchAction_dialog_title=Surround with try/catch
-SurroundWithTryCatchAction_exception=An unexpected exception occurred. See the error log for more details.
-SurroundWithTryCatchAction_no_exceptions=No uncaught exceptions are thrown by the selected code. Catch java.lang.RuntimeException ?
-
-RefactoringGroup_modify_Parameters_label=&Change Function Signature...
-RefactoringGroup_pull_Up_label=Pull &Up...
-RefactoringGroup_move_label=&Move...
-
-
-RefactoringStarter_unexpected_exception=An unexpected exception occurred. See the error log for more details.
-RefactoringStarter_saving=Saving Resources
-RefactoringStarter_always_save=&Always save all modified resources automatically prior to refactoring
-RefactoringStarter_save_all_resources=Save Modified Resources
-RefactoringStarter_must_save=Some modified resources must be saved before this operation.
-
-RefactoringExecutionHelper_cannot_execute=The operation cannot be performed due to the following problem:\n\n{0}
-
-#######################################
-# org.eclipse.wst.jsdt.internal.ui.code
-#######################################
-
-ExtractMethodWizard_extract_method=Extract Function
-
-ExtractMethodInputPage_access_Modifiers=&Access modifier:
-ExtractMethodInputPage_public=public
-ExtractMethodInputPage_default=default
-ExtractMethodInputPage_protected=protected
-ExtractMethodInputPage_private=private
-ExtractMethodInputPage_signature_preview=Function signature preview:
-ExtractMethodInputPage_description=Enter new function name and specify the function's visibility
-ExtractMethodInputPage_label_text=Function &name:
-ExtractMethodInputPage_parameters=&Parameters:
-ExtractMethodInputPage_throwRuntimeExceptions=Declare thrown runtime e&xceptions
-ExtractMethodInputPage_validation_emptyMethodName=Provide a function name
-ExtractMethodInputPage_validation_emptyParameterName=Parameter names cannot be empty
-ExtractMethodInputPage_duplicates_none=&Replace all occurrences of statements with function
-ExtractMethodInputPage_duplicates_single=&Replace 1 occurrence of statements with function
-ExtractMethodInputPage_duplicates_multi=&Replace {0} occurrences of statements with function
-ExtractMethodInputPage_destination_type=Destination &type:
-ExtractMethodInputPage_anonymous_type_label=new {0}() '{'...}
-ExtractMethodInputPage_generateJavadocComment=Generate function &comment
-
-InlineMethodWizard_page_title=Inline Function
-
-#######################################
-# org.eclipse.wst.jsdt.internal.ui.sef
-#######################################
-
-SelfEncapsulateField_sef=Encapsulate Var
-SelfEncapsulateField_field_access=Var access in declaring type:
-SelfEncapsulateField_use_setter_getter=us&e setter and getter
-SelfEncapsulateField_keep_references=&keep var reference
-
-SelfEncapsulateFieldInputPage_description=Create getting and setting functions for the var and use only those to access the var
-SelfEncapsulateFieldInputPage_getter_name=&Getter name:
-SelfEncapsulateFieldInputPage_setter_name=&Setter name:
-SelfEncapsulateFieldInputPage_insert_after=&Insert new functions after:
-SelfEncapsulateFieldInputPage_first_method=As first function
-SelfEncapsulateFieldInputPage_access_Modifiers=Access modifier:
-SelfEncapsulateFieldInputPage_public=&public
-SelfEncapsulateFieldInputPage_default=defa&ult
-SelfEncapsulateFieldInputPage_protected=pro&tected
-SelfEncapsulateFieldInputPage_private=pri&vate
-SelfEncapsulateFieldInputPage_generateJavadocComment=Generate function &comments
-SelfEncapsulateFieldInputPage_useexistingsetter_label=(using existing setter)
-SelfEncapsulateFieldInputPage_useexistinggetter_label=(using existing getter)
-SelfEncapsulateFieldInputPage_usenewgetter_label=(new setter created)
-SelfEncapsulateFieldInputPage_usenewsetter_label=(new getter created)
-
-#######################################
-# Misc
-#######################################
-
-ExtractTempWizard_defaultPageTitle=Extract Local Variable
-ExtractTempInputPage_enter_name=Enter a name for the new local variable
-ExtractTempInputPage_variable_name=&Variable name:
-ExtractTempInputPage_replace_all=&Replace all occurrences of the selected expression with references to the local variable
-ExtractTempInputPage_declare_final=&Declare the local variable as \'final\'
-ExtractTempInputPage_signature_preview=Signature Preview:
-ExtractTempInputPage_extract_local=Extract local variable
-ExtractTempInputPage_exception=An unexpected exception occurred. See the error log for more details
-
-ExtractConstantInputPage_enter_name=Enter a name for the new constant
-ExtractConstantInputPage_constant_name=&Constant name:
-ExtractConstantInputPage_replace_all=&Replace all occurrences of the selected expression with references to the constant
-ExtractConstantInputPage_qualify_constant_references_with_class_name=&Qualify constant references with type name
-ExtractConstantInputPage_signature_preview=Signature Preview:
-ExtractConstantInputPage_exception=An unexpected exception occurred. See the error log for more details
-ExtractConstantInputPage_access_modifiers=Access modifier:
-ExtractConstantInputPage_selection_refers_to_nonfinal_fields=The selected expression refers to non-final or non-static vars
-
-PromoteTempInputPage_description=Select visibility and name for the new var
-
-MoveMembersWizard_page_title=Move Static Members
-
-RenameInputWizardPage_update_references=Update &references
-RenameInputWizardPage_update_textual_matches=Update &textual occurrences in comments and strings (forces preview)
-RenameInputWizardPage_update_qualified_names=Update fully &qualified names in non-JavaScript text files (forces preview)
-
-PullUpInputPage_select_methods=Select the functions to be removed in subclasses.
-PullUpInputPage_pull_Up=Pull Up
-PullUpInputPage_pull_up1=Pull Up Functions
-PullUpInputPage_exception=An unexpected exception occurred. See the error log for more details
-
-ExtractTempAction_label=Extract &Local Variable...
-ExtractTempAction_extract_temp=Extract Local Variable
-
-ConvertLocalToField_label=Con&vert Local Variable to Var...
-ConvertLocalToField_title=Convert Local Variable to Var
-
-ExtractConstantAction_label=Extr&act Constant...
-ExtractSuperTypeAction_label=Ex&tract Superclass...
-ExtractConstantAction_extract_constant=Extract Constant
-
-InlineTempAction_inline_temp=Inline Local Variable
-InlineTempAction_label=&Inline Local Variable...
-
-RenameAction_rename=Rename
-RenameAction_unavailable=Operation unavailable on the current selection.\n\nSelect a javaScript project, source folder, resource, or a JavaScript file, or a non-readonly type, var, function, parameter, local variable, or type variable.
-RenameAction_text=Re&name...
-
-NewTextRefactoringAction_exception=An unexpected exception occurred. See the error log for more details
-
-RenameEnumConstWizard_defaultPageTitle=Rename Enum Constant
-RenameEnumConstWizard_inputPage_description=Enter the new name for this constant.
-
-RenameFieldWizard_defaultPageTitle=Rename Var
-RenameFieldWizard_inputPage_description=Enter the new name for this var.
-RenameFieldInputWizardPage_rename_getter=Rename &getter function
-RenameFieldInputWizardPage_rename_getter_to=Rename &getter: ''{0}'' to ''{1}''
-RenameFieldInputWizardPage_rename_setter=Rename &setter function
-RenameFieldInputWizardPage_rename_setter_to=Rename &setter: ''{0}'' to ''{1}''
-RenameFieldInputWizardPage_setter_label={0} ({1})
-RenameFieldInputWizardPage_getter_label={0} ({1})
-
-MoveMembersInputPage_descriptionKey={0} member(s) from ''{1}''
-MoveMembersInputPage_destination_single=Destination &type for ''{0}'':
-MoveMembersInputPage_destination_multi=Destination &type for {0} selected elements:
-MoveMembersInputPage_browse=&Browse...
-MoveMembersInputPage_move_Member=Move Member
-MoveMembersInputPage_exception=An unexpected exception occurred. See the error log for more details
-MoveMembersInputPage_choose_Type=Choose Type
-MoveMembersInputPage_dialogMessage=&Choose a type (? = any character, * = any string):
-MoveMembersInputPage_upperListLabel=&Matching types:
-MoveMembersInputPage_lowerListLabel=&Qualifier:
-MoveMembersInputPage_not_found=Destination type does not exist (fully qualified type name expected)
-MoveMembersInputPage_invalid_name=Invalid Type Name
-MoveMembersInputPage_Invalid_selection=Invalid selection
-MoveMembersInputPage_no_binary=Cannot move members to binary types
-MoveMembersInputPage_internal_error=An unexpected exception occurred. See the error log for more details.
-MoveMembersInputPage_move=Move Members
-
-RenameJavaElementAction_exception=An unexpected exception occurred. See the error log for more details
-RenameJavaElementAction_not_available=Operation unavailable on the current selection.\nSelect a javaScript project, source folder, resource, package, JavaScript file, type, var, function, parameter or a local variable
-RenameJavaElementAction_name=Rename
-
-MoveAction_text=&Move...
-
-QualifiedNameComponent_patterns_label=File name &patterns:
-QualifiedNameComponent_patterns_description= The patterns are separated by commas (* = any string, ? = any character)
-
-DelegateCreator_deprecate_delegates=Mark as &deprecated
-
-PullUpInputPage_hierarchyLabal={0} function(s) selected
-PullUpInputPage_see_log=An unexpected exception occurred. See the error log for more details
-
-##Change Signature
-ChangeSignatureInputPage_change=Change the signature of the selected function and all its overriding functions.
-ChangeSignatureInputPage_access_modifier=A&ccess modifier:
-ChangeSignatureInputPage_default=default
-ChangeSignatureInputPage_return_type=Return &type:
-ChangeSignatureInputPage_method_name=Function &name:
-ChangeSignatureInputPage_parameters=Pa&rameters
-ChangeSignatureInputPage_exceptions=E&xceptions
-ChangeSignatureInputPage_method_Signature_Preview=Function signature preview:
-ChangeSignatureInputPage_exception=An unexpected exception occurred. See the error log for more details
-ChangeSignatureInputPage_unchanged=Function signature is unchanged.
-ChangeSignatureInputPage_Internal_Error=An unexpected exception occurred. See the error log for more details.
-ChangeSignatureInputPage_Change_Signature=Change Signature
-ChangeSignatureRefactoring_modify_Parameters=Change Function Signature
-
-RenameTempAction_exception=An unexpected exception occurred. See the error log for more details
-ModifyParametersAction_unavailable=To activate this refactoring, please select the name of a function. Binary functions and annotation elements are not supported.
-OpenRefactoringWizardAction_unavailable=Operation Unavailable
-PullUpAction_unavailable=To activate this refactoring, select a top-level type or the name of a non-binary instance function or var.
-MoveMembersAction_unavailable=To activate this refactoring, please select the name of a non-binary static function or var.
-PullUpInputPage_subtypes=&Subtypes of type ''{0}''
-
-MoveMembersAction_error_title=Refactoring
-MoveMembersAction_error_message=Cannot perform operation.
-RefactoringErrorDialogUtil_okToPerformQuestion=\n\nOK to perform the operation on this function?
-
-ChangeParametersControl_table_type=Type
-ChangeParametersControl_table_name=Name
-ChangeParametersControl_new=new
-ChangeParametersControl_default=default
-ChangeParametersControl_type=type
-ChangeParametersControl_table_defaultValue=Default value
-ChangeParametersControl_new_parameter_default_name=newParam
-ChangeParametersControl_buttons_move_up=&Up
-ChangeParametersControl_buttons_move_down=D&own
-ChangeParametersControl_buttons_edit=&Edit...
-ChangeParametersControl_buttons_add=&Add
-ChangeParametersControl_buttons_remove=Re&move
-
-ChangeExceptionsControl_buttons_add=&Add...
-ChangeExceptionsControl_buttons_remove=Re&move
-ChangeExceptionsControl_choose_title=Add Exception
-ChangeExceptionsControl_choose_message=&Choose an Exception (? = any character, * = any string):
-ChangeExceptionsControl_not_exception=Not an Exception
-
-ChangeExceptionHandler_undo_button=Undo
-ChangeExceptionHandler_abort_button=Abort
-ChangeExceptionHandler_message=\n Click 'Undo' to undo all successfully executed changes of the current refactoring.\n Click 'Abort' to abort the current refactoring.
-ChangeExceptionHandler_dialog_title=Refactoring
-ChangeExceptionHandler_status_without_detail=Exception does not provide a detail message
-ChangeExceptionHandler_undo_dialog_title=Undo Refactoring
-ChangeExceptionHandler_undo_dialog_message=An unexpected exception occurred while undoing the refactoring
-ChangeExceptionHandler_dialog_message=An exception has been caught while processing the refactoring ''{0}''.
-
-ParameterEditDialog_title=Function Parameter
-ParameterEditDialog_message_new=Declaration of Parameter:
-ParameterEditDialog_message=Declaration of Parameter ''{0}'':
-
-ParameterEditDialog_type=&Type:
-ParameterEditDialog_type_error=Type name must not be empty.
-ParameterEditDialog_name=&Name:
-ParameterEditDialog_name_error= Parameter name must not be empty.
-ParameterEditDialog_defaultValue=&Default value:
-ParameterEditDialog_defaultValue_error= Default value must not be empty.
-ParameterEditDialog_defaultValue_invalid=''{0}'' is not a valid expression.
-
-InlineTempWizard_defaultPageTitle= Inline Local Variable
-InlineTempInputPage_message_one= Inline 1 occurrence of local variable ''{0}'' ?
-InlineTempInputPage_message_multi= Inline {0} occurrences of local variable ''{1}'' ?
-InlineTempInputPage_message_zero=Inline 0 occurrences of local variable ''{0}'' ?\n\nSince no references have been found, the variable declaration will simply be removed.
-
-ConvertAnonymousToNestedInputPage_description=Select the name and modifiers for the new nested type
-ConvertAnonymousToNestedInputPage_class_name=Type &name:
-ConvertAnonymousToNestedInputPage_declare_final=Declare the nested type as \'&final\'
-ConvertAnonymousToNestedInputPage_declare_static=Declare the nested type as \'&static\'
-
-ExtractConstantWizard_defaultPageTitle=Extract Constant
-ExtractConstantInputPage_Internal_Error=An unexpected exception occurred. See the error log for more details.
-
-ExtractSupertypeWizard_defaultPageTitle=Extract Superclass
-ExtractSupertypeMemberPage_page_title=Select the members to extract to the new type.
-ExtractSupertypeMemberPage_name_label=&Superclass name:
-ExtractSupertypeMemberPage_create_stubs_label=&Create necessary functions stubs in non-abstract subtypes of the extracted type
-ExtractSupertypeMemberPage_types_list_caption=&Types to extract a superclass from:
-ExtractSupertypeMemberPage_extract_supertype=Extract Superclass
-ExtractSupertypeMemberPage_extract=extract
-ExtractSupertypeMemberPage_add_button_label=A&dd...
-ExtractSupertypeMemberPage_declare_abstract=declare abstract in superclass
-ExtractSupertypeMemberPage_use_supertype_label=&Use the extracted class in 'instanceof' expressions
-ExtractSupertypeMemberPage_remove_button_label=Re&move
-ExtractSupertypeMemberPage_choose_type_caption=Choose Types
-ExtractSupertypeMemberPage_choose_type_message=Choose types where to extract the new superclass from:
-ExtractSupertypeMemberPage_no_members_selected=No members selected to extract or declare abstract
-ExtractSupertypeMemberPage_use_instanceof_label=Use the &extracted class where possible
-
-ExtractInterfaceInputPage_description=Select the name for the new interface and select the members that will be declared in the interface.
-ExtractInterfaceInputPage_Interface_name=&Interface name:
-ExtractInterfaceInputPage_Members=&Members to declare in the interface:
-ExtractInterfaceInputPage_Extract_Interface=Extract Interface
-ExtractInterfaceInputPage_Internal_Error=An unexpected exception occurred. See the error log for more details.
-ExtractInterfaceInputPage_Select_All=Select &All
-ExtractInterfaceInputPage_Deselect_All=&Deselect All
-ExtractInterfaceInputPage_change_references=Use the extracted interface &type where possible
-ExtractInterfaceWizard_Extract_Interface=Extract Interface
-ExtractInterfaceWizard_generate_comments=Generate function &comments
-ExtractInterfaceWizard_use_supertype=&Use the extracted interface in \'instanceof\' expressions
-ExtractInterfaceWizard_public_label=&public
-ExtractInterfaceWizard_abstract_label=a&bstract
-
-InlineConstantInputPage_Inline=Inline
-InlineConstantInputPage_All_references=&All references
-InlineConstantInputPage_Delete_constant=&Delete constant declaration
-InlineConstantInputPage_Only_selected=&Only the selected reference
-InlineConstantWizard_message=Specify where to inline references to the constant.
-InlineConstantWizard_Inline_Constant=Inline Constant
-InlineConstantWizard_initializer_refers_to_fields=This constant\'s initializer refers to non-final or non-static vars
-
-MoveInnerToTopWizard_Move_Inner=Convert Member Type to Top Level
-MoveInnerToToplnputPage_description=Specify a name for the var that will be used to access the enclosing instance
-MoveInnerToToplnputPage_instance_final=&Declare instance var as \'final\'
-MoveInnerToToplnputPage_optional_info=Choose a name to optionally create an enclosing instance var.
-MoveInnerToToplnputPage_mandatory_info=Choose a name for the enclosing instance var.
-MoveInnerToToplnputPage_enter_name_mandatory=Enclosing instance var &name:
-MoveInnerToToplnputPage_enter_name=Enclosing instance var &name (optional):
-
-MoveInstanceMethodWizard_Move_Method=Move Function
-MoveInstanceMethodPage_Target_name=New &parameter name:
-MoveInstanceMethodPage_Method_name=New &function name:
-MoveInstanceMethodPage_New_receiver=&New target for ''{0}'':
-MoveInstanceMethodPage_Name=Name
-MoveInstanceMethodPage_Type=Type
-MoveInstanceMethodPage_Create_button_name=&Keep original function as delegate to moved function
-MoveInstanceMethodPage_Deprecate_button_name=Mark as &deprecated
-MoveInstanceMethodPage_invalid_target=Target ''{0}'' is used in an assignment.
-
-PromoteTempInputPage_Field_declaration=Var decla&ration
-PromoteTempInputPage_Current_method=&Current function
-PromoteTempInputPage_constructors=C&lass constructor(s)
-PromoteTempInputPage_Field_name=F&ield name:
-PromoteTempInputPage_Initialize=Initialize in
-PromoteTempInputPage_declare_static=D&eclare var as \'static\'
-PromoteTempInputPage_declare_final=Decl&are var as \'final\'
-
-UseSupertypeInputPage_Select_supertype=Select the supertype to use
-UseSupertypeInputPage_Use_in_instanceof=&Use the selected supertype in \'instanceof\' expressions
-UseSupertypeInputPage_Select_supertype_to_use=&Select supertype to use instead of ''{0}'':
-UseSupertypeInputPage_No_updates=No updates possible for the selected supertype
-UseSupertypeInputPage_Use_Supertype=Use Supertype
-UseSupertypeInputPage_Internal_Error=An unexpected exception occurred. See the error log for more details.
-UseSupertypeInputPage_no_possible_updates={0} - no possible updates found
-UseSupertypeInputPage_updates_possible_in_file={0} - updates possible in 1 file
-UseSupertypeInputPage_updates_possible_in_files={0} - updates possible in {1} files
-UseSupertypeWizard_Use_Super_Type_Where_Possible=Use Super Type Where Possible
-
-VisibilityControlUtil_Access_modifier=Access modifier
-VisibilityControlUtil_defa_ult_4=d&efault
-VisibilityControlUtil_final=&final
-VisibilityControlUtil_synchronized=s&ynchronized
-
-PullUpWizard_defaultPageTitle=Pull Up
-PullUpWizard_select_all_label=Select &All
-PullUpWizard_deselect_all_label=Dese&lect All
-PullUpInputPage1_pull_up=pull up
-PullUpInputPage1_declare_abstract=declare abstract in destination
-PullUpInputPage1_Create_stubs=&Create necessary functions stubs in non-abstract subtypes of the destination type
-PullUpInputPage1_Select_destination=&Select destination type:
-PullUpInputPage1_Specify_actions=S&pecify actions for members:
-PullUpInputPage1_Edit=Set Act&ion...
-PullUpInputPage1_Add_Required=Add &Required
-PullUpInputPage1_Edit_members=Set Action
-PullUpInputPage1_Mark_selected_members=&Action for selected member(s):
-PullUpInputPage1_label_use_destination=Use the d&estination type where possible
-PullUpInputPage1_Member=Member
-PullUpInputPage1_Action=Action
-PullUpInputPage1_Select_members_to_pull_up=No members selected to pull up or declare abstract
-PullUpInputPage1_label_use_in_instanceof=&Use the destination type in 'instanceof' expressions
-PullUpInputPage1_page_message=Select the destination type and the members to pull up.
-PullUpInputPage1_status_line={0} member(s) selected.
-
-PullUpInputPage2_Select=Restore &Defaults
-PullUpInputPage2_Source=Source
-
-PushDownWizard_defaultPageTitle= Push Down
-PushDownInputPage_leave_abstract=leave abstract declaration
-PushDownInputPage_push_down=push down
-PushDownInputPage_Specify_actions=&Specify actions for members:
-PushDownInputPage_Member=Member
-PushDownInputPage_Action=Action
-PushDownInputPage_Edit=Se&t Action...
-PushDownInputPage_Add_Required=Add &Required
-PushDownInputPage_Push_Down=Push Down
-PushDownInputPage_Internal_Error=An unexpected exception occurred. See the error log for more details.
-PushDownInputPage_Edit_members=Set Action
-PushDownInputPage_Mark_selected_members=&Action for selected member(s):
-PushDownInputPage_Select_members_to_push_down=No members selected to push down or declare abstract
-PushDownInputPage_status_line={0} member(s) selected.
-
-MoveInstanceMethodAction_dialog_title=Move Function
-MoveInstanceMethodAction_Move_Method=Move Function...
-MoveInstanceMethodAction_unexpected_exception=An unexpected exception occurred. See the error log for more details
-MoveInstanceMethodAction_No_reference_or_declaration=No function reference or declaration selected.
-
-InlineConstantAction_dialog_title=Inline Constant
-InlineConstantAction_inline_Constant=Inline &Constant...
-InlineConstantAction_unexpected_exception=An unexpected exception occurred. See the error log for more details
-InlineConstantAction_no_constant_reference_or_declaration=No constant reference or declaration selected.
-
-InlineMethodInputPage_description=Specify where to inline the function invocation.
-InlineMethodInputPage_inline=Inline
-InlineMethodInputPage_all_invocations=&All invocations
-InlineMethodInputPage_delete_declaration=&Delete function declaration
-InlineMethodInputPage_only_selected=&Only the selected invocation
-
-InlineMethodAction_dialog_title=Inline Function
-InlineMethodAction_inline_Method=I&nline Function...
-InlineMethodAction_unexpected_exception=An unexpected exception occurred. See the error log for more details
-InlineMethodAction_no_method_invocation_or_declaration_selected=No function invocation or declaration selected.
-
-UseSupertypeAction_use_Supertype=Use Supertype W&here Possible...
-UseSupertypeAction_to_activate=To activate this refactoring, please select the name of a type.
-UseSupertypeAction_Refactoring=Refactoring
-UseSupertypeAction_not_possible=Cannot perform operation.
-
-PushDownAction_Push_Down=Push &Down...
-PushDownAction_To_activate=To activate this refactoring, please select the name of a non-binary instance function or var.
-PushDownAction_Refactoring=Refactoring
-PushDownAction_not_possible=Cannot perform operation.
-
-MoveAction_Move=Move
-MoveAction_select=Select a static function, a static var or an instance function that can be moved to a component (parameter or var).
-
-InlineAction_Inline=&Inline...
-InlineAction_dialog_title=Inline
-InlineAction_select=Select a function declaration, a function invocation, a static final var or a local variable that you want to inline.
-
-ExtractInterfaceAction_Extract_Interface=&Extract Interface...
-ExtractInterfaceAction_To_activate=To activate this refactoring, please select the name of a top level type.
-ExtractInterfaceAction_Refactoring=Refactoring
-ExtractSuperTypeAction_unavailable=To activate this refactoring, please select a top-level type or the name of a non-binary instance function or var.
-ExtractInterfaceAction_not_possible=Cannot perform operation.
-
-ConvertNestedToTopAction_Convert=Con&vert Member Type to Top Level
-ConvertNestedToTopAction_To_activate=To activate this refactoring, please select the name of a member type.
-ConvertNestedToTopAction_Refactoring=Refactoring
-ConvertNestedToTopAction_not_possible=Cannot perform operation.
-
-ConvertAnonymousToNestedAction_dialog_title=Convert Anonymous Class to Nested Class
-ConvertAnonymousToNestedAction_Convert_Anonymous=C&onvert Anonymous Class to Nested...
-ConvertAnonymousToNestedAction_wizard_title=Convert Anonymous Class to Nested Class
-
-###################### Temporary Participant Keys #################################
-RenameResourceWizard_defaultPageTitle=Rename Resource
-RenameResourceWizard_inputPage_description=Enter the new name for this resource.
-
-RenameJavaProject_defaultPageTitle=Rename JavaScript Project
-RenameJavaProject_inputPage_description=Enter the new name for this JavaScript project.
-
-RenameSourceFolder_defaultPageTitle=Rename Source Folder
-RenameSourceFolder_inputPage_description=Enter the new name for this source folder.
-
-RenamePackageWizard_defaultPageTitle=Rename Package
-RenamePackageWizard_inputPage_description=Enter the new name for this package.
-RenamePackageWizard_rename_subpackages=Rename &subpackages
-
-RenameCuWizard_defaultPageTitle= Rename JavaScript file
-RenameCuWizard_inputPage_description= Enter the new name for this JavaScript file.
-
-RenameTypeParameterWizard_defaultPageTitle=Rename Type Variable
-RenameTypeParameterWizard_inputPage_description=Enter the new name for this type variable.
-
-RenameMethodWizard_defaultPageTitle=Rename Function
-RenameMethodWizard_inputPage_description= Enter the new name for this function.
-
-RenameLocalVariableWizard_defaultPageTitle=Rename Local Variable
-RenameLocalVariableWizard_inputPage_description=Enter the new name for this local variable.
-
-ExtractInterfaceWizard_12=Declare interface functions as ''{0}''
-
-ParameterEditDialog_type_invalid=''{0}'' is not a valid parameter type name.
-UseSupertypeWizard_10=No updates are possible for the supertypes
-
-DeleteWizard_1=Confirm Delete
-DeleteWizard_2=An unexpected exception occurred. See the error log for more details.
-DeleteWizard_3=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.
-DeleteWizard_4=Are you sure you want to delete {0}?
-DeleteWizard_5=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.
-DeleteWizard_6=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.\n\nNote that all subelements of the selected linked packages and package fragment roots will be removed from the workspace.
-DeleteWizard_7=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.
-DeleteWizard_8=Are you sure you want to delete {0}?
-DeleteWizard_9=Are you sure you want to delete these {0} elements?
-DeleteWizard_10=Are you sure you want to delete these {0} elements?\n\nSelection contains linked resources.\nOnly the workspace links will be deleted. Link targets will remain unchanged.
-DeleteWizard_11=Are you sure you want to delete these {0} elements?\n\nSelection contains linked packages.\nOnly the workspace links will be deleted. Link targets will remain unchanged.\n\nNote that all subelements of linked packages and package fragment roots will be removed from the workspace.
-DeleteWizard_12=The selected element(s) do not exist anymore and cannot be deleted.
-DeleteWizard_also_delete_sub_packages=Delete &subpackages of selected packages
-
-#####################################
-# Rename Type
-#####################################
-
-RenameTypeWizard_defaultPageTitle= Rename Type
-RenameTypeWizard_unexpected_exception=An unexpected exception occurred. See the error log for more details
-
-RenameTypeWizardInputPage_description=Enter the new name for this type.
-RenameTypeWizardInputPage_update_similar_elements=Update &similarly named variables and functions
-RenameTypeWizardInputPage_update_similar_elements_configure=<a>&Configure...</a>
-RenameTypeWizardSimilarElementsPage_name_empty=Please enter a name.
-RenameTypeWizardSimilarElementsPage_rename_to=Rename ''{0}'' to ''{1}''
-RenameTypeWizardSimilarElementsPage_change_element_name=Change Element Name
-RenameTypeWizardSimilarElementsPage_enter_new_name=Enter a new name for the selected element:
-RenameTypeWizardSimilarElementsPage_field_exists=A var with this name already exists in the file.
-RenameTypeWizardSimilarElementsPage_method_exists=A function with this name already exists in the file.
-RenameTypeWizardSimilarElementsPage_restore_defaults=Restore &Defaults
-RenameTypeWizardSimilarElementsPage_change_name=&Change Name...
-RenameTypeWizardSimilarElementsPage_name_should_start_lowercase=Element names should start with a lowercase character.
-RenameTypeWizardSimilarElementsPage_review_similar_elements=&Similarly named variables and functions to be renamed
-RenameTypeWizardSimilarElementsPage_select_element_to_view_source=Select an element
-
-RenameTypeWizardSimilarElementsOptionsDialog_title=Similar Names Configuration
-RenameTypeWizardSimilarElementsOptionsDialog_select_strategy=Strategy for matching type names (e.g., 'SomeClass') in variable and function names:
-RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names=Short type names or short suffixes may lead to unexpected results when matching partial names. Please review the matched elements carefully.
-RenameTypeWizardSimilarElementsOptionsDialog_strategy_1=Find &exact names only ('someClass' or 'someClass()')
-RenameTypeWizardSimilarElementsOptionsDialog_strategy_2=Also find e&mbedded names ('mySomeClassToUse' or 'getSomeClass()')
-RenameTypeWizardSimilarElementsOptionsDialog_strategy_3=Also find name &suffixes ('class', 'myClass', or 'getClassToUse()')
-
-#######################################
-# IntroduceParameter
-#######################################
-IntroduceParameterAction_label=Introduce &Parameter...
-IntroduceParameterAction_dialog_title=Introduce Parameter
-
-IntroduceParameterWizard_defaultPageTitle=Introduce Parameter
-IntroduceParameterWizard_parameters=&Parameters:
-IntroduceParameterInputPage_description=Enter the name for the new parameter.
-
-#######################################
-# Introduce Indirection
-#######################################
-IntroduceIndirectionAction_title=Introduce Indirec&tion...
-IntroduceIndirectionAction_dialog_title=Introduce Indirection
-IntroduceIndirectionAction_tooltip=Introduce an Indirection to Encapsulate Function Calls
-IntroduceIndirectionAction_description=Introduces an indirection to encapsulate calls to the selected function
-IntroduceIndirectionAction_unknown_exception=An unexpected exception occurred. See the error log for more details
-IntroduceIndirectionInputPage_browse=&Browse...
-IntroduceIndirectionInputPage_new_method_name=New function &name:
-IntroduceIndirectionInputPage_declaring_class=Declaring &type:
-IntroduceIndirectionInputPage_update_references=&Redirect all function invocations
-IntroduceIndirectionInputPage_select_declaring_class=Please select a declaring type.
-IntroduceIndirectionInputPage_dialog_choose_declaring_class=Choose Type
-IntroduceIndirectionInputPage_dialog_choose_declaring_class_long=&Choose the type where to insert the new function:
-
-#######################################
-# Introduce Factory
-#######################################
-IntroduceFactoryAction_label=Intr&oduce Factory...
-IntroduceFactoryAction_dialog_title=Introduce Factory
-IntroduceFactoryAction_tooltipText=Introduce a Factory to Encapsulate Object Instantiation
-IntroduceFactoryAction_description=Creates a factory to encapsulate calls to the selected constructor
-IntroduceFactoryAction_use_factory=Introduce Factory
-IntroduceFactoryAction_exception=An unexpected exception occurred. See the error log for more details
-IntroduceFactoryInputPage_name_factory=Factory options
-IntroduceFactoryInputPage_method_name=Factory function &name:
-IntroduceFactoryInputPage_protectConstructorLabel=Ma&ke constructor private
-IntroduceFactoryInputPage_browseLabel=&Browse...
-IntroduceFactoryInputPage_factoryClassLabel=Factory &class:
-IntroduceFactoryInputPage_chooseFactoryClass_title=Choose Factory Class
-IntroduceFactoryInputPage_chooseFactoryClass_message=&Choose the class on which to place the factory function:
-
-#######################################
-# Generalize Declared Type
-#######################################
-ChangeTypeAction_label=Generali&ze Declared Type...
-ChangeTypeAction_tooltipText=Generalize Variable\'s Declared Type
-ChangeTypeAction_description=Change variable\'s declared type to more general type consistent with usage
-ChangeTypeAction_exception=An unexpected exception occurred. See the error log for more details
-ChangeTypeAction_dialog_title=Generalize Declared Type
-
-ChangeTypeWizard_title=Generalize Declared Type
-ChangeTypeWizard_declCannotBeChanged=Type of selected declaration cannot be changed
-ChangeTypeWizard_pleaseChooseType=&Choose new type for ''{0}'':
-ChangeTypeWizard_analyzing=Analyzing...
-ChangeTypeWizard_internalError=An unexpected exception occurred. See the error log for more details.
-ChangeTypeWizard_computationInterrupted=Computation of valid types was interrupted
-ChangeTypeWizard_grayed_types= Type ''{0}'' cannot be used as a replacement for type ''{1}''
-ChangeTypeWizard_with_itself= Cannot replace type ''{0}'' with itself
-ChangeTypeInputPage_Select_Type=Press "Compute" to determine allowable supertypes
-
-JavaTypeCompletionProcessor_no_completion=No completions available.
-JavaStatusContextViewer_no_source_found0=Source not found\n\nThe jar file {0} has no source attachment.
-JavaStatusContextViewer_no_source_available=No source available
-
-#######################################
-# Infer Type Arguments
-#######################################
-InferTypeArgumentsAction_label=Infer &Generic Type Arguments...
-InferTypeArgumentsAction_dialog_title=Infer Generic Type Arguments
-InferTypeArgumentsAction_unavailable=To activate this refactoring, please select a set of JavaScript files, packages, source folders, or javaScript projects.
-
-InferTypeArgumentsWizard_defaultPageTitle=Infer Generic Type Arguments
-InferTypeArgumentsInputPage_description=Infer Generic Type Arguments
-InferTypeArgumentsWizard_lengthyDescription=Infer type arguments for references to generic types and remove unnecessary casts.
-InferTypeArgumentsWizard_assumeCloneSameType=&Assume clone() returns an instance of the receiver type
-InferTypeArgumentsWizard_leaveUnconstrainedRaw=&Leave unconstrained type arguments raw (rather than inferring <?>)
-
-#######################################
-# Replace Invocations
-#######################################
-ReplaceInvocationsAction_label=Replace In&vocations...
-ReplaceInvocationsWizard_title=Replace Function Invocations
-ReplaceInvocationsAction_dialog_title=Replace Invocations
-ReplaceInvocationsInputPage_replaceInvocationsBy=&Replace Invocations by:
-ReplaceInvocationsInputPage_replaceAll=Replace &all invocations
-ReplaceInvocationsAction_unavailable=An unexpected exception occurred. See the error log for more details
-RefactoringExecutionStarter_IntroduceParameterObject_problem_title=Introduce Parameter Object
-RefactoringExecutionStarter_IntroduceParameterObject_problem_description=Cannot add a parameter object as the selected function overrides or implements a read only function
-
-
-JarImportWizard_prepare_import=Prepare replay of refactorings...
-JarImportWizard_error_shared_jar=Cannot replay refactorings, since the JAR file is also on the build path of project ''{0}''.
-BinaryRefactoringHistoryWizard_error_missing_source_attachment=The refactoring ''{0}'' cannot be performed, since it needs a source attachment.
-JarImportWizard_cleanup_import=Finish replay of refactorings...
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java
deleted file mode 100644
index 2a4391b4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.TypedSource;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaElementTransfer;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ParentChecker;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-
-public class CopyToClipboardAction extends SelectionDispatchAction{
-
- private final Clipboard fClipboard;
- private boolean fAutoRepeatOnFailure= false;
-
- public CopyToClipboardAction(IWorkbenchSite site, Clipboard clipboard) {
- super(site);
- setText(ReorgMessages.CopyToClipboardAction_0);
- setDescription(ReorgMessages.CopyToClipboardAction_1);
- Assert.isNotNull(clipboard);
- fClipboard= clipboard;
- ISharedImages workbenchImages= getWorkbenchSharedImages();
- setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
- setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- update(getSelection());
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.COPY_ACTION);
- }
-
- public void setAutoRepeatOnFailure(boolean autorepeatOnFailure){
- fAutoRepeatOnFailure= autorepeatOnFailure;
- }
-
- private static ISharedImages getWorkbenchSharedImages() {
- return JavaScriptPlugin.getDefault().getWorkbench().getSharedImages();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (elements.size() != resources.length + javaElements.length)
- setEnabled(false);
- else
- setEnabled(canEnable(resources, javaElements));
- } catch (JavaScriptModelException e) {
- //no ui here - this happens on selection changes
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (elements.size() == resources.length + javaElements.length && canEnable(resources, javaElements))
- doRun(resources, javaElements);
- } catch (CoreException e) {
- ExceptionHandler.handle(e, getShell(), ReorgMessages.CopyToClipboardAction_2, ReorgMessages.CopyToClipboardAction_3);
- }
- }
-
- private void doRun(IResource[] resources, IJavaScriptElement[] javaElements) throws CoreException {
- new ClipboardCopier(resources, javaElements, fClipboard, getShell(), fAutoRepeatOnFailure).copyToClipboard();
- }
-
- private boolean canEnable(IResource[] resources, IJavaScriptElement[] javaElements) throws JavaScriptModelException {
- return new CopyToClipboardEnablementPolicy(resources, javaElements).canEnable();
- }
-
- //----------------------------------------------------------------------------------------//
-
- private static class ClipboardCopier{
- private final boolean fAutoRepeatOnFailure;
- private final IResource[] fResources;
- private final IJavaScriptElement[] fJavaElements;
- private final Clipboard fClipboard;
- private final Shell fShell;
- private final ILabelProvider fLabelProvider;
-
- private ClipboardCopier(IResource[] resources, IJavaScriptElement[] javaElements, Clipboard clipboard, Shell shell, boolean autoRepeatOnFailure){
- Assert.isNotNull(resources);
- Assert.isNotNull(javaElements);
- Assert.isNotNull(clipboard);
- Assert.isNotNull(shell);
- fResources= resources;
- fJavaElements= javaElements;
- fClipboard= clipboard;
- fShell= shell;
- fLabelProvider= createLabelProvider();
- fAutoRepeatOnFailure= autoRepeatOnFailure;
- }
-
- public void copyToClipboard() throws CoreException{
- //Set<String> fileNames
- Set fileNames= new HashSet(fResources.length + fJavaElements.length);
- StringBuffer namesBuf = new StringBuffer();
- processResources(fileNames, namesBuf);
- processJavaElements(fileNames, namesBuf);
-
- IType[] mainTypes= ReorgUtils.getMainTypes(fJavaElements);
- IJavaScriptUnit[] cusOfMainTypes= ReorgUtils.getCompilationUnits(mainTypes);
- IResource[] resourcesOfMainTypes= ReorgUtils.getResources(cusOfMainTypes);
- addFileNames(fileNames, resourcesOfMainTypes);
-
- IResource[] cuResources= ReorgUtils.getResources(getCompilationUnits(fJavaElements));
- addFileNames(fileNames, cuResources);
-
- IResource[] resourcesForClipboard= ReorgUtils.union(fResources, ReorgUtils.union(cuResources, resourcesOfMainTypes));
- IJavaScriptElement[] javaElementsForClipboard= ReorgUtils.union(fJavaElements, cusOfMainTypes);
-
- TypedSource[] typedSources= TypedSource.createTypedSources(javaElementsForClipboard);
- String[] fileNameArray= (String[]) fileNames.toArray(new String[fileNames.size()]);
- copyToClipboard(resourcesForClipboard, fileNameArray, namesBuf.toString(), javaElementsForClipboard, typedSources, 0);
- }
-
- private static IJavaScriptElement[] getCompilationUnits(IJavaScriptElement[] javaElements) {
- List cus= ReorgUtils.getElementsOfType(javaElements, IJavaScriptElement.JAVASCRIPT_UNIT);
- return (IJavaScriptUnit[]) cus.toArray(new IJavaScriptUnit[cus.size()]);
- }
-
- private void processResources(Set fileNames, StringBuffer namesBuf) {
- for (int i= 0; i < fResources.length; i++) {
- IResource resource= fResources[i];
- addFileName(fileNames, resource);
-
- if (i > 0)
- namesBuf.append('\n');
- namesBuf.append(getName(resource));
- }
- }
-
- private void processJavaElements(Set fileNames, StringBuffer namesBuf) {
- for (int i= 0; i < fJavaElements.length; i++) {
- IJavaScriptElement element= fJavaElements[i];
- switch (element.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- case IJavaScriptElement.JAVASCRIPT_UNIT :
- case IJavaScriptElement.CLASS_FILE :
- addFileName(fileNames, ReorgUtils.getResource(element));
- break;
- default :
- break;
- }
-
- if (fResources.length > 0 || i > 0)
- namesBuf.append('\n');
- namesBuf.append(getName(element));
- }
- }
-
- private static void addFileNames(Set fileName, IResource[] resources) {
- for (int i= 0; i < resources.length; i++) {
- addFileName(fileName, resources[i]);
- }
- }
-
- private static void addFileName(Set fileName, IResource resource){
- if (resource == null)
- return;
- IPath location = resource.getLocation();
- if (location != null) {
- fileName.add(location.toOSString());
- } else {
- // not a file system path. skip file.
- }
- }
-
- private void copyToClipboard(IResource[] resources, String[] fileNames, String names, IJavaScriptElement[] javaElements, TypedSource[] typedSources, int repeat){
- final int repeat_max_count= 10;
- try{
- fClipboard.setContents( createDataArray(resources, javaElements, fileNames, names, typedSources),
- createDataTypeArray(resources, javaElements, fileNames, typedSources));
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeat >= repeat_max_count)
- throw e;
- if (fAutoRepeatOnFailure) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e1) {
- // do nothing.
- }
- }
- if (fAutoRepeatOnFailure || MessageDialog.openQuestion(fShell, ReorgMessages.CopyToClipboardAction_4, ReorgMessages.CopyToClipboardAction_5))
- copyToClipboard(resources, fileNames, names, javaElements, typedSources, repeat+1);
- }
- }
-
- private static Transfer[] createDataTypeArray(IResource[] resources, IJavaScriptElement[] javaElements, String[] fileNames, TypedSource[] typedSources) {
- List result= new ArrayList(4);
- if (resources.length != 0)
- result.add(ResourceTransfer.getInstance());
- if (javaElements.length != 0)
- result.add(JavaElementTransfer.getInstance());
- if (fileNames.length != 0)
- result.add(FileTransfer.getInstance());
- if (typedSources.length != 0)
- result.add(TypedSourceTransfer.getInstance());
- result.add(TextTransfer.getInstance());
- return (Transfer[]) result.toArray(new Transfer[result.size()]);
- }
-
- private static Object[] createDataArray(IResource[] resources, IJavaScriptElement[] javaElements, String[] fileNames, String names, TypedSource[] typedSources) {
- List result= new ArrayList(4);
- if (resources.length != 0)
- result.add(resources);
- if (javaElements.length != 0)
- result.add(javaElements);
- if (fileNames.length != 0)
- result.add(fileNames);
- if (typedSources.length != 0)
- result.add(typedSources);
- result.add(names);
- return result.toArray();
- }
-
- private static ILabelProvider createLabelProvider(){
- return new JavaScriptElementLabelProvider(
- JavaScriptElementLabelProvider.SHOW_VARIABLE
- + JavaScriptElementLabelProvider.SHOW_PARAMETERS
- + JavaScriptElementLabelProvider.SHOW_TYPE
- );
- }
- private String getName(IResource resource){
- return fLabelProvider.getText(resource);
- }
- private String getName(IJavaScriptElement javaElement){
- return fLabelProvider.getText(javaElement);
- }
- }
-
- private static class CopyToClipboardEnablementPolicy {
- private final IResource[] fResources;
- private final IJavaScriptElement[] fJavaElements;
- public CopyToClipboardEnablementPolicy(IResource[] resources, IJavaScriptElement[] javaElements){
- Assert.isNotNull(resources);
- Assert.isNotNull(javaElements);
- fResources= resources;
- fJavaElements= javaElements;
- }
-
- public boolean canEnable() throws JavaScriptModelException{
- if (fResources.length + fJavaElements.length == 0)
- return false;
- if (hasProjects() && hasNonProjects())
- return false;
- if (! canCopyAllToClipboard())
- return false;
- if (! new ParentChecker(fResources, fJavaElements).haveCommonParent())
- return false;
- return true;
- }
-
- private boolean canCopyAllToClipboard() throws JavaScriptModelException {
- for (int i= 0; i < fResources.length; i++) {
- if (! canCopyToClipboard(fResources[i])) return false;
- }
- for (int i= 0; i < fJavaElements.length; i++) {
- if (! canCopyToClipboard(fJavaElements[i])) return false;
- }
- return true;
- }
-
- private static boolean canCopyToClipboard(IJavaScriptElement element) throws JavaScriptModelException {
- if (element == null || ! element.exists())
- return false;
-
- if (JavaElementUtil.isDefaultPackage(element))
- return false;
-
- return true;
- }
-
- private static boolean canCopyToClipboard(IResource resource) {
- return resource != null &&
- resource.exists() &&
- ! resource.isPhantom() &&
- resource.getType() != IResource.ROOT;
- }
-
- private boolean hasProjects() {
- for (int i= 0; i < fResources.length; i++) {
- if (ReorgUtils.isProject(fResources[i])) return true;
- }
- for (int i= 0; i < fJavaElements.length; i++) {
- if (ReorgUtils.isProject(fJavaElements[i])) return true;
- }
- return false;
- }
-
- private boolean hasNonProjects() {
- for (int i= 0; i < fResources.length; i++) {
- if (! ReorgUtils.isProject(fResources[i])) return true;
- }
- for (int i= 0; i < fJavaElements.length; i++) {
- if (! ReorgUtils.isProject(fJavaElements[i])) return true;
- }
- return false;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CreateTargetQueries.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CreateTargetQueries.java
deleted file mode 100644
index 74a5c170..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CreateTargetQueries.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ICreateTargetQueries;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ICreateTargetQuery;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.util.PixelConverter;
-import org.eclipse.wst.jsdt.internal.ui.wizards.NewPackageCreationWizard;
-import org.eclipse.wst.jsdt.ui.wizards.NewPackageWizardPage;
-
-public class CreateTargetQueries implements ICreateTargetQueries {
-
- private final Wizard fWizard;
- private final Shell fShell;
-
- public CreateTargetQueries(Wizard wizard) {
- fWizard= wizard;
- fShell= null;
- }
-
- public CreateTargetQueries(Shell shell) {
- fShell = shell;
- fWizard= null;
- }
-
- private Shell getShell() {
- Assert.isTrue(fWizard == null || fShell == null);
- if (fWizard != null)
- return fWizard.getContainer().getShell();
- else if (fShell != null)
- return fShell;
- else
- return JavaScriptPlugin.getActiveWorkbenchShell();
- }
-
- public ICreateTargetQuery createNewPackageQuery() {
- return new ICreateTargetQuery() {
- public Object getCreatedTarget(Object selection) {
- IWorkbenchWizard packageCreationWizard= new NewPackageCreationWizard();
-
- IWizardPage[] pages= openNewElementWizard(packageCreationWizard, getShell(), selection);
-
- NewPackageWizardPage page= (NewPackageWizardPage) pages[0];
- return page.getNewPackageFragment();
- }
-
- public String getNewButtonLabel() {
- return ReorgMessages.ReorgMoveWizard_newPackage;
- }
- };
- }
-
- private IWizardPage[] openNewElementWizard(IWorkbenchWizard wizard, Shell shell, Object selection) {
- wizard.init(JavaScriptPlugin.getDefault().getWorkbench(), new StructuredSelection(selection));
-
- WizardDialog dialog= new WizardDialog(shell, wizard);
- PixelConverter converter= new PixelConverter(JFaceResources.getDialogFont());
- dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
- dialog.create();
- dialog.open();
- IWizardPage[] pages= wizard.getPages();
- return pages;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CutAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CutAction.java
deleted file mode 100644
index 4ca8533c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/CutAction.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class CutAction extends SelectionDispatchAction{
-
- private CopyToClipboardAction fCopyToClipboardAction;
-
- public CutAction(IWorkbenchSite site, Clipboard clipboard) {
- super(site);
- setText(ReorgMessages.CutAction_text);
- fCopyToClipboardAction= new CopyToClipboardAction(site, clipboard);
-
- ISharedImages workbenchImages= JavaScriptPlugin.getDefault().getWorkbench().getSharedImages();
- setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
- setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
- setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CUT_ACTION);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- try {
- // cannot cut top-level types. this deletes the cu and then you cannot paste because the cu is gone.
- if (!containsOnlyElementsInsideCompilationUnits(selection) || containsTopLevelTypes(selection)) {
- setEnabled(false);
- return;
- }
- fCopyToClipboardAction.selectionChanged(selection);
- setEnabled(fCopyToClipboardAction.isEnabled() && RefactoringAvailabilityTester.isDeleteAvailable(selection));
- } catch (CoreException e) {
- // no ui here - this happens on selection changes
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);
- }
- } else
- setEnabled(false);
- }
-
- private static boolean containsOnlyElementsInsideCompilationUnits(IStructuredSelection selection) {
- for (Iterator iter = selection.iterator(); iter.hasNext();) {
- Object object= iter.next();
- if (! (object instanceof IJavaScriptElement && ReorgUtils.isInsideCompilationUnit((IJavaScriptElement)object)))
- return false;
- }
- return true;
- }
-
- private static boolean containsTopLevelTypes(IStructuredSelection selection) {
- for (Iterator iter = selection.iterator(); iter.hasNext();) {
- Object each= iter.next();
- if ((each instanceof IType) && ((IType)each).getDeclaringType() == null)
- return true;
- }
- return false;
- }
-
- public void run(IStructuredSelection selection) {
- try {
- selectionChanged(selection);
- if (isEnabled()) {
- fCopyToClipboardAction.run(selection);
- RefactoringExecutionStarter.startCutRefactoring(selection.toArray(), getShell());
- }
- } catch (CoreException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- } catch (InterruptedException e) {
- //OK
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteAction.java
deleted file mode 100644
index 32ba24cd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.DeleteResourceAction;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-
-public class DeleteAction extends SelectionDispatchAction {
-
- public DeleteAction(IWorkbenchSite site) {
- super(site);
- setText(ReorgMessages.DeleteAction_3);
- setDescription(ReorgMessages.DeleteAction_4);
- ISharedImages workbenchImages= JavaScriptPlugin.getDefault().getWorkbench().getSharedImages();
- setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
- setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.DELETE_ACTION);
- }
-
- /*
- * @see SelectionDispatchAction#selectionChanged(IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())) {
- setEnabled(createWorkbenchAction(selection).isEnabled());
- return;
- }
- try {
- setEnabled(RefactoringAvailabilityTester.isDeleteAvailable(selection.toArray()));
- } catch (CoreException e) {
- //no ui here - this happens on selection changes
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);
- }
- }
-
- private IAction createWorkbenchAction(IStructuredSelection selection) {
- DeleteResourceAction action= new DeleteResourceAction(getShell());
- action.selectionChanged(selection);
- return action;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())) {
- createWorkbenchAction(selection).run();
- return;
- }
- try {
- RefactoringExecutionStarter.startDeleteRefactoring(selection.toArray(), getShell());
- } catch (CoreException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteUserInterfaceManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteUserInterfaceManager.java
deleted file mode 100644
index b0fe6b8d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteUserInterfaceManager.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaDeleteProcessor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.UserInterfaceManager;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.UserInterfaceStarter;
-
-public class DeleteUserInterfaceManager extends UserInterfaceManager {
- private static final UserInterfaceManager fgInstance= new DeleteUserInterfaceManager();
-
- public static UserInterfaceManager getDefault() {
- return fgInstance;
- }
-
- private DeleteUserInterfaceManager() {
- put(JavaDeleteProcessor.class, UserInterfaceStarter.class, DeleteWizard.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteWizard.java
deleted file mode 100644
index bf29ea4f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DeleteWizard.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.participants.DeleteRefactoring;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaDeleteProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.MessageWizardPage;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class DeleteWizard extends RefactoringWizard {
-
- public DeleteWizard(Refactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE | YES_NO_BUTTON_STYLE | NO_PREVIEW_PAGE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
- setDefaultPageTitle(RefactoringMessages.DeleteWizard_1);
- ((JavaDeleteProcessor)((DeleteRefactoring)getRefactoring()).getProcessor()).setQueries(new ReorgQueries(this));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizard#addUserInputPages()
- */
- protected void addUserInputPages() {
- addPage(new DeleteInputPage());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizard#getMessageLineWidthInChars()
- */
- public int getMessageLineWidthInChars() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#needsProgressMonitor()
- */
- public boolean needsProgressMonitor() {
- DeleteRefactoring refactoring= (DeleteRefactoring)getRefactoring();
- RefactoringProcessor processor= refactoring.getProcessor();
- if (processor instanceof JavaDeleteProcessor) {
- return ((JavaDeleteProcessor)processor).needsProgressMonitor();
- }
- return super.needsProgressMonitor();
- }
-
- private static class DeleteInputPage extends MessageWizardPage {
- private static final String PAGE_NAME= "DeleteInputPage"; //$NON-NLS-1$
- private static final String DIALOG_SETTINGS_DELETE_SUB_PACKAGES= "deleteSubPackages"; //$NON-NLS-1$
- private Button fDeleteSubPackagesCheckBox;
-
- public DeleteInputPage() {
- super(PAGE_NAME, true, MessageWizardPage.STYLE_QUESTION);
- }
-
- protected String getMessageString() {
- try {
- if (1 == numberOfSelectedElements()) {
- String pattern= createConfirmationStringForOneElement();
- String name= getNameOfSingleSelectedElement();
- return Messages.format(pattern, new String[] { name });
- } else {
- String pattern= createConfirmationStringForManyElements();
- return Messages.format(pattern, new String[] { String.valueOf(numberOfSelectedElements())});
- }
- } catch (JavaScriptModelException e) {
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setPageComplete(false);
- if (e.isDoesNotExist())
- return RefactoringMessages.DeleteWizard_12;
- return RefactoringMessages.DeleteWizard_2;
- }
- }
-
- public void createControl(Composite parent) {
- super.createControl(parent);
-
- if (getDeleteProcessor().hasSubPackagesToDelete())
- addDeleteSubPackagesCheckBox();
- }
-
- /**
- * Adds the "delete subpackages" checkbox to the composite. Note that
- * this code assumes that the control of the parent is a Composite with
- * GridLayout and a horizontal span of 2.
- *
- * @see MessageWizardPage#createControl(Composite)
- */
- private void addDeleteSubPackagesCheckBox() {
-
- Composite c= new Composite((Composite) getControl(), SWT.NONE);
- GridLayout gd= new GridLayout();
- gd.horizontalSpacing= 10;
- c.setLayout(gd);
-
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan= 2;
- c.setLayoutData(data);
-
- final boolean selection= getRefactoringSettings().getBoolean(DIALOG_SETTINGS_DELETE_SUB_PACKAGES);
-
- fDeleteSubPackagesCheckBox= new Button(c, SWT.CHECK);
- fDeleteSubPackagesCheckBox.setText(RefactoringMessages.DeleteWizard_also_delete_sub_packages);
- fDeleteSubPackagesCheckBox.setSelection(selection);
-
- fDeleteSubPackagesCheckBox.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection());
- }
- });
-
- getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection());
- }
-
- private String getNameOfSingleSelectedElement() throws JavaScriptModelException {
- if (getSingleSelectedResource() != null)
- return ReorgUtils.getName(getSingleSelectedResource());
- else
- return ReorgUtils.getName(getSingleSelectedJavaElement());
- }
-
- private IJavaScriptElement getSingleSelectedJavaElement() {
- IJavaScriptElement[] elements= getSelectedJavaElements();
- return elements.length == 1 ? elements[0] : null;
- }
-
- private IResource getSingleSelectedResource() {
- IResource[] resources= getSelectedResources();
- return resources.length == 1 ? resources[0] : null;
- }
-
- private int numberOfSelectedElements() {
- return getSelectedJavaElements().length + getSelectedResources().length;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizardPage#performFinish()
- */
- protected boolean performFinish() {
- return super.performFinish() || getDeleteProcessor().wasCanceled(); //close the dialog if canceled
- }
-
- protected boolean saveSettings() {
- if (getContainer() instanceof Dialog)
- return ((Dialog) getContainer()).getReturnCode() == IDialogConstants.OK_ID;
- return true;
- }
-
- public void dispose() {
- if (fDeleteSubPackagesCheckBox != null && saveSettings())
- getRefactoringSettings().put(DIALOG_SETTINGS_DELETE_SUB_PACKAGES, fDeleteSubPackagesCheckBox.getSelection());
- super.dispose();
- }
-
- private String createConfirmationStringForOneElement() throws JavaScriptModelException {
- IJavaScriptElement[] elements= getSelectedJavaElements();
- if (elements.length == 1) {
- IJavaScriptElement element= elements[0];
- if (isDefaultPackageWithLinkedFiles(element))
- return RefactoringMessages.DeleteWizard_3;
-
- if (!isLinkedResource(element))
- return RefactoringMessages.DeleteWizard_4;
-
- if (isLinkedPackageOrPackageFragmentRoot(element))
- //XXX workaround for jcore bugs 31998 and 31456 - linked packages or source folders cannot be deleted properly
- return RefactoringMessages.DeleteWizard_6;
-
- return RefactoringMessages.DeleteWizard_5;
- } else {
- if (isLinked(getSelectedResources()[0])) //checked before that this will work
- return RefactoringMessages.DeleteWizard_7;
- else
- return RefactoringMessages.DeleteWizard_8;
- }
- }
-
- private String createConfirmationStringForManyElements() throws JavaScriptModelException {
- IResource[] resources= getSelectedResources();
- IJavaScriptElement[] javaElements= getSelectedJavaElements();
- if (!containsLinkedResources(resources, javaElements))
- return RefactoringMessages.DeleteWizard_9;
-
- if (!containsLinkedPackagesOrPackageFragmentRoots(javaElements))
- return RefactoringMessages.DeleteWizard_10;
-
- //XXX workaround for jcore bugs - linked packages or source folders cannot be deleted properly
- return RefactoringMessages.DeleteWizard_11;
- }
-
- private static boolean isLinkedPackageOrPackageFragmentRoot(IJavaScriptElement element) {
- if ((element instanceof IPackageFragment) || (element instanceof IPackageFragmentRoot))
- return isLinkedResource(element);
- else
- return false;
- }
-
- private static boolean containsLinkedPackagesOrPackageFragmentRoots(IJavaScriptElement[] javaElements) {
- for (int i= 0; i < javaElements.length; i++) {
- IJavaScriptElement element= javaElements[i];
- if (isLinkedPackageOrPackageFragmentRoot(element))
- return true;
- }
- return false;
- }
-
- private static boolean containsLinkedResources(IResource[] resources, IJavaScriptElement[] javaElements) throws JavaScriptModelException {
- for (int i= 0; i < javaElements.length; i++) {
- IJavaScriptElement element= javaElements[i];
- if (isLinkedResource(element))
- return true;
- if (isDefaultPackageWithLinkedFiles(element))
- return true;
- }
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isLinked(resource))
- return true;
- }
- return false;
- }
-
- private static boolean isDefaultPackageWithLinkedFiles(Object firstElement) throws JavaScriptModelException {
- if (!JavaElementUtil.isDefaultPackage(firstElement))
- return false;
- IPackageFragment defaultPackage= (IPackageFragment)firstElement;
- IJavaScriptUnit[] cus= defaultPackage.getJavaScriptUnits();
- for (int i= 0; i < cus.length; i++) {
- if (isLinkedResource(cus[i]))
- return true;
- }
- return false;
- }
-
- private static boolean isLinkedResource(IJavaScriptElement element) {
- return isLinked(ReorgUtils.getResource(element));
- }
-
- private static boolean isLinked(IResource resource) {
- return resource != null && resource.isLinked();
- }
-
- private IJavaScriptElement[] getSelectedJavaElements() {
- return getDeleteProcessor().getJavaElementsToDelete();
- }
-
- private IResource[] getSelectedResources() {
- return getDeleteProcessor().getResourcesToDelete();
- }
-
- private JavaDeleteProcessor getDeleteProcessor() {
- return (JavaDeleteProcessor) ((DeleteRefactoring) getRefactoring()).getProcessor();
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DestinationContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DestinationContentProvider.java
deleted file mode 100644
index 47165a24..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/DestinationContentProvider.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgDestinationValidator;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-
-public final class DestinationContentProvider extends StandardJavaScriptElementContentProvider {
-
- private IReorgDestinationValidator fValidator;
-
- public DestinationContentProvider(IReorgDestinationValidator validator) {
- super(true);
- fValidator= validator;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof IJavaScriptElement){
- IJavaScriptElement javaElement= (IJavaScriptElement) element;
- if (! fValidator.canChildrenBeDestinations(javaElement))
- return false;
- if (javaElement.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT_ROOT){
- if (((IPackageFragmentRoot)javaElement).isArchive())
- return false;
- }
- } else if (element instanceof IResource) {
- IResource resource= (IResource) element;
- if (! fValidator.canChildrenBeDestinations(resource))
- return false;
- }
- return super.hasChildren(element);
- }
-
- public Object[] getChildren(Object element) {
- try {
- if (element instanceof IJavaScriptModel) {
- return concatenate(getJavaProjects((IJavaScriptModel)element), getOpenNonJavaProjects((IJavaScriptModel)element));
- } else {
- Object[] children= doGetChildren(element);
- ArrayList result= new ArrayList(children.length);
- for (int i= 0; i < children.length; i++) {
- if (children[i] instanceof IJavaScriptElement) {
- IJavaScriptElement javaElement= (IJavaScriptElement) children[i];
- if (fValidator.canElementBeDestination(javaElement) || fValidator.canChildrenBeDestinations(javaElement))
- result.add(javaElement);
- } else if (children[i] instanceof IResource) {
- IResource resource= (IResource) children[i];
- if (fValidator.canElementBeDestination(resource) || fValidator.canChildrenBeDestinations(resource))
- result.add(resource);
- }
- }
- return result.toArray();
- }
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return new Object[0];
- }
- }
-
- private Object[] doGetChildren(Object parentElement) {
- if (parentElement instanceof IContainer) {
- final IContainer container= (IContainer) parentElement;
- return getResources(container);
- }
- return super.getChildren(parentElement);
- }
-
- // Copied from supertype
- private Object[] getResources(IContainer container) {
- try {
- IResource[] members= container.members();
- IJavaScriptProject javaProject= JavaScriptCore.create(container.getProject());
- if (javaProject == null || !javaProject.exists())
- return members;
- boolean isFolderOnClasspath = javaProject.isOnIncludepath(container);
- List nonJavaResources= new ArrayList();
- // Can be on classpath but as a member of non-java resource folder
- for (int i= 0; i < members.length; i++) {
- IResource member= members[i];
- // A resource can also be a java element
- // in the case of exclusion and inclusion filters.
- // We therefore exclude Java elements from the list
- // of non-Java resources.
- if (isFolderOnClasspath) {
- if (javaProject.findPackageFragmentRoot(member.getFullPath()) == null) {
- nonJavaResources.add(member);
- }
- } else if (!javaProject.isOnIncludepath(member)) {
- nonJavaResources.add(member);
- }
- }
- return nonJavaResources.toArray();
- } catch(CoreException e) {
- return NO_CHILDREN;
- }
- }
-
- private static Object[] getOpenNonJavaProjects(IJavaScriptModel model) throws JavaScriptModelException {
- Object[] nonJavaProjects= model.getNonJavaScriptResources();
- ArrayList result= new ArrayList(nonJavaProjects.length);
- for (int i= 0; i < nonJavaProjects.length; i++) {
- IProject project = (IProject) nonJavaProjects[i];
- if (project.isOpen())
- result.add(project);
- }
- return result.toArray();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/NewNameQueries.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/NewNameQueries.java
deleted file mode 100644
index 1d72dec9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/NewNameQueries.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.Checks;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamePackageProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.INewNameQueries;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.INewNameQuery;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-
-public class NewNameQueries implements INewNameQueries {
-
- private static final String INVALID_NAME_NO_MESSAGE= "";//$NON-NLS-1$
- private final Wizard fWizard;
- private final Shell fShell;
-
- public NewNameQueries() {
- fShell= null;
- fWizard= null;
- }
-
- public NewNameQueries(Wizard wizard) {
- fWizard= wizard;
- fShell= null;
- }
-
- public NewNameQueries(Shell shell) {
- fShell = shell;
- fWizard= null;
- }
-
- private Shell getShell() {
- Assert.isTrue(fWizard == null || fShell == null);
- if (fWizard != null)
- return fWizard.getContainer().getShell();
-
- if (fShell != null)
- return fShell;
- return JavaScriptPlugin.getActiveWorkbenchShell();
- }
-
- public INewNameQuery createNewCompilationUnitNameQuery(IJavaScriptUnit cu, String initialSuggestedName) {
- String[] keys= {JavaScriptCore.removeJavaScriptLikeExtension(cu.getElementName())};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
- return createStaticQuery(createCompilationUnitNameValidator(cu), message, initialSuggestedName, getShell());
- }
-
-
- public INewNameQuery createNewResourceNameQuery(IResource res, String initialSuggestedName) {
- String[] keys= {res.getName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
- return createStaticQuery(createResourceNameValidator(res), message, initialSuggestedName, getShell());
- }
-
-
- public INewNameQuery createNewPackageNameQuery(IPackageFragment pack, String initialSuggestedName) {
- String[] keys= {pack.getElementName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
- return createStaticQuery(createPackageNameValidator(pack), message, initialSuggestedName, getShell());
- }
-
- public INewNameQuery createNewPackageFragmentRootNameQuery(IPackageFragmentRoot root, String initialSuggestedName) {
- String[] keys= {root.getElementName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
- return createStaticQuery(createPackageFragmentRootNameValidator(root), message, initialSuggestedName, getShell());
- }
-
-
- public INewNameQuery createNullQuery(){
- return createStaticQuery(null);
- }
-
-
- public INewNameQuery createStaticQuery(final String newName){
- return new INewNameQuery(){
- public String getNewName() {
- return newName;
- }
- };
- }
-
- private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){
- return new INewNameQuery(){
- public String getNewName() throws OperationCanceledException {
- InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) {
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Control area= super.createDialogArea(parent);
- TextFieldNavigationHandler.install(getText());
- return area;
- }
- };
- if (dialog.open() == Window.CANCEL)
- throw new OperationCanceledException();
- return dialog.getValue();
- }
- };
- }
-
- private static IInputValidator createResourceNameValidator(final IResource res){
- IInputValidator validator= new IInputValidator(){
- public String isValid(String newText) {
- if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
- return INVALID_NAME_NO_MESSAGE;
- if (res.getParent().findMember(newText) != null)
- return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
- if (! res.getParent().getFullPath().isValidSegment(newText))
- return ReorgMessages.ReorgQueries_invalidNameMessage;
- IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
- if (status.getSeverity() == IStatus.ERROR)
- return status.getMessage();
-
- if (res.getName().equalsIgnoreCase(newText))
- return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
-
- return null;
- }
- };
- return validator;
- }
-
- private static IInputValidator createCompilationUnitNameValidator(final IJavaScriptUnit cu) {
- IInputValidator validator= new IInputValidator(){
- public String isValid(String newText) {
- if (newText == null || "".equals(newText)) //$NON-NLS-1$
- return INVALID_NAME_NO_MESSAGE;
- String newCuName= JavaModelUtil.getRenamedCUName(cu, newText);
- IStatus status= JavaScriptConventions.validateCompilationUnitName(newCuName);
- if (status.getSeverity() == IStatus.ERROR)
- return status.getMessage();
- RefactoringStatus refStatus;
- refStatus= Checks.checkCompilationUnitNewName(cu, newText);
- if (refStatus.hasFatalError())
- return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL);
-
- if (cu.getElementName().equalsIgnoreCase(newCuName))
- return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
-
- return null;
- }
- };
- return validator;
- }
-
-
- private static IInputValidator createPackageFragmentRootNameValidator(final IPackageFragmentRoot root) {
- return new IInputValidator() {
- IInputValidator resourceNameValidator= createResourceNameValidator(root.getResource());
- public String isValid(String newText) {
- return resourceNameValidator.isValid(newText);
- }
- };
- }
-
- private static IInputValidator createPackageNameValidator(final IPackageFragment pack) {
- IInputValidator validator= new IInputValidator(){
- public String isValid(String newText) {
- if (newText == null || "".equals(newText)) //$NON-NLS-1$
- return INVALID_NAME_NO_MESSAGE;
- IStatus status= JavaScriptConventions.validatePackageName(newText);
- if (status.getSeverity() == IStatus.ERROR)
- return status.getMessage();
-
- IJavaScriptElement parent= pack.getParent();
- try {
- if (parent instanceof IPackageFragmentRoot){
- if (! RenamePackageProcessor.isPackageNameOkInRoot(newText, (IPackageFragmentRoot)parent))
- return ReorgMessages.ReorgQueries_packagewithThatNameexistsMassage;
- }
- } catch (CoreException e) {
- return INVALID_NAME_NO_MESSAGE;
- }
- if (pack.getElementName().equalsIgnoreCase(newText))
- return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
-
- return null;
- }
- };
- return validator;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/PasteAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/PasteAction.java
deleted file mode 100644
index 66d502b6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/PasteAction.java
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-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.IWorkspaceRunnable;
-import org.eclipse.core.runtime.Assert;
-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.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
-import org.eclipse.ui.actions.CopyProjectOperation;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IPackageDeclaration;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTParser;
-import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
-import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.Checks;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.TypedSource;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.CompilationUnitChange;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.changes.TextChangeCompatibility;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IConfirmQuery;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgQueries;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaElementTransfer;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ParentChecker;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.RefactoringFileBuffers;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.ResourceUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringExecutionHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSaveHelper;
-import org.eclipse.wst.jsdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SelectionUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
-import org.eclipse.wst.jsdt.internal.ui.workingsets.OthersWorkingSetUpdater;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-
-public class PasteAction extends SelectionDispatchAction{
-
- private final Clipboard fClipboard;
-
- public PasteAction(IWorkbenchSite site, Clipboard clipboard) {
- super(site);
- Assert.isNotNull(clipboard);
- fClipboard= clipboard;
-
- setText(ReorgMessages.PasteAction_4);
- setDescription(ReorgMessages.PasteAction_5);
-
- ISharedImages workbenchImages= JavaScriptPlugin.getDefault().getWorkbench().getSharedImages();
- setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
- setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
- setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.PASTE_ACTION);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- // Moved condition checking to run (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=78450)
- }
-
- private Paster[] createEnabledPasters(TransferData[] availableDataTypes) throws JavaScriptModelException {
- Paster paster;
- Shell shell = getShell();
- List result= new ArrayList(2);
- paster= new ProjectPaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
-
- paster= new JavaElementAndResourcePaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
-
- paster= new TypedSourcePaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
-
- paster= new FilePaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
-
- paster= new WorkingSetPaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
-
- paster= new TextPaster(shell, fClipboard);
- if (paster.canEnable(availableDataTypes))
- result.add(paster);
- return (Paster[]) result.toArray(new Paster[result.size()]);
- }
-
- private static Object getContents(final Clipboard clipboard, final Transfer transfer, Shell shell) {
- //see bug 33028 for explanation why we need this
- final Object[] result= new Object[1];
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0]= clipboard.getContents(transfer);
- }
- });
- return result[0];
- }
-
- private static boolean isAvailable(Transfer transfer, TransferData[] availableDataTypes) {
- for (int i= 0; i < availableDataTypes.length; i++) {
- if (transfer.isSupportedType(availableDataTypes[i])) return true;
- }
- return false;
- }
-
- public void run(IStructuredSelection selection) {
- try {
- TransferData[] availableTypes= fClipboard.getAvailableTypes();
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- IWorkingSet[] workingSets= ReorgUtils.getWorkingSets(elements);
- Paster[] pasters= createEnabledPasters(availableTypes);
- for (int i= 0; i < pasters.length; i++) {
- if (pasters[i].canPasteOn(javaElements, resources, workingSets)) {
- pasters[i].paste(javaElements, resources, workingSets, availableTypes);
- return;// one is enough
- }
- }
- String msg= resources.length + javaElements.length + workingSets.length == 0
- ? ReorgMessages.PasteAction_cannot_no_selection
- : ReorgMessages.PasteAction_cannot_selection;
- MessageDialog.openError(JavaScriptPlugin.getActiveWorkbenchShell(), ReorgMessages.PasteAction_name, msg);
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- } catch (InterruptedException e) {
- // OK
- }
- }
-
- private abstract static class Paster{
- private final Shell fShell;
- private final Clipboard fClipboard2;
- protected Paster(Shell shell, Clipboard clipboard){
- fShell= shell;
- fClipboard2= clipboard;
- }
- protected final Shell getShell() {
- return fShell;
- }
- protected final Clipboard getClipboard() {
- return fClipboard2;
- }
-
- protected final IResource[] getClipboardResources(TransferData[] availableDataTypes) {
- Transfer transfer= ResourceTransfer.getInstance();
- if (isAvailable(transfer, availableDataTypes)) {
- return (IResource[])getContents(fClipboard2, transfer, getShell());
- }
- return null;
- }
-
- protected final IJavaScriptElement[] getClipboardJavaElements(TransferData[] availableDataTypes) {
- Transfer transfer= JavaElementTransfer.getInstance();
- if (isAvailable(transfer, availableDataTypes)) {
- return (IJavaScriptElement[])getContents(fClipboard2, transfer, getShell());
- }
- return null;
- }
-
- protected final TypedSource[] getClipboardTypedSources(TransferData[] availableDataTypes) {
- Transfer transfer= TypedSourceTransfer.getInstance();
- if (isAvailable(transfer, availableDataTypes)) {
- return (TypedSource[])getContents(fClipboard2, transfer, getShell());
- }
- return null;
- }
-
- protected final String getClipboardText(TransferData[] availableDataTypes) {
- Transfer transfer= TextTransfer.getInstance();
- if (isAvailable(transfer, availableDataTypes)) {
- return (String) getContents(fClipboard2, transfer, getShell());
- }
- return null;
- }
-
- /**
- * Used to be called on selection change, but is only called on execution now
- * (before {@link #canPasteOn(IJavaScriptElement[], IResource[], IWorkingSet[])}).
- * @param availableTypes transfer types
- * @return whether the paste action can be enabled
- * @throws JavaScriptModelException
- */
- public abstract boolean canEnable(TransferData[] availableTypes) throws JavaScriptModelException;
-
- /**
- * Only called if {@link #canEnable(TransferData[])} returns <code>true</code>.
- * @param selectedJavaElements
- * @param selectedResources
- * @param selectedWorkingSets
- * @return whether the paste action can be enabled
- * @throws JavaScriptModelException
- */
- public abstract boolean canPasteOn(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException;
-
- /**
- * only called if {@link #canPasteOn(IJavaScriptElement[], IResource[], IWorkingSet[])} returns <code>true</code>
- * @param selectedJavaElements
- * @param selectedResources
- * @param selectedWorkingSets
- * @param availableTypes
- * @throws JavaScriptModelException
- * @throws InterruptedException
- * @throws InvocationTargetException
- */
- public abstract void paste(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException, InterruptedException, InvocationTargetException;
- }
-
- private static class TextPaster extends Paster {
-
- private static class ParsedCu {
- private final String fText;
- private final String fTypeName;
- private final String fPackageName;
-
- public static ParsedCu[] parse(IJavaScriptProject javaProject, String text) {
- IScanner scanner= ToolFactory.createScanner(false, false, false, false);
- scanner.setSource(text.toCharArray());
-
- ArrayList cus= new ArrayList();
- int start= 0;
- boolean tokensScanned= false;
- int tok;
- while (true) {
- try {
- tok= scanner.getNextToken();
- } catch (InvalidInputException e) {
- // Handle gracefully to give the ASTParser a chance to recover,
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=168691
- tok= ITerminalSymbols.TokenNameEOF;
- }
- if (tok == ITerminalSymbols.TokenNamepackage && tokensScanned) {
- int packageStart= scanner.getCurrentTokenStartPosition();
- ParsedCu cu= parseCu(javaProject, text.substring(start, packageStart));
- if (cu != null) {
- cus.add(cu);
- start= packageStart;
- }
- } else if (tok == ITerminalSymbols.TokenNameEOF) {
- ParsedCu cu= parseCu(javaProject, text.substring(start, text.length()));
- if (cu != null) {
- cus.add(cu);
- }
- break;
- }
- tokensScanned= true;
- }
-
- return (ParsedCu[]) cus.toArray(new ParsedCu[cus.size()]);
- }
-
- private static ParsedCu parseCu(IJavaScriptProject javaProject, String text) {
- String packageName= IPackageFragment.DEFAULT_PACKAGE_NAME;
- ASTParser parser= ASTParser.newParser(AST.JLS3);
- parser.setProject(javaProject);
- parser.setSource(text.toCharArray());
- parser.setStatementsRecovery(true);
- JavaScriptUnit unit= (JavaScriptUnit) parser.createAST(null);
-
- if (unit == null)
- return null;
-
- int typesCount= unit.types().size();
- String typeName= null;
- if (typesCount > 0) {
- // get first most visible type:
- int maxVisibility= Modifier.PRIVATE;
- for (ListIterator iter= unit.types().listIterator(typesCount); iter.hasPrevious();) {
- AbstractTypeDeclaration type= (AbstractTypeDeclaration) iter.previous();
- int visibility= JdtFlags.getVisibilityCode(type);
- if (! JdtFlags.isHigherVisibility(maxVisibility, visibility)) {
- maxVisibility= visibility;
- typeName= type.getName().getIdentifier();
- }
- }
- }
- if (typeName == null)
- return null;
-
- PackageDeclaration pack= unit.getPackage();
- if (pack != null) {
- packageName= pack.getName().getFullyQualifiedName();
- }
-
- return new ParsedCu(text, typeName, packageName);
- }
-
- private ParsedCu(String text, String typeName, String packageName) {
- fText= text;
- fTypeName= typeName;
- fPackageName= packageName;
- }
-
- public String getTypeName() {
- return fTypeName;
- }
-
- public String getPackageName() {
- return fPackageName;
- }
-
- public String getText() {
- return fText;
- }
- }
-
- private IPackageFragmentRoot fDestination;
- /**
- * destination pack iff pasted 1 CU to package fragment or compilation unit, <code>null</code> otherwise
- */
- private IPackageFragment fDestinationPack;
- private ParsedCu[] fParsedCus;
- private TransferData[] fAvailableTypes;
-
- protected TextPaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
-
- public boolean canEnable(TransferData[] availableTypes) {
- fAvailableTypes= availableTypes;
- return PasteAction.isAvailable(TextTransfer.getInstance(), availableTypes);
- }
-
- public boolean canPasteOn(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException {
- if (selectedWorkingSets.length != 0)
- return false;
- if (resources.length != 0)
- return false; //alternative: create text file?
- if (javaElements.length > 1)
- return false;
-
- String text= getClipboardText(fAvailableTypes);
- IJavaScriptProject javaProject= null;
- IJavaScriptElement destination= null;
- if (javaElements.length == 1) {
- destination= javaElements[0];
- javaProject= destination.getJavaScriptProject();
- }
- fParsedCus= ParsedCu.parse(javaProject, text);
-
- if (fParsedCus.length == 0)
- return false;
-
- if (destination == null)
- return true;
-
- /*
- * 1 CU: paste into package, adapt package declaration
- * 2+ CUs: always paste into source folder
- */
-
- IPackageFragmentRoot packageFragmentRoot;
- IPackageFragment destinationPack;
- switch (destination.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- IPackageFragmentRoot[] packageFragmentRoots= ((IJavaScriptProject) destination).getPackageFragmentRoots();
- for (int i= 0; i < packageFragmentRoots.length; i++) {
- packageFragmentRoot= packageFragmentRoots[i];
- if (isWritable(packageFragmentRoot)) {
- fDestination= packageFragmentRoot;
- return true;
- }
- }
- return false;
-
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- packageFragmentRoot= (IPackageFragmentRoot) destination;
- if (isWritable(packageFragmentRoot)) {
- fDestination= packageFragmentRoot;
- return true;
- }
- return false;
-
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- destinationPack= (IPackageFragment) destination;
- packageFragmentRoot= (IPackageFragmentRoot) destinationPack.getParent();
- if (isWritable(packageFragmentRoot)) {
- fDestination= packageFragmentRoot;
- if (fParsedCus.length == 1) {
- fDestinationPack= destinationPack;
- }
- return true;
- }
- return false;
-
- case IJavaScriptElement.JAVASCRIPT_UNIT :
- destinationPack= (IPackageFragment) destination.getParent();
- packageFragmentRoot= (IPackageFragmentRoot) destinationPack.getParent();
- if (isWritable(packageFragmentRoot)) {
- fDestination= packageFragmentRoot;
- if (fParsedCus.length == 1) {
- fDestinationPack= destinationPack;
- }
- return true;
- }
- return false;
-
- default:
- return false;
- }
- }
-
- private boolean isWritable(IPackageFragmentRoot packageFragmentRoot) {
- try {
- return packageFragmentRoot.exists() && ! packageFragmentRoot.isArchive() && ! packageFragmentRoot.isReadOnly()
- && packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE;
- } catch (JavaScriptModelException e) {
- return false;
- }
- }
-
- public void paste(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException, InterruptedException, InvocationTargetException{
- final IEditorPart[] editorPart= new IEditorPart[1];
-
- IRunnableWithProgress op= new IRunnableWithProgress() {
- private IPath fVMPath;
- private String fCompilerCompliance;
-
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- final ArrayList cus= new ArrayList();
- try {
- JavaScriptCore.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- pm.beginTask("", 1 + fParsedCus.length); //$NON-NLS-1$
-
- if (fDestination == null) {
- fDestination= createNewProject(new SubProgressMonitor(pm, 1));
- } else {
- pm.worked(1);
- }
- IConfirmQuery confirmQuery= new ReorgQueries(getShell()).createYesYesToAllNoNoToAllQuery(ReorgMessages.PasteAction_TextPaster_confirmOverwriting, true, IReorgQueries.CONFIRM_OVERWRITING);
- for (int i= 0; i < fParsedCus.length; i++) {
- if (pm.isCanceled())
- break;
- IJavaScriptUnit cu= pasteCU(fParsedCus[i], new SubProgressMonitor(pm, 1), confirmQuery);
- if (cu != null)
- cus.add(cu);
- }
-
- }
- }, monitor);
- } catch (OperationCanceledException e) {
- // cancelling is fine
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- IResource[] cuResources= ResourceUtil.getFiles((IJavaScriptUnit[]) cus.toArray(new IJavaScriptUnit[cus.size()]));
- SelectionUtil.selectAndReveal(cuResources, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
-
- private IJavaScriptUnit pasteCU(ParsedCu parsedCu, SubProgressMonitor pm, IConfirmQuery confirmQuery) throws CoreException, OperationCanceledException {
- pm.beginTask("", 4); //$NON-NLS-1$
- try {
- IPackageFragment destinationPack;
- if (fDestinationPack != null) {
- destinationPack= fDestinationPack;
- pm.worked(1);
- } else {
- String packageName= parsedCu.getPackageName();
- destinationPack= fDestination.getPackageFragment(packageName);
- if (! destinationPack.exists()) {
- JavaModelUtil.getPackageFragmentRoot(destinationPack).createPackageFragment(packageName, true, new SubProgressMonitor(pm, 1));
- } else {
- pm.worked(1);
- }
- }
-
- final String cuName= parsedCu.getTypeName() + JavaModelUtil.DEFAULT_CU_SUFFIX;
- IJavaScriptUnit cu= destinationPack.getJavaScriptUnit(cuName);
- boolean alreadyExists= cu.exists();
- if (alreadyExists) {
- String msg= Messages.format(ReorgMessages.PasteAction_TextPaster_exists, new Object[] {cuName});
- boolean overwrite= confirmQuery.confirm(msg);
- if (! overwrite)
- return null;
-
- editorPart[0]= openCu(cu); //Open editor before overwriting to allow undo to restore original package declaration
- }
-
- destinationPack.createCompilationUnit(cuName, parsedCu.getText(), true, new SubProgressMonitor(pm, 1));
-
- if (! alreadyExists) {
- editorPart[0]= openCu(cu);
- }
- if (fDestinationPack != null && ! fDestinationPack.getElementName().equals(parsedCu.getPackageName())) {
- if (fDestinationPack.getElementName().length() == 0) {
- removePackageDeclaration(cu);
- } else {
- cu.createPackageDeclaration(fDestinationPack.getElementName(), new SubProgressMonitor(pm, 1));
- }
- if (! alreadyExists && editorPart[0] != null)
- editorPart[0].doSave(new SubProgressMonitor(pm, 1)); //avoid showing error marker due to missing/wrong package declaration
- else
- pm.worked(1);
- } else {
- pm.worked(1);
- }
- return cu;
- } finally {
- pm.done();
- }
- }
-
- private IPackageFragmentRoot createNewProject(SubProgressMonitor pm) throws CoreException {
- pm.beginTask("", 10); //$NON-NLS-1$
- IProject project;
- int i= 1;
- do {
- String name= Messages.format(ReorgMessages.PasteAction_projectName, i == 1 ? (Object) "" : new Integer(i)); //$NON-NLS-1$
- project= JavaScriptPlugin.getWorkspace().getRoot().getProject(name);
- i++;
- } while (project.exists());
-
- BuildPathsBlock.createProject(project, null, new SubProgressMonitor(pm, 3));
- BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(pm, 1));
- IJavaScriptProject javaProject= JavaScriptCore.create(project);
-
- IResource srcFolder;
- IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- String sourceFolderName= store.getString(PreferenceConstants.SRCBIN_SRCNAME);
- if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ) && sourceFolderName.length() > 0) {
- IFolder folder= project.getFolder(sourceFolderName);
- if (! folder.exists()) {
- folder.create(false, true, new SubProgressMonitor(pm, 1));
- }
- srcFolder= folder;
- } else {
- srcFolder= project;
- }
-
- computeLatestVM();
- if (fCompilerCompliance != null) {
- Map options= javaProject.getOptions(false);
- JavaModelUtil.setCompilanceOptions(options, fCompilerCompliance);
- JavaModelUtil.setDefaultClassfileOptions(options, fCompilerCompliance);
- javaProject.setOptions(options);
- }
- IIncludePathEntry srcEntry= JavaScriptCore.newSourceEntry(srcFolder.getFullPath());
- IIncludePathEntry jreEntry= JavaScriptCore.newContainerEntry(fVMPath);
- //IPath outputLocation= BuildPathsBlock.getDefaultOutputLocation(javaProject);
- IIncludePathEntry[] cpes= new IIncludePathEntry[] { srcEntry, jreEntry };
- javaProject.setRawIncludepath(cpes, null, new SubProgressMonitor(pm, 1));
- return javaProject.getPackageFragmentRoot(srcFolder);
- }
-
- private void computeLatestVM() {
-// IVMInstall bestVM= JavaRuntime.getDefaultVMInstall();
-// String bestVersion= getVMVersion(bestVM);
-//
-// IExecutionEnvironmentsManager eeManager= JavaRuntime.getExecutionEnvironmentsManager();
-// IExecutionEnvironment bestEE= null;
-//
-// IExecutionEnvironment[] ees= eeManager.getExecutionEnvironments();
-// for (int j= 0; j < ees.length; j++) {
-// IExecutionEnvironment ee= ees[j];
-// IVMInstall vm= ee.getDefaultVM();
-// String ver= getVMVersion(vm);
-// if (ver != null && (bestVersion == null || JavaModelUtil.isVersionLessThan(bestVersion, ver))) {
-// bestVersion= ver;
-// bestEE= ee;
-// }
-// }
-//
-// IVMInstallType[] vmTypes= JavaRuntime.getVMInstallTypes();
-// for (int i= 0; i < vmTypes.length; i++) {
-// IVMInstall[] vms= vmTypes[i].getVMInstalls();
-// for (int j= 0; j < vms.length; j++) {
-// IVMInstall vm= vms[j];
-// String ver= getVMVersion(vm);
-// if (ver != null && (bestVersion == null || JavaModelUtil.isVersionLessThan(bestVersion, ver))) {
-// bestVersion= ver;
-// bestVM= vm;
-// bestEE= null;
-// }
-// }
-// }
-//
-// if (bestEE != null) {
-// fVMPath= JavaRuntime.newJREContainerPath(bestEE);
-// fCompilerCompliance= bestVersion;
-// } else if (bestVM != null) {
-// fVMPath= JavaRuntime.newJREContainerPath(bestVM);
-// fCompilerCompliance= bestVersion;
-// } else {
-// fVMPath= JavaRuntime.newDefaultJREContainerPath();
-// }
- }
-
-// private String getVMVersion(IVMInstall vm) {
-// if (vm instanceof IVMInstall2) {
-// IVMInstall2 vm2= (IVMInstall2) vm;
-// return JavaModelUtil.getCompilerCompliance(vm2, null);
-// } else {
-// return null;
-// }
-// }
-
- private void removePackageDeclaration(final IJavaScriptUnit cu) throws JavaScriptModelException, CoreException {
- IPackageDeclaration[] packageDeclarations= cu.getPackageDeclarations();
- if (packageDeclarations.length != 0) {
- ITextFileBuffer buffer= null;
- try {
- buffer= RefactoringFileBuffers.acquire(cu);
- ISourceRange sourceRange= packageDeclarations[0].getSourceRange();
- buffer.getDocument().replace(sourceRange.getOffset(), sourceRange.getLength(), ""); //$NON-NLS-1$
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- } finally {
- if (buffer != null)
- RefactoringFileBuffers.release(cu);
- }
- }
- }
- };
-
- IRunnableContext context= JavaScriptPlugin.getActiveWorkbenchWindow();
- if (context == null) {
- context= new BusyIndicatorRunnableContext();
- }
- PlatformUI.getWorkbench().getProgressService().runInUI(context, op, JavaScriptPlugin.getWorkspace().getRoot());
-
- if (editorPart[0] != null)
- editorPart[0].getEditorSite().getPage().activate(editorPart[0]); //activate editor again, since runInUI restores previous active part
- }
-
- private IEditorPart openCu(IJavaScriptUnit cu) {
- try {
- return JavaScriptUI.openInEditor(cu, true, true);
- } catch (PartInitException e) {
- JavaScriptPlugin.log(e);
- return null;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- return null;
- }
- }
- }
-
- private static class WorkingSetPaster extends Paster {
- protected WorkingSetPaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
- public void paste(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException, InterruptedException, InvocationTargetException {
- IWorkingSet workingSet= selectedWorkingSets[0];
- Set elements= new HashSet(Arrays.asList(workingSet.getElements()));
- IJavaScriptElement[] javaElements= getClipboardJavaElements(availableTypes);
- if (javaElements != null) {
- for (int i= 0; i < javaElements.length; i++) {
- if (!ReorgUtils.containsElementOrParent(elements, javaElements[i]))
- elements.add(javaElements[i]);
- }
- }
- IResource[] resources= getClipboardResources(availableTypes);
- if (resources != null) {
- List realJavaElements= new ArrayList();
- List realResource= new ArrayList();
- ReorgUtils.splitIntoJavaElementsAndResources(resources, realJavaElements, realResource);
- for (Iterator iter= realJavaElements.iterator(); iter.hasNext();) {
- IJavaScriptElement element= (IJavaScriptElement)iter.next();
- if (!ReorgUtils.containsElementOrParent(elements, element))
- elements.add(element);
- }
- for (Iterator iter= realResource.iterator(); iter.hasNext();) {
- IResource element= (IResource)iter.next();
- if (!ReorgUtils.containsElementOrParent(elements, element))
- elements.add(element);
- }
- }
- workingSet.setElements((IAdaptable[])elements.toArray(new IAdaptable[elements.size()]));
- }
- public boolean canEnable(TransferData[] availableTypes) throws JavaScriptModelException {
- return isAvailable(ResourceTransfer.getInstance(), availableTypes) ||
- isAvailable(JavaElementTransfer.getInstance(), availableTypes);
- }
- public boolean canPasteOn(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException {
- if (selectedResources.length != 0 || selectedJavaElements.length != 0 || selectedWorkingSets.length != 1)
- return false;
- IWorkingSet ws= selectedWorkingSets[0];
- return !OthersWorkingSetUpdater.ID.equals(ws.getId());
- }
- }
-
- private static class ProjectPaster extends Paster{
-
- protected ProjectPaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
-
- public boolean canEnable(TransferData[] availableDataTypes) {
- boolean resourceTransfer= isAvailable(ResourceTransfer.getInstance(), availableDataTypes);
- boolean javaElementTransfer= isAvailable(JavaElementTransfer.getInstance(), availableDataTypes);
- if (! javaElementTransfer)
- return canPasteSimpleProjects(availableDataTypes);
- if (! resourceTransfer)
- return canPasteJavaProjects(availableDataTypes);
- return canPasteJavaProjects(availableDataTypes) && canPasteSimpleProjects(availableDataTypes);
- }
-
- public void paste(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) {
- pasteProjects(availableTypes);
- }
-
- private void pasteProjects(TransferData[] availableTypes) {
- pasteProjects(getProjectsToPaste(availableTypes));
- }
-
- private void pasteProjects(IProject[] projects){
- Shell shell= getShell();
- for (int i = 0; i < projects.length; i++) {
- new CopyProjectOperation(shell).copyProject(projects[i]);
- }
- }
- private IProject[] getProjectsToPaste(TransferData[] availableTypes) {
- IResource[] resources= getClipboardResources(availableTypes);
- IJavaScriptElement[] javaElements= getClipboardJavaElements(availableTypes);
- Set result= new HashSet();
- if (resources != null)
- result.addAll(Arrays.asList(resources));
- if (javaElements != null)
- result.addAll(Arrays.asList(ReorgUtils.getNotNulls(ReorgUtils.getResources(javaElements))));
- Assert.isTrue(result.size() > 0);
- return (IProject[]) result.toArray(new IProject[result.size()]);
- }
-
- public boolean canPasteOn(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets) {
- return selectedWorkingSets.length == 0; // Can't paste on working sets here
- }
-
- private boolean canPasteJavaProjects(TransferData[] availableDataTypes) {
- IJavaScriptElement[] javaElements= getClipboardJavaElements(availableDataTypes);
- return javaElements != null &&
- javaElements.length != 0 &&
- ! ReorgUtils.hasElementsNotOfType(javaElements, IJavaScriptElement.JAVASCRIPT_PROJECT);
- }
-
- private boolean canPasteSimpleProjects(TransferData[] availableDataTypes) {
- IResource[] resources= getClipboardResources(availableDataTypes);
- if (resources == null || resources.length == 0) return false;
- for (int i= 0; i < resources.length; i++) {
- if (resources[i].getType() != IResource.PROJECT || ! ((IProject)resources[i]).isOpen())
- return false;
- }
- return true;
- }
- }
-
- private static class FilePaster extends Paster{
- protected FilePaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
-
- public void paste(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException {
- String[] fileData= getClipboardFiles(availableTypes);
- if (fileData == null)
- return;
-
- IContainer container= getAsContainer(getTarget(javaElements, resources));
- if (container == null)
- return;
-
- new CopyFilesAndFoldersOperation(getShell()).copyFiles(fileData, container);
- }
-
- private Object getTarget(IJavaScriptElement[] javaElements, IResource[] resources) {
- if (javaElements.length + resources.length == 1){
- if (javaElements.length == 1)
- return javaElements[0];
- else
- return resources[0];
- } else
- return getCommonParent(javaElements, resources);
- }
-
- public boolean canPasteOn(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException {
- Object target= getTarget(javaElements, resources);
- return target != null && canPasteFilesOn(getAsContainer(target)) && selectedWorkingSets.length == 0;
- }
-
- public boolean canEnable(TransferData[] availableDataTypes) throws JavaScriptModelException {
- return isAvailable(FileTransfer.getInstance(), availableDataTypes);
- }
-
- private boolean canPasteFilesOn(Object target) {
- boolean isPackageFragment= target instanceof IPackageFragment;
- boolean isJavaProject= target instanceof IJavaScriptProject;
- boolean isPackageFragmentRoot= target instanceof IPackageFragmentRoot;
- boolean isContainer= target instanceof IContainer;
-
- if (!(isPackageFragment || isJavaProject || isPackageFragmentRoot || isContainer))
- return false;
-
- if (isContainer) {
- return true;
- } else {
- IJavaScriptElement element= (IJavaScriptElement)target;
- return !element.isReadOnly();
- }
- }
-
- private IContainer getAsContainer(Object target) throws JavaScriptModelException{
- if (target == null)
- return null;
- if (target instanceof IContainer)
- return (IContainer)target;
- if (target instanceof IFile)
- return ((IFile)target).getParent();
- return getAsContainer(((IJavaScriptElement)target).getCorrespondingResource());
- }
-
- private String[] getClipboardFiles(TransferData[] availableDataTypes) {
- Transfer transfer= FileTransfer.getInstance();
- if (isAvailable(transfer, availableDataTypes)) {
- return (String[])getContents(getClipboard(), transfer, getShell());
- }
- return null;
- }
- private Object getCommonParent(IJavaScriptElement[] javaElements, IResource[] resources) {
- return new ParentChecker(resources, javaElements).getCommonParent();
- }
- }
- private static class JavaElementAndResourcePaster extends Paster {
-
- protected JavaElementAndResourcePaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
-
- private TransferData[] fAvailableTypes;
-
- public void paste(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException, InterruptedException, InvocationTargetException{
- IResource[] clipboardResources= getClipboardResources(availableTypes);
- if (clipboardResources == null)
- clipboardResources= new IResource[0];
- IJavaScriptElement[] clipboardJavaElements= getClipboardJavaElements(availableTypes);
- if (clipboardJavaElements == null)
- clipboardJavaElements= new IJavaScriptElement[0];
-
- Object destination= getTarget(javaElements, resources);
- if (destination instanceof IJavaScriptElement)
- ReorgCopyStarter.create(clipboardJavaElements, clipboardResources, (IJavaScriptElement)destination).run(getShell());
- else if (destination instanceof IResource)
- ReorgCopyStarter.create(clipboardJavaElements, clipboardResources, (IResource)destination).run(getShell());
- }
-
- private Object getTarget(IJavaScriptElement[] javaElements, IResource[] resources) {
- if (javaElements.length + resources.length == 1){
- if (javaElements.length == 1)
- return javaElements[0];
- else
- return resources[0];
- } else
- return getCommonParent(javaElements, resources);
- }
-
- private Object getCommonParent(IJavaScriptElement[] javaElements, IResource[] resources) {
- return new ParentChecker(resources, javaElements).getCommonParent();
- }
-
- public boolean canPasteOn(IJavaScriptElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException {
- if (selectedWorkingSets.length != 0)
- return false;
- IResource[] clipboardResources= getClipboardResources(fAvailableTypes);
- if (clipboardResources == null)
- clipboardResources= new IResource[0];
- IJavaScriptElement[] clipboardJavaElements= getClipboardJavaElements(fAvailableTypes);
- if (clipboardJavaElements == null)
- clipboardJavaElements= new IJavaScriptElement[0];
- Object destination= getTarget(javaElements, resources);
- if (destination instanceof IJavaScriptElement)
- return ReorgCopyStarter.create(clipboardJavaElements, clipboardResources, (IJavaScriptElement)destination) != null;
- if (destination instanceof IResource)
- return ReorgCopyStarter.create(clipboardJavaElements, clipboardResources, (IResource)destination) != null;
- return false;
- }
-
- public boolean canEnable(TransferData[] availableTypes) {
- fAvailableTypes= availableTypes;
- return isAvailable(JavaElementTransfer.getInstance(), availableTypes) || isAvailable(ResourceTransfer.getInstance(), availableTypes);
- }
- }
-
- private static class TypedSourcePaster extends Paster{
-
- protected TypedSourcePaster(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
- private TransferData[] fAvailableTypes;
-
- public boolean canEnable(TransferData[] availableTypes) throws JavaScriptModelException {
- fAvailableTypes= availableTypes;
- return isAvailable(TypedSourceTransfer.getInstance(), availableTypes);
- }
-
- public boolean canPasteOn(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets) throws JavaScriptModelException {
- if (selectedResources.length != 0 || selectedWorkingSets.length != 0)
- return false;
- TypedSource[] typedSources= getClipboardTypedSources(fAvailableTypes);
- Object destination= getTarget(selectedJavaElements, selectedResources);
- if (destination instanceof IJavaScriptElement)
- return ReorgTypedSourcePasteStarter.create(typedSources, (IJavaScriptElement)destination) != null;
- return false;
- }
-
- public void paste(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaScriptModelException, InterruptedException, InvocationTargetException {
- TypedSource[] typedSources= getClipboardTypedSources(availableTypes);
- IJavaScriptElement destination= getTarget(selectedJavaElements, selectedResources);
- ReorgTypedSourcePasteStarter.create(typedSources, destination).run(getShell());
- }
-
- private static IJavaScriptElement getTarget(IJavaScriptElement[] selectedJavaElements, IResource[] selectedResources) {
- Assert.isTrue(selectedResources.length == 0);
- if (selectedJavaElements.length == 1)
- return getAsTypeOrCu(selectedJavaElements[0]);
- Object parent= new ParentChecker(selectedResources, selectedJavaElements).getCommonParent();
- if (parent instanceof IJavaScriptElement)
- return getAsTypeOrCu((IJavaScriptElement)parent);
- return null;
- }
- private static IJavaScriptElement getAsTypeOrCu(IJavaScriptElement element) {
- //try to get type first
- if (element.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT || element.getElementType() == IJavaScriptElement.TYPE)
- return element;
- IJavaScriptElement ancestorType= element.getAncestor(IJavaScriptElement.TYPE);
- if (ancestorType != null)
- return ancestorType;
- return ReorgUtils.getCompilationUnit(element);
- }
- private static class ReorgTypedSourcePasteStarter {
-
- private final PasteTypedSourcesRefactoring fPasteRefactoring;
-
- private ReorgTypedSourcePasteStarter(PasteTypedSourcesRefactoring pasteRefactoring) {
- Assert.isNotNull(pasteRefactoring);
- fPasteRefactoring= pasteRefactoring;
- }
-
- public static ReorgTypedSourcePasteStarter create(TypedSource[] typedSources, IJavaScriptElement destination) {
- Assert.isNotNull(typedSources);
- Assert.isNotNull(destination);
- PasteTypedSourcesRefactoring pasteRefactoring= PasteTypedSourcesRefactoring.create(typedSources);
- if (pasteRefactoring == null)
- return null;
- if (! pasteRefactoring.setDestination(destination).isOK())
- return null;
- return new ReorgTypedSourcePasteStarter(pasteRefactoring);
- }
-
- public void run(Shell parent) throws InterruptedException, InvocationTargetException {
- IRunnableContext context= new ProgressMonitorDialog(parent);
- new RefactoringExecutionHelper(fPasteRefactoring, RefactoringCore.getConditionCheckingFailedSeverity(), RefactoringSaveHelper.SAVE_NOTHING, parent, context).perform(false, false);
- }
- }
- private static class PasteTypedSourcesRefactoring extends Refactoring {
-
- private final TypedSource[] fSources;
- private IJavaScriptElement fDestination;
-
- static PasteTypedSourcesRefactoring create(TypedSource[] sources){
- if (! isAvailable(sources))
- return null;
- return new PasteTypedSourcesRefactoring(sources);
- }
- public RefactoringStatus setDestination(IJavaScriptElement destination) {
- fDestination= destination;
- if (ReorgUtils.getCompilationUnit(destination) == null)
- return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_wrong_destination);
- if (! destination.exists())
- return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_element_doesnot_exist);
- if (! canPasteAll(destination))
- return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_invalid_destination);
- return new RefactoringStatus();
- }
- private boolean canPasteAll(IJavaScriptElement destination) {
- for (int i= 0; i < fSources.length; i++) {
- if (! canPaste(fSources[i].getType(), destination))
- return false;
- }
- return true;
- }
- private static boolean canPaste(int elementType, IJavaScriptElement destination) {
- IType ancestorType= getAncestorType(destination);
- if (ancestorType != null)
- return canPasteToType(elementType);
- return canPasteToCu(elementType);
- }
- private static boolean canPasteToType(int elementType) {
- return elementType == IJavaScriptElement.TYPE ||
- elementType == IJavaScriptElement.FIELD ||
- elementType == IJavaScriptElement.INITIALIZER ||
- elementType == IJavaScriptElement.METHOD;
- }
- private static boolean canPasteToCu(int elementType) {
- return elementType == IJavaScriptElement.PACKAGE_DECLARATION ||
- elementType == IJavaScriptElement.TYPE ||
- elementType == IJavaScriptElement.IMPORT_DECLARATION;
- }
- PasteTypedSourcesRefactoring(TypedSource[] sources){
- Assert.isNotNull(sources);
- Assert.isTrue(sources.length != 0);
- fSources= sources;
- }
-
- private static boolean isAvailable(TypedSource[] sources) {
- return sources != null && sources.length > 0;
- }
-
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
- return new RefactoringStatus();
- }
-
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= Checks.validateModifiesFiles(
- ResourceUtil.getFiles(new IJavaScriptUnit[]{getDestinationCu()}), getValidationContext());
- return result;
- }
-
- public Change createChange(IProgressMonitor pm) throws CoreException {
- ASTParser p= ASTParser.newParser(AST.JLS3);
- p.setSource(getDestinationCu());
- JavaScriptUnit cuNode= (JavaScriptUnit) p.createAST(pm);
- ASTRewrite rewrite= ASTRewrite.create(cuNode.getAST());
- TypedSource source= null;
- for (int i= fSources.length - 1; i >= 0; i--) {
- source= fSources[i];
- final ASTNode destination= getDestinationNodeForSourceElement(fDestination, source.getType(), cuNode);
- if (destination != null) {
- if (destination instanceof JavaScriptUnit)
- insertToCu(rewrite, createNewNodeToInsertToCu(source, rewrite), (JavaScriptUnit) destination);
- else if (destination instanceof AbstractTypeDeclaration)
- insertToType(rewrite, createNewNodeToInsertToType(source, rewrite), (AbstractTypeDeclaration) destination);
- }
- }
- final CompilationUnitChange result= new CompilationUnitChange(ReorgMessages.PasteAction_change_name, getDestinationCu());
- try {
- ITextFileBuffer buffer= RefactoringFileBuffers.acquire(getDestinationCu());
- TextEdit rootEdit= rewrite.rewriteAST(buffer.getDocument(), fDestination.getJavaScriptProject().getOptions(true));
- if (getDestinationCu().isWorkingCopy())
- result.setSaveMode(TextFileChange.LEAVE_DIRTY);
- TextChangeCompatibility.addTextEdit(result, ReorgMessages.PasteAction_edit_name, rootEdit);
- } finally {
- RefactoringFileBuffers.release(getDestinationCu());
- }
- return result;
- }
-
- private static void insertToType(ASTRewrite rewrite, ASTNode node, AbstractTypeDeclaration typeDeclaration) {
- switch (node.getNodeType()) {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.FUNCTION_DECLARATION:
- case ASTNode.FIELD_DECLARATION:
- case ASTNode.INITIALIZER:
- rewrite.getListRewrite(typeDeclaration, typeDeclaration.getBodyDeclarationsProperty()).insertAt(node, ASTNodes.getInsertionIndex((BodyDeclaration) node, typeDeclaration.bodyDeclarations()), null);
- break;
- default:
- Assert.isTrue(false, String.valueOf(node.getNodeType()));
- }
- }
-
- private static void insertToCu(ASTRewrite rewrite, ASTNode node, JavaScriptUnit cuNode) {
- switch (node.getNodeType()) {
- case ASTNode.TYPE_DECLARATION:
- rewrite.getListRewrite(cuNode, JavaScriptUnit.TYPES_PROPERTY).insertAt(node, ASTNodes.getInsertionIndex((AbstractTypeDeclaration) node, cuNode.types()), null);
- break;
- case ASTNode.IMPORT_DECLARATION:
- rewrite.getListRewrite(cuNode, JavaScriptUnit.IMPORTS_PROPERTY).insertLast(node, null);
- break;
- case ASTNode.PACKAGE_DECLARATION:
- // only insert if none exists
- if (cuNode.getPackage() == null)
- rewrite.set(cuNode, JavaScriptUnit.PACKAGE_PROPERTY, node, null);
- break;
- default:
- Assert.isTrue(false, String.valueOf(node.getNodeType()));
- }
- }
-
- /**
- * @return an AbstractTypeDeclaration, a JavaScriptUnit, or null
- */
- private ASTNode getDestinationNodeForSourceElement(IJavaScriptElement destination, int kind, JavaScriptUnit unit) throws JavaScriptModelException {
- final IType ancestor= getAncestorType(destination);
- if (ancestor != null)
- return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(ancestor, unit);
- if (kind == IJavaScriptElement.TYPE || kind == IJavaScriptElement.PACKAGE_DECLARATION || kind == IJavaScriptElement.IMPORT_DECLARATION || kind == IJavaScriptElement.IMPORT_CONTAINER)
- return unit;
- return null;
- }
-
- private static IType getAncestorType(IJavaScriptElement destinationElement) {
- return destinationElement.getElementType() == IJavaScriptElement.TYPE ? (IType)destinationElement: (IType)destinationElement.getAncestor(IJavaScriptElement.TYPE);
- }
- private ASTNode createNewNodeToInsertToCu(TypedSource source, ASTRewrite rewrite) {
- switch(source.getType()){
- case IJavaScriptElement.TYPE:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.TYPE_DECLARATION);
- case IJavaScriptElement.PACKAGE_DECLARATION:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.PACKAGE_DECLARATION);
- case IJavaScriptElement.IMPORT_DECLARATION:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.IMPORT_DECLARATION);
- default: Assert.isTrue(false, String.valueOf(source.getType()));
- return null;
- }
- }
-
- private ASTNode createNewNodeToInsertToType(TypedSource source, ASTRewrite rewrite) {
- switch(source.getType()){
- case IJavaScriptElement.TYPE:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.TYPE_DECLARATION);
- case IJavaScriptElement.METHOD:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.FUNCTION_DECLARATION);
- case IJavaScriptElement.FIELD:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.FIELD_DECLARATION);
- case IJavaScriptElement.INITIALIZER:
- return rewrite.createStringPlaceholder(source.getSource(), ASTNode.INITIALIZER);
- default: Assert.isTrue(false);
- return null;
- }
- }
-
- private IJavaScriptUnit getDestinationCu() {
- return ReorgUtils.getCompilationUnit(fDestination);
- }
-
- public String getName() {
- return ReorgMessages.PasteAction_name;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameCuWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameCuWizard.java
deleted file mode 100644
index c60f756c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameCuWizard.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt Chapman, mpchapman@gmail.com - 89977 Make JDT .java agnostic
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.INameUpdating;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameCuWizard extends RenameTypeWizard {
-
- public RenameCuWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenameCuWizard_defaultPageTitle,
- RefactoringMessages.RenameCuWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR_CU,
- IJavaHelpContextIds.RENAME_CU_WIZARD_PAGE);
- }
-
- protected RefactoringStatus validateNewName(String newName) {
- String fullName= JavaModelUtil.getRenamedCUName(getCompilationUnit(), newName);
- return super.validateNewName(fullName);
- }
-
- private IJavaScriptUnit getCompilationUnit() {
- return (IJavaScriptUnit) getCompilationUnitProcessor().getElements()[0];
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameTypeWizardInputPage(message, IJavaHelpContextIds.RENAME_CU_WIZARD_PAGE, true, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- protected String getNewName(INameUpdating nameUpdating) {
- String result= nameUpdating.getNewElementName();
- // If renaming a CU we have to remove the java file extension
- return JavaScriptCore.removeJavaScriptLikeExtension(result);
- }
- };
- }
-
- protected boolean isRenameType() {
- // the flag 'willRenameType' may change in checkInitialConditions(), but
- // only from true to false.
- return getCompilationUnitProcessor().isWillRenameType();
- }
-
- private RenameCompilationUnitProcessor getCompilationUnitProcessor() {
- return ((RenameCompilationUnitProcessor) ((RenameRefactoring) getRefactoring()).getProcessor());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameFieldWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameFieldWizard.java
deleted file mode 100644
index 32c9f2aa..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameFieldWizard.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameFieldProcessor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameFieldWizard extends RenameRefactoringWizard {
-
- public RenameFieldWizard(Refactoring refactoring) {
- super(refactoring, RefactoringMessages.RenameFieldWizard_defaultPageTitle,
- RefactoringMessages.RenameFieldWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR_FIELD,
- IJavaHelpContextIds.RENAME_FIELD_WIZARD_PAGE);
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameFieldInputWizardPage(message, IJavaHelpContextIds.RENAME_FIELD_WIZARD_PAGE, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- RefactoringStatus result= validateNewName(text);
- updateGetterSetterLabels();
- return result;
- }
- };
- }
-
- private static class RenameFieldInputWizardPage extends RenameInputWizardPage {
-
- private Button fRenameGetter;
- private Button fRenameSetter;
- private String fGetterRenamingErrorMessage;
- private String fSetterRenamingErrorMessage;
-
- public RenameFieldInputWizardPage(String message, String contextHelpId, String initialValue) {
- super(message, contextHelpId, true, initialValue);
- }
-
- public void createControl(Composite parent) {
- super.createControl(parent);
- Composite parentComposite= (Composite)getControl();
-
- Composite composite= new Composite(parentComposite, SWT.NONE);
- final GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- getGetterSetterRenamingEnablement();
-
- fRenameGetter= new Button(composite, SWT.CHECK);
- boolean getterEnablement= fGetterRenamingErrorMessage == null;
- fRenameGetter.setEnabled(getterEnablement);
- boolean getterSelection= getterEnablement && getBooleanSetting(RenameRefactoringWizard.FIELD_RENAME_GETTER, getRenameFieldProcessor().getRenameGetter());
- fRenameGetter.setSelection(getterSelection);
- getRenameFieldProcessor().setRenameGetter(getterSelection);
- fRenameGetter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fRenameGetter.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getRenameFieldProcessor().setRenameGetter(fRenameGetter.getSelection());
- updateLeaveDelegateCheckbox(getRenameFieldProcessor().getDelegateCount());
- }
- });
-
- fRenameSetter= new Button(composite, SWT.CHECK);
- boolean setterEnablement= fSetterRenamingErrorMessage == null;
- fRenameSetter.setEnabled(setterEnablement);
- boolean setterSelection= setterEnablement && getBooleanSetting(RenameRefactoringWizard.FIELD_RENAME_SETTER, getRenameFieldProcessor().getRenameSetter());
- fRenameSetter.setSelection(setterSelection);
- getRenameFieldProcessor().setRenameSetter(setterSelection);
- fRenameSetter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fRenameSetter.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getRenameFieldProcessor().setRenameSetter(fRenameSetter.getSelection());
- updateLeaveDelegateCheckbox(getRenameFieldProcessor().getDelegateCount());
- }
- });
-
- updateGetterSetterLabels();
- updateLeaveDelegateCheckbox(getRenameFieldProcessor().getDelegateCount());
- Dialog.applyDialogFont(composite);
- }
-
- public void dispose() {
- if (saveSettings()) {
- if (fRenameGetter.isEnabled())
- saveBooleanSetting(RenameRefactoringWizard.FIELD_RENAME_GETTER, fRenameGetter);
- if (fRenameSetter.isEnabled())
- saveBooleanSetting(RenameRefactoringWizard.FIELD_RENAME_SETTER, fRenameSetter);
- }
- super.dispose();
- }
-
- private void getGetterSetterRenamingEnablement() {
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable(){
- public void run() {
- checkGetterRenamingEnablement();
- checkSetterRenamingEnablement();
- }
- });
- }
-
- protected void updateGetterSetterLabels(){
- fRenameGetter.setText(getRenameGetterLabel());
- fRenameSetter.setText(getRenameSetterLabel());
- }
-
- private String getRenameGetterLabel(){
- String defaultLabel= RefactoringMessages.RenameFieldInputWizardPage_rename_getter;
- if (fGetterRenamingErrorMessage != null)
- return constructDisabledGetterRenamingLabel(defaultLabel);
- try {
- IFunction getter= getRenameFieldProcessor().getGetter();
- if (getter == null || ! getter.exists())
- return defaultLabel;
- String oldGetterName= getter.getElementName();
- String newGetterName= createNewGetterName();
- return Messages.format(RefactoringMessages.RenameFieldInputWizardPage_rename_getter_to, new String[]{oldGetterName, newGetterName});
- } catch(CoreException e) {
- JavaScriptPlugin.log(e) ;
- return defaultLabel;
- }
- }
-
- private String getRenameSetterLabel(){
- String defaultLabel= RefactoringMessages.RenameFieldInputWizardPage_rename_setter;
- if (fSetterRenamingErrorMessage != null)
- return constructDisabledSetterRenamingLabel(defaultLabel);
- try {
- IFunction setter= getRenameFieldProcessor().getSetter();
- if (setter == null || ! setter.exists())
- return defaultLabel;
- String oldSetterName= setter.getElementName();
- String newSetterName= createNewSetterName();
- return Messages.format(RefactoringMessages.RenameFieldInputWizardPage_rename_setter_to, new String[]{oldSetterName, newSetterName});
- } catch(CoreException e) {
- JavaScriptPlugin.log(e);
- return defaultLabel;
- }
- }
- private String constructDisabledSetterRenamingLabel(String defaultLabel) {
- if (fSetterRenamingErrorMessage.equals("")) //$NON-NLS-1$
- return defaultLabel;
- String[] keys= {defaultLabel, fSetterRenamingErrorMessage};
- return Messages.format(RefactoringMessages.RenameFieldInputWizardPage_setter_label, keys);
- }
-
- private String constructDisabledGetterRenamingLabel(String defaultLabel) {
- if (fGetterRenamingErrorMessage.equals("")) //$NON-NLS-1$
- return defaultLabel;
- String[] keys= {defaultLabel, fGetterRenamingErrorMessage};
- return Messages.format(RefactoringMessages.RenameFieldInputWizardPage_getter_label, keys);
- }
-
- private String createNewGetterName() throws CoreException {
- return getRenameFieldProcessor().getNewGetterName();
- }
-
- private String createNewSetterName() throws CoreException {
- return getRenameFieldProcessor().getNewSetterName();
- }
-
- private String checkGetterRenamingEnablement() {
- if (fGetterRenamingErrorMessage != null)
- return fGetterRenamingErrorMessage;
- try {
- fGetterRenamingErrorMessage= getRenameFieldProcessor().canEnableGetterRenaming();
- return fGetterRenamingErrorMessage;
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return ""; //$NON-NLS-1$
- }
- }
-
- private String checkSetterRenamingEnablement() {
- if (fSetterRenamingErrorMessage != null)
- return fSetterRenamingErrorMessage;
- try {
- fSetterRenamingErrorMessage= getRenameFieldProcessor().canEnableSetterRenaming();
- return fSetterRenamingErrorMessage;
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- return ""; //$NON-NLS-1$
- }
- }
-
- private RenameFieldProcessor getRenameFieldProcessor() {
- return (RenameFieldProcessor)((RenameRefactoring)getRefactoring()).getProcessor();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInformationPopup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInformationPopup.java
deleted file mode 100644
index 9bad38c0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInformationPopup.java
+++ /dev/null
@@ -1,822 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener2;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyLookupFactory;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.layout.GridLayout;
-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.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tracker;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavaBasePreferencePage;
-import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
-
-public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
- private class PopupVisibilityManager implements IPartListener2, ControlListener, MouseListener, KeyListener, ITextListener, IViewportListener {
-
- public void start() {
- fEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(this);
- final ISourceViewer viewer= fEditor.getViewer();
- final StyledText textWidget= viewer.getTextWidget();
- textWidget.addControlListener(this);
- textWidget.addMouseListener(this);
- textWidget.addKeyListener(this);
- fEditor.getSite().getShell().addControlListener(this);
- viewer.addTextListener(this);
- viewer.addViewportListener(this);
- fPopup.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(PopupVisibilityManager.this);
- if (! textWidget.isDisposed()) {
- textWidget.removeControlListener(PopupVisibilityManager.this);
- textWidget.removeMouseListener(PopupVisibilityManager.this);
- textWidget.removeKeyListener(PopupVisibilityManager.this);
- }
- fEditor.getSite().getShell().removeControlListener(PopupVisibilityManager.this);
- viewer.removeTextListener(PopupVisibilityManager.this);
- viewer.removeViewportListener(PopupVisibilityManager.this);
- if (fMenuImage != null) {
- fMenuImage.dispose();
- fMenuImage= null;
- }
- if (fMenuManager != null) {
- fMenuManager.dispose();
- fMenuManager= null;
- }
- fRenameLinkedMode.cancel();
- }
- });
- }
-
- public void partActivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
- if (partRef.getPart(false) == fPart) {
- updateVisibility();
- }
- }
-
- public void partBroughtToTop(IWorkbenchPartReference partRef) {
- }
-
- public void partClosed(IWorkbenchPartReference partRef) {
- }
-
- public void partDeactivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
- if (fPopup != null && ! fPopup.isDisposed() && partRef.getPart(false) == fPart) {
- fPopup.setVisible(false);
- }
- }
-
- public void partHidden(IWorkbenchPartReference partRef) {
- }
-
- public void partInputChanged(IWorkbenchPartReference partRef) {
- }
-
- public void partOpened(IWorkbenchPartReference partRef) {
- }
-
- public void partVisible(IWorkbenchPartReference partRef) {
- }
-
-
- public void controlMoved(ControlEvent e) {
- updatePopupLocation(true);
- updateVisibility(); //only for hiding outside editor area
- }
-
- public void controlResized(ControlEvent e) {
- updatePopupLocation(true);
- updateVisibility(); //only for hiding outside editor area
- }
-
-
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- updatePopupLocation(false);
- updateVisibility();
- }
-
- public void keyPressed(KeyEvent e) {
- updatePopupLocation(false);
- updateVisibility();
- }
-
- public void keyReleased(KeyEvent e) {
- }
-
-
- public void textChanged(TextEvent event) {
- updatePopupLocation(false);
- updateVisibility(); //only for hiding outside editor area
- }
-
- public void viewportChanged(int verticalOffset) {
- updatePopupLocation(true);
- updateVisibility(); //only for hiding outside editor area
- }
- }
-
- /**
- * Cached platform flags for dealing with platform-specific issues.
- */
- private static boolean CARBON = "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
-
- private static final int WIDGET_PRIORITY= 1000;
-
- private static final String DIALOG_SETTINGS_SECTION= "RenameInformationPopup"; //$NON-NLS-1$
- private static final String SNAP_POSITION_KEY= "snap_position"; //$NON-NLS-1$
-
- private static final int SNAP_POSITION_UNDER_RIGHT_FIELD= 0;
- private static final int SNAP_POSITION_OVER_RIGHT_FIELD= 1;
- private static final int SNAP_POSITION_UNDER_LEFT_FIELD= 2;
- private static final int SNAP_POSITION_OVER_LEFT_FIELD= 3;
- private static final int SNAP_POSITION_LOWER_RIGHT= 4;
-
- private static final int POPUP_VISIBILITY_DELAY= 300;
-
- /**
- * Offset of info hover arrow from the left or right side.
- */
- private static final int HAO= 10;
-
- /**
- * Width of info hover arrow.
- */
- private static final int HAW= 8;
-
- /**
- * Height of info hover arrow.
- */
- private static final int HAH= 10;
-
- /**
- * Gap between linked position and popup.
- */
- private static final int GAP= 2;
-
- private final CompilationUnitEditor fEditor;
- private final RenameLinkedMode fRenameLinkedMode;
-
- private int fSnapPosition;
- private Shell fPopup;
- private GridLayout fPopupLayout;
- private Region fRegion;
-
- private Image fMenuImage;
- private MenuManager fMenuManager;
- private ToolBar fToolBar;
- private String fOpenDialogBinding= ""; //$NON-NLS-1$
- private boolean fIsMenuUp= false;
-
- private boolean fDelayJobFinished= false;
-
- public RenameInformationPopup(CompilationUnitEditor editor, RenameLinkedMode renameLinkedMode) {
- fEditor= editor;
- fRenameLinkedMode= renameLinkedMode;
- restoreSnapPosition();
- }
-
- private void restoreSnapPosition() {
- IDialogSettings settings= getDialogSettings();
- try {
- fSnapPosition= settings.getInt(SNAP_POSITION_KEY);
- } catch (NumberFormatException e) {
- // default:
- fSnapPosition= SNAP_POSITION_UNDER_LEFT_FIELD;
- }
- }
-
- private IDialogSettings getDialogSettings() {
- return JavaScriptPlugin.getDefault().getDialogSettingsSection(DIALOG_SETTINGS_SECTION);
- }
-
- public void open() {
- // Must cache here, since editor context is not available in menu from popup shell:
- fOpenDialogBinding= getOpenDialogBinding();
-
- Shell workbenchShell= fEditor.getSite().getShell();
- final Display display= workbenchShell.getDisplay();
-
- fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
- fPopupLayout= new GridLayout(2, false);
- fPopupLayout.marginWidth= 1;
- fPopupLayout.marginHeight= 1;
- fPopupLayout.marginLeft= 4;
- fPopupLayout.horizontalSpacing= 0;
- fPopup.setLayout(fPopupLayout);
-
- createContent(fPopup);
- updatePopupLocation(true);
- new PopupVisibilityManager().start();
-
- // Leave linked mode when popup loses focus
- // (except when focus goes back to workbench window or menu is open):
- fPopup.addShellListener(new ShellAdapter() {
- public void shellDeactivated(ShellEvent e) {
- if (fIsMenuUp)
- return;
-
- final Shell editorShell= fEditor.getSite().getShell();
- display.asyncExec(new Runnable() {
- // post to UI thread since editor shell only gets activated after popup has lost focus
- public void run() {
- Shell activeShell= display.getActiveShell();
- if (activeShell != editorShell) {
- fRenameLinkedMode.cancel();
- }
- }
- });
- }
- });
-
- if (! CARBON) { // carbon draws its own border...
- fPopup.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent pe) {
- pe.gc.drawPolygon(getPolygon(true));
- }
- });
- }
-
-// fPopup.moveBelow(null); // make sure hovers are on top of the info popup
-// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
-// fPopup.moveBelow(workbenchShell.getShells()[0]);
-
- UIJob delayJob= new UIJob(display, ReorgMessages.RenameInformationPopup_delayJobName) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- fDelayJobFinished= true;
- if (fPopup != null && ! fPopup.isDisposed()) {
- updateVisibility();
- }
- return Status.OK_STATUS;
- }
- };
- delayJob.setSystem(true);
- delayJob.setPriority(Job.INTERACTIVE);
- delayJob.schedule(POPUP_VISIBILITY_DELAY);
- }
-
- public void close() {
- if (fPopup != null) {
- if (!fPopup.isDisposed()) {
- fPopup.close();
- }
- fPopup= null;
- }
- releaseWidgetToken();
- if (fRegion != null) {
- if (! fRegion.isDisposed()) {
- fRegion.dispose();
- }
- }
- }
-
- public Shell getShell() {
- return fPopup;
- }
-
- private void updatePopupLocation(boolean force) {
- if (! force && fSnapPosition == SNAP_POSITION_LOWER_RIGHT)
- return;
-
- packPopup();
- Point loc= computePopupLocation(fSnapPosition);
- if (loc != null) {
- fPopup.setLocation(loc);
- // XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
-// fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
- }
- }
-
- private void updateVisibility() {
- if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
- boolean visible= false;
- //TODO: Check for visibility of linked position, not whether popup is outside of editor?
- if (fRenameLinkedMode.isCaretInLinkedPosition()) {
- StyledText textWidget= fEditor.getViewer().getTextWidget();
- Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea());
- Rectangle pBounds= fPopup.getBounds();
- pBounds.x-= GAP;
- pBounds.y-= GAP;
- pBounds.width+= 2 * GAP;
- pBounds.height+= 2 * GAP;
- if (eArea.intersects(pBounds)) {
- visible= true;
- }
- }
- if (visible && ! fPopup.isVisible()) {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer;
- widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
- }
- } else if (! visible && fPopup.isVisible()) {
- releaseWidgetToken();
- }
- fPopup.setVisible(visible);
- }
- }
-
- private void releaseWidgetToken() {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner widgetTokenOwner= (IWidgetTokenOwner) viewer;
- widgetTokenOwner.releaseWidgetToken(this);
- }
- }
-
- /**
- * @param snapPosition one of the SNAP_POSITION_* constants
- * @return the location in display coordinates or <code>null</code> iff not visible
- */
- private Point computePopupLocation(int snapPosition) {
- if (fPopup == null || fPopup.isDisposed())
- return null;
-
- switch (snapPosition) {
- case SNAP_POSITION_LOWER_RIGHT:
- {
- StyledText eWidget= fEditor.getViewer().getTextWidget();
- Rectangle eBounds= eWidget.getClientArea();
- Point eLowerRight= eWidget.toDisplay(eBounds.x + eBounds.width, eBounds.y + eBounds.height);
- Point pSize= getExtent();
- return new Point(eLowerRight.x - pSize.x - 5, eLowerRight.y - pSize.y - 5);
- }
-
- case SNAP_POSITION_UNDER_RIGHT_FIELD:
- case SNAP_POSITION_OVER_RIGHT_FIELD:
- {
- LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
- if (position == null)
- return null;
- ISourceViewer viewer= fEditor.getViewer();
- ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
- int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset + position.length);
-
- StyledText textWidget= viewer.getTextWidget();
- Point pos= textWidget.getLocationAtOffset(widgetOffset);
- Point pSize= getExtent();
- if (snapPosition == SNAP_POSITION_OVER_RIGHT_FIELD) {
- pos.y-= pSize.y + GAP;
- } else {
- pos.y+= textWidget.getLineHeight(widgetOffset) + GAP;
- }
- pos.x+= GAP;
- Point dPos= textWidget.toDisplay(pos);
- Rectangle displayBounds= textWidget.getDisplay().getClientArea();
- Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
- Geometry.moveInside(dPopupRect, displayBounds);
- return new Point(dPopupRect.x, dPopupRect.y);
- }
-
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- case SNAP_POSITION_OVER_LEFT_FIELD:
- default: // same as SNAP_POSITION_UNDER_LEFT_FIELD
- {
- LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
- if (position == null)
- return null;
- ISourceViewer viewer= fEditor.getViewer();
- ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
- int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset/* + position.length*/);
-
- StyledText textWidget= viewer.getTextWidget();
- Point pos= textWidget.getLocationAtOffset(widgetOffset);
- Point pSize= getExtent();
- pSize.y+= HAH + 1;
- pos.x-= HAO;
- if (snapPosition == SNAP_POSITION_OVER_LEFT_FIELD) {
- pos.y-= pSize.y;
- } else {
- pos.y+= textWidget.getLineHeight(widgetOffset);
- }
- Point dPos= textWidget.toDisplay(pos);
- Rectangle displayBounds= textWidget.getDisplay().getClientArea();
- Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
- Geometry.moveInside(dPopupRect, displayBounds);
- return new Point(dPopupRect.x, dPopupRect.y);
- }
-
- }
- }
-
- private void addMoveSupport(final Shell popupShell, final Control movedControl) {
- movedControl.addMouseListener(new MouseAdapter() {
-
- public void mouseDown(final MouseEvent downEvent) {
- if (downEvent.button != 1) {
- return;
- }
-
- final Point POPUP_SOURCE= popupShell.getLocation();
- final StyledText textWidget= fEditor.getViewer().getTextWidget();
- Point pSize= getExtent();
- int originalSnapPosition= fSnapPosition;
-
- /*
- * Feature in Tracker: it is not possible to directly control the feedback,
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121300
- * and https://bugs.eclipse.org/bugs/show_bug.cgi?id=121298#c1 .
- *
- * Workaround is to have an offscreen rectangle for tracking mouse movement
- * and a manually updated rectangle for the actual drop target.
- */
- final Tracker tracker= new Tracker(textWidget, SWT.NONE);
-
- final Point[] LOCATIONS= {
- textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_RIGHT_FIELD)),
- textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_RIGHT_FIELD)),
- textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_LEFT_FIELD)),
- textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_LEFT_FIELD)),
- textWidget.toControl(computePopupLocation(SNAP_POSITION_LOWER_RIGHT))
- };
-
- final Rectangle[] DROP_TARGETS= {
- Geometry.createRectangle(LOCATIONS[0], pSize),
- Geometry.createRectangle(LOCATIONS[1], pSize),
- new Rectangle(LOCATIONS[2].x, LOCATIONS[2].y + HAH, pSize.x, pSize.y),
- Geometry.createRectangle(LOCATIONS[3], pSize),
- Geometry.createRectangle(LOCATIONS[4], pSize)
- };
- final Rectangle MOUSE_MOVE_SOURCE= new Rectangle(1000000, 0, 0, 0);
- tracker.setRectangles(new Rectangle[] { MOUSE_MOVE_SOURCE, DROP_TARGETS[fSnapPosition] });
- tracker.setStippled(true);
-
- ControlListener moveListener= new ControlAdapter() {
- /*
- * @see org.eclipse.swt.events.ControlAdapter#controlMoved(org.eclipse.swt.events.ControlEvent)
- */
- public void controlMoved(ControlEvent moveEvent) {
- Rectangle[] currentRects= tracker.getRectangles();
- final Rectangle mouseMoveCurrent= currentRects[0];
- Point popupLoc= new Point(
- POPUP_SOURCE.x + mouseMoveCurrent.x - MOUSE_MOVE_SOURCE.x,
- POPUP_SOURCE.y + mouseMoveCurrent.y - MOUSE_MOVE_SOURCE.y);
-
- popupShell.setLocation(popupLoc);
-
- Point ePopupLoc= textWidget.toControl(popupLoc);
- int minDist= Integer.MAX_VALUE;
- for (int snapPos= 0; snapPos < DROP_TARGETS.length; snapPos++) {
- int dist= Geometry.distanceSquared(ePopupLoc, LOCATIONS[snapPos]);
- if (dist < minDist) {
- minDist= dist;
- fSnapPosition= snapPos;
- currentRects[1]= DROP_TARGETS[snapPos];
- }
- }
- tracker.setRectangles(currentRects);
- }
- };
- tracker.addControlListener(moveListener);
- boolean committed= tracker.open();
- tracker.close();
- tracker.dispose();
- if (committed) {
- getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
- } else {
- fSnapPosition= originalSnapPosition;
- }
- updatePopupLocation(true);
- activateEditor();
- }
- });
- }
-
- private void packPopup() {
- boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
- boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
- fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
- fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
- fPopup.pack();
-
- Region oldRegion= fRegion;
- if (isUnderLeft || isOverLeft) {
- fRegion= new Region();
- fRegion.add(getPolygon(false));
- fPopup.setRegion(fRegion);
- Rectangle bounds= fRegion.getBounds();
- fPopup.setSize(bounds.width, bounds.height + 1);
- } else {
- fRegion= null;
- fPopup.setRegion(null);
- }
-
- if (oldRegion != null) {
- oldRegion.dispose();
- }
- }
-
- private Point getExtent() {
- Point e = fPopup.getSize();
- switch (fSnapPosition) {
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- e.y -= HAH;
- break;
- case SNAP_POSITION_OVER_LEFT_FIELD:
- e.y -= HAH + 1;
- break;
- }
- return e;
- }
-
- private int[] getPolygon(boolean border) {
- Point e = getExtent();
- int b = border ? 1 : 0;
- if (true /*arrowOnLeft*/) {
- switch (fSnapPosition) {
- case SNAP_POSITION_OVER_LEFT_FIELD:
- return new int[] {
- 0, 0,
- e.x - b, 0,
- e.x - b, e.y - b,
- HAO + HAW, e.y - b,
- HAO + HAW / 2, e.y + HAH - b,
- HAO, e.y - b,
- 0, e.y - b,
- 0, 0 };
-
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- return new int[] {
- 0, HAH,
- HAO + b, HAH,
- HAO + HAW / 2, b,
- HAO + HAW - b, HAH,
- e.x - b, HAH,
- e.x - b, e.y + HAH - b,
- 0, e.y + HAH - b,
- 0, HAH };
-
- default:
- return new int[] {
- 0, 0,
- e.x - b, 0,
- e.x - b, e.y - b,
- 0, e.y - b,
- 0, 0 };
- }
- }
- //TODO: BiDi?
- return new int[] { 0, 0, e.x - b, 0, e.x - b, e.y - b,
- e.x - HAO - b, e.y - b, e.x - HAO - HAW / 2, e.y + HAH - b,
- e.x - HAO - HAW, e.y - b, 0, e.y - b, 0, 0 };
- }
-
- private void createContent(Composite parent) {
- Display display= parent.getDisplay();
- Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- addMoveSupport(fPopup, parent);
-
- StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE);
- String enterKeyName= getEnterBinding();
- String hintTemplate= ReorgMessages.RenameInformationPopup_EnterNewName;
- hint.setText(Messages.format(hintTemplate, enterKeyName));
- hint.setForeground(foreground);
- hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
- hint.setEnabled(false); // text must not be selectable
- addMoveSupport(fPopup, hint);
-
- addViewMenu(parent);
-
- recursiveSetBackgroundColor(parent, background);
-
- }
-
- private ToolBar addViewMenu(final Composite parent) {
- fToolBar= new ToolBar(parent, SWT.FLAT);
- final ToolItem menuButton = new ToolItem(fToolBar, SWT.PUSH, 0);
- fMenuImage= JavaPluginImages.DESC_ELCL_VIEW_MENU.createImage();
- menuButton.setImage(fMenuImage);
- menuButton.setToolTipText(ReorgMessages.RenameInformationPopup_menu);
- fToolBar.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- showMenu(fToolBar);
- }
- });
- menuButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- showMenu(fToolBar);
- }
- });
- fToolBar.pack();
- return fToolBar;
- }
-
- private void showMenu(ToolBar toolBar) {
- Menu menu= getMenuManager().createContextMenu(toolBar);
- menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y));
- fIsMenuUp= true;
- menu.setVisible(true);
- }
-
- private MenuManager getMenuManager() {
- if (fMenuManager != null) {
- return fMenuManager;
- }
-
- fMenuManager= new MenuManager();
- fMenuManager.setRemoveAllWhenShown(true);
-
- fMenuManager.addMenuListener(new IMenuListener2() {
- public void menuAboutToHide(IMenuManager manager) {
- fIsMenuUp= false;
- }
- public void menuAboutToShow(IMenuManager manager) {
- IAction refactorAction= new Action(ReorgMessages.RenameInformationPopup_RenameInWorkspace) {
- public void run() {
- activateEditor();
- fRenameLinkedMode.doRename(false);
- }
- };
- refactorAction.setAccelerator(SWT.CR);
- manager.add(refactorAction);
-
- IAction previewAction= new Action(ReorgMessages.RenameInformationPopup_Preview) {
- public void run() {
- activateEditor();
- fRenameLinkedMode.doRename(true);
- }
- };
- previewAction.setAccelerator(SWT.CTRL | SWT.CR);
- manager.add(previewAction);
-
- IAction openDialogAction= new Action(ReorgMessages.RenameInformationPopup_OpenDialog + '\t' + fOpenDialogBinding) {
- public void run() {
- activateEditor();
- fRenameLinkedMode.startFullDialog();
- }
- };
- manager.add(openDialogAction);
-
- manager.add(new Separator());
-
- MenuManager subMenuManager= new MenuManager(ReorgMessages.RenameInformationPopup_SnapTo);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_LEFT_FIELD, ReorgMessages.RenameInformationPopup_snap_under_left);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_RIGHT_FIELD, ReorgMessages.RenameInformationPopup_snap_under_right);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_LEFT_FIELD, ReorgMessages.RenameInformationPopup_snap_over_left);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_RIGHT_FIELD, ReorgMessages.RenameInformationPopup_snap_over_right);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_LOWER_RIGHT, ReorgMessages.RenameInformationPopup_snap_bottom_right);
- manager.add(subMenuManager);
-
- IAction prefsAction= new Action(ReorgMessages.RenameInformationPopup_preferences) {
- public void run() {
- fRenameLinkedMode.cancel();
- String linkedModePrefPageID= "org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage"; //$NON-NLS-1$
- String refactoringPrefPageID= JavaBasePreferencePage.JAVA_BASE_PREF_PAGE_ID;
- PreferencesUtil.createPreferenceDialogOn(fEditor.getSite().getShell(), refactoringPrefPageID, new String[] { linkedModePrefPageID, refactoringPrefPageID }, null).open();
- }
- };
- manager.add(prefsAction);
- }
- });
- return fMenuManager;
- }
-
- private void addMoveMenuItem(IMenuManager manager, final int snapPosition, String text) {
- IAction action= new Action(text, IAction.AS_RADIO_BUTTON) {
- public void run() {
- fSnapPosition= snapPosition;
- getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
- updatePopupLocation(true);
- activateEditor();
- }
- };
- action.setChecked(fSnapPosition == snapPosition);
- manager.add(action);
- }
-
- private static String getEnterBinding() {
- return KeyStroke.getInstance(KeyLookupFactory.getDefault().formalKeyLookup(IKeyLookup.CR_NAME)).format();
- }
-
- /**
- * WARNING: only works in workbench window context!
- * @return the keybinding for Refactor &gt; Rename
- */
- private static String getOpenDialogBinding() {
- IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- if (bindingService == null)
- return ""; //$NON-NLS-1$
- String binding= bindingService.getBestActiveBindingFormattedFor(IJavaEditorActionDefinitionIds.RENAME_ELEMENT);
- return binding == null ? "" : binding; //$NON-NLS-1$
- }
-
- private static void recursiveSetBackgroundColor(Control control, Color color) {
- control.setBackground(color);
- if (control instanceof Composite) {
- Control[] children= ((Composite) control).getChildren();
- for (int i= 0; i < children.length; i++) {
- recursiveSetBackgroundColor(children[i], color);
- }
- }
- }
-
- public boolean ownsFocusShell() {
- if (fIsMenuUp)
- return true;
- if (fPopup == null || fPopup.isDisposed())
- return false;
- Shell activeShell= fPopup.getDisplay().getActiveShell();
- if (fPopup == activeShell)
- return true;
- return false;
- }
-
- private void activateEditor() {
- fEditor.getSite().getShell().setActive();
- }
-
- public boolean requestWidgetToken(IWidgetTokenOwner owner) {
- return false;
- }
-
- public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
- return false;
- }
-
- public boolean setFocus(IWidgetTokenOwner owner) {
- if (fToolBar != null && ! fToolBar.isDisposed())
- showMenu(fToolBar);
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
deleted file mode 100644
index ccd61d09..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.IDelegateUpdating;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.INameUpdating;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.IQualifiedNameUpdating;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.IReferenceUpdating;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.ITextUpdating;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.DelegateUIHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.QualifiedNameComponent;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.TextInputWizardPage;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-
-abstract class RenameInputWizardPage extends TextInputWizardPage {
-
- private String fHelpContextID;
- private Button fUpdateReferences;
- private Button fUpdateTextualMatches;
- private Button fUpdateQualifiedNames;
- private Button fLeaveDelegateCheckBox;
- private Button fDeprecateDelegateCheckBox;
- private QualifiedNameComponent fQualifiedNameComponent;
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage <code>true</code> if this page is the wizard's last
- * user input page. Otherwise <code>false</code>.
- * @param initialValue the initial value
- */
- public RenameInputWizardPage(String description, String contextHelpId, boolean isLastUserPage, String initialValue) {
- super(description, isLastUserPage, initialValue);
- fHelpContextID= contextHelpId;
- }
-
- public void createControl(Composite parent) {
- Composite superComposite= new Composite(parent, SWT.NONE);
- setControl(superComposite);
- initializeDialogUnits(superComposite);
- superComposite.setLayout(new GridLayout());
- Composite composite= new Composite(superComposite, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
-
- composite.setLayout(layout);
- RowLayouter layouter= new RowLayouter(2);
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(getLabelText());
-
- Text text= createTextInputField(composite);
- text.selectAll();
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(25);
- text.setLayoutData(gd);
-
- layouter.perform(label, text, 1);
-
- Label separator= new Label(composite, SWT.NONE);
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, false, false);
- gridData.heightHint= 2;
- separator.setLayoutData(gridData);
-
-
- int indent= convertWidthInCharsToPixels(2);
-
- addOptionalUpdateReferencesCheckbox(composite, layouter);
- addAdditionalOptions(composite, layouter);
- addOptionalUpdateTextualMatches(composite, layouter);
- addOptionalUpdateQualifiedNameComponent(composite, layouter, indent);
- addOptionalLeaveDelegateCheckbox(composite, layouter);
- addOptionalDeprecateDelegateCheckbox(composite, layouter, indent);
- updateForcePreview();
-
- Dialog.applyDialogFont(superComposite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), fHelpContextID);
- }
-
- /**
- * Clients can override this method to provide more UI elements. By default, does nothing
- *
- * @param composite the parent composite
- * @param layouter the row layouter to use
- */
- protected void addAdditionalOptions(Composite composite, RowLayouter layouter) {
- // none by default
- }
-
- public void setVisible(boolean visible) {
- if (visible) {
- INameUpdating nameUpdating= (INameUpdating)getRefactoring().getAdapter(INameUpdating.class);
- if (nameUpdating != null) {
- String newName= getNewName(nameUpdating);
- if (newName != null && newName.length() > 0 && !newName.equals(getInitialValue())) {
- Text textField= getTextField();
- textField.setText(newName);
- textField.setSelection(0, newName.length());
- }
- }
- }
- super.setVisible(visible);
- }
-
- /**
- * Returns the new name for the Java element or <code>null</code>
- * if no new name is provided
- *
- * @return the new name or <code>null</code>
- */
- protected String getNewName(INameUpdating nameUpdating) {
- return nameUpdating.getNewElementName();
- }
-
- protected boolean saveSettings() {
- // always save
-// if (getContainer() instanceof Dialog)
-// return ((Dialog)getContainer()).getReturnCode() == IDialogConstants.OK_ID;
- return true;
- }
-
- public void dispose() {
- if (saveSettings()) {
- saveBooleanSetting(RenameRefactoringWizard.UPDATE_TEXTUAL_MATCHES, fUpdateTextualMatches);
- saveBooleanSetting(RenameRefactoringWizard.UPDATE_QUALIFIED_NAMES, fUpdateQualifiedNames);
- if (fQualifiedNameComponent != null)
- fQualifiedNameComponent.savePatterns(getRefactoringSettings());
- DelegateUIHelper.saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
- DelegateUIHelper.saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
- }
- super.dispose();
- }
-
- private void addOptionalUpdateReferencesCheckbox(Composite result, RowLayouter layouter) {
- final IReferenceUpdating ref= (IReferenceUpdating)getRefactoring().getAdapter(IReferenceUpdating.class);
- if (ref == null || !ref.canEnableUpdateReferences())
- return;
- String title= RefactoringMessages.RenameInputWizardPage_update_references;
- boolean defaultValue= true; //bug 77901
- fUpdateReferences= createCheckbox(result, title, defaultValue, layouter);
- ref.setUpdateReferences(fUpdateReferences.getSelection());
- fUpdateReferences.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- ref.setUpdateReferences(fUpdateReferences.getSelection());
- }
- });
- }
-
- private void addOptionalUpdateTextualMatches(Composite result, RowLayouter layouter) {
- final ITextUpdating refactoring= (ITextUpdating) getRefactoring().getAdapter(ITextUpdating.class);
- if (refactoring == null || !refactoring.canEnableTextUpdating())
- return;
- String title= RefactoringMessages.RenameInputWizardPage_update_textual_matches;
- boolean defaultValue= getBooleanSetting(RenameRefactoringWizard.UPDATE_TEXTUAL_MATCHES, refactoring.getUpdateTextualMatches());
- fUpdateTextualMatches= createCheckbox(result, title, defaultValue, layouter);
- refactoring.setUpdateTextualMatches(fUpdateTextualMatches.getSelection());
- fUpdateTextualMatches.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- refactoring.setUpdateTextualMatches(fUpdateTextualMatches.getSelection());
- updateForcePreview();
- }
- });
- }
-
- private void addOptionalUpdateQualifiedNameComponent(Composite parent, RowLayouter layouter, int marginWidth) {
- final IQualifiedNameUpdating ref= (IQualifiedNameUpdating)getRefactoring().getAdapter(IQualifiedNameUpdating.class);
- if (ref == null || !ref.canEnableQualifiedNameUpdating())
- return;
- fUpdateQualifiedNames= new Button(parent, SWT.CHECK);
- int indent= marginWidth + fUpdateQualifiedNames.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- fUpdateQualifiedNames.setText(RefactoringMessages.RenameInputWizardPage_update_qualified_names);
- layouter.perform(fUpdateQualifiedNames);
-
- fQualifiedNameComponent= new QualifiedNameComponent(parent, SWT.NONE, ref, getRefactoringSettings());
- layouter.perform(fQualifiedNameComponent);
- GridData gd= (GridData)fQualifiedNameComponent.getLayoutData();
- gd.horizontalAlignment= GridData.FILL;
- gd.horizontalIndent= indent;
-
- boolean defaultSelection= getBooleanSetting(RenameRefactoringWizard.UPDATE_QUALIFIED_NAMES, ref.getUpdateQualifiedNames());
- fUpdateQualifiedNames.setSelection(defaultSelection);
- updateQulifiedNameUpdating(ref, defaultSelection);
-
- fUpdateQualifiedNames.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean enabled= ((Button)e.widget).getSelection();
- updateQulifiedNameUpdating(ref, enabled);
- }
- });
- }
-
- private void updateQulifiedNameUpdating(final IQualifiedNameUpdating ref, boolean enabled) {
- fQualifiedNameComponent.setEnabled(enabled);
- ref.setUpdateQualifiedNames(enabled);
- updateForcePreview();
- }
-
- private void addOptionalLeaveDelegateCheckbox(Composite result, RowLayouter layouter) {
- final IDelegateUpdating refactoring= (IDelegateUpdating) getRefactoring().getAdapter(IDelegateUpdating.class);
- if (refactoring == null || !refactoring.canEnableDelegateUpdating())
- return;
- fLeaveDelegateCheckBox= createCheckbox(result, refactoring.getDelegateUpdatingTitle(false), DelegateUIHelper.loadLeaveDelegateSetting(refactoring), layouter);
- refactoring.setDelegateUpdating(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- refactoring.setDelegateUpdating(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
-
- private void addOptionalDeprecateDelegateCheckbox(Composite result, RowLayouter layouter, int marginWidth) {
- final IDelegateUpdating refactoring= (IDelegateUpdating) getRefactoring().getAdapter(IDelegateUpdating.class);
- if (refactoring == null || !refactoring.canEnableDelegateUpdating())
- return;
- fDeprecateDelegateCheckBox= new Button(result, SWT.CHECK);
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.horizontalIndent= (marginWidth + fDeprecateDelegateCheckBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
- fDeprecateDelegateCheckBox.setLayoutData(data);
- fDeprecateDelegateCheckBox.setText(DelegateUIHelper.getDeprecateDelegateCheckBoxTitle());
- fDeprecateDelegateCheckBox.setSelection(DelegateUIHelper.loadDeprecateDelegateSetting(refactoring));
- layouter.perform(fDeprecateDelegateCheckBox);
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- fDeprecateDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- refactoring.setDeprecateDelegates(fDeprecateDelegateCheckBox.getSelection());
- }
- });
- if (fLeaveDelegateCheckBox != null) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- fLeaveDelegateCheckBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fDeprecateDelegateCheckBox.setEnabled(fLeaveDelegateCheckBox.getSelection());
- }
- });
- }
- }
-
- protected void updateLeaveDelegateCheckbox(int delegateCount) {
- if (fLeaveDelegateCheckBox == null)
- return;
- final IDelegateUpdating refactoring= (IDelegateUpdating) getRefactoring().getAdapter(IDelegateUpdating.class);
- fLeaveDelegateCheckBox.setEnabled(delegateCount > 0);
- fLeaveDelegateCheckBox.setText(refactoring.getDelegateUpdatingTitle(delegateCount > 1));
- if (delegateCount == 0) {
- fLeaveDelegateCheckBox.setSelection(false);
- refactoring.setDelegateUpdating(false);
- }
- }
-
- protected String getLabelText() {
- return RefactoringMessages.RenameInputWizardPage_new_name;
- }
-
- protected boolean getBooleanSetting(String key, boolean defaultValue) {
- String update= getRefactoringSettings().get(key);
- if (update != null)
- return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
- }
-
- protected void saveBooleanSetting(String key, Button checkBox) {
- if (checkBox != null)
- getRefactoringSettings().put(key, checkBox.getSelection());
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value, RowLayouter layouter) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- layouter.perform(checkBox);
- return checkBox;
- }
-
- private void updateForcePreview() {
- boolean forcePreview= false;
- Refactoring refactoring= getRefactoring();
- ITextUpdating tu= (ITextUpdating) refactoring.getAdapter(ITextUpdating.class);
- IQualifiedNameUpdating qu= (IQualifiedNameUpdating)refactoring.getAdapter(IQualifiedNameUpdating.class);
- if (tu != null) {
- forcePreview= tu.getUpdateTextualMatches();
- }
- if (qu != null) {
- forcePreview |= qu.getUpdateQualifiedNames();
- }
- getRefactoringWizard().setForcePreviewReview(forcePreview);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameJavaProjectWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameJavaProjectWizard.java
deleted file mode 100644
index d1d4475e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameJavaProjectWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameJavaProjectWizard extends RenameRefactoringWizard {
-
- public RenameJavaProjectWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenameJavaProject_defaultPageTitle,
- RefactoringMessages.RenameJavaProject_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR,
- IJavaHelpContextIds.RENAME_JAVA_PROJECT_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLinkedMode.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLinkedMode.java
deleted file mode 100644
index b4397c31..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLinkedMode.java
+++ /dev/null
@@ -1,618 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.core.runtime.Assert;
-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.dialogs.IDialogSettings;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEditingSupport;
-import org.eclipse.jface.text.IEditingSupportRegistry;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.link.ILinkedModeListener;
-import org.eclipse.jface.text.link.LinkedModeModel;
-import org.eclipse.jface.text.link.LinkedModeUI;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-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.Shell;
-import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.refactoring.IJavaScriptRefactorings;
-import org.eclipse.wst.jsdt.core.refactoring.descriptors.RenameJavaScriptElementDescriptor;
-import org.eclipse.wst.jsdt.internal.corext.dom.LinkedNodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamingNameSuggestor;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorHighlightingSynchronizer;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.DelegateUIHelper;
-import org.eclipse.wst.jsdt.internal.ui.text.correction.LinkedNamesAssistProposal.DeleteBlockingExitPolicy;
-import org.eclipse.wst.jsdt.ui.refactoring.RenameSupport;
-
-public class RenameLinkedMode {
-
- private class FocusEditingSupport implements IEditingSupport {
- public boolean ownsFocusShell() {
- if (fInfoPopup == null)
- return false;
- if (fInfoPopup.ownsFocusShell()) {
- return true;
- }
-
- Shell editorShell= fEditor.getSite().getShell();
- Shell activeShell= editorShell.getDisplay().getActiveShell();
- if (editorShell == activeShell)
- return true;
- return false;
- }
-
- public boolean isOriginator(DocumentEvent event, IRegion subjectRegion) {
- return false; //leave on external modification outside positions
- }
- }
-
- private class EditorSynchronizer implements ILinkedModeListener {
- public void left(LinkedModeModel model, int flags) {
- linkedModeLeft();
- if ( (flags & ILinkedModeListener.UPDATE_CARET) != 0) {
- doRename(fShowPreview);
- }
- }
-
- public void resume(LinkedModeModel model, int flags) {
- }
-
- public void suspend(LinkedModeModel model) {
- }
- }
-
- private class ExitPolicy extends DeleteBlockingExitPolicy {
- public ExitPolicy(IDocument document) {
- super(document);
- }
-
- public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
- fShowPreview|= (event.stateMask & SWT.CTRL) != 0;
- return super.doExit(model, event, offset, length);
- }
- }
-
-
- private static RenameLinkedMode fgActiveLinkedMode;
-
- private final CompilationUnitEditor fEditor;
- private final IJavaScriptElement fJavaElement;
-
- private RenameInformationPopup fInfoPopup;
-
- private boolean fOriginalSaved;
- private Point fOriginalSelection;
- private String fOriginalName;
-
- private LinkedPosition fNamePosition;
- private LinkedModeModel fLinkedModeModel;
- private LinkedPositionGroup fLinkedPositionGroup;
- private final FocusEditingSupport fFocusEditingSupport;
- private boolean fShowPreview;
-
-
- public RenameLinkedMode(IJavaScriptElement element, CompilationUnitEditor editor) {
- Assert.isNotNull(element);
- Assert.isNotNull(editor);
- fEditor= editor;
- fJavaElement= element;
- fFocusEditingSupport= new FocusEditingSupport();
- }
-
- public static RenameLinkedMode getActiveLinkedMode() {
- if (fgActiveLinkedMode != null) {
- ISourceViewer viewer= fgActiveLinkedMode.fEditor.getViewer();
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && ! textWidget.isDisposed()) {
- return fgActiveLinkedMode;
- }
- }
- // make sure we don't hold onto the active linked mode if anything went wrong with canceling:
- fgActiveLinkedMode= null;
- }
- return null;
- }
-
- public void start() {
- if (getActiveLinkedMode() != null) {
- // for safety; should already be handled in RenameJavaElementAction
- fgActiveLinkedMode.startFullDialog();
- return;
- }
-
- fOriginalSaved= ! fEditor.isDirty();
-
- ISourceViewer viewer= fEditor.getViewer();
- IDocument document= viewer.getDocument();
- fOriginalSelection= viewer.getSelectedRange();
- int offset= fOriginalSelection.x;
-
- try {
- JavaScriptUnit root= JavaScriptPlugin.getDefault().getASTProvider().getAST(getCompilationUnit(), ASTProvider.WAIT_YES, null);
-
- fLinkedPositionGroup= new LinkedPositionGroup();
- ASTNode selectedNode= NodeFinder.perform(root, fOriginalSelection.x, fOriginalSelection.y);
- if (! (selectedNode instanceof SimpleName)) {
- return; // TODO: show dialog
- }
- SimpleName nameNode= (SimpleName) selectedNode;
-
- fOriginalName= nameNode.getIdentifier();
- final int pos= nameNode.getStartPosition();
- ASTNode[] sameNodes= LinkedNodeFinder.findByNode(root, nameNode);
-
- //TODO: copied from LinkedNamesAssistProposal#apply(..):
- // sort for iteration order, starting with the node @ offset
- Arrays.sort(sameNodes, new Comparator() {
- public int compare(Object o1, Object o2) {
- return rank((ASTNode) o1) - rank((ASTNode) o2);
- }
- /**
- * Returns the absolute rank of an <code>ASTNode</code>. Nodes
- * preceding <code>pos</code> are ranked last.
- *
- * @param node the node to compute the rank for
- * @return the rank of the node with respect to the invocation offset
- */
- private int rank(ASTNode node) {
- int relativeRank= node.getStartPosition() + node.getLength() - pos;
- if (relativeRank < 0)
- return Integer.MAX_VALUE + relativeRank;
- else
- return relativeRank;
- }
- });
- for (int i= 0; i < sameNodes.length; i++) {
- ASTNode elem= sameNodes[i];
- LinkedPosition linkedPosition= new LinkedPosition(document, elem.getStartPosition(), elem.getLength(), i);
- if (i == 0)
- fNamePosition= linkedPosition;
- fLinkedPositionGroup.addPosition(linkedPosition);
- }
-
- fLinkedModeModel= new LinkedModeModel();
- fLinkedModeModel.addGroup(fLinkedPositionGroup);
- fLinkedModeModel.forceInstall();
- fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
- fLinkedModeModel.addLinkingListener(new EditorSynchronizer());
-
- LinkedModeUI ui= new EditorLinkedModeUI(fLinkedModeModel, viewer);
- ui.setExitPosition(viewer, offset, 0, Integer.MAX_VALUE);
- ui.setExitPolicy(new ExitPolicy(document));
- ui.enter();
-
- viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y); // by default, full word is selected; restore original selection
-
- if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
- registry.register(fFocusEditingSupport);
- }
-
- openSecondaryPopup();
-// startAnimation();
- fgActiveLinkedMode= this;
-
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
-// private void startAnimation() {
-// //TODO:
-// // - switch off if animations disabled
-// // - show rectangle around target for 500ms after animation
-// Shell shell= fEditor.getSite().getShell();
-// StyledText textWidget= fEditor.getViewer().getTextWidget();
-//
-// // from popup:
-// Rectangle startRect= fPopup.getBounds();
-//
-// // from editor:
-//// Point startLoc= textWidget.getParent().toDisplay(textWidget.getLocation());
-//// Point startSize= textWidget.getSize();
-//// Rectangle startRect= new Rectangle(startLoc.x, startLoc.y, startSize.x, startSize.y);
-//
-// // from hell:
-//// Rectangle startRect= shell.getClientArea();
-//
-// Point caretLocation= textWidget.getLocationAtOffset(textWidget.getCaretOffset());
-// Point displayLocation= textWidget.toDisplay(caretLocation);
-// Rectangle targetRect= new Rectangle(displayLocation.x, displayLocation.y, 0, 0);
-//
-// RectangleAnimation anim= new RectangleAnimation(shell, startRect, targetRect);
-// anim.schedule();
-// }
-
- void doRename(boolean showPreview) {
- cancel();
-
- Image image= null;
- Label label= null;
-
- fShowPreview|= showPreview;
- try {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof SourceViewer) {
- SourceViewer sourceViewer= (SourceViewer) viewer;
- Control viewerControl= sourceViewer.getControl();
- if (viewerControl instanceof Composite) {
- Composite composite= (Composite) viewerControl;
- Display display= composite.getDisplay();
-
- // Flush pending redraw requests:
- while (! display.isDisposed() && display.readAndDispatch()) {
- }
-
- // Copy editor area:
- GC gc= new GC(composite);
- Point size;
- try {
- size= composite.getSize();
- image= new Image(gc.getDevice(), size.x, size.y);
- gc.copyArea(image, 0, 0);
- } finally {
- gc.dispose();
- gc= null;
- }
-
- // Persist editor area while executing refactoring:
- label= new Label(composite, SWT.NONE);
- label.setImage(image);
- label.setBounds(0, 0, size.x, size.y);
- label.moveAbove(null);
- }
- }
-
- String newName= fNamePosition.getContent();
- if (fOriginalName.equals(newName))
- return;
- RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
- if (renameSupport == null)
- return;
-
- Shell shell= fEditor.getSite().getShell();
- boolean executed;
- if (fShowPreview) { // could have been updated by undoAndCreateRenameSupport(..)
- executed= renameSupport.openDialog(shell, true);
- } else {
- renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow());
- executed= true;
- }
- if (executed) {
- restoreFullSelection();
- }
- JavaModelUtil.reconcile(getCompilationUnit());
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- } catch (InterruptedException ex) {
- // canceling is OK -> redo text changes in that case?
- } catch (InvocationTargetException ex) {
- JavaScriptPlugin.log(ex);
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- } finally {
- if (label != null)
- label.dispose();
- if (image != null)
- image.dispose();
- }
- }
-
- public void cancel() {
- if (fLinkedModeModel != null) {
- fLinkedModeModel.exit(ILinkedModeListener.NONE);
- }
- linkedModeLeft();
- }
-
- private void restoreFullSelection() {
- if (fOriginalSelection.y != 0) {
- int originalOffset= fOriginalSelection.x;
- LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition position= positions[i];
- if (! position.isDeleted() && position.includes(originalOffset)) {
- fEditor.getViewer().setSelectedRange(position.offset, position.length);
- return;
- }
- }
- }
- }
-
- private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
- // Assumption: the linked mode model should be shut down by now.
-
- ISourceViewer viewer= fEditor.getViewer();
- final IDocument document= viewer.getDocument();
-
- try {
- if (! fOriginalName.equals(newName)) {
- fEditor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
- Arrays.sort(positions, new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((LinkedPosition) o1).offset - ((LinkedPosition) o2).offset;
- }
- });
- int correction= 0;
- int originalLength= fOriginalName.length();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition position= positions[i];
- try {
- int length= position.getLength();
- document.replace(position.getOffset() + correction, length, fOriginalName);
- correction= correction - length + originalLength;
- } catch (BadLocationException e) {
- throw new InvocationTargetException(e);
- }
- }
- if (fOriginalSaved) {
- fEditor.doSave(monitor); // started saved -> end saved
- }
- }
- });
- }
- } catch (InvocationTargetException e) {
- throw new CoreException(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), ReorgMessages.RenameLinkedMode_error_saving_editor, e));
- } catch (InterruptedException e) {
- // cancelling is OK
- return null;
- } finally {
- JavaModelUtil.reconcile(getCompilationUnit());
- }
-
- viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y);
-
- RenameJavaScriptElementDescriptor descriptor= createRenameDescriptor(fJavaElement, newName);
- RenameSupport renameSupport= RenameSupport.create(descriptor);
- return renameSupport;
- }
-
- private IJavaScriptUnit getCompilationUnit() {
- return (IJavaScriptUnit) EditorUtility.getEditorInputJavaElement(fEditor, false);
- }
-
- public void startFullDialog() {
- cancel();
-
- try {
- String newName= fNamePosition.getContent();
- RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
- if (renameSupport != null)
- renameSupport.openDialog(fEditor.getSite().getShell());
- } catch (CoreException e) {
- JavaScriptPlugin.log(e);
- } catch (BadLocationException e) {
- JavaScriptPlugin.log(e);
- }
- }
-
- /**
- * @param javaElement
- * @param newName
- * @return a rename descriptor with current settings as used in the refactoring dialogs
- * @throws JavaScriptModelException
- */
- private RenameJavaScriptElementDescriptor createRenameDescriptor(IJavaScriptElement javaElement, String newName) throws JavaScriptModelException {
- String contributionId;
- // see RefactoringExecutionStarter#createRenameSupport(..):
- int elementType= javaElement.getElementType();
- switch (elementType) {
- case IJavaScriptElement.JAVASCRIPT_PROJECT:
- contributionId= IJavaScriptRefactorings.RENAME_JAVA_PROJECT;
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
- contributionId= IJavaScriptRefactorings.RENAME_SOURCE_FOLDER;
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- contributionId= IJavaScriptRefactorings.RENAME_PACKAGE;
- break;
- case IJavaScriptElement.JAVASCRIPT_UNIT:
- contributionId= IJavaScriptRefactorings.RENAME_JAVASCRIPT_UNIT;
- break;
- case IJavaScriptElement.TYPE:
- contributionId= IJavaScriptRefactorings.RENAME_TYPE;
- break;
- case IJavaScriptElement.METHOD:
- final IFunction method= (IFunction) javaElement;
- if (method.isConstructor())
- return createRenameDescriptor(method.getDeclaringType(), newName);
- else
- contributionId= IJavaScriptRefactorings.RENAME_METHOD;
- break;
- case IJavaScriptElement.FIELD:
- IField field= (IField) javaElement;
- if (field.isEnumConstant())
- contributionId= IJavaScriptRefactorings.RENAME_ENUM_CONSTANT;
- else
- contributionId= IJavaScriptRefactorings.RENAME_FIELD;
- break;
- case IJavaScriptElement.TYPE_PARAMETER:
- contributionId= IJavaScriptRefactorings.RENAME_TYPE_PARAMETER;
- break;
- case IJavaScriptElement.LOCAL_VARIABLE:
- contributionId= IJavaScriptRefactorings.RENAME_LOCAL_VARIABLE;
- break;
- default:
- return null;
- }
-
- RenameJavaScriptElementDescriptor descriptor= (RenameJavaScriptElementDescriptor) RefactoringCore.getRefactoringContribution(contributionId).createDescriptor();
- descriptor.setJavaElement(javaElement);
- descriptor.setNewName(newName);
- if (elementType != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT)
- descriptor.setUpdateReferences(true);
-
- IDialogSettings javaSettings= JavaScriptPlugin.getDefault().getDialogSettings();
- IDialogSettings refactoringSettings= javaSettings.getSection(RefactoringWizardPage.REFACTORING_SETTINGS); //TODO: undocumented API
- if (refactoringSettings == null) {
- refactoringSettings= javaSettings.addNewSection(RefactoringWizardPage.REFACTORING_SETTINGS);
- }
-
- switch (elementType) {
- case IJavaScriptElement.METHOD:
- case IJavaScriptElement.FIELD:
- descriptor.setDeprecateDelegate(refactoringSettings.getBoolean(DelegateUIHelper.DELEGATE_DEPRECATION));
- descriptor.setKeepOriginal(refactoringSettings.getBoolean(DelegateUIHelper.DELEGATE_UPDATING));
- }
- switch (elementType) {
- case IJavaScriptElement.TYPE:
-// case IJavaScriptElement.JAVASCRIPT_UNIT: // TODO
- descriptor.setUpdateSimilarDeclarations(refactoringSettings.getBoolean(RenameRefactoringWizard.TYPE_UPDATE_SIMILAR_ELEMENTS));
- int strategy;
- try {
- strategy= refactoringSettings.getInt(RenameRefactoringWizard.TYPE_SIMILAR_MATCH_STRATEGY);
- } catch (NumberFormatException e) {
- strategy= RenamingNameSuggestor.STRATEGY_EXACT;
- }
- descriptor.setMatchStrategy(strategy);
- }
- switch (elementType) {
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- descriptor.setUpdateHierarchy(refactoringSettings.getBoolean(RenameRefactoringWizard.PACKAGE_RENAME_SUBPACKAGES));
- }
- switch (elementType) {
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- case IJavaScriptElement.TYPE:
- String fileNamePatterns= refactoringSettings.get(RenameRefactoringWizard.QUALIFIED_NAMES_PATTERNS);
- if (fileNamePatterns != null && fileNamePatterns.length() != 0) {
- descriptor.setFileNamePatterns(fileNamePatterns);
- boolean updateQualifiedNames= refactoringSettings.getBoolean(RenameRefactoringWizard.UPDATE_QUALIFIED_NAMES);
- descriptor.setUpdateQualifiedNames(updateQualifiedNames);
- fShowPreview|= updateQualifiedNames;
- }
- }
- switch (elementType) {
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- case IJavaScriptElement.TYPE:
- case IJavaScriptElement.FIELD:
- boolean updateTextualOccurrences= refactoringSettings.getBoolean(RenameRefactoringWizard.UPDATE_TEXTUAL_MATCHES);
- descriptor.setUpdateTextualOccurrences(updateTextualOccurrences);
- fShowPreview|= updateTextualOccurrences;
- }
- switch (elementType) {
- case IJavaScriptElement.FIELD:
- descriptor.setRenameGetters(refactoringSettings.getBoolean(RenameRefactoringWizard.FIELD_RENAME_GETTER));
- descriptor.setRenameSetters(refactoringSettings.getBoolean(RenameRefactoringWizard.FIELD_RENAME_SETTER));
- }
- return descriptor;
- }
-
- private void linkedModeLeft() {
- fgActiveLinkedMode= null;
- if (fInfoPopup != null) {
- fInfoPopup.close();
- }
-
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
- registry.unregister(fFocusEditingSupport);
- }
- }
-
- private void openSecondaryPopup() {
- fInfoPopup= new RenameInformationPopup(fEditor, this);
- fInfoPopup.open();
- }
-
- public boolean isCaretInLinkedPosition() {
- return getCurrentLinkedPosition() != null;
- }
-
- public LinkedPosition getCurrentLinkedPosition() {
- Point selection= fEditor.getViewer().getSelectedRange();
- int start= selection.x;
- int end= start + selection.y;
- LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition position= positions[i];
- if (position.includes(start) && position.includes(end))
- return position;
- }
- return null;
- }
-
- public boolean isEnabled() {
- try {
- String newName= fNamePosition.getContent();
- if (fOriginalName.equals(newName))
- return false;
- /*
- * TODO: use JavaRenameProcessor#checkNewElementName(String)
- * but make sure implementations don't access outdated Java Model
- * (cache all necessary information before starting linked mode).
- */
- IJavaScriptProject project= fJavaElement.getJavaScriptProject();
- String sourceLevel= project.getOption(JavaScriptCore.COMPILER_SOURCE, true);
- String complianceLevel= project.getOption(JavaScriptCore.COMPILER_COMPLIANCE, true);
- return JavaScriptConventions.validateIdentifier(newName, sourceLevel, complianceLevel).isOK();
- } catch (BadLocationException e) {
- return false;
- }
-
- }
-
- public boolean isOriginalName() {
- try {
- String newName= fNamePosition.getContent();
- return fOriginalName.equals(newName);
- } catch (BadLocationException e) {
- return false;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLocalVariableWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLocalVariableWizard.java
deleted file mode 100644
index f5271bb5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameLocalVariableWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public final class RenameLocalVariableWizard extends RenameRefactoringWizard {
-
- public RenameLocalVariableWizard(Refactoring refactoring) {
- super(
- refactoring,
- RefactoringMessages.RenameLocalVariableWizard_defaultPageTitle,
- RefactoringMessages.RenameTypeParameterWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR, IJavaHelpContextIds.RENAME_LOCAL_VARIABLE_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodUserInterfaceStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodUserInterfaceStarter.java
deleted file mode 100644
index 5d95b273..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodUserInterfaceStarter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-
-public class RenameMethodUserInterfaceStarter extends RenameUserInterfaceStarter {
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter#activate(org.eclipse.wst.jsdt.internal.corext.refactoring.base.Refactoring, org.eclipse.swt.widgets.Shell)
- */
- public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
- RenameVirtualMethodProcessor processor= (RenameVirtualMethodProcessor)refactoring.getAdapter(RenameVirtualMethodProcessor.class);
- if (processor != null) {
- RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
- if (!status.hasFatalError()) {
- IFunction method= processor.getMethod();
- if (!method.equals(processor.getOriginalMethod())) {
- String message= null;
- if (method.getDeclaringType()!=null && method.getDeclaringType().isInterface()) {
- message= Messages.format(
- RefactoringCoreMessages.MethodChecks_implements,
- new String[]{
- JavaElementUtil.createMethodSignature(method),
- JavaModelUtil.getFullyQualifiedName(method.getDeclaringType())});
- } else {
- message= Messages.format(
- RefactoringCoreMessages.MethodChecks_overrides,
- new String[]{
- JavaElementUtil.createMethodSignature(method),
- JavaModelUtil.getFullyQualifiedName(method.getDeclaringType())});
- }
- message= Messages.format(
- ReorgMessages.RenameMethodUserInterfaceStarter_message,
- message);
- if (!MessageDialog.openQuestion(parent,
- ReorgMessages.RenameMethodUserInterfaceStarter_name,
- message)) {
- return false;
- }
- }
- }
- }
- return super.activate(refactoring, parent, saveMode);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodWizard.java
deleted file mode 100644
index afc5d7c3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameMethodWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameMethodWizard extends RenameRefactoringWizard {
-
- public RenameMethodWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenameMethodWizard_defaultPageTitle,
- RefactoringMessages.RenameMethodWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR_METHOD,
- IJavaHelpContextIds.RENAME_METHOD_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenamePackageWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenamePackageWizard.java
deleted file mode 100644
index 71a3e344..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenamePackageWizard.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamePackageProcessor;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-
-
-public class RenamePackageWizard extends RenameRefactoringWizard {
-
- public RenamePackageWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenamePackageWizard_defaultPageTitle,
- RefactoringMessages.RenamePackageWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR_PACKAGE,
- IJavaHelpContextIds.RENAME_PACKAGE_WIZARD_PAGE);
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenamePackageInputWizardPage(message, IJavaHelpContextIds.RENAME_PACKAGE_WIZARD_PAGE, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- };
- }
-
- private static class RenamePackageInputWizardPage extends RenameInputWizardPage {
-
- private Button fRenameSubpackages;
- public RenamePackageInputWizardPage(String message, String contextHelpId, String initialValue) {
- super(message, contextHelpId, true, initialValue);
- }
-
- protected void addAdditionalOptions(Composite composite, RowLayouter layouter) {
- fRenameSubpackages= new Button(composite, SWT.CHECK);
- fRenameSubpackages.setText(RefactoringMessages.RenamePackageWizard_rename_subpackages);
- boolean subpackagesSelection= getBooleanSetting(RenameRefactoringWizard.PACKAGE_RENAME_SUBPACKAGES, getRenamePackageProcessor().getRenameSubpackages());
- fRenameSubpackages.setSelection(subpackagesSelection);
- getRenamePackageProcessor().setRenameSubpackages(subpackagesSelection);
- fRenameSubpackages.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fRenameSubpackages.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- getRenamePackageProcessor().setRenameSubpackages(fRenameSubpackages.getSelection());
- }
- });
- layouter.perform(fRenameSubpackages);
-
- Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layouter.perform(separator);
- }
-
- public void dispose() {
- if (saveSettings() && fRenameSubpackages.isEnabled())
- saveBooleanSetting(RenameRefactoringWizard.PACKAGE_RENAME_SUBPACKAGES, fRenameSubpackages);
- super.dispose();
- }
-
- private RenamePackageProcessor getRenamePackageProcessor() {
- return (RenamePackageProcessor) ((RenameRefactoring) getRefactoring()).getProcessor();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameRefactoringWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameRefactoringWizard.java
deleted file mode 100644
index 4ed13f70..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameRefactoringWizard.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.INameUpdating;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameRefactoringWizard extends RefactoringWizard {
-
- private final String fInputPageDescription;
- private final String fPageContextHelpId;
- private final ImageDescriptor fInputPageImageDescriptor;
-
- // dialog settings constants:
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String UPDATE_TEXTUAL_MATCHES= "updateTextualMatches"; //$NON-NLS-1$
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String UPDATE_QUALIFIED_NAMES= "updateQualifiedNames"; //$NON-NLS-1$
- /**
- * Dialog settings key (value is of type String).
- */
- public static final String QUALIFIED_NAMES_PATTERNS= "patterns"; //$NON-NLS-1$
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String TYPE_UPDATE_SIMILAR_ELEMENTS= "updateSimilarElements"; //$NON-NLS-1$
- /**
- * Dialog settings key (value is of type int).
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamingNameSuggestor
- */
- public static final String TYPE_SIMILAR_MATCH_STRATEGY= "updateSimilarElementsMatchStrategy"; //$NON-NLS-1$
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String PACKAGE_RENAME_SUBPACKAGES= "renameSubpackages"; //$NON-NLS-1$
-
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String FIELD_RENAME_GETTER= "renameGetter"; //$NON-NLS-1$
- /**
- * Dialog settings key (value is of type boolean).
- */
- public static final String FIELD_RENAME_SETTER= "renameSetter"; //$NON-NLS-1$
-
-
- public RenameRefactoringWizard(Refactoring refactoring, String defaultPageTitle, String inputPageDescription,
- ImageDescriptor inputPageImageDescriptor, String pageContextHelpId) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(defaultPageTitle);
- fInputPageDescription= inputPageDescription;
- fInputPageImageDescriptor= inputPageImageDescriptor;
- fPageContextHelpId= pageContextHelpId;
- setDialogSettings(JavaScriptPlugin.getDefault().getDialogSettings());
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- String initialSetting= getNameUpdating().getCurrentElementName();
- RenameInputWizardPage inputPage= createInputPage(fInputPageDescription, initialSetting);
- inputPage.setImageDescriptor(fInputPageImageDescriptor);
- addPage(inputPage);
- }
-
- private INameUpdating getNameUpdating() {
- return (INameUpdating)getRefactoring().getAdapter(INameUpdating.class);
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameInputWizardPage(message, fPageContextHelpId, true, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- };
- }
-
- protected RefactoringStatus validateNewName(String newName) {
- INameUpdating ref= getNameUpdating();
- ref.setNewElementName(newName);
- try{
- return ref.checkNewElementName(newName);
- } catch (CoreException e){
- JavaScriptPlugin.log(e);
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.RenameRefactoringWizard_internal_error);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameResourceWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameResourceWizard.java
deleted file mode 100644
index 246e222a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameResourceWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameResourceWizard extends RenameRefactoringWizard {
-
- public RenameResourceWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenameResourceWizard_defaultPageTitle,
- RefactoringMessages.RenameResourceWizard_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR,
- IJavaHelpContextIds.RENAME_RESOURCE_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSelectionState.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSelectionState.java
deleted file mode 100644
index 1372beb7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSelectionState.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-public class RenameSelectionState {
- private final Display fDisplay;
- private final Object fElement;
- private final List fParts;
- private final List fSelections;
-
- public RenameSelectionState(Object element) {
- fElement= element;
- fParts= new ArrayList();
- fSelections= new ArrayList();
-
- IWorkbenchWindow dw = JavaScriptPlugin.getActiveWorkbenchWindow();
- if (dw == null) {
- fDisplay= null;
- return;
- }
- fDisplay= dw.getShell().getDisplay();
- IWorkbenchPage page = dw.getActivePage();
- if (page == null)
- return;
- IViewReference vrefs[]= page.getViewReferences();
- for(int i= 0; i < vrefs.length; i++) {
- consider(vrefs[i].getPart(false));
- }
- IEditorReference refs[]= page.getEditorReferences();
- for(int i= 0; i < refs.length; i++) {
- consider(refs[i].getPart(false));
- }
- }
-
- private void consider(IWorkbenchPart part) {
- if (part == null)
- return;
- ISetSelectionTarget target= null;
- if (!(part instanceof ISetSelectionTarget)) {
- target= (ISetSelectionTarget)part.getAdapter(ISetSelectionTarget.class);
- if (target == null)
- return;
- } else {
- target= (ISetSelectionTarget)part;
- }
- ISelectionProvider selectionProvider= part.getSite().getSelectionProvider();
- if (selectionProvider == null)
- return;
- ISelection s= selectionProvider.getSelection();
- if (!(s instanceof IStructuredSelection))
- return;
- IStructuredSelection selection= (IStructuredSelection)s;
- if (!selection.toList().contains(fElement))
- return;
- fParts.add(part);
- fSelections.add(selection);
- }
-
- public void restore(Object newElement) {
- if (fDisplay == null)
- return;
- for (int i= 0; i < fParts.size(); i++) {
- IStructuredSelection currentSelection= (IStructuredSelection)fSelections.get(i);
- boolean changed= false;
- final ISetSelectionTarget target= (ISetSelectionTarget)fParts.get(i);
- final IStructuredSelection[] newSelection= new IStructuredSelection[1];
- newSelection[0]= currentSelection;
- if (currentSelection instanceof TreeSelection) {
- TreeSelection treeSelection= (TreeSelection)currentSelection;
- TreePath[] paths= treeSelection.getPaths();
- for (int p= 0; p < paths.length; p++) {
- TreePath path= paths[p];
- if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) {
- paths[p]= createTreePath(path, newElement);
- changed= true;
- }
- }
- if (changed) {
- newSelection[0]= new TreeSelection(paths, treeSelection.getElementComparer());
- }
- } else {
- Object[] elements= currentSelection.toArray();
- for (int e= 0; e < elements.length; e++) {
- if (elements[e].equals(fElement)) {
- elements[e]= newElement;
- changed= true;
- }
- }
- if (changed) {
- newSelection[0]= new StructuredSelection(elements);
- }
- }
- if (changed) {
- fDisplay.asyncExec(new Runnable() {
- public void run() {
- target.selectReveal(newSelection[0]);
- }
- });
- }
- }
- }
-
- // Method assumes that segment count of path > 0.
- private TreePath createTreePath(TreePath old, Object newElement) {
- int count= old.getSegmentCount();
- Object[] newObjects= new Object[count];
- for (int i= 0; i < count - 1; i++) {
- newObjects[i]= old.getSegment(i);
- }
- newObjects[count - 1]= newElement;
- return new TreePath(newObjects);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSourceFolderWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSourceFolderWizard.java
deleted file mode 100644
index 1a95fbbb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameSourceFolderWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameSourceFolderWizard extends RenameRefactoringWizard {
-
- public RenameSourceFolderWizard(Refactoring refactoring) {
- super(refactoring,
- RefactoringMessages.RenameSourceFolder_defaultPageTitle,
- RefactoringMessages.RenameSourceFolder_inputPage_description,
- JavaPluginImages.DESC_WIZBAN_REFACTOR,
- IJavaHelpContextIds.RENAME_SOURCE_FOLDER_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeParameterWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeParameterWizard.java
deleted file mode 100644
index 33bcc9dd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeParameterWizard.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-/**
- * Wizard for the rename type parameter refactoring.
- */
-public final class RenameTypeParameterWizard extends RenameRefactoringWizard {
-
- /**
- * Creates a new rename type parameter wizard.
- *
- * @param refactoring
- * the refactoring to create the wizard for
- */
- public RenameTypeParameterWizard(Refactoring refactoring) {
- super(refactoring, RefactoringMessages.RenameTypeParameterWizard_defaultPageTitle, RefactoringMessages.RenameTypeParameterWizard_inputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR, IJavaHelpContextIds.RENAME_TYPE_PARAMETER_WIZARD_PAGE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizard.java
deleted file mode 100644
index c0193313..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizard.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameTypeProcessor;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-/**
- * The type renaming wizard.
- */
-public class RenameTypeWizard extends RenameRefactoringWizard {
-
- public RenameTypeWizard(Refactoring refactoring) {
- this(refactoring, RefactoringMessages.RenameTypeWizard_defaultPageTitle, RefactoringMessages.RenameTypeWizardInputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR_TYPE,
- IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE);
- }
-
- public RenameTypeWizard(Refactoring refactoring, String defaultPageTitle, String inputPageDescription, ImageDescriptor inputPageImageDescriptor, String pageContextHelpId) {
- super(refactoring, defaultPageTitle, inputPageDescription, inputPageImageDescriptor, pageContextHelpId);
- }
-
- /*
- * non java-doc
- *
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- super.addUserInputPages();
- if (isRenameType())
- addPage(new RenameTypeWizardSimilarElementsPage());
-
- }
-
- public RenameTypeProcessor getRenameTypeProcessor() {
- RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor();
- if (proc instanceof RenameTypeProcessor)
- return (RenameTypeProcessor) proc;
- else if (proc instanceof RenameCompilationUnitProcessor) {
- RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc;
- return rcu.getRenameTypeProcessor();
- }
- Assert.isTrue(false); // Should never get here
- return null;
- }
-
- protected boolean isRenameType() {
- return true;
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameTypeWizardInputPage(message, IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE, true, initialSetting) {
-
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardInputPage.java
deleted file mode 100644
index de516370..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardInputPage.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-
-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.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameTypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.ISimilarDeclarationUpdating;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.RowLayouter;
-
-/**
- * Wizard page for renaming a type (with similarly named elements)
- *
- *
- *
- */
-class RenameTypeWizardInputPage extends RenameInputWizardPage {
-
- private Button fUpdateSimilarElements;
- private int fSelectedStrategy;
-
- private Link fUpdateSimilarElementsButton;
-
- public RenameTypeWizardInputPage(String description, String contextHelpId, boolean isLastUserPage, String initialValue) {
- super(description, contextHelpId, isLastUserPage, initialValue);
- }
-
- protected void addAdditionalOptions(Composite composite, RowLayouter layouter) {
-
- if (getSimilarElementUpdating() == null || !getSimilarElementUpdating().canEnableSimilarDeclarationUpdating())
- return;
-
- try {
- fSelectedStrategy= getRefactoringSettings().getInt(RenameRefactoringWizard.TYPE_SIMILAR_MATCH_STRATEGY);
- } catch (NumberFormatException e) {
- fSelectedStrategy= getSimilarElementUpdating().getMatchStrategy();
- }
-
- getSimilarElementUpdating().setMatchStrategy(fSelectedStrategy);
-
- Composite c= new Composite(composite, SWT.NULL);
- GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- c.setLayout(layout);
-
- fUpdateSimilarElements= new Button(c, SWT.CHECK);
- fUpdateSimilarElements.setText(RefactoringMessages.RenameTypeWizardInputPage_update_similar_elements);
-
- final boolean updateSimilarElements= getBooleanSetting(RenameRefactoringWizard.TYPE_UPDATE_SIMILAR_ELEMENTS, getSimilarElementUpdating().getUpdateSimilarDeclarations());
- fUpdateSimilarElements.setSelection(updateSimilarElements);
- getSimilarElementUpdating().setUpdateSimilarDeclarations(updateSimilarElements);
- fUpdateSimilarElements.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fUpdateSimilarElements.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- getSimilarElementUpdating().setUpdateSimilarDeclarations(fUpdateSimilarElements.getSelection());
- fUpdateSimilarElementsButton.setEnabled(fUpdateSimilarElements.getSelection());
- }
- });
-
- fUpdateSimilarElementsButton= new Link(c, SWT.NONE);
- GridData d= new GridData();
- d.grabExcessHorizontalSpace= true;
- d.horizontalAlignment= SWT.RIGHT;
- fUpdateSimilarElementsButton.setText(RefactoringMessages.RenameTypeWizardInputPage_update_similar_elements_configure);
- fUpdateSimilarElementsButton.setEnabled(updateSimilarElements);
- fUpdateSimilarElementsButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- RenameTypeWizardSimilarElementsOptionsDialog dialog= new RenameTypeWizardSimilarElementsOptionsDialog(getShell(), fSelectedStrategy);
- if (dialog.open() == Window.OK) {
- fSelectedStrategy= dialog.getSelectedStrategy();
- getSimilarElementUpdating().setMatchStrategy(fSelectedStrategy);
- }
- }
- });
- fUpdateSimilarElementsButton.setLayoutData(d);
-
- GridData forC= new GridData();
- forC.grabExcessHorizontalSpace= true;
- forC.horizontalAlignment= SWT.FILL;
- forC.horizontalSpan= 2;
- c.setLayoutData(forC);
-
- final Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layouter.perform(separator);
- }
-
- public void dispose() {
- if (saveSettings())
- if (fUpdateSimilarElements != null && !fUpdateSimilarElements.isDisposed() && fUpdateSimilarElements.isEnabled()) {
- saveBooleanSetting(RenameRefactoringWizard.TYPE_UPDATE_SIMILAR_ELEMENTS, fUpdateSimilarElements);
- getRefactoringSettings().put(RenameRefactoringWizard.TYPE_SIMILAR_MATCH_STRATEGY, fSelectedStrategy);
- }
-
- super.dispose();
- }
-
- /*
- * Override - we don't want to initialize the next page (may needlessly
- * trigger change creation if similar elements page is skipped, which is not
- * indicated by fIsLastUserInputPage in parent).
- */
- public boolean canFlipToNextPage() {
- return isPageComplete();
- }
-
- private ISimilarDeclarationUpdating getSimilarElementUpdating() {
- return (ISimilarDeclarationUpdating) getRefactoring().getAdapter(ISimilarDeclarationUpdating.class);
- }
-
- protected boolean performFinish() {
- boolean returner= super.performFinish();
- // check if we got deferred to the error page
- if (!returner && getContainer().getCurrentPage() != null)
- getContainer().getCurrentPage().setPreviousPage(this);
- return returner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.ui.refactoring.UserInputWizardPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- RenameTypeWizard wizard= (RenameTypeWizard) getWizard();
- IWizardPage nextPage;
-
- if (wizard.isRenameType()) {
- final RenameTypeProcessor renameTypeProcessor= wizard.getRenameTypeProcessor();
- try {
- getContainer().run(true, true, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor pm) throws InterruptedException {
- try {
- renameTypeProcessor.initializeReferences(pm);
- } catch (OperationCanceledException e) {
- throw new InterruptedException();
- } catch (CoreException e) {
- ExceptionHandler.handle(e, RefactoringMessages.RenameTypeWizard_defaultPageTitle,
- RefactoringMessages.RenameTypeWizard_unexpected_exception);
- } finally {
- pm.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.RenameTypeWizard_defaultPageTitle,
- RefactoringMessages.RenameTypeWizard_unexpected_exception);
- } catch (InterruptedException e) {
- // user canceled
- return this;
- }
-
- if (renameTypeProcessor.hasSimilarElementsToRename()) {
- nextPage= super.getNextPage();
- } else {
- nextPage= computeSuccessorPage();
- }
-
- } else
- nextPage= computeSuccessorPage();
-
- nextPage.setPreviousPage(this);
- return nextPage;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsOptionsDialog.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsOptionsDialog.java
deleted file mode 100644
index 6154e656..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsOptionsDialog.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamingNameSuggestor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-
-/**
- * Option dialog for selecting a similarly named element renaming strategy
- *
- *
- *
- */
-public class RenameTypeWizardSimilarElementsOptionsDialog extends MessageDialog {
-
- private SelectionButtonDialogField fExactStrategyRadio;
- private SelectionButtonDialogField fEmbeddedStrategyRadio;
- private SelectionButtonDialogField fSuffixStrategyRadio;
-
- private Label fWarningLabel;
- private Label fWarningImageLabel;
- private int fSelectedStrategy;
-
- public RenameTypeWizardSimilarElementsOptionsDialog(Shell parentShell, int defaultStrategy) {
- super(parentShell, RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_title, null, new String(), INFORMATION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- fSelectedStrategy= defaultStrategy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createMessageArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite messageComposite= new Composite(parent, SWT.NONE);
- messageComposite.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- messageComposite.setLayout(layout);
- messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Label infoLabel= new Label(messageComposite, SWT.WRAP);
- infoLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_select_strategy);
- GridData gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
- gd.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- infoLabel.setLayoutData(gd);
- infoLabel.setFont(parent.getFont());
-
- int indent= convertWidthInCharsToPixels(3);
-
- fExactStrategyRadio= new SelectionButtonDialogField(SWT.RADIO);
- fExactStrategyRadio.setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_1);
- fExactStrategyRadio.doFillIntoGrid(messageComposite, 1);
- fExactStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EXACT);
- LayoutUtil.setHorizontalIndent(fExactStrategyRadio.getSelectionButton(null), indent);
-
- fEmbeddedStrategyRadio= new SelectionButtonDialogField(SWT.RADIO);
- fEmbeddedStrategyRadio.setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_2);
- fEmbeddedStrategyRadio.doFillIntoGrid(messageComposite, 1);
- fEmbeddedStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EMBEDDED);
- LayoutUtil.setHorizontalIndent(fEmbeddedStrategyRadio.getSelectionButton(null), indent);
-
- fSuffixStrategyRadio= new SelectionButtonDialogField(SWT.RADIO);
- fSuffixStrategyRadio.setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_3);
- fSuffixStrategyRadio.doFillIntoGrid(messageComposite, 1);
- fSuffixStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_SUFFIX);
- LayoutUtil.setHorizontalIndent(fSuffixStrategyRadio.getSelectionButton(null), indent);
-
- final Composite warningComposite= new Composite(messageComposite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- warningComposite.setLayout(layout);
- warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- warningComposite.setFont(messageComposite.getFont());
-
- Image image= Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
- fWarningImageLabel= new Label(warningComposite, SWT.LEFT | SWT.WRAP);
- fWarningImageLabel.setImage(image);
- fWarningImageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
-
- fWarningLabel= new Label(warningComposite, SWT.WRAP);
- fWarningLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names);
- GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
- gridData.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- fWarningLabel.setLayoutData(gridData);
- fWarningLabel.setFont(warningComposite.getFont());
-
- fExactStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {
-
- public void dialogFieldChanged(DialogField field) {
- updateLabel();
- fSelectedStrategy= RenamingNameSuggestor.STRATEGY_EXACT;
- }
- });
-
- fEmbeddedStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {
-
- public void dialogFieldChanged(DialogField field) {
- updateLabel();
- fSelectedStrategy= RenamingNameSuggestor.STRATEGY_EMBEDDED;
- }
- });
-
- fSuffixStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {
-
- public void dialogFieldChanged(DialogField field) {
- updateLabel();
- fSelectedStrategy= RenamingNameSuggestor.STRATEGY_SUFFIX;
- }
- });
-
- updateLabel();
-
- return messageComposite;
- }
-
-
- protected boolean customShouldTakeFocus() {
- return true;
- }
-
- private void updateLabel() {
- fWarningImageLabel.setEnabled(!fExactStrategyRadio.isSelected());
- fWarningLabel.setEnabled(!fExactStrategyRadio.isSelected());
- }
-
- /**
- * @return one of the STRATEGY_* constants in {@link RenamingNameSuggestor}
- */
- public int getSelectedStrategy() {
- return fSelectedStrategy;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsPage.java
deleted file mode 100644
index 992f7090..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameTypeWizardSimilarElementsPage.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptConventions;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.Checks;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameTypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-/**
- *
- * Wizard page for displaying a tree of similarly named elements renamed along with a
- * type.
- *
- *
- *
- */
-class RenameTypeWizardSimilarElementsPage extends UserInputWizardPage {
-
- public static class EditElementDialog extends StatusDialog implements IDialogFieldListener {
-
- private StringDialogField fNameField;
- private IJavaScriptElement fElementToEdit;
-
- public EditElementDialog(Shell parent, IJavaScriptElement elementToEdit, String newName) {
- super(parent);
- setTitle(RefactoringMessages.RenameTypeWizardSimilarElementsPage_change_element_name);
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- fElementToEdit= elementToEdit;
-
- fNameField= new StringDialogField();
- fNameField.setDialogFieldListener(this);
- fNameField.setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsPage_enter_new_name);
-
- fNameField.setText(newName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- final Composite composite= (Composite) super.createDialogArea(parent);
- LayoutUtil.doDefaultLayout(composite, new DialogField[] { fNameField }, true, SWT.DEFAULT, SWT.DEFAULT);
- fNameField.postSetFocusOnDialogField(parent.getDisplay());
-
- LayoutUtil.setWidthHint(fNameField.getLabelControl(null), convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH));
- Text text= fNameField.getTextControl(null);
- LayoutUtil.setHorizontalGrabbing(text);
- TextFieldNavigationHandler.install(text);
-
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- if (field == fNameField)
- updateStatus(validateSettings());
- }
-
- private IStatus validateSettings() {
- final String name= fNameField.getText();
- if (name.length() == 0) {
- return new StatusInfo(IStatus.ERROR, RefactoringMessages.RenameTypeWizardSimilarElementsPage_name_empty);
- }
- IStatus status= JavaScriptConventions.validateIdentifier(name);
- if (status.matches(IStatus.ERROR))
- return status;
- if (!Checks.startsWithLowerCase(name))
- return new StatusInfo(IStatus.WARNING, RefactoringMessages.RenameTypeWizardSimilarElementsPage_name_should_start_lowercase);
-
- if (fElementToEdit instanceof IMember && ((IMember) fElementToEdit).getDeclaringType() != null) {
- IType type= ((IMember) fElementToEdit).getDeclaringType();
- if (fElementToEdit instanceof IField) {
- final IField f= type.getField(name);
- if (f.exists())
- return new StatusInfo(IStatus.ERROR, RefactoringMessages.RenameTypeWizardSimilarElementsPage_field_exists);
- }
- if (fElementToEdit instanceof IFunction) {
- final IFunction m= type.getFunction(name, ((IFunction) fElementToEdit).getParameterTypes());
- if (m.exists())
- return new StatusInfo(IStatus.ERROR, RefactoringMessages.RenameTypeWizardSimilarElementsPage_method_exists);
- }
- }
-
- // cannot check local variables; no .getLocalVariable(String) in IMember
-
- return StatusInfo.OK_STATUS;
- }
-
- public String getNewName() {
- return fNameField.getText();
- }
- }
-
- private static class SimilarElementTreeContentProvider implements ITreeContentProvider {
-
- private Map/* <IJavaScriptElement,Set<IJavaScriptElement>> */fTreeElementMap;
- private Set/* <IJavaScriptUnit> */fTopLevelElements;
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
- final Set children= (Set) fTreeElementMap.get(parentElement);
- if (children != null)
- return children.toArray();
- else
- return new Object[0];
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- if (element instanceof IMember || element instanceof ILocalVariable) {
- return ((IJavaScriptElement) element).getParent();
- }
- if (element instanceof IJavaScriptUnit)
- return null;
- Assert.isTrue(false, "Should not get here"); //$NON-NLS-1$
- return null;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return fTreeElementMap.containsKey(element);
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
- Assert.isTrue(inputElement == null || inputElement instanceof Map);
- return fTopLevelElements.toArray();
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- fTreeElementMap.clear();
- fTreeElementMap= null;
- fTopLevelElements= null;
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- Assert.isTrue(newInput == null || newInput instanceof Map);
- if (newInput == null)
- return;
- final Map similarElementsMap= (Map) newInput;
- final IJavaScriptElement[] similarElements= (IJavaScriptElement[]) similarElementsMap.keySet().toArray(new IJavaScriptElement[0]);
- fTreeElementMap= new HashMap();
- fTopLevelElements= new HashSet();
- for (int i= 0; i < similarElements.length; i++) {
- final IType declaring= (IType) similarElements[i].getAncestor(IJavaScriptElement.TYPE);
- if (similarElements[i] instanceof IMember) {
- // methods, fields, initializers, inner types
- addToMap(declaring, similarElements[i]);
- } else {
- // local variables
- final IJavaScriptElement parent= similarElements[i].getParent();
- if (parent instanceof IMember) {
- // parent is a method or an initializer
- addToMap(parent, similarElements[i]);
- addToMap(declaring, parent);
- }
- }
- handleDeclaring(declaring);
- }
- }
-
- private void handleDeclaring(final IJavaScriptElement someType) {
-
- final IJavaScriptElement enclosing= someType.getParent();
- if (enclosing instanceof IJavaScriptUnit) {
- fTopLevelElements.add(someType.getParent());
- addToMap(someType.getParent(), someType);
- } else {
- addToMap(enclosing, someType);
- handleDeclaring(enclosing);
- }
- }
-
- private void addToMap(final IJavaScriptElement key, final IJavaScriptElement element) {
- Set elements= (Set) fTreeElementMap.get(key);
- if (elements == null) {
- elements= new HashSet();
- fTreeElementMap.put(key, elements);
- }
- elements.add(element);
- }
-
- }
-
- private static class SimilarLabelProvider extends JavaScriptElementLabelProvider {
-
- private Map fDescriptorImageMap= new HashMap();
- private Map fElementToNewName;
-
- public SimilarLabelProvider() {
- super(JavaScriptElementLabelProvider.SHOW_DEFAULT | JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
- public void initialize(Map elementToNewName) {
- this.fElementToNewName= elementToNewName;
- }
-
- public void dispose() {
- for (Iterator iter= fDescriptorImageMap.values().iterator(); iter.hasNext();) {
- Image image= (Image) iter.next();
- image.dispose();
- }
- super.dispose();
- }
-
- private Image manageImageDescriptor(ImageDescriptor descriptor) {
- Image image= (Image) fDescriptorImageMap.get(descriptor);
- if (image == null) {
- image= descriptor.createImage();
- fDescriptorImageMap.put(descriptor, image);
- }
- return image;
- }
-
- public Image getImage(Object element) {
- if (isSimilarElement(element))
- return manageImageDescriptor(JavaPluginImages.DESC_OBJS_DEFAULT_CHANGE);
- return super.getImage(element);
- }
-
- public Image getJavaImage(Object element) {
- return super.getImage(element);
- }
-
- public String getText(Object element) {
- if (isSimilarElement(element)) {
- return Messages.format(RefactoringMessages.RenameTypeWizardSimilarElementsPage_rename_to, new String[] { super.getText(element), (String)fElementToNewName.get(element) } );
- }
- return super.getText(element);
- }
-
- private boolean isSimilarElement(Object element) {
- return fElementToNewName.containsKey(element);
- }
-
- }
-
- private static class SimilarElementComparator extends JavaScriptElementComparator {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.jsdt.ui.JavaElementSorter#category(java.lang.Object)
- */
- public int category(Object element) {
-
- /*
- * We'd like to present the elements in the same order as they
- * appear in the source. This can be achieved by assigning a
- * distinct category to every element; the category being derived
- * from the source position of the element.
- */
-
- ISourceRange sourceRange= null;
- if (element instanceof IMember) {
- IMember member= (IMember) element;
- try {
- sourceRange= member.getNameRange();
- } catch (JavaScriptModelException e) {
- // fall through
- }
- }
- if (element instanceof ILocalVariable) {
- ILocalVariable var= (ILocalVariable) element;
- sourceRange= var.getNameRange();
- }
-
- if (sourceRange != null)
- return 100 + sourceRange.getOffset(); // +100: safe distance from all other categories.
-
- return super.category(element);
- }
- }
-
- public static final String PAGE_NAME= "SimilarElementSelectionPage"; //$NON-NLS-1$
-
- private final long LABEL_FLAGS= JavaScriptElementLabels.DEFAULT_QUALIFIED | JavaScriptElementLabels.ROOT_POST_QUALIFIED | JavaScriptElementLabels.APPEND_ROOT_PATH | JavaScriptElementLabels.M_PARAMETER_TYPES
- | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_APP_RETURNTYPE | JavaScriptElementLabels.M_EXCEPTIONS | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.T_TYPE_PARAMETERS;
-
- private Label fSimilarElementsLabel;
- private SourceViewer fSourceViewer;
- private ContainerCheckedTreeViewer fTreeViewer;
- private SimilarLabelProvider fTreeViewerLabelProvider;
- private Map fSimilarElementsToNewName;
- private Button fEditElementButton;
- private boolean fWasInitialized;
- private CLabel fCurrentElementLabel;
-
- public RenameTypeWizardSimilarElementsPage() {
- super(PAGE_NAME);
- }
-
- // --- UI creation
-
- public void createControl(Composite parent) {
-
- ViewForm viewForm= new ViewForm(parent, SWT.BORDER | SWT.FLAT);
-
- Composite inner= new Composite(viewForm, SWT.NULL);
- GridLayout layout= new GridLayout();
- inner.setLayout(layout);
-
- createTreeAndSourceViewer(inner);
- createButtonComposite(inner);
- viewForm.setContent(inner);
-
- setControl(viewForm);
-
- Dialog.applyDialogFont(viewForm);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE);
- }
-
- private void createTreeAndSourceViewer(Composite superComposite) {
- SashForm composite= new SashForm(superComposite, SWT.HORIZONTAL);
- initializeDialogUnits(superComposite);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(20);
- gd.widthHint= convertWidthInCharsToPixels(10);
- composite.setLayoutData(gd);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createSimilarElementTreeComposite(composite);
- createSourceViewerComposite(composite);
- composite.setWeights(new int[] { 50, 50 });
- }
-
- private void createSimilarElementTreeComposite(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- composite.setLayout(layout);
-
- createTypeHierarchyLabel(composite);
- createTreeViewer(composite);
- }
-
- private void createTypeHierarchyLabel(Composite composite) {
- fSimilarElementsLabel= new Label(composite, SWT.WRAP);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= JavaElementImageProvider.SMALL_SIZE.x;
- fSimilarElementsLabel.setLayoutData(gd);
- fSimilarElementsLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsPage_review_similar_elements);
- }
-
- private void createTreeViewer(Composite composite) {
- Tree tree= new Tree(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- fTreeViewer= new ContainerCheckedTreeViewer(tree);
- fTreeViewer.setUseHashlookup(true);
- fTreeViewer.setComparator(new SimilarElementComparator());
- fTreeViewer.setContentProvider(new SimilarElementTreeContentProvider());
- fTreeViewerLabelProvider= new SimilarLabelProvider();
- fTreeViewer.setLabelProvider(fTreeViewerLabelProvider);
- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- RenameTypeWizardSimilarElementsPage.this.treeViewerSelectionChanged(event);
- }
- });
- fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- RenameTypeWizardSimilarElementsPage.this.editCurrentElement();
- }
- });
- }
-
- private void createSourceViewerComposite(Composite parent) {
- Composite c= new Composite(parent, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- c.setLayout(layout);
-
- createSourceViewerLabel(c);
- createSourceViewer(c);
- }
-
- private void createSourceViewerLabel(Composite c) {
- fCurrentElementLabel= new CLabel(c, SWT.NONE);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= JavaElementImageProvider.SMALL_SIZE.x;
- fCurrentElementLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsPage_select_element_to_view_source);
- fCurrentElementLabel.setLayoutData(gd);
- }
-
- private void createSourceViewer(Composite c) {
- IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
- fSourceViewer= new JavaSourceViewer(c, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store);
- fSourceViewer.configure(new JavaScriptSourceViewerConfiguration(getJavaTextTools().getColorManager(), store, null, null));
- fSourceViewer.setEditable(false);
- fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
- Document document= new Document();
- getJavaTextTools().setupJavaDocumentPartitioner(document);
- fSourceViewer.setDocument(document);
- }
-
- private static JavaScriptTextTools getJavaTextTools() {
- return JavaScriptPlugin.getDefault().getJavaTextTools();
- }
-
- private void createButtonComposite(Composite superComposite) {
- Composite buttonComposite= new Composite(superComposite, SWT.NONE);
- buttonComposite.setLayoutData(new GridData());
- GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- buttonComposite.setLayout(layout);
-
- Button returnToDefaults= new Button(buttonComposite, SWT.PUSH);
- returnToDefaults.setText(RefactoringMessages.RenameTypeWizardSimilarElementsPage_restore_defaults);
- returnToDefaults.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(returnToDefaults);
- returnToDefaults.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- RenameTypeWizardSimilarElementsPage.this.resetDataInRefAndUI();
- }
- });
- fEditElementButton= new Button(buttonComposite, SWT.PUSH);
- fEditElementButton.setText(RefactoringMessages.RenameTypeWizardSimilarElementsPage_change_name);
- fEditElementButton.setLayoutData(new GridData());
- fEditElementButton.setEnabled(false);
- SWTUtil.setButtonDimensionHint(fEditElementButton);
- fEditElementButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- RenameTypeWizardSimilarElementsPage.this.editCurrentElement();
- }
- });
- }
-
-
- // ---------------------- Acting
-
- public void setVisible(boolean visible) {
- if (visible) {
- initializeUIFromRef();
- }
- super.setVisible(visible);
- selectFirstElement();
- }
-
- private void selectFirstElement() {
- if (fTreeViewer.getTree().getItemCount() > 0) {
- TreeItem item= fTreeViewer.getTree().getItem(0);
- if (item.getData() != null) {
- fTreeViewer.reveal(item.getData());
- Object data= getFirstSimilarElement(item);
- if (data != null) {
- fTreeViewer.setSelection(new StructuredSelection(data));
- }
- }
- }
- fTreeViewer.getTree().setFocus();
- }
-
- private Object getFirstSimilarElement(TreeItem item) {
- Object data= item.getData();
- if (isSimilarElement(data)) {
- return data;
- } else {
- TreeItem[] children= item.getItems();
- for (int i= 0; i < children.length; i++) {
- Object childData= getFirstSimilarElement(children[i]);
- if (childData != null)
- return childData;
- }
- }
- return null;
- }
-
- private void initializeUIFromRef() {
- // Get data from the refactoring
- final Map elementsToNewNames= getRenameTypeProcessor().getSimilarElementsToNewNames();
- try {
- // To prevent flickering, stop redrawing
- getShell().setRedraw(false);
- if (fSimilarElementsToNewName == null || elementsToNewNames != fSimilarElementsToNewName) {
- fSimilarElementsToNewName= elementsToNewNames;
- fTreeViewerLabelProvider.initialize(fSimilarElementsToNewName);
- fTreeViewer.setInput(fSimilarElementsToNewName);
- }
- fTreeViewer.expandAll();
- restoreSelectionAndNames(getRenameTypeProcessor().getSimilarElementsToSelection());
- } finally {
- getShell().setRedraw(true);
- }
- fWasInitialized= true;
- }
-
- private void initializeRefFromUI() {
- IJavaScriptElement[] selected= getCheckedSimilarElements();
- Map selection= getRenameTypeProcessor().getSimilarElementsToSelection();
- for (Iterator iter= selection.keySet().iterator(); iter.hasNext();) {
- IJavaScriptElement element= (IJavaScriptElement) iter.next();
- selection.put(element, Boolean.FALSE);
- }
- for (int i= 0; i < selected.length; i++)
- selection.put(selected[i], Boolean.TRUE);
-
- }
-
- private void resetDataInRefAndUI() {
- getRenameTypeProcessor().resetSelectedSimilarElements();
- restoreSelectionAndNames(getRenameTypeProcessor().getSimilarElementsToSelection());
- }
-
- protected void editCurrentElement() {
- IStructuredSelection selection= (IStructuredSelection) fTreeViewer.getSelection();
- if ( (selection != null) && isSimilarElement(selection.getFirstElement())) {
- IJavaScriptElement element= (IJavaScriptElement) selection.getFirstElement();
- String newName= (String) fSimilarElementsToNewName.get(element);
- if (newName == null)
- return;
- EditElementDialog dialog= new EditElementDialog(getShell(), element, newName);
- if (dialog.open() == Window.OK) {
- String changedName= dialog.getNewName();
- if (!changedName.equals(newName)) {
- fSimilarElementsToNewName.put(element, changedName);
- fTreeViewer.update(element, null);
- }
- }
- }
- }
-
- private void restoreSelectionAndNames(final Map selection) {
- final Map selectedElements= selection;
- for (Iterator iter= selectedElements.keySet().iterator(); iter.hasNext();) {
- IJavaScriptElement element= (IJavaScriptElement) iter.next();
- boolean isSelected= ((Boolean) selectedElements.get(element)).booleanValue();
- fTreeViewer.setChecked(element, isSelected);
- fTreeViewer.update(element, null);
- }
- }
-
- // ------------ Navigation
-
- /*
- * @see IWizardPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- if (fWasInitialized)
- initializeRefFromUI();
- // computes the input successor page
- // (=create changes)
- IWizardPage nextPage= super.getNextPage();
- if (nextPage != this) // if user pressed cancel, then the next page is the current page
- nextPage.setPreviousPage(this);
- return nextPage;
- }
-
-
- /*
- * @see IWizardPage#getPreviousPage()
- */
- public IWizardPage getPreviousPage() {
- if (fWasInitialized)
- initializeRefFromUI();
- return super.getPreviousPage();
- }
-
- /*
- * @see RefactoringWizardPage#performFinish()
- */
- protected boolean performFinish() {
- initializeRefFromUI();
- return super.performFinish();
- }
-
- // ------------ Helper
-
- private boolean isSimilarElement(Object element) {
- if (!fWasInitialized)
- return false;
-
- return fSimilarElementsToNewName.containsKey(element);
- }
-
- private void treeViewerSelectionChanged(SelectionChangedEvent event) {
- try {
- final IJavaScriptElement selection= getFirstSelectedSourceReference(event);
- setSourceViewerContents(selection);
- fEditElementButton.setEnabled(selection != null && (isSimilarElement(selection)));
- fCurrentElementLabel.setText(selection != null ? JavaScriptElementLabels.getElementLabel(selection, LABEL_FLAGS) : RefactoringMessages.RenameTypeWizardSimilarElementsPage_select_element_to_view_source);
- fCurrentElementLabel.setImage(selection != null ? fTreeViewerLabelProvider.getJavaImage(selection) : null);
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.RenameTypeWizard_defaultPageTitle, RefactoringMessages.RenameTypeWizard_unexpected_exception);
- }
- }
-
- private IJavaScriptElement getFirstSelectedSourceReference(SelectionChangedEvent event) {
- ISelection s= event.getSelection();
- if (! (s instanceof IStructuredSelection))
- return null;
- IStructuredSelection strSel= (IStructuredSelection) s;
- if (strSel.size() != 1)
- return null;
- Object first= strSel.getFirstElement();
- if (! (first instanceof IJavaScriptElement))
- return null;
- return (IJavaScriptElement) first;
- }
-
- private void setSourceViewerContents(IJavaScriptElement el) throws JavaScriptModelException {
- String EMPTY= ""; //$NON-NLS-1$
- if (el == null) {
- fSourceViewer.getDocument().set(EMPTY);
- return;
- }
- IJavaScriptUnit element= (IJavaScriptUnit) el.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (element == null) {
- fSourceViewer.getDocument().set(EMPTY);
- return;
- }
-
- String contents= element.getSource();
- try {
- fSourceViewer.setRedraw(false);
- fSourceViewer.getDocument().set(contents == null ? EMPTY : contents);
- ISourceRange sr= getNameRange(el);
- if (sr != null) {
- fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength());
- }
- } finally {
- fSourceViewer.setRedraw(true);
- }
- }
-
- private ISourceRange getNameRange(IJavaScriptElement element) throws JavaScriptModelException {
- if (element instanceof IMember)
- return ((IMember) element).getNameRange();
- else if (element instanceof ILocalVariable)
- return ((ILocalVariable) element).getNameRange();
- else
- return null;
- }
-
- private IJavaScriptElement[] getCheckedSimilarElements() {
- Object[] checked= fTreeViewer.getCheckedElements();
- List elements= new ArrayList(checked.length);
- for (int i= 0; i < checked.length; i++) {
- if (isSimilarElement(checked[i]))
- elements.add(checked[i]);
- }
- return (IJavaScriptElement[]) elements.toArray(new IJavaScriptElement[elements.size()]);
- }
-
- public RenameTypeProcessor getRenameTypeProcessor() {
- RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor();
- if (proc instanceof RenameTypeProcessor)
- return (RenameTypeProcessor) proc;
- else if (proc instanceof RenameCompilationUnitProcessor) {
- RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc;
- return rcu.getRenameTypeProcessor();
- }
- Assert.isTrue(false); // Should never get here
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceManager.java
deleted file mode 100644
index 59374e89..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceManager.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameFieldProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameJavaProjectProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameLocalVariableProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenamePackageProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameResourceProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameSourceFolderProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameTypeProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.UserInterfaceManager;
-
-public class RenameUserInterfaceManager extends UserInterfaceManager {
- private static final UserInterfaceManager fgInstance= new RenameUserInterfaceManager();
-
- public static UserInterfaceManager getDefault() {
- return fgInstance;
- }
-
- private RenameUserInterfaceManager() {
- put(RenameResourceProcessor.class, RenameUserInterfaceStarter.class, RenameResourceWizard.class);
-
- put(RenameJavaProjectProcessor.class, RenameUserInterfaceStarter.class, RenameJavaProjectWizard.class);
- put(RenameSourceFolderProcessor.class, RenameUserInterfaceStarter.class, RenameSourceFolderWizard.class);
- put(RenamePackageProcessor.class, RenameUserInterfaceStarter.class, RenamePackageWizard.class);
- put(RenameCompilationUnitProcessor.class, RenameUserInterfaceStarter.class, RenameCuWizard.class);
- put(RenameTypeProcessor.class, RenameUserInterfaceStarter.class, RenameTypeWizard.class);
- put(RenameFieldProcessor.class, RenameUserInterfaceStarter.class, RenameFieldWizard.class);
-// put(RenameEnumConstProcessor.class, RenameUserInterfaceStarter.class, RenameEnumConstWizard.class);
- put(RenameTypeParameterProcessor.class, RenameUserInterfaceStarter.class, RenameTypeParameterWizard.class);
- put(RenameNonVirtualMethodProcessor.class, RenameMethodUserInterfaceStarter.class, RenameMethodWizard.class);
- put(RenameVirtualMethodProcessor.class, RenameMethodUserInterfaceStarter.class, RenameMethodWizard.class);
- put(RenameLocalVariableProcessor.class, RenameUserInterfaceStarter.class, RenameLocalVariableWizard.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceStarter.java
deleted file mode 100644
index 8eae3ed1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/RenameUserInterfaceStarter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.tagging.INameUpdating;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.UserInterfaceStarter;
-
-public class RenameUserInterfaceStarter extends UserInterfaceStarter {
-
- public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
- RenameProcessor processor= (RenameProcessor)refactoring.getAdapter(RenameProcessor.class);
- Object[] elements= processor.getElements();
- RenameSelectionState state= elements.length == 1 ? new RenameSelectionState(elements[0]) : null;
- boolean executed= super.activate(refactoring, parent, saveMode);
- INameUpdating nameUpdating= (INameUpdating)refactoring.getAdapter(INameUpdating.class);
- if (executed && nameUpdating != null && state != null) {
- Object newElement= nameUpdating.getNewElement();
- if (newElement != null) {
- state.restore(newElement);
- }
- }
- return executed;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyAction.java
deleted file mode 100644
index 7a60a5a0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyAction.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CopyProjectAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-
-public class ReorgCopyAction extends SelectionDispatchAction {
-
- public ReorgCopyAction(IWorkbenchSite site) {
- super(site);
- setText(ReorgMessages.ReorgCopyAction_3);
- setDescription(ReorgMessages.ReorgCopyAction_4);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.COPY_ACTION);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())) {
- setEnabled(createWorkbenchAction(selection).isEnabled());
- return;
- }
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (elements.size() != resources.length + javaElements.length)
- setEnabled(false);
- else
- setEnabled(RefactoringAvailabilityTester.isCopyAvailable(resources, javaElements));
- } catch (JavaScriptModelException e) {
- // no ui here - this happens on selection changes
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);
- }
- } else
- setEnabled(false);
- }
-
- private CopyProjectAction createWorkbenchAction(IStructuredSelection selection) {
- CopyProjectAction action= new CopyProjectAction(getShell());
- action.selectionChanged(selection);
- return action;
- }
-
- public void run(IStructuredSelection selection) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())){
- createWorkbenchAction(selection).run();
- return;
- }
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (RefactoringAvailabilityTester.isCopyAvailable(resources, javaElements))
- RefactoringExecutionStarter.startCopyRefactoring(resources, javaElements, getShell());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyStarter.java
deleted file mode 100644
index fad72a3b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyStarter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaCopyRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringExecutionHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSaveHelper;
-
-public class ReorgCopyStarter {
-
- public static ReorgCopyStarter create(IJavaScriptElement[] javaElements, IResource[] resources, IJavaScriptElement destination) throws JavaScriptModelException {
- Assert.isNotNull(javaElements);
- Assert.isNotNull(resources);
- Assert.isNotNull(destination);
- ICopyPolicy copyPolicy= ReorgPolicyFactory.createCopyPolicy(resources, javaElements);
- if (!copyPolicy.canEnable())
- return null;
- JavaCopyProcessor copyProcessor= new JavaCopyProcessor(copyPolicy);
- if (!copyProcessor.setDestination(destination).isOK())
- return null;
- return new ReorgCopyStarter(copyProcessor);
- }
-
- public static ReorgCopyStarter create(IJavaScriptElement[] javaElements, IResource[] resources, IResource destination) throws JavaScriptModelException {
- Assert.isNotNull(javaElements);
- Assert.isNotNull(resources);
- Assert.isNotNull(destination);
- ICopyPolicy copyPolicy= ReorgPolicyFactory.createCopyPolicy(resources, javaElements);
- if (!copyPolicy.canEnable())
- return null;
- JavaCopyProcessor copyProcessor= new JavaCopyProcessor(copyPolicy);
- if (!copyProcessor.setDestination(destination).isOK())
- return null;
- return new ReorgCopyStarter(copyProcessor);
- }
-
- private final JavaCopyProcessor fCopyProcessor;
-
- private ReorgCopyStarter(JavaCopyProcessor copyProcessor) {
- Assert.isNotNull(copyProcessor);
- fCopyProcessor= copyProcessor;
- }
-
- public void run(Shell parent) throws InterruptedException, InvocationTargetException {
- IRunnableContext context= new ProgressMonitorDialog(parent);
- fCopyProcessor.setNewNameQueries(new NewNameQueries(parent));
- fCopyProcessor.setReorgQueries(new ReorgQueries(parent));
- new RefactoringExecutionHelper(new JavaCopyRefactoring(fCopyProcessor), RefactoringCore.getConditionCheckingFailedSeverity(), RefactoringSaveHelper.SAVE_NOTHING, parent, context).perform(false, false);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyWizard.java
deleted file mode 100644
index b512fbbd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgCopyWizard.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CopyRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgDestinationValidator;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
-
-
-public class ReorgCopyWizard extends RefactoringWizard {
-
- public ReorgCopyWizard(CopyRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | NO_PREVIEW_PAGE);
- setDefaultPageTitle(ReorgMessages.ReorgCopyWizard_1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringWizard#addUserInputPages()
- */
- protected void addUserInputPages() {
- addPage(new CopyInputPage());
- }
-
- private static class CopyInputPage extends ReorgUserInputPage{
-
- private static final String PAGE_NAME= "CopyInputPage"; //$NON-NLS-1$
-
- public CopyInputPage() {
- super(PAGE_NAME);
- }
-
- private JavaCopyProcessor getCopyProcessor(){
- return (JavaCopyProcessor)((CopyRefactoring)getRefactoring()).getCopyProcessor();
- }
-
- protected Object getInitiallySelectedElement() {
- return getCopyProcessor().getCommonParentForInputElements();
- }
-
- protected IJavaScriptElement[] getJavaElements() {
- return getCopyProcessor().getJavaElements();
- }
-
- protected IResource[] getResources() {
- return getCopyProcessor().getResources();
- }
-
- protected IReorgDestinationValidator getDestinationValidator() {
- return getCopyProcessor();
- }
-
- protected RefactoringStatus verifyDestination(Object selected) throws JavaScriptModelException{
- if (selected instanceof IJavaScriptElement)
- return getCopyProcessor().setDestination((IJavaScriptElement)selected);
- if (selected instanceof IResource)
- return getCopyProcessor().setDestination((IResource)selected);
- return RefactoringStatus.createFatalErrorStatus(ReorgMessages.ReorgCopyWizard_2);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.java
deleted file mode 100644
index 0d103669..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class ReorgMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.refactoring.reorg.ReorgMessages";//$NON-NLS-1$
-
- private ReorgMessages() {
- // Do not instantiate
- }
-
- public static String CutAction_text;
- public static String copyAction_description;
- public static String copyAction_destination_label;
- public static String copyAction_name;
- public static String deleteAction_checkDeletion;
- public static String deleteAction_confirm_title;
- public static String deleteAction_confirmReadOnly;
- public static String deleteAction_description;
- public static String DestinationRenderer_packages;
- public static String moveAction_checkMove;
- public static String moveAction_error_readOnly;
- public static String moveAction_label;
- public static String moveAction_name;
- public static String moveAction_destination_label;
- public static String PasteAction_projectName;
- public static String RenameInformationPopup_delayJobName;
- public static String RenameInformationPopup_EnterNewName;
- public static String RenameInformationPopup_menu;
- public static String RenameInformationPopup_OpenDialog;
- public static String RenameInformationPopup_preferences;
- public static String RenameInformationPopup_Preview;
- public static String RenameInformationPopup_RenameInWorkspace;
- public static String RenameInformationPopup_snap_bottom_right;
- public static String RenameInformationPopup_snap_over_left;
- public static String RenameInformationPopup_snap_over_right;
- public static String RenameInformationPopup_snap_under_left;
- public static String RenameInformationPopup_snap_under_right;
- public static String RenameInformationPopup_SnapTo;
- public static String RenameLinkedMode_error_saving_editor;
- public static String ReorgAction_checkSaveTargets;
- public static String ReorgAction_checkSaveTargets_title;
- public static String ReorgAction_exception_saving;
- public static String ReorgAction_task_saving;
- public static String ReorgAction_exception;
- public static String ReorgAction_reorganize;
- public static String CopyResourcesToClipboardAction_copy;
- public static String CutSourceReferencesToClipboardAction_cut;
- public static String DeleteResourceAction_delete;
- public static String DeleteResourceAction_exception;
- public static String PasteSourceReferencesFromClipboardAction_paste1;
- public static String PasteSourceReferencesFromClipboardAction_exception;
- public static String ReorgExceptionHandler_see_details;
- public static String ReorgGroup_copy;
- public static String ReorgGroup_paste;
- public static String ReorgGroup_pasteAction_description;
- public static String ReorgGroup_delete;
- public static String SourceReferenceAction_exception;
- public static String JdtCopyAction_referenced;
- public static String JdtCopyAction_update_classpath;
- public static String JdtCopyAction_Copy;
- public static String JdtMoveAction_move;
- public static String JdtMoveAction_update_references;
- public static String JdtMoveAction_preview;
- public static String JdtMoveAction_exception;
- public static String JdtMoveAction_referenced;
- public static String JdtMoveAction_update_classpath;
- public static String JdtMoveAction_Move;
- public static String JdtMoveAction_default_package_warning;
- public static String DeleteSourceReferencesAction_delete_elements;
- public static String DeleteSourceReferencesAction_exception;
- public static String DeleteSourceReferencesAction_delete1;
- public static String DeleteSourceReferencesAction_confirm_gs_delete;
- public static String DeleteSourceReferencesAction_delete_gs;
- public static String DeleteSourceReferencesAction_title;
- public static String DeleteSourceReferencesAction_read_only;
- public static String DeleteSourceReferencesAction_cu_read_only;
- public static String DeleteSourceReferencesAction_cu_empty;
- public static String DeleteSourceReferencesAction_cus_empty;
- public static String ReorgDestinationAction_duplicate_name;
- public static String ReorgDestinationAction_error;
- public static String ReorgDestinationAction_exception;
- public static String ReorgDestinationAction_duplicate;
- public static String ReorgDestinationAction_exception_title;
- public static String ReorgDestinationAction_error_occurred;
- public static String ReorgQueries_enterNewNameQuestion;
- public static String ReorgQueries_nameConflictMessage;
- public static String ReorgQueries_resourceWithThisNameAlreadyExists;
- public static String ReorgQueries_invalidNameMessage;
- public static String ReorgQueries_packagewithThatNameexistsMassage;
- public static String ReorgQueries_resourceExistsWithDifferentCaseMassage;
- public static String ReorgQueries_Confirm_Overwritting;
- public static String ReorgQueries_exists_read_only;
- public static String ReorgQueries_exists;
- public static String ReorgQueries_skip_all;
- public static String CopyToClipboardProblemDialog_title;
- public static String CopyToClipboardProblemDialog_message;
- public static String PasteResourcesFromClipboardAction_error_title;
- public static String PasteResourcesFromClipboardAction_error_message;
- public static String ReorgExceptionHandler_error_title;
- public static String ReorgExceptionHandler_error_message;
- public static String DeleteSourceReferencesAction_sure;
- public static String DeleteSourceReferencesAction_sure_elements;
- public static String DeleteSourceReferenceAction_error_title;
- public static String DeleteSourceReferenceAction_error_message;
- public static String DeleteSourceReferenceAction_deleting;
- public static String DeleteResourcesAction_deleteAction_confirm_message;
- public static String DeleteResourcesAction_Delete;
- public static String DeleteResourcesAction_sure_delete;
- public static String DeleteResourcesAction_sure_delete_resources;
- public static String DeleteResourcesAction_default_package;
- public static String DeleteResourcesAction_referenced;
- public static String DeleteResourcesAction_sure_delete_linked_single;
- public static String DeleteResourcesAction_sure_delete_linked_single_package_or_pfr;
- public static String DeleteResourcesAction_sure_delete_linked_multiple;
- public static String DeleteResourcesAction_sure_delete_linked_multiple_with_packages_or_pfr;
- public static String CopyToClipboardAction_0;
- public static String CopyToClipboardAction_1;
- public static String CopyToClipboardAction_2;
- public static String CopyToClipboardAction_3;
- public static String CopyToClipboardAction_4;
- public static String CopyToClipboardAction_5;
- public static String DeleteAction_3;
- public static String DeleteAction_4;
- public static String NewNameQueries_21;
- public static String NewNameQueries_22;
- public static String ReorgCopyAction_3;
- public static String ReorgCopyAction_4;
- public static String ReorgCopyWizard_1;
- public static String ReorgCopyWizard_2;
- public static String ReorgMoveAction_3;
- public static String ReorgMoveAction_4;
- public static String ReorgMoveWizard_3;
- public static String ReorgMoveWizard_4;
- public static String ReorgMoveWizard_textual_move;
- public static String ReorgMoveWizard_newPackage;
- public static String ReorgUserInputPage_choose_destination_single;
- public static String ReorgUserInputPage_choose_destination_multi;
- public static String RenameMethodUserInterfaceStarter_name;
- public static String RenameMethodUserInterfaceStarter_message;
- public static String PasteAction_4;
- public static String PasteAction_5;
- public static String PasteAction_change_name;
- public static String PasteAction_edit_name;
- public static String PasteAction_element_doesnot_exist;
- public static String PasteAction_invalid_destination;
- public static String PasteAction_name;
- public static String PasteAction_wrong_destination;
- public static String PasteAction_TextPaster_exists;
- public static String PasteAction_TextPaster_confirmOverwriting;
- public static String PasteAction_cannot_selection;
- public static String PasteAction_cannot_no_selection;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ReorgMessages.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.properties
deleted file mode 100644
index 6afcbb54..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMessages.properties
+++ /dev/null
@@ -1,176 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-CutAction_text=Cu&t
-
-copyAction_description=Copy the selected elements
-copyAction_destination_label=&Select the copy destination
-copyAction_name=Copy
-
-deleteAction_checkDeletion=Check Deletion
-deleteAction_confirm_title=Confirm Delete
-deleteAction_confirmReadOnly=The selected elements contain read-only resources. Do you still want to delete them?
-deleteAction_description=Delete the selected elements
-DestinationRenderer_packages=packages
-
-moveAction_checkMove=Check Move
-moveAction_error_readOnly=The selected elements contain read-only resources. Do you still want to move them?
-moveAction_label=Mo&ve...
-moveAction_name=Move
-moveAction_destination_label=&Select the move destination:
-
-ReorgAction_checkSaveTargets=These elements contain unsaved changes.\nCheck the elements you want to save before proceeding.
-ReorgAction_checkSaveTargets_title=Save Resources
-ReorgAction_exception_saving=An exception occurred while saving editor contents.
-ReorgAction_task_saving=Saving
-ReorgAction_exception=Unexpected exception. See log for details
-ReorgAction_reorganize=Reorganize
-
-CopyResourcesToClipboardAction_copy=&Copy
-
-CutSourceReferencesToClipboardAction_cut=Cu&t
-
-DeleteResourceAction_delete=Delete
-DeleteResourceAction_exception=Unexpected exception. See log for details
-
-PasteSourceReferencesFromClipboardAction_paste1=Paste
-PasteSourceReferencesFromClipboardAction_exception=Unexpected exception. See log for details
-
-ReorgExceptionHandler_see_details=See details
-ReorgGroup_copy=&Copy
-ReorgGroup_paste=&Paste
-ReorgGroup_pasteAction_description=Pastes elements from the clipboard
-ReorgGroup_delete=&Delete
-
-SourceReferenceAction_exception=Unexpected exception. See log for details
-
-JdtCopyAction_referenced=Source Folder ''{0}'' is referenced by other projects.
-JdtCopyAction_update_classpath=Do you want to update includepath of the other projects?
-JdtCopyAction_Copy=Copy
-
-JdtMoveAction_move=Move
-JdtMoveAction_update_references=Update &references to the moved element(s)
-JdtMoveAction_preview=Preview...
-JdtMoveAction_exception=Unexpected exception occurred. See log for details
-JdtMoveAction_referenced=Source Folder root ''{0}'' is referenced by other projects.
-JdtMoveAction_update_classpath=Do you want to update includepath of the other projects?
-JdtMoveAction_Move=Move
-JdtMoveAction_default_package_warning=Moving JavaScript files to or from the default package will not update references.
-
-DeleteSourceReferencesAction_delete_elements=Delete elements
-DeleteSourceReferencesAction_exception=Unexpected exception. See log for details
-DeleteSourceReferencesAction_delete1=Delete
-DeleteSourceReferencesAction_confirm_gs_delete=Confirm Delete of Getters/Setters
-DeleteSourceReferencesAction_delete_gs=Do you also want to delete getters/setters for the selected vars?
-DeleteSourceReferencesAction_title=Delete
-DeleteSourceReferencesAction_read_only=Cannot delete. All selected elements are defined in read-only files.
-DeleteSourceReferencesAction_cu_read_only=JavaScript file ''{0}'' is read-only. Do you still want to delete it?
-DeleteSourceReferencesAction_cu_empty=After the delete operation the JavaScript file ''{0}'' contains no types. \nOK to delete this JavaScript file?
-DeleteSourceReferencesAction_cus_empty=After the delete operation {0} JavaScript files contain no types. \nOK to delete these JavaScript files?
-
-ReorgDestinationAction_duplicate_name=Duplicate Element Name
-ReorgDestinationAction_error=An error occurred while reorganizing resources
-ReorgDestinationAction_exception=Unexpected exception occurred. See log for details
-ReorgDestinationAction_duplicate=Two or more elements named {0} are selected
-ReorgDestinationAction_exception_title=Exception
-ReorgDestinationAction_error_occurred=Error occurred while performing this operation.
-
-ReorgQueries_enterNewNameQuestion=Enter a new name for ''{0}'':
-ReorgQueries_nameConflictMessage=Name Conflict
-ReorgQueries_resourceWithThisNameAlreadyExists=Resource with this name already exists
-ReorgQueries_invalidNameMessage=Invalid name
-ReorgQueries_packagewithThatNameexistsMassage=Package with that name exists
-ReorgQueries_resourceExistsWithDifferentCaseMassage=Resource exists with different case
-ReorgQueries_Confirm_Overwritting=Confirm Overwriting
-ReorgQueries_exists_read_only=''{0}'' exists and is read-only. Do you wish to overwrite ?
-ReorgQueries_exists=''{0}'' exists. Do you wish to overwrite ?
-ReorgQueries_skip_all=Skip All
-
-CopyToClipboardProblemDialog_title=Problem Copying to Clipboard
-CopyToClipboardProblemDialog_message=There was a problem when accessing the system clipboard. Retry?
-
-PasteResourcesFromClipboardAction_error_title=Paste
-PasteResourcesFromClipboardAction_error_message=Internal error occurred. Please see log for details.
-
-ReorgExceptionHandler_error_title=Problems Deleting
-ReorgExceptionHandler_error_message=Resource {0} is out of synch with the file system. Do you want to delete it anyway?
-
-DeleteSourceReferencesAction_sure=Are you sure you want to delete ''{0}''?
-DeleteSourceReferencesAction_sure_elements=Are you sure you want to delete these {0} elements?
-DeleteSourceReferenceAction_error_title=Delete
-DeleteSourceReferenceAction_error_message=An error occurred while performing this operation. See log for details.
-DeleteSourceReferenceAction_deleting=Deleting
-
-DeleteResourcesAction_deleteAction_confirm_message=The selection includes a folder that contains a JavaScript source folder. Delete this folder?
-DeleteResourcesAction_Delete=Delete
-DeleteResourcesAction_sure_delete=Are you sure you want to delete ''{0}''?
-DeleteResourcesAction_sure_delete_resources=Are you sure you want to delete these {0} resources?
-DeleteResourcesAction_default_package=(default package)
-DeleteResourcesAction_referenced=Source Folder ''{0}'' is referenced by the following projects. Do you still want to delete it?
-DeleteResourcesAction_sure_delete_linked_single=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.
-DeleteResourcesAction_sure_delete_linked_single_package_or_pfr=Are you sure you want to delete linked resource ''{0}''?\nOnly the workspace link will be deleted. Link target will remain unchanged.\n\nNote that all subelements of the selected source folders will be removed from the workspace as well.
-DeleteResourcesAction_sure_delete_linked_multiple=Are you sure you want to delete these {0} resources?\n\nSelection contains linked resources.\nOnly the workspace links will be deleted. Link targets will remain unchanged.
-DeleteResourcesAction_sure_delete_linked_multiple_with_packages_or_pfr=Are you sure you want to delete these {0} resources?\n\nSelection contains linked source folders.\nOnly the workspace links will be deleted. Link targets will remain unchanged.\n\nNote that all subelements of linked source folders will be removed from the workspace as well.
-CopyToClipboardAction_0=&Copy
-CopyToClipboardAction_1=Copy the selected elements to the clipboard
-CopyToClipboardAction_2=Copy To Clipboard
-CopyToClipboardAction_3=Internal error. See log for details.
-CopyToClipboardAction_4=Problem Copying to Clipboard
-CopyToClipboardAction_5=There was a problem when accessing the system clipboard. Retry?
-DeleteAction_3=&Delete
-DeleteAction_4=Deletes the selected elements
-NewNameQueries_21=Error
-NewNameQueries_22=Internal error occurred. See log for details.
-ReorgCopyAction_3=&Copy...
-ReorgCopyAction_4=Copy the selected elements
-ReorgCopyWizard_1=Copy
-ReorgCopyWizard_2=The selected element cannot be the destination of this operation.
-ReorgMoveAction_3=&Move...
-ReorgMoveAction_4=Move the selected elements
-ReorgMoveWizard_3=Move
-ReorgMoveWizard_4=The selected element cannot be the destination of this operation.
-ReorgMoveWizard_textual_move=Textual Move
-ReorgMoveWizard_newPackage=Create &Package...
-ReorgUserInputPage_choose_destination_single=&Choose destination for ''{0}'':
-ReorgUserInputPage_choose_destination_multi=&Choose destination for {0} selected elements:
-
-RenameMethodUserInterfaceStarter_name= Rename Refactoring
-RenameMethodUserInterfaceStarter_message= {0}\n\nOK to perform the operation on this method?
-
-PasteAction_4=&Paste
-PasteAction_5=Pastes elements from the clipboard
-PasteAction_change_name=Paste
-PasteAction_projectName=_pasted_code_{0}
-PasteAction_edit_name=paste elements
-PasteAction_element_doesnot_exist=The selected element does not exist in the workspace
-PasteAction_invalid_destination=The selected element cannot be the destination of this paste operation
-PasteAction_name=Paste
-PasteAction_wrong_destination=A member of a JavaScript file should be selected as the destination
-PasteAction_TextPaster_confirmOverwriting=Confirm Overwriting
-PasteAction_TextPaster_exists=''{0}'' already exists. Do you want to overwrite?
-PasteAction_cannot_selection=Cannot paste the clipboard contents into the selected elements.
-PasteAction_cannot_no_selection=Cannot paste the clipboard contents.
-
-RenameLinkedMode_error_saving_editor=An error occurred while saving the editor
-
-RenameInformationPopup_SnapTo=&Snap To
-RenameInformationPopup_snap_under_left=&Under Left
-RenameInformationPopup_snap_under_right=U&nder Right
-RenameInformationPopup_snap_over_left=&Over Left
-RenameInformationPopup_snap_over_right=O&ver Right
-RenameInformationPopup_snap_bottom_right=&Bottom Right
-RenameInformationPopup_menu=Menu
-RenameInformationPopup_RenameInWorkspace=&Refactor
-RenameInformationPopup_Preview=Pre&view...
-RenameInformationPopup_OpenDialog=&Open Rename Dialog...
-RenameInformationPopup_preferences=&Preferences...
-RenameInformationPopup_EnterNewName=Enter new name, press {0} to refactor
-RenameInformationPopup_delayJobName=delayed RenameInformationPopup
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveAction.java
deleted file mode 100644
index 62b09ce0..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveAction.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.MoveProjectAction;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringAvailabilityTester;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.RefactoringExecutionStarter;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.wst.jsdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaTextSelection;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-
-public class ReorgMoveAction extends SelectionDispatchAction {
- public ReorgMoveAction(IWorkbenchSite site) {
- super(site);
- setText(ReorgMessages.ReorgMoveAction_3);
- setDescription(ReorgMessages.ReorgMoveAction_4);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.MOVE_ACTION);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())) {
- setEnabled(createWorkbenchAction(selection).isEnabled());
- return;
- }
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (elements.size() != resources.length + javaElements.length)
- setEnabled(false);
- else
- setEnabled(RefactoringAvailabilityTester.isMoveAvailable(resources, javaElements));
- } catch (JavaScriptModelException e) {
- // no ui here - this happens on selection changes
- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- if (JavaModelUtil.isExceptionToBeLogged(e))
- JavaScriptPlugin.log(e);
- setEnabled(false);
- }
- } else
- setEnabled(false);
- }
-
- public void selectionChanged(ITextSelection selection) {
- setEnabled(true);
- }
-
- /**
- * Note: This method is for internal use only. Clients should not call this method.
- */
- public void selectionChanged(JavaTextSelection selection) {
- try {
- setEnabled(RefactoringAvailabilityTester.isMoveAvailable(selection));
- } catch (JavaScriptModelException e) {
- setEnabled(false);
- }
- }
-
- private MoveProjectAction createWorkbenchAction(IStructuredSelection selection) {
- MoveProjectAction action= new MoveProjectAction(getShell());
- action.selectionChanged(selection);
- return action;
- }
-
- public void run(IStructuredSelection selection) {
- if (ReorgUtils.containsOnlyProjects(selection.toList())) {
- createWorkbenchAction(selection).run();
- return;
- }
- try {
- List elements= selection.toList();
- IResource[] resources= ReorgUtils.getResources(elements);
- IJavaScriptElement[] javaElements= ReorgUtils.getJavaElements(elements);
- if (RefactoringAvailabilityTester.isMoveAvailable(resources, javaElements))
- RefactoringExecutionStarter.startMoveRefactoring(resources, javaElements, getShell());
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveStarter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveStarter.java
deleted file mode 100644
index 323c67c6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveStarter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.structure.JavaMoveRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringExecutionHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringSaveHelper;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.actions.RefactoringStarter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-
-
-public class ReorgMoveStarter {
- private final JavaMoveProcessor fMoveProcessor;
-
- private ReorgMoveStarter(JavaMoveProcessor moveProcessor) {
- Assert.isNotNull(moveProcessor);
- fMoveProcessor= moveProcessor;
- }
-
- public static ReorgMoveStarter create(IJavaScriptElement[] javaElements, IResource[] resources, IJavaScriptElement destination) throws JavaScriptModelException {
- Assert.isNotNull(javaElements);
- Assert.isNotNull(resources);
- Assert.isNotNull(destination);
- IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements);
- if (!policy.canEnable())
- return null;
- JavaMoveProcessor processor= new JavaMoveProcessor(policy);
- if (! processor.setDestination(destination).isOK())
- return null;
- return new ReorgMoveStarter(processor);
- }
-
- public static ReorgMoveStarter create(IJavaScriptElement[] javaElements, IResource[] resources, IResource destination) throws JavaScriptModelException {
- Assert.isNotNull(javaElements);
- Assert.isNotNull(resources);
- Assert.isNotNull(destination);
- IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements);
- if (!policy.canEnable())
- return null;
- JavaMoveProcessor processor= new JavaMoveProcessor(policy);
- if (! processor.setDestination(destination).isOK())
- return null;
- return new ReorgMoveStarter(processor);
- }
-
- public void run(Shell parent) throws InterruptedException, InvocationTargetException {
- try {
- JavaMoveRefactoring ref= new JavaMoveRefactoring(fMoveProcessor);
- if (fMoveProcessor.hasAllInputSet()) {
- IRunnableContext context= new ProgressMonitorDialog(parent);
- fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(parent));
- fMoveProcessor.setReorgQueries(new ReorgQueries(parent));
- new RefactoringExecutionHelper(ref, RefactoringCore.getConditionCheckingFailedSeverity(), RefactoringSaveHelper.SAVE_ALL, parent, context).perform(false, false);
- } else {
- RefactoringWizard wizard= new ReorgMoveWizard(ref);
- /*
- * We want to get the shell from the refactoring dialog but it's not known at this point,
- * so we pass the wizard and then, once the dialog is open, we will have access to its shell.
- */
- fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(wizard));
- fMoveProcessor.setReorgQueries(new ReorgQueries(wizard));
- new RefactoringStarter().activate(ref, wizard, parent, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_ALL);
- }
- } catch (JavaScriptModelException e) {
- ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveWizard.java
deleted file mode 100644
index 90949fa8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgMoveWizard.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-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.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.ICreateTargetQuery;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgDestinationValidator;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.QualifiedNameComponent;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.internal.ui.util.SWTUtil;
-
-
-public class ReorgMoveWizard extends RefactoringWizard {
-
- public ReorgMoveWizard(MoveRefactoring ref) {
- super(ref, DIALOG_BASED_USER_INTERFACE | computeHasPreviewPage(ref));
- if (isTextualMove(ref))
- setDefaultPageTitle(ReorgMessages.ReorgMoveWizard_textual_move);
- else
- setDefaultPageTitle(ReorgMessages.ReorgMoveWizard_3);
- }
-
- private static boolean isTextualMove(MoveRefactoring ref) {
- JavaMoveProcessor moveProcessor= (JavaMoveProcessor) ref.getAdapter(JavaMoveProcessor.class);
- return moveProcessor.isTextualMove();
- }
-
- private static int computeHasPreviewPage(MoveRefactoring refactoring) {
- JavaMoveProcessor processor= (JavaMoveProcessor)refactoring.getAdapter(JavaMoveProcessor.class);
- if (processor.canUpdateReferences() || processor.canEnableQualifiedNameUpdating())
- return NONE;
- return NO_PREVIEW_PAGE;
- }
-
- protected void addUserInputPages() {
- addPage(new MoveInputPage());
- }
-
- private static class MoveInputPage extends ReorgUserInputPage{
-
- private static final String PAGE_NAME= "MoveInputPage"; //$NON-NLS-1$
- private Button fReferenceCheckbox;
- private Button fQualifiedNameCheckbox;
- private QualifiedNameComponent fQualifiedNameComponent;
- private ICreateTargetQuery fCreateTargetQuery;
-
- private Object fDestination;
-
- public MoveInputPage() {
- super(PAGE_NAME);
- }
-
- private JavaMoveProcessor getJavaMoveProcessor(){
- return (JavaMoveProcessor)getRefactoring().getAdapter(JavaMoveProcessor.class);
- }
-
- protected Object getInitiallySelectedElement() {
- return getJavaMoveProcessor().getCommonParentForInputElements();
- }
-
- protected IJavaScriptElement[] getJavaElements() {
- return getJavaMoveProcessor().getJavaElements();
- }
-
- protected IResource[] getResources() {
- return getJavaMoveProcessor().getResources();
- }
-
- protected IReorgDestinationValidator getDestinationValidator() {
- return getJavaMoveProcessor();
- }
-
- protected boolean performFinish() {
- return super.performFinish() || getJavaMoveProcessor().wasCanceled(); //close the dialog if canceled
- }
-
- protected RefactoringStatus verifyDestination(Object selected) throws JavaScriptModelException{
- JavaMoveProcessor processor= getJavaMoveProcessor();
- final RefactoringStatus refactoringStatus;
- if (selected instanceof IJavaScriptElement)
- refactoringStatus= processor.setDestination((IJavaScriptElement)selected);
- else if (selected instanceof IResource)
- refactoringStatus= processor.setDestination((IResource)selected);
- else refactoringStatus= RefactoringStatus.createFatalErrorStatus(ReorgMessages.ReorgMoveWizard_4);
-
- updateUIStatus();
- fDestination= selected;
- return refactoringStatus;
- }
-
- private void updateUIStatus() {
- getRefactoringWizard().setForcePreviewReview(false);
- JavaMoveProcessor processor= getJavaMoveProcessor();
- if (fReferenceCheckbox != null){
- fReferenceCheckbox.setEnabled(canUpdateReferences());
- processor.setUpdateReferences(fReferenceCheckbox.getEnabled() && fReferenceCheckbox.getSelection());
- }
- if (fQualifiedNameCheckbox != null){
- boolean enabled= processor.canEnableQualifiedNameUpdating();
- fQualifiedNameCheckbox.setEnabled(enabled);
- if (enabled) {
- fQualifiedNameComponent.setEnabled(processor.getUpdateQualifiedNames());
- if (processor.getUpdateQualifiedNames())
- getRefactoringWizard().setForcePreviewReview(true);
- } else {
- fQualifiedNameComponent.setEnabled(false);
- }
- processor.setUpdateQualifiedNames(fQualifiedNameCheckbox.getEnabled() && fQualifiedNameCheckbox.getSelection());
- }
- }
-
- private void addUpdateReferenceComponent(Composite result) {
- final JavaMoveProcessor processor= getJavaMoveProcessor();
- if (! processor.canUpdateReferences())
- return;
- fReferenceCheckbox= new Button(result, SWT.CHECK);
- fReferenceCheckbox.setText(ReorgMessages.JdtMoveAction_update_references);
- fReferenceCheckbox.setSelection(processor.getUpdateReferences());
- fReferenceCheckbox.setEnabled(canUpdateReferences());
-
- fReferenceCheckbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- processor.setUpdateReferences(((Button)e.widget).getSelection());
- updateUIStatus();
- }
- });
- }
-
- private void addUpdateQualifiedNameComponent(Composite parent, int marginWidth) {
- final JavaMoveProcessor processor= getJavaMoveProcessor();
- if (!processor.canEnableQualifiedNameUpdating() || !processor.canUpdateQualifiedNames())
- return;
- fQualifiedNameCheckbox= new Button(parent, SWT.CHECK);
- int indent= marginWidth + fQualifiedNameCheckbox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- fQualifiedNameCheckbox.setText(RefactoringMessages.RenameInputWizardPage_update_qualified_names);
- fQualifiedNameCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fQualifiedNameCheckbox.setSelection(processor.getUpdateQualifiedNames());
-
- fQualifiedNameComponent= new QualifiedNameComponent(parent, SWT.NONE, processor, getRefactoringSettings());
- fQualifiedNameComponent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridData gd= (GridData)fQualifiedNameComponent.getLayoutData();
- gd.horizontalAlignment= GridData.FILL;
- gd.horizontalIndent= indent;
- updateQualifiedNameUpdating(processor, processor.getUpdateQualifiedNames());
-
- fQualifiedNameCheckbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean enabled= ((Button)e.widget).getSelection();
- updateQualifiedNameUpdating(processor, enabled);
- }
-
- });
- }
-
- private void updateQualifiedNameUpdating(final JavaMoveProcessor processor, boolean enabled) {
- fQualifiedNameComponent.setEnabled(enabled);
- processor.setUpdateQualifiedNames(enabled);
- updateUIStatus();
- }
-
- public void createControl(Composite parent) {
- Composite result;
-
- boolean showDestinationTree= ! getJavaMoveProcessor().hasDestinationSet();
- if (showDestinationTree) {
- fCreateTargetQuery= getJavaMoveProcessor().getCreateTargetQuery();
- super.createControl(parent);
- getTreeViewer().getTree().setFocus();
- result= (Composite)super.getControl();
- } else {
- initializeDialogUnits(parent);
- result= new Composite(parent, SWT.NONE);
- setControl(result);
- result.setLayout(new GridLayout());
- Dialog.applyDialogFont(result);
- }
- addUpdateReferenceComponent(result);
- addUpdateQualifiedNameComponent(result, ((GridLayout)result.getLayout()).marginWidth);
- setControl(result);
- Dialog.applyDialogFont(result);
- }
-
- protected Control addLabel(Composite parent) {
- if (fCreateTargetQuery != null) {
- Composite firstLine= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= layout.marginWidth= 0;
- firstLine.setLayout(layout);
- firstLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control label= super.addLabel(firstLine);
- label.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
- e.detail= SWT.TRAVERSE_NONE;
- getTreeViewer().getTree().setFocus();
- }
- }
- });
-
- Button newButton= new Button(firstLine, SWT.PUSH);
- newButton.setText(fCreateTargetQuery.getNewButtonLabel());
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- gd.widthHint = SWTUtil.getButtonWidthHint(newButton);
- newButton.setLayoutData(gd);
- newButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- doNewButtonPressed();
- }
- });
-
- return firstLine;
-
- } else {
- return super.addLabel(parent);
- }
- }
-
- private boolean canUpdateReferences() {
- return getJavaMoveProcessor().canUpdateReferences();
- }
-
- private void doNewButtonPressed() {
- Object newElement= fCreateTargetQuery.getCreatedTarget(fDestination);
- if (newElement != null) {
- TreeViewer viewer= getTreeViewer();
- ITreeContentProvider contentProvider= (ITreeContentProvider) viewer.getContentProvider();
- viewer.refresh(contentProvider.getParent(newElement));
- viewer.setSelection(new StructuredSelection(newElement), true);
- viewer.getTree().setFocus();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgQueries.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgQueries.java
deleted file mode 100644
index ed0cf9f7..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgQueries.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IConfirmQuery;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgQueries;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.ListDialog;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-public class ReorgQueries implements IReorgQueries {
-
- private final Wizard fWizard;
- private final Shell fShell;
-
- public ReorgQueries(Wizard wizard){
- Assert.isNotNull(wizard);
- fWizard= wizard;
- fShell= null;
- }
-
- public ReorgQueries(Shell shell){
- Assert.isNotNull(shell);
- fWizard= null;
- fShell= shell;
- }
-
- private Shell getShell() {
- Assert.isTrue(fShell == null || fWizard == null);
- Assert.isTrue(fShell != null || fWizard != null);
- if (fWizard != null)
- return fWizard.getContainer().getShell();
- else
- return fShell;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IReorgQueries#createYesYesToAllNoNoToAllQuery(java.lang.String)
- */
- public IConfirmQuery createYesYesToAllNoNoToAllQuery(String dialogTitle, boolean allowCancel, int queryID) {
- return new YesYesToAllNoNoToAllQuery(getShell(), allowCancel, dialogTitle);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IReorgQueries#createYesNoQuery(java.lang.String)
- */
- public IConfirmQuery createYesNoQuery(String dialogTitle, boolean allowCancel, int queryID) {
- return new YesNoQuery(getShell(), allowCancel, dialogTitle);
- }
-
- public IConfirmQuery createSkipQuery(String dialogTitle, int queryID) {
- return new SkipQuery(getShell(), dialogTitle);
- }
-
- private static class YesYesToAllNoNoToAllQuery implements IConfirmQuery{
- private final boolean fAllowCancel;
- private boolean fYesToAll= false;
- private boolean fNoToAll= false;
- private final Shell fShell;
- private final String fDialogTitle;
-
- YesYesToAllNoNoToAllQuery(Shell parent, boolean allowCancel, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fAllowCancel= allowCancel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IConfirmQuery#confirm(java.lang.String)
- */
- public boolean confirm(final String question) throws OperationCanceledException {
- if (fYesToAll)
- return true;
-
- if (fNoToAll)
- return false;
-
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, result));
- return getResult(result);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IConfirmQuery#confirm(java.lang.String, java.lang.Object[])
- */
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
- if (fYesToAll)
- return true;
-
- if (fNoToAll)
- return false;
-
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, elements, result));
- return getResult(result);
- }
-
- private Runnable createQueryRunnable(final String question, final int[] result) {
- return new Runnable() {
- public void run() {
- int[] resultId= getResultIDs();
-
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
- dialog.open();
-
- if (dialog.getReturnCode() == -1) { //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= fAllowCancel ? IDialogConstants.CANCEL_ID : IDialogConstants.NO_ID;
- } else {
- result[0]= resultId[dialog.getReturnCode()];
- }
- }
-
- private String[] getButtonLabels() {
- if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
- return new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.NO_TO_ALL_LABEL,
- IDialogConstants.CANCEL_LABEL };
- else
- return new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.NO_TO_ALL_LABEL};
- }
-
- private int[] getResultIDs() {
- if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
- return new int[] {
- IDialogConstants.YES_ID,
- IDialogConstants.YES_TO_ALL_ID,
- IDialogConstants.NO_ID,
- IDialogConstants.NO_TO_ALL_ID,
- IDialogConstants.CANCEL_ID};
- else
- return new int[] {
- IDialogConstants.YES_ID,
- IDialogConstants.YES_TO_ALL_ID,
- IDialogConstants.NO_ID,
- IDialogConstants.NO_TO_ALL_ID};
- }
- };
- }
-
- private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) {
- return new Runnable() {
- public void run() {
- ListDialog dialog= new YesNoListDialog(fShell, true);
- dialog.setAddCancelButton(false);
- dialog.setBlockOnOpen(true);
- dialog.setContentProvider(new ArrayContentProvider());
- dialog.setLabelProvider(new JavaScriptElementLabelProvider());
- dialog.setTitle(fDialogTitle);
- dialog.setMessage(question);
- dialog.setInput(elements);
-
- dialog.open();
- result[0]= dialog.getReturnCode();
- }
- };
- }
-
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- case IDialogConstants.YES_TO_ALL_ID:
- fYesToAll= true;
- return true;
- case IDialogConstants.YES_ID:
- return true;
- case IDialogConstants.CANCEL_ID:
- throw new OperationCanceledException();
- case IDialogConstants.NO_ID:
- return false;
- case IDialogConstants.NO_TO_ALL_ID:
- fNoToAll= true;
- return false;
- default:
- Assert.isTrue(false);
- return false;
- }
- }
- }
-
- private static class YesNoQuery implements IConfirmQuery{
-
- private final Shell fShell;
- private final String fDialogTitle;
- private final boolean fAllowCancel;
-
- YesNoQuery(Shell parent, boolean allowCancel, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fAllowCancel= allowCancel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IConfirmQuery#confirm(java.lang.String)
- */
- public boolean confirm(String question) throws OperationCanceledException {
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, result));
- return getResult(result);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IReorgQueries.IConfirmQuery#confirm(java.lang.String, java.lang.Object[])
- */
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, elements, result));
- return getResult(result);
- }
-
- private Runnable createQueryRunnable(final String question, final int[] result){
- return new Runnable() {
- public void run() {
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
- dialog.open();
-
- switch (dialog.getReturnCode()) {
- case -1 : //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= fAllowCancel ? IDialogConstants.CANCEL_ID : IDialogConstants.NO_ID;
- break;
- case 0 :
- result[0]= IDialogConstants.YES_ID;
- break;
- case 1 :
- result[0]= IDialogConstants.NO_ID;
- break;
- case 2 :
- if (fAllowCancel)
- result[0]= IDialogConstants.CANCEL_ID;
- else
- Assert.isTrue(false);
- break;
- default :
- Assert.isTrue(false);
- break;
- }
- }
-
- private String[] getButtonLabels() {
- if (fAllowCancel)
- return new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
- else
- return new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL};
- }
- };
- }
-
- private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) {
- return new Runnable() {
- public void run() {
- ListDialog dialog= new YesNoListDialog(fShell, false);
- dialog.setAddCancelButton(false);
- dialog.setBlockOnOpen(true);
- dialog.setContentProvider(new ArrayContentProvider());
- dialog.setLabelProvider(new JavaScriptElementLabelProvider());
- dialog.setTitle(fDialogTitle);
- dialog.setMessage(question);
- dialog.setInput(elements);
-
- dialog.open();
- result[0]= dialog.getReturnCode();
- }
- };
- }
-
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- case IDialogConstants.YES_ID:
- return true;
- case IDialogConstants.CANCEL_ID:
- throw new OperationCanceledException();
- case IDialogConstants.NO_ID:
- return false;
- default:
- Assert.isTrue(false);
- return false;
- }
- }
- }
-
- private static class SkipQuery implements IConfirmQuery{
-
- private final Shell fShell;
- private final String fDialogTitle;
- private boolean fSkipAll;
-
- SkipQuery(Shell parent, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fSkipAll= false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IConfirmQuery#confirm(java.lang.String)
- */
- public boolean confirm(String question) throws OperationCanceledException {
- if (fSkipAll)
- return false;
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, result));
- return getResult(result);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.corext.refactoring.reorg2.IReorgQueries.IConfirmQuery#confirm(java.lang.String, java.lang.Object[])
- */
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
- throw new UnsupportedOperationException("Not supported for skip queries"); //$NON-NLS-1$
- }
-
- private Runnable createQueryRunnable(final String question, final int[] result){
- return new Runnable() {
- public void run() {
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
- dialog.open();
-
- switch (dialog.getReturnCode()) {
- case -1 : //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= IDialogConstants.CANCEL_ID;
- break;
- default:
- result[0]= dialog.getReturnCode();
- }
- }
-
- private String[] getButtonLabels() {
- return new String[] {IDialogConstants.SKIP_LABEL, ReorgMessages.ReorgQueries_skip_all, IDialogConstants.CANCEL_LABEL};
- }
- };
- }
-
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- // skip button
- case 0:
- return false;
- // skip all button
- case 1:
- fSkipAll= true;
- return false;
- // Cancel button
- case 2:
- throw new OperationCanceledException();
- default:
- return false;
- }
- }
- }
-
- private static final class YesNoListDialog extends ListDialog {
- private final boolean fYesToAllNoToAll;
- private YesNoListDialog(Shell parent, boolean includeYesToAllNoToAll) {
- super(parent, SWT.TITLE | SWT.BORDER | SWT.RESIZE | SWT.APPLICATION_MODAL);
- fYesToAllNoToAll= includeYesToAllNoToAll;
- }
-
- protected void buttonPressed(int buttonId) {
- super.buttonPressed(buttonId);
- setReturnCode(buttonId);
- close();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
- if (fYesToAllNoToAll)
- createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false);
- createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
- if (fYesToAllNoToAll)
- createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgUserInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgUserInputPage.java
deleted file mode 100644
index bdd32911..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/ReorgUserInputPage.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.dialogs.Dialog;
-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.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.reorg.IReorgDestinationValidator;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-
-abstract class ReorgUserInputPage extends UserInputWizardPage{
- private static final long LABEL_FLAGS= JavaScriptElementLabels.ALL_DEFAULT
- | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.F_PRE_TYPE_SIGNATURE;
- private TreeViewer fViewer;
- public ReorgUserInputPage(String pageName) {
- super(pageName);
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- result.setLayout(new GridLayout());
-
- Object initialSelection= getInitiallySelectedElement();
- verifyDestination(initialSelection, true);
-
- addLabel(result);
-
- fViewer= createViewer(result);
- fViewer.setSelection(new StructuredSelection(initialSelection), true);
- fViewer.addSelectionChangedListener(new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- ReorgUserInputPage.this.viewerSelectionChanged(event);
- }
- });
- Dialog.applyDialogFont(result);
- }
-
- protected Control addLabel(Composite parent) {
- Label label= new Label(parent, SWT.WRAP);
- String text;
- int resources= getResources().length;
- int javaElements= getJavaElements().length;
-
- if (resources == 0 && javaElements == 1) {
- text= Messages.format(
- ReorgMessages.ReorgUserInputPage_choose_destination_single,
- JavaScriptElementLabels.getElementLabel(getJavaElements()[0], LABEL_FLAGS));
- } else if (resources == 1 && javaElements == 0) {
- text= Messages.format(
- ReorgMessages.ReorgUserInputPage_choose_destination_single,
- getResources()[0].getName());
- } else {
- text= Messages.format(
- ReorgMessages.ReorgUserInputPage_choose_destination_multi,
- String.valueOf(resources + javaElements));
- }
-
- label.setText(text);
- GridData data= new GridData(SWT.FILL, SWT.END, true, false);
- data.widthHint= convertWidthInCharsToPixels(50);
- label.setLayoutData(data);
- return label;
- }
-
- private void viewerSelectionChanged(SelectionChangedEvent event) {
- ISelection selection= event.getSelection();
- if (!(selection instanceof IStructuredSelection))
- return;
- IStructuredSelection ss= (IStructuredSelection)selection;
- verifyDestination(ss.getFirstElement(), false);
- }
-
- protected abstract Object getInitiallySelectedElement();
-
- /** Set and verify destination */
- protected abstract RefactoringStatus verifyDestination(Object selected) throws JavaScriptModelException;
-
- protected abstract IResource[] getResources();
- protected abstract IJavaScriptElement[] getJavaElements();
-
- protected abstract IReorgDestinationValidator getDestinationValidator();
-
- private final void verifyDestination(Object selected, boolean initialVerification) {
- try {
- RefactoringStatus status= verifyDestination(selected);
- if (initialVerification)
- setPageComplete(status.isOK());
- else
- setPageComplete(status);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- setPageComplete(false);
- }
- }
-
- private TreeViewer createViewer(Composite parent) {
- TreeViewer treeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(40);
- gd.heightHint= convertHeightInCharsToPixels(15);
- treeViewer.getTree().setLayoutData(gd);
- treeViewer.setLabelProvider(new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_SMALL_ICONS));
- treeViewer.setContentProvider(new DestinationContentProvider(getDestinationValidator()));
- treeViewer.setComparator(new JavaScriptElementComparator());
- treeViewer.setInput(JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()));
- return treeViewer;
- }
-
- protected TreeViewer getTreeViewer() {
- return fViewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/TypedSourceTransfer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/TypedSourceTransfer.java
deleted file mode 100644
index 435d7f12..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/reorg/TypedSourceTransfer.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.reorg;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.TypedSource;
-
-public class TypedSourceTransfer extends ByteArrayTransfer {
-
- /**
- * Singleton instance.
- */
- private static final TypedSourceTransfer fgInstance = new TypedSourceTransfer();
-
- // Create a unique ID to make sure that different Eclipse
- // applications use different "types" of <code>TypedSourceTransfer</code>
- private static final String TYPE_NAME = "typed-source-transfer-format:" + System.currentTimeMillis() + ":" + fgInstance.hashCode();//$NON-NLS-2$//$NON-NLS-1$
-
- private static final int TYPEID = registerType(TYPE_NAME);
-
- private TypedSourceTransfer() {
- }
-
- /**
- * Returns the singleton instance.
- *
- * @return the singleton instance
- */
- public static TypedSourceTransfer getInstance() {
- return fgInstance;
- }
-
- /* (non-Javadoc)
- * Method declared on Transfer.
- */
- protected int[] getTypeIds() {
- return new int[] {TYPEID};
- }
-
- /* (non-Javadoc)
- * Returns the type names.
- *
- * @return the list of type names
- */
- protected String[] getTypeNames() {
- return new String[] {TYPE_NAME};
- }
-
- /* (non-Javadoc)
- * Method declared on Transfer.
- */
- protected void javaToNative(Object data, TransferData transferData) {
- if (! (data instanceof TypedSource[]))
- return;
- TypedSource[] sources = (TypedSource[]) data;
-
- /*
- * The serialization format is:
- * (int) number of elements
- * Then, the following for each element:
- * (int) type (see <code>IJavaScriptElement</code>)
- * (String) source of the element
- */
-
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(out);
-
- dataOut.writeInt(sources.length);
-
- for (int i = 0; i < sources.length; i++) {
- writeJavaElement(dataOut, sources[i]);
- }
-
- dataOut.close();
- out.close();
-
- super.javaToNative(out.toByteArray(), transferData);
- } catch (IOException e) {
- //it's best to send nothing if there were problems
- }
- }
-
- /* (non-Javadoc)
- * Method declared on Transfer.
- */
- protected Object nativeToJava(TransferData transferData) {
-
- byte[] bytes = (byte[]) super.nativeToJava(transferData);
- if (bytes == null)
- return null;
- DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
- try {
- int count = in.readInt();
- TypedSource[] results = new TypedSource[count];
- for (int i = 0; i < count; i++) {
- results[i] = readJavaElement(in);
- Assert.isNotNull(results[i]);
- }
- in.close();
- return results;
- } catch (IOException e) {
- return null;
- }
- }
-
- private static TypedSource readJavaElement(DataInputStream dataIn) throws IOException {
- int type= dataIn.readInt();
- String source= dataIn.readUTF();
- return TypedSource.create(source, type);
- }
-
- private static void writeJavaElement(DataOutputStream dataOut, TypedSource sourceReference) throws IOException {
- dataOut.writeInt(sourceReference.getType());
- dataOut.writeUTF(sourceReference.getSource());
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldInputPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldInputPage.java
deleted file mode 100644
index bde0f040..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldInputPage.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.refactoring.sef;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-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.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.sef.SelfEncapsulateFieldRefactoring;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class SelfEncapsulateFieldInputPage extends UserInputWizardPage {
-
- private SelfEncapsulateFieldRefactoring fRefactoring;
- private IDialogSettings fSettings;
- private List fEnablements;
-
- private static final String GENERATE_JAVADOC= "GenerateJavadoc"; //$NON-NLS-1$
-
-
- public SelfEncapsulateFieldInputPage() {
- super("InputPage"); //$NON-NLS-1$
- setDescription(RefactoringMessages.SelfEncapsulateFieldInputPage_description);
- setImageDescriptor(JavaPluginImages.DESC_WIZBAN_REFACTOR_CU);
- }
-
- public void createControl(Composite parent) {
- fRefactoring= (SelfEncapsulateFieldRefactoring)getRefactoring();
- fEnablements= new ArrayList();
- loadSettings();
-
- Composite result= new Composite(parent, SWT.NONE);
- setControl(result);
- initializeDialogUnits(result);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- layout.verticalSpacing= 8;
- result.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(25);
-
- Label label= new Label(result, SWT.LEAD);
- label.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_getter_name);
-
- Text getter= new Text(result, SWT.BORDER);
- getter.setText(fRefactoring.getGetterName());
- getter.setLayoutData(gd);
- TextFieldNavigationHandler.install(getter);
-
- final Label reUseGetter= new Label(result,SWT.LEAD);
- GridData getterGD= new GridData();
- getterGD.widthHint=convertWidthInCharsToPixels(23);
- reUseGetter.setLayoutData(getterGD);
- updateUseGetter(reUseGetter);
- getter.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String getterName= ((Text)e.widget).getText();
- fRefactoring.setGetterName(getterName);
- updateUseGetter(reUseGetter);
- processValidation();
- }
- });
-
- if (needsSetter()) {
- label= new Label(result, SWT.LEAD);
- label.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_setter_name);
-
- Text setter= new Text(result, SWT.BORDER);
- setter.setText(fRefactoring.getSetterName());
- setter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Label reUseSetter= new Label(result, SWT.LEAD);
- GridData setterGD= new GridData();
- setterGD.widthHint=convertWidthInCharsToPixels(23);
- reUseSetter.setLayoutData(setterGD);
- updateUseSetter(reUseSetter);
- setter.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String setterName= ((Text)e.widget).getText();
- fRefactoring.setSetterName(setterName);
- updateUseSetter(reUseSetter);
- processValidation();
- }
-
- });
- TextFieldNavigationHandler.install(setter);
- }
-
- // createSeparator(result, layouter);
- createFieldAccessBlock(result);
-
- label= new Label(result, SWT.LEFT);
- label.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_insert_after);
- fEnablements.add(label);
- final Combo combo= new Combo(result, SWT.READ_ONLY);
- fillWithPossibleInsertPositions(combo, fRefactoring.getField());
- combo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRefactoring.setInsertionIndex(combo.getSelectionIndex() - 1);
- }
- });
- GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan=2;
- combo.setLayoutData(gridData);
- fEnablements.add(combo);
-
-
- createAccessModifier(result);
-
- Button checkBox= new Button(result, SWT.CHECK);
- checkBox.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_generateJavadocComment);
- checkBox.setSelection(fRefactoring.getGenerateJavadoc());
- checkBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setGenerateJavadoc(((Button)e.widget).getSelection());
- }
- });
- GridData checkGD= new GridData(GridData.FILL_HORIZONTAL);
- checkGD.horizontalSpan=3;
- checkBox.setLayoutData(checkGD);
- fEnablements.add(checkBox);
-
- updateEnablements();
-
- processValidation();
-
- getter.setFocus();
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.SEF_WIZARD_PAGE);
- }
-
- private void updateUseSetter(Label reUseSetter) {
- if (fRefactoring.isUsingLocalSetter())
- reUseSetter.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_useexistingsetter_label);
- else
- reUseSetter.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_usenewgetter_label);
- updateEnablements();
- }
-
- private void updateEnablements() {
- boolean enable=!(fRefactoring.isUsingLocalSetter()&&fRefactoring.isUsingLocalGetter());
- for (Iterator iter= fEnablements.iterator(); iter.hasNext();) {
- Control control= (Control) iter.next();
- control.setEnabled(enable);
- }
- }
-
- private void updateUseGetter(Label reUseGetter) {
- if (fRefactoring.isUsingLocalGetter())
- reUseGetter.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_useexistinggetter_label);
- else
- reUseGetter.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_usenewsetter_label);
- updateEnablements();
- }
-
- private void loadSettings() {
- fSettings= getDialogSettings().getSection(SelfEncapsulateFieldWizard.DIALOG_SETTING_SECTION);
- if (fSettings == null) {
- fSettings= getDialogSettings().addNewSection(SelfEncapsulateFieldWizard.DIALOG_SETTING_SECTION);
- fSettings.put(GENERATE_JAVADOC, JavaPreferencesSettings.getCodeGenerationSettings(fRefactoring.getField().getJavaScriptProject()).createComments);
- }
- fRefactoring.setGenerateJavadoc(fSettings.getBoolean(GENERATE_JAVADOC));
- }
-
- private void createAccessModifier(Composite result) {
- int visibility= fRefactoring.getVisibility();
- if (Flags.isPublic(visibility))
- return;
- GridLayout layout;
- Label label;
- label= new Label(result, SWT.NONE);
- label.setText(RefactoringMessages.SelfEncapsulateFieldInputPage_access_Modifiers);
- fEnablements.add(label);
- Composite group= new Composite(result, SWT.NONE);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layout= new GridLayout();
- layout.numColumns= 4; layout.marginWidth= 0; layout.marginHeight= 0;
- group.setLayout(layout);
- GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan=2;
- group.setLayoutData(gridData);
-
- Object[] info= createData(visibility);
- String[] labels= (String[])info[0];
- Integer[] data= (Integer[])info[1];
- for (int i= 0; i < labels.length; i++) {
- Button radio= new Button(group, SWT.RADIO);
- radio.setText(labels[i]);
- radio.setData(data[i]);
- int iData= data[i].intValue();
- if (iData == visibility)
- radio.setSelection(true);
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- fRefactoring.setVisibility(((Integer)event.widget.getData()).intValue());
- }
- });
- fEnablements.add(radio);
- }
- }
-
- private void createFieldAccessBlock(Composite result) {
- Label label= new Label(result, SWT.LEFT);
- label.setText(RefactoringMessages.SelfEncapsulateField_field_access);
-
- Composite group= new Composite(result, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0; layout.marginHeight= 0; layout.numColumns= 2;
- group.setLayout(layout);
- GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan=2;
- group.setLayoutData(gridData);
- Button radio= new Button(group, SWT.RADIO);
- radio.setText(RefactoringMessages.SelfEncapsulateField_use_setter_getter);
- radio.setSelection(true);
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setEncapsulateDeclaringClass(true);
- }
- });
- radio.setLayoutData(new GridData());
-
- radio= new Button(group, SWT.RADIO);
- radio.setText(RefactoringMessages.SelfEncapsulateField_keep_references);
- radio.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fRefactoring.setEncapsulateDeclaringClass(false);
- }
- });
- radio.setLayoutData(new GridData());
- }
-
- private Object[] createData(int visibility) {
- String pub= RefactoringMessages.SelfEncapsulateFieldInputPage_public;
- String pro= RefactoringMessages.SelfEncapsulateFieldInputPage_protected;
- String def= RefactoringMessages.SelfEncapsulateFieldInputPage_default;
- String priv= RefactoringMessages.SelfEncapsulateFieldInputPage_private;
-
- String[] labels= null;
- Integer[] data= null;
- if (Flags.isPrivate(visibility)) {
- labels= new String[] { pub, pro, def, priv };
- data= new Integer[] {new Integer(Flags.AccPublic), new Integer(Flags.AccProtected), new Integer(0), new Integer(Flags.AccPrivate) };
- } else if (Flags.isProtected(visibility)) {
- labels= new String[] { pub, pro };
- data= new Integer[] {new Integer(Flags.AccPublic), new Integer(Flags.AccProtected)};
- } else {
- labels= new String[] { pub, def };
- data= new Integer[] {new Integer(Flags.AccPublic), new Integer(0)};
- }
- return new Object[] {labels, data};
- }
-
- private void fillWithPossibleInsertPositions(Combo combo, IField field) {
- int select= 0;
- combo.add(RefactoringMessages.SelfEncapsulateFieldInputPage_first_method);
- try {
- IFunction[] methods= field.getDeclaringType().getFunctions();
- for (int i= 0; i < methods.length; i++) {
- combo.add(JavaScriptElementLabels.getElementLabel(methods[i], JavaScriptElementLabels.M_PARAMETER_TYPES));
- }
- if (methods.length > 0)
- select= methods.length;
- } catch (JavaScriptModelException e) {
- // Fall through
- }
- combo.select(select);
- fRefactoring.setInsertionIndex(select - 1);
- }
-
- private void setGenerateJavadoc(boolean value) {
- fSettings.put(GENERATE_JAVADOC, value);
- fRefactoring.setGenerateJavadoc(value);
- }
-
- private void processValidation() {
- RefactoringStatus status= fRefactoring.checkMethodNames();
- String message= null;
- boolean valid= true;
- if (status.hasFatalError()) {
- message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
- valid= false;
- }
- setErrorMessage(message);
- setPageComplete(valid);
- }
-
- private boolean needsSetter() {
- try {
- return !JdtFlags.isFinal(fRefactoring.getField());
- } catch(JavaScriptModelException e) {
- return true;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldWizard.java
deleted file mode 100644
index 6858b3da..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/refactoring/sef/SelfEncapsulateFieldWizard.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.refactoring.sef;
-
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.sef.SelfEncapsulateFieldRefactoring;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.refactoring.RefactoringMessages;
-
-public class SelfEncapsulateFieldWizard extends RefactoringWizard {
-
- /* package */ static final String DIALOG_SETTING_SECTION= "SelfEncapsulateFieldWizard"; //$NON-NLS-1$
-
- public SelfEncapsulateFieldWizard(SelfEncapsulateFieldRefactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(RefactoringMessages.SelfEncapsulateField_sef);
- setDialogSettings(JavaScriptPlugin.getDefault().getDialogSettings());
- }
-
- protected void addUserInputPages() {
- addPage(new SelfEncapsulateFieldInputPage());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/BreakContinueTargetFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/BreakContinueTargetFinder.java
deleted file mode 100644
index 74b6a958..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/BreakContinueTargetFinder.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.compiler.IScanner;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.Block;
-import org.eclipse.wst.jsdt.core.dom.BreakStatement;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.ContinueStatement;
-import org.eclipse.wst.jsdt.core.dom.DoStatement;
-import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
-import org.eclipse.wst.jsdt.core.dom.ForInStatement;
-import org.eclipse.wst.jsdt.core.dom.ForStatement;
-import org.eclipse.wst.jsdt.core.dom.Initializer;
-import org.eclipse.wst.jsdt.core.dom.LabeledStatement;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.SwitchStatement;
-import org.eclipse.wst.jsdt.core.dom.WhileStatement;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Class used to find the target for a break or continue statement according
- * to the language specification.
- * <p>
- * The target statement is a while, do, switch, for or a labeled statement.
- * Break is described in section 14.15 of the JLS3 and continue in section 14.16.</p>
- *
- *
- */
-public class BreakContinueTargetFinder extends ASTVisitor {
- private ASTNode fSelected;
- private boolean fIsBreak;
- private SimpleName fLabel;
- private String fContents;//contents are used for scanning to select the right extent of the keyword
- private static final Class[] STOPPERS= {FunctionDeclaration.class, Initializer.class};
- private static final Class[] BREAKTARGETS= {ForStatement.class, ForInStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class, SwitchStatement.class};
- private static final Class[] CONTINUETARGETS= {ForStatement.class, ForInStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class};
- private static final int BRACE_LENGTH= 1;
-
- /*
- * Initializes the finder. Returns error message or <code>null</code> if everything is OK.
- */
- public String initialize(JavaScriptUnit root, int offset, int length) {
- return initialize(root, NodeFinder.perform(root, offset, length));
- }
-
- /*
- * Initializes the finder. Returns error message or <code>null</code> if everything is OK.
- */
- public String initialize(JavaScriptUnit root, ASTNode node) {
- ASTNode controlNode= getBreakOrContinueNode(node);
- if (controlNode != null){
- fContents= getContents(root);
- if (fContents == null)
- return SearchMessages.BreakContinueTargetFinder_cannot_highlight;
-
- fSelected= controlNode;
- fIsBreak= fSelected instanceof BreakStatement;
- fLabel= getLabel();
- return null;
- } else {
- return SearchMessages.BreakContinueTargetFinder_no_break_or_continue_selected;
- }
- }
-
- /* Returns contents or <code>null</code> if there's trouble. */
- private String getContents(JavaScriptUnit root) {
- try {
- IJavaScriptElement rootElem= root.getJavaElement();
- if ((rootElem instanceof ISourceReference))
- return ((ISourceReference)rootElem).getSource();
- else
- return null;
- } catch (JavaScriptModelException e) {
- //We must handle it here because JavaEditor does not expect an exception
-
- /* showing a dialog here would be too heavy but we cannot just
- * swallow the exception */
- JavaScriptPlugin.log(e);
- return null;
- }
- }
-
- //extract the control node: handle labels
- private ASTNode getBreakOrContinueNode(ASTNode selectedNode) {
- if (selectedNode instanceof BreakStatement)
- return selectedNode;
- if (selectedNode instanceof ContinueStatement)
- return selectedNode;
- if (selectedNode instanceof SimpleName && selectedNode.getParent() instanceof BreakStatement)
- return selectedNode.getParent();
- if (selectedNode instanceof SimpleName && selectedNode.getParent() instanceof ContinueStatement)
- return selectedNode.getParent();
- return null;
- }
-
- public List perform() {
- return getNodesToHighlight();
- }
-
- private SimpleName getLabel() {
- if (fIsBreak){
- BreakStatement bs= (BreakStatement) fSelected;
- return bs.getLabel();
- } else {
- ContinueStatement cs= (ContinueStatement) fSelected;
- return cs.getLabel();
- }
- }
-
- private List getNodesToHighlight() {
- ASTNode targetNode= findTargetNode(fSelected);
- if (!isEnclosingStatement(targetNode))
- return Collections.EMPTY_LIST;
-
- List list= new ArrayList();
- ASTNode node= makeFakeNodeForFirstToken(targetNode);
- if (node != null)
- list.add(node);
-
- if (fIsBreak) {
- node= makeFakeNodeForClosingBrace(targetNode);
- if (node != null)
- list.add(node);
- }
-
- return list;
-
- }
-
- private boolean isEnclosingStatement(ASTNode targetNode) {
- return (targetNode != null) && !(targetNode instanceof FunctionDeclaration) && !(targetNode instanceof Initializer);
- }
-
- private ASTNode findTargetNode(ASTNode node) {
- do {
- node= node.getParent();
- } while (keepWalkingUp(node));
- return node;
- }
-
- private ASTNode makeFakeNodeForFirstToken(ASTNode node) {
- try {
- int length= getLengthOfFirstTokenOf(node);
- if (length < 1)
- return node;//fallback
- return makeFakeNode(node.getStartPosition(), length, node.getAST());
- } catch (InvalidInputException e) {
- return node;//fallback
- }
- }
-
- private SimpleName makeFakeNode(int start, int length, AST ast) {
- String fakeName= makeStringOfLength(length);
- SimpleName name= ast.newSimpleName(fakeName);
- name.setSourceRange(start, length);
- return name;
- }
-
- private ASTNode makeFakeNodeForClosingBrace(ASTNode targetNode) {
- ASTNode maybeBlock= getOptionalBlock(targetNode);
- if (maybeBlock == null)
- return null;
-
- /* Ideally, we'd scan backwards to find the '}' token, but it may be an overkill
- * so I'll just assume the closing brace token has a fixed length. */
- return makeFakeNode(ASTNodes.getExclusiveEnd(maybeBlock)-BRACE_LENGTH, BRACE_LENGTH, targetNode.getAST());
- }
-
- /*
- * Block cannot be return type here because SwitchStatement has no block
- * and yet it does have a closing brace.
- */
- private ASTNode getOptionalBlock(ASTNode targetNode) {
- final ASTNode[] maybeBlock= new ASTNode[1];
- targetNode.accept(new ASTVisitor(){
- public boolean visit(ForStatement node) {
- if (node.getBody() instanceof Block)
- maybeBlock[0]= node.getBody();
- return false;
- }
- public boolean visit(ForInStatement node) {
- if (node.getBody() instanceof Block)
- maybeBlock[0]= node.getBody();
- return false;
- }
- public boolean visit(EnhancedForStatement node) {
- if (node.getBody() instanceof Block)
- maybeBlock[0]= node.getBody();
- return false;
- }
- public boolean visit(WhileStatement node) {
- if (node.getBody() instanceof Block)
- maybeBlock[0]= node.getBody();
- return false;
- }
- public boolean visit(DoStatement node) {
- if (node.getBody() instanceof Block)
- maybeBlock[0]= node.getBody();
- return false;
- }
- public boolean visit(SwitchStatement node) {
- maybeBlock[0]= node;
- return false;
- }
- });
- return maybeBlock[0];
- }
-
- private static String makeStringOfLength(int length) {
- char[] chars= new char[length];
- Arrays.fill(chars, 'x');
- return new String(chars);
- }
-
- //must scan because of unicode
- private int getLengthOfFirstTokenOf(ASTNode node) throws InvalidInputException {
- IScanner scanner= ToolFactory.createScanner(true, true, false, true);
- scanner.setSource(getSource(node).toCharArray());
- scanner.getNextToken();
- return scanner.getRawTokenSource().length;
- }
-
- private String getSource(ASTNode node) {
- return fContents.substring(node.getStartPosition(), ASTNodes.getInclusiveEnd(node));
- }
-
- private boolean keepWalkingUp(ASTNode node) {
- if (node == null)
- return false;
- if (isAnyInstanceOf(STOPPERS, node))
- return false;
- if (fLabel != null && LabeledStatement.class.isInstance(node)){
- LabeledStatement ls= (LabeledStatement)node;
- return ! areEqualLabels(ls.getLabel(), fLabel);
- }
- if (fLabel == null && fIsBreak && isAnyInstanceOf(BREAKTARGETS, node))
- return false;
- if (fLabel == null && !fIsBreak && isAnyInstanceOf(CONTINUETARGETS, node))
- return false;
- return true;
- }
-
- //TODO see bug 33739 - resolveBinding always returns null
- //so we just compare names
- private static boolean areEqualLabels(SimpleName labelToMatch, SimpleName labelSelected) {
- return labelSelected.getIdentifier().equals(labelToMatch.getIdentifier());
- }
-
- private static boolean isAnyInstanceOf(Class[] continueTargets, ASTNode node) {
- for (int i= 0; i < continueTargets.length; i++) {
- if (continueTargets[i].isInstance(node))
- return true;
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesFinder.java
deleted file mode 100644
index 420b00c9..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesFinder.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTMatcher;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.wst.jsdt.core.dom.CastExpression;
-import org.eclipse.wst.jsdt.core.dom.CatchClause;
-import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.JSdoc;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
-import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
-import org.eclipse.wst.jsdt.core.dom.ThrowStatement;
-import org.eclipse.wst.jsdt.core.dom.TryStatement;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-
-public class ExceptionOccurrencesFinder extends ASTVisitor implements IOccurrencesFinder {
-
- public static final String IS_EXCEPTION= "isException"; //$NON-NLS-1$
-
- private AST fAST;
- private Name fSelectedName;
-
- private ITypeBinding fException;
- private ASTNode fStart;
- private List fResult;
-
- public ExceptionOccurrencesFinder() {
- fResult= new ArrayList();
- }
-
- public String initialize(JavaScriptUnit root, int offset, int length) {
- return initialize(root, NodeFinder.perform(root, offset, length));
- }
-
- public String initialize(JavaScriptUnit root, ASTNode node) {
- fAST= root.getAST();
- if (!(node instanceof Name)) {
- return SearchMessages.ExceptionOccurrencesFinder_no_exception;
- }
- fSelectedName= ASTNodes.getTopMostName((Name)node);
- ASTNode parent= fSelectedName.getParent();
- FunctionDeclaration decl= resolveMethodDeclaration(parent);
- if (decl != null && methodThrowsException(decl, fSelectedName)) {
- fException= fSelectedName.resolveTypeBinding();
- fStart= decl.getBody();
- } else if (parent instanceof Type) {
- parent= parent.getParent();
- if (parent instanceof SingleVariableDeclaration && parent.getParent() instanceof CatchClause) {
- CatchClause catchClause= (CatchClause)parent.getParent();
- TryStatement tryStatement= (TryStatement)catchClause.getParent();
- if (tryStatement != null) {
- IVariableBinding var= catchClause.getException().resolveBinding();
- if (var != null && var.getType() != null) {
- fException= var.getType();
- fStart= tryStatement.getBody();
- }
- }
- }
- }
- if (fException == null || fStart == null)
- return SearchMessages.ExceptionOccurrencesFinder_no_exception;
- return null;
- }
-
- private FunctionDeclaration resolveMethodDeclaration(ASTNode node) {
- if (node instanceof FunctionDeclaration)
- return (FunctionDeclaration)node;
- JSdoc doc= (JSdoc) ASTNodes.getParent(node, ASTNode.JSDOC);
- if (doc == null)
- return null;
- if (doc.getParent() instanceof FunctionDeclaration)
- return (FunctionDeclaration) doc.getParent();
- return null;
- }
-
- private boolean methodThrowsException(FunctionDeclaration method, Name exception) {
- ASTMatcher matcher = new ASTMatcher();
- for (Iterator iter = method.thrownExceptions().iterator(); iter.hasNext();) {
- Name thrown = (Name)iter.next();
- if (exception.subtreeMatch(matcher, thrown))
- return true;
- }
- return false;
- }
-
- public List perform() {
- fStart.accept(this);
- if (fSelectedName != null) {
- fResult.add(fSelectedName);
- }
- return fResult;
- }
-
- public void collectOccurrenceMatches(IJavaScriptElement element, IDocument document, Collection resultingMatches) {
- HashMap lineToLineElement= new HashMap();
-
- for (Iterator iter= fResult.iterator(); iter.hasNext();) {
- ASTNode node= (ASTNode) iter.next();
- int startPosition= node.getStartPosition();
- int length= node.getLength();
- try {
- boolean isException= node == fSelectedName;
- int line= document.getLineOfOffset(startPosition);
- Integer lineInteger= new Integer(line);
- ExceptionOccurrencesGroupKey groupKey= (ExceptionOccurrencesGroupKey) lineToLineElement.get(lineInteger);
- if (groupKey == null) {
- IRegion region= document.getLineInformation(line);
- String lineContents= document.get(region.getOffset(), region.getLength()).trim();
- groupKey= new ExceptionOccurrencesGroupKey(element, line, lineContents, isException);
- lineToLineElement.put(lineInteger, groupKey);
- } else if (isException) {
- // the line with the target exception always has the exception icon:
- groupKey.setException(true);
- }
- Match match= new Match(groupKey, startPosition, length);
- resultingMatches.add(match);
- } catch (BadLocationException e) {
- //nothing
- }
- }
- }
-
- public String getJobLabel() {
- return SearchMessages.ExceptionOccurrencesFinder_searchfor ;
- }
-
- public String getElementName() {
- if (fSelectedName != null) {
- return ASTNodes.asString(fSelectedName);
- }
- return null;
- }
-
- public String getUnformattedPluralLabel() {
- return SearchMessages.ExceptionOccurrencesFinder_label_plural;
- }
-
- public String getUnformattedSingularLabel() {
- return SearchMessages.ExceptionOccurrencesFinder_label_singular;
- }
-
- public boolean visit(AnonymousClassDeclaration node) {
- return false;
- }
-
- public boolean visit(CastExpression node) {
- if ("java.lang.ClassCastException".equals(fException.getQualifiedName())) //$NON-NLS-1$
- fResult.add(node.getType());
- return super.visit(node);
- }
-
- public boolean visit(ClassInstanceCreation node) {
- if (matches(node.resolveConstructorBinding())) {
- fResult.add(node.getType());
- }
- return super.visit(node);
- }
-
- public boolean visit(ConstructorInvocation node) {
- if (matches(node.resolveConstructorBinding())) {
- // mark this
- SimpleName name= fAST.newSimpleName("xxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 4);
- fResult.add(name);
- }
- return super.visit(node);
- }
-
- public boolean visit(FunctionInvocation node) {
- if (matches(node.resolveMethodBinding()))
- fResult.add(node.getName());
- return super.visit(node);
- }
-
- public boolean visit(SuperConstructorInvocation node) {
- if (matches(node.resolveConstructorBinding())) {
- SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 5);
- fResult.add(name);
- }
- return super.visit(node);
- }
-
- public boolean visit(SuperMethodInvocation node) {
- if (matches(node.resolveMethodBinding())) {
- fResult.add(node.getName());
- }
- return super.visit(node);
- }
-
- public boolean visit(ThrowStatement node) {
- if (matches(node.getExpression().resolveTypeBinding())) {
- SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 5);
- fResult.add(name);
-
- }
- return super.visit(node);
- }
-
- public boolean visit(TypeDeclarationStatement node) {
- // don't dive into local type declarations.
- return false;
- }
-
- private boolean matches(IFunctionBinding binding) {
- if (binding == null)
- return false;
- ITypeBinding[] exceptions= binding.getExceptionTypes();
- for (int i = 0; i < exceptions.length; i++) {
- ITypeBinding exception= exceptions[i];
- if(matches(exception))
- return true;
- }
- return false;
- }
-
- private boolean matches(ITypeBinding exception) {
- if (exception == null)
- return false;
- while (exception != null) {
- if (Bindings.equals(fException, exception))
- return true;
- exception= exception.getSuperclass();
- }
- return false;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesGroupKey.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesGroupKey.java
deleted file mode 100644
index 57f0af3d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ExceptionOccurrencesGroupKey.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-public class ExceptionOccurrencesGroupKey extends JavaElementLine {
- private boolean fIsException;
-
- /**
- * @param element either an IJavaScriptUnit or an IClassFile
- */
- public ExceptionOccurrencesGroupKey(IJavaScriptElement element, int line, String lineContents, boolean isException) {
- super(element, line, lineContents);
- fIsException= isException;
- }
-
- public boolean isException() {
- return fIsException;
- }
-
- public void setException(boolean isException) {
- fIsException= isException;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/FindOccurrencesEngine.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/FindOccurrencesEngine.java
deleted file mode 100644
index d41bf29c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/FindOccurrencesEngine.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
-
-public abstract class FindOccurrencesEngine {
-
- private IOccurrencesFinder fFinder;
-
- private static class FindOccurencesClassFileEngine extends FindOccurrencesEngine {
- private IClassFile fClassFile;
-
- public FindOccurencesClassFileEngine(IClassFile file, IOccurrencesFinder finder) {
- super(finder);
- fClassFile= file;
- }
- protected JavaScriptUnit createAST() {
- return JavaScriptPlugin.getDefault().getASTProvider().getAST(fClassFile, ASTProvider.WAIT_YES, null);
- }
- protected IJavaScriptElement getInput() {
- return fClassFile;
- }
- protected ISourceReference getSourceReference() {
- return fClassFile;
- }
- }
-
- private static class FindOccurencesCUEngine extends FindOccurrencesEngine {
- private IJavaScriptUnit fCUnit;
-
- public FindOccurencesCUEngine(IJavaScriptUnit unit, IOccurrencesFinder finder) {
- super(finder);
- fCUnit= unit;
- }
- protected JavaScriptUnit createAST() {
- return JavaScriptPlugin.getDefault().getASTProvider().getAST(fCUnit, ASTProvider.WAIT_YES, null);
- }
- protected IJavaScriptElement getInput() {
- return fCUnit;
- }
- protected ISourceReference getSourceReference() {
- return fCUnit;
- }
- }
-
- protected FindOccurrencesEngine(IOccurrencesFinder finder) {
- fFinder= finder;
- }
-
- public static FindOccurrencesEngine create(IJavaScriptElement root, IOccurrencesFinder finder) {
- if (root == null || finder == null)
- return null;
-
- IJavaScriptUnit unit= (IJavaScriptUnit)root.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (unit != null)
- return new FindOccurencesCUEngine(unit, finder);
- IClassFile cf= (IClassFile)root.getAncestor(IJavaScriptElement.CLASS_FILE);
- if (cf != null)
- return new FindOccurencesClassFileEngine(cf, finder);
- return null;
- }
-
- protected abstract JavaScriptUnit createAST();
-
- protected abstract IJavaScriptElement getInput();
-
- protected abstract ISourceReference getSourceReference();
-
- protected IOccurrencesFinder getOccurrencesFinder() {
- return fFinder;
- }
-
- public String run(int offset, int length) throws JavaScriptModelException {
- ISourceReference sr= getSourceReference();
- if (sr.getSourceRange() == null) {
- return SearchMessages.FindOccurrencesEngine_noSource_text;
- }
-
- final JavaScriptUnit root= createAST();
- if (root == null) {
- return SearchMessages.FindOccurrencesEngine_cannotParse_text;
- }
- String message= fFinder.initialize(root, offset, length);
- if (message != null)
- return message;
-
- final IDocument document= new Document(getSourceReference().getSource());
-
- performNewSearch(fFinder, document, getInput());
- return null;
- }
-
- private void performNewSearch(IOccurrencesFinder finder, IDocument document, IJavaScriptElement element) {
- NewSearchUI.runQueryInBackground(new OccurrencesSearchQuery(finder, document, element));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/GroupAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/GroupAction.java
deleted file mode 100644
index 06f92a1a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/GroupAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.action.Action;
-
-
-public class GroupAction extends Action {
- private int fGrouping;
- private JavaSearchResultPage fPage;
-
- public GroupAction(String label, String tooltip, JavaSearchResultPage page, int grouping) {
- super(label);
- setToolTipText(tooltip);
- fPage= page;
- fGrouping= grouping;
- }
-
- public void run() {
- fPage.setGrouping(fGrouping);
- }
-
- public int getGrouping() {
- return fGrouping;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/IOccurrencesFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/IOccurrencesFinder.java
deleted file mode 100644
index d6ebc3c8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/IOccurrencesFinder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-
-public interface IOccurrencesFinder {
-
- public String initialize(JavaScriptUnit root, int offset, int length);
-
- public List perform();
-
- public String getJobLabel();
-
- /**
- * Returns the plural label for this finder with 3 placeholders:
- * <ul>
- * <li>{0} for the {@link #getElementName() element name}</li>
- * <li>{1} for the number of results found</li>
- * <li>{2} for the scope (name of the compilation unit)</li>
- * </ul>
- * @return the unformatted label
- */
- public String getUnformattedPluralLabel();
-
- /**
- * Returns the singular label for this finder with 2 placeholders:
- * <ul>
- * <li>{0} for the {@link #getElementName() element name}</li>
- * <li>{1} for the scope (name of the compilation unit)</li>
- * </ul>
- * @return the unformatted label
- */
- public String getUnformattedSingularLabel();
-
- /**
- * Returns the name of the lement to look for or <code>null</code> if the finder hasn't
- * been initialized yet.
- * @return the name of the element
- */
- public String getElementName();
-
- public void collectOccurrenceMatches(IJavaScriptElement element, IDocument document, Collection resultingMatches);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ImplementOccurrencesFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ImplementOccurrencesFinder.java
deleted file mode 100644
index 265597a6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/ImplementOccurrencesFinder.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-
-
-/**
- * Finds all implement occurrences of an extended class or an implemented interface.
- *
- *
- */
-public class ImplementOccurrencesFinder implements org.eclipse.wst.jsdt.internal.ui.search.IOccurrencesFinder {
-
-
- private class MethodVisitor extends ASTVisitor {
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.FunctionDeclaration)
- */
- public boolean visit(FunctionDeclaration node) {
- IFunctionBinding binding= node.resolveBinding();
- if (binding != null) {
- IFunctionBinding method= Bindings.findOverriddenMethodInHierarchy(fSelectedType, binding);
- if (method != null)
- fResult.add(node.getName());
- }
- return super.visit(node);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration)
- */
- public boolean visit(AnonymousClassDeclaration node) {
- // don't dive into anonymous type declarations.
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement)
- */
- public boolean visit(TypeDeclarationStatement node) {
- // don't dive into local type declarations.
- return false;
- }
- }
-
-
- private ASTNode fStart;
- private List fResult;
- private ASTNode fSelectedNode;
- private ITypeBinding fSelectedType;
-
- public ImplementOccurrencesFinder() {
- fResult= new ArrayList();
- }
-
- public String initialize(JavaScriptUnit root, int offset, int length) {
- return initialize(root, NodeFinder.perform(root, offset, length));
- }
-
- public String initialize(JavaScriptUnit root, ASTNode node) {
- if (!(node instanceof Name))
- return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
-
- fSelectedNode= ASTNodes.getNormalizedNode(node);
- if (!(fSelectedNode instanceof Type))
- return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
-
- ASTNode typeDeclaration= fSelectedNode.getParent();
- if (!(typeDeclaration instanceof AbstractTypeDeclaration))
- return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
-
- fSelectedType= ((Type)fSelectedNode).resolveBinding();
- if (fSelectedType == null)
- return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
-
- fStart= typeDeclaration;
- return null;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.search.IOccurrencesFinder#perform()
- */
- public List perform() {
- fStart.accept(new MethodVisitor());
- if (fSelectedNode != null)
- fResult.add(fSelectedNode);
-
- return fResult;
- }
-
- public void collectOccurrenceMatches(IJavaScriptElement element, IDocument document, Collection resultingMatches) {
- for (Iterator iter= fResult.iterator(); iter.hasNext();) {
- ASTNode node= (ASTNode) iter.next();
- int startPosition= node.getStartPosition();
- int length= node.getLength();
- try {
- int line= document.getLineOfOffset(startPosition);
- IRegion region= document.getLineInformation(line);
- String lineContents= document.get(region.getOffset(), region.getLength()).trim();
- JavaElementLine groupKey= new JavaElementLine(element, line, lineContents);
- resultingMatches.add(new Match(groupKey, startPosition, length));
- } catch (BadLocationException e) {
- //nothing
- }
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.search.IOccurrencesFinder#getJobLabel()
- */
- public String getJobLabel() {
- return SearchMessages.ImplementOccurrencesFinder_searchfor ;
- }
-
- public String getElementName() {
- if (fSelectedNode != null) {
- return ASTNodes.asString(fSelectedNode);
- }
- return null;
- }
-
- public String getUnformattedPluralLabel() {
- return SearchMessages.ImplementOccurrencesFinder_label_plural;
- }
-
- public String getUnformattedSingularLabel() {
- return SearchMessages.ImplementOccurrencesFinder_label_singular;
- }
-
- public void releaseAST() {
- fStart= null;
- fSelectedType= null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementLine.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementLine.java
deleted file mode 100644
index 9a0b3586..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementLine.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-public class JavaElementLine {
- private IJavaScriptElement fElement;
- private int fLine;
- private String fLineContents;
-
- /**
- * @param element either an IJavaScriptUnit or an IClassFile
- */
- public JavaElementLine(IJavaScriptElement element, int line, String lineContents) {
- fElement= element;
- fLine= line;
- fLineContents= lineContents;
- }
-
- public IJavaScriptElement getJavaElement() {
- return fElement;
- }
-
- public int getLine() {
- return fLine;
- }
-
- public String getLineContents() {
- return fLineContents;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementMatch.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementMatch.java
deleted file mode 100644
index ff002664..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaElementMatch.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.search.ui.text.Match;
-
-/**
- * A search match with additional java-specific info.
- */
-public class JavaElementMatch extends Match {
- private final int fAccuracy;
- private final int fMatchRule;
- private final boolean fIsWriteAccess;
- private final boolean fIsReadAccess;
- private final boolean fIsJavadoc;
- private final boolean fIsSuperInvocation;
-
- JavaElementMatch(Object element, int matchRule, int offset, int length, int accuracy, boolean isReadAccess, boolean isWriteAccess, boolean isJavadoc, boolean isSuperInvocation) {
- super(element, offset, length);
- fAccuracy= accuracy;
- fMatchRule= matchRule;
- fIsWriteAccess= isWriteAccess;
- fIsReadAccess= isReadAccess;
- fIsJavadoc= isJavadoc;
- fIsSuperInvocation= isSuperInvocation;
- }
-
- public int getAccuracy() {
- return fAccuracy;
- }
-
- public boolean isWriteAccess() {
- return fIsWriteAccess;
- }
-
- public boolean isReadAccess() {
- return fIsReadAccess;
- }
-
- public boolean isJavadoc() {
- return fIsJavadoc;
- }
-
- public boolean isSuperInvocation() {
- return fIsSuperInvocation;
- }
-
- public int getMatchRule() {
- return fMatchRule;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaMatchFilter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaMatchFilter.java
deleted file mode 100644
index 478bd6fd..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaMatchFilter.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.StringTokenizer;
-
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.ui.text.MatchFilter;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeParameter;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.SearchMatch;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.internal.corext.util.JdtFlags;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.QuerySpecification;
-
-abstract class JavaMatchFilter extends MatchFilter {
-
- public abstract boolean filters(JavaElementMatch match);
-
- /**
- * Returns whether this filter is applicable for this query
- * @param query
- * @return returns <code>true</code> if this match filter is applicable for the given query
- */
- public abstract boolean isApplicable(JavaSearchQuery query);
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.MatchFilter#filters(org.eclipse.search.ui.text.Match)
- */
- public boolean filters(Match match) {
- if (match instanceof JavaElementMatch) {
- return filters((JavaElementMatch) match);
- }
- return false;
- }
-
- private static final String SETTINGS_LAST_USED_FILTERS= "filters_last_used"; //$NON-NLS-1$
-
- public static MatchFilter[] getLastUsedFilters() {
- String string= JavaScriptPlugin.getDefault().getDialogSettings().get(SETTINGS_LAST_USED_FILTERS);
- if (string != null && string.length() > 0) {
- return decodeFiltersString(string);
- }
- return getDefaultFilters();
- }
-
- public static void setLastUsedFilters(MatchFilter[] filters) {
- String encoded= encodeFilters(filters);
- JavaScriptPlugin.getDefault().getDialogSettings().put(SETTINGS_LAST_USED_FILTERS, encoded);
- }
-
- public static MatchFilter[] getDefaultFilters() {
- return new MatchFilter[] { IMPORT_FILTER };
- }
-
- private static String encodeFilters(MatchFilter[] enabledFilters) {
- StringBuffer buf= new StringBuffer();
- for (int i= 0; i < enabledFilters.length; i++) {
- MatchFilter matchFilter= enabledFilters[i];
- buf.append(matchFilter.getID());
- buf.append(';');
- }
- return buf.toString();
- }
-
- private static JavaMatchFilter[] decodeFiltersString(String encodedString) {
- StringTokenizer tokenizer= new StringTokenizer(encodedString, String.valueOf(';'));
- HashSet result= new HashSet();
- while (tokenizer.hasMoreTokens()) {
- JavaMatchFilter curr= findMatchFilter(tokenizer.nextToken());
- if (curr != null) {
- result.add(curr);
- }
- }
- return (JavaMatchFilter[]) result.toArray(new JavaMatchFilter[result.size()]);
- }
-
- private static final JavaMatchFilter POTENTIAL_FILTER= new PotentialFilter();
- private static final JavaMatchFilter IMPORT_FILTER= new ImportFilter();
- private static final JavaMatchFilter JAVADOC_FILTER= new JavadocFilter();
- private static final JavaMatchFilter READ_FILTER= new ReadFilter();
- private static final JavaMatchFilter WRITE_FILTER= new WriteFilter();
-
- //private static final JavaMatchFilter POLYMORPHIC_FILTER= new PolymorphicFilter();
- private static final JavaMatchFilter INEXACT_FILTER= new InexactMatchFilter();
- private static final JavaMatchFilter ERASURE_FILTER= new ErasureMatchFilter();
-
- //private static final JavaMatchFilter NON_PUBLIC_FILTER= new NonPublicFilter();
- private static final JavaMatchFilter STATIC_FILTER= new StaticFilter();
- private static final JavaMatchFilter NON_STATIC_FILTER= new NonStaticFilter();
- private static final JavaMatchFilter DEPRECATED_FILTER= new DeprecatedFilter();
- private static final JavaMatchFilter NON_DEPRECATED_FILTER= new NonDeprecatedFilter();
-
- private static final JavaMatchFilter[] ALL_FILTERS= new JavaMatchFilter[] {
- POTENTIAL_FILTER,
- IMPORT_FILTER,
- JAVADOC_FILTER,
- READ_FILTER,
- WRITE_FILTER,
-
- /*POLYMORPHIC_FILTER,*/
- INEXACT_FILTER,
- ERASURE_FILTER,
-
- /* NON_PUBLIC_FILTER,*/
- STATIC_FILTER,
- NON_STATIC_FILTER,
- DEPRECATED_FILTER,
- NON_DEPRECATED_FILTER
- };
-
- public static JavaMatchFilter[] allFilters() {
- return ALL_FILTERS;
- }
-
- public static JavaMatchFilter[] allFilters(JavaSearchQuery query) {
- ArrayList res= new ArrayList();
- for (int i= 0; i < ALL_FILTERS.length; i++) {
- JavaMatchFilter curr= ALL_FILTERS[i];
- if (curr.isApplicable(query)) {
- res.add(curr);
- }
- }
- return (JavaMatchFilter[]) res.toArray(new JavaMatchFilter[res.size()]);
- }
-
- private static JavaMatchFilter findMatchFilter(String id) {
- for (int i= 0; i < ALL_FILTERS.length; i++) {
- JavaMatchFilter matchFilter= ALL_FILTERS[i];
- if (matchFilter.getID().equals(id))
- return matchFilter;
- }
- return null;
- }
-}
-
-class PotentialFilter extends JavaMatchFilter {
- public boolean filters(JavaElementMatch match) {
- return match.getAccuracy() == SearchMatch.A_INACCURATE;
- }
-
- public String getName() {
- return SearchMessages.MatchFilter_PotentialFilter_name;
- }
-
- public String getActionLabel() {
- return SearchMessages.MatchFilter_PotentialFilter_actionLabel;
- }
-
- public String getDescription() {
- return SearchMessages.MatchFilter_PotentialFilter_description;
- }
-
- public boolean isApplicable(JavaSearchQuery query) {
- return true;
- }
-
- public String getID() {
- return "filter_potential"; //$NON-NLS-1$
- }
-}
-
-class ImportFilter extends JavaMatchFilter {
- public boolean filters(JavaElementMatch match) {
- return match.getElement() instanceof IImportDeclaration;
- }
-
- public String getName() {
- return SearchMessages.MatchFilter_ImportFilter_name;
- }
-
- public String getActionLabel() {
- return SearchMessages.MatchFilter_ImportFilter_actionLabel;
- }
-
- public String getDescription() {
- return SearchMessages.MatchFilter_ImportFilter_description;
- }
-
- public boolean isApplicable(JavaSearchQuery query) {
- QuerySpecification spec= query.getSpecification();
- if (spec instanceof ElementQuerySpecification) {
- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
- IJavaScriptElement element= elementSpec.getElement();
- return element instanceof IType || element instanceof IPackageFragment;
- } else if (spec instanceof PatternQuerySpecification) {
- PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
- int searchFor= patternSpec.getSearchFor();
- return searchFor == IJavaScriptSearchConstants.TYPE || searchFor == IJavaScriptSearchConstants.PACKAGE;
- }
- return false;
- }
-
- public String getID() {
- return "filter_imports"; //$NON-NLS-1$
- }
-}
-
-abstract class VariableFilter extends JavaMatchFilter {
- public boolean isApplicable(JavaSearchQuery query) {
- QuerySpecification spec= query.getSpecification();
- if (spec instanceof ElementQuerySpecification) {
- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
- IJavaScriptElement element= elementSpec.getElement();
- return element instanceof IField || element instanceof ILocalVariable;
- } else if (spec instanceof PatternQuerySpecification) {
- PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
- return patternSpec.getSearchFor() == IJavaScriptSearchConstants.FIELD;
- }
- return false;
- }
-
-}
-
-class WriteFilter extends VariableFilter {
- public boolean filters(JavaElementMatch match) {
- return match.isWriteAccess() && !match.isReadAccess();
- }
- public String getName() {
- return SearchMessages.MatchFilter_WriteFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_WriteFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_WriteFilter_description;
- }
- public String getID() {
- return "filter_writes"; //$NON-NLS-1$
- }
-}
-
-class ReadFilter extends VariableFilter {
- public boolean filters(JavaElementMatch match) {
- return match.isReadAccess() && !match.isWriteAccess();
- }
- public String getName() {
- return SearchMessages.MatchFilter_ReadFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_ReadFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_ReadFilter_description;
- }
- public String getID() {
- return "filter_reads"; //$NON-NLS-1$
- }
-}
-
-class JavadocFilter extends JavaMatchFilter {
- public boolean filters(JavaElementMatch match) {
- return match.isJavadoc();
- }
- public String getName() {
- return SearchMessages.MatchFilter_JavadocFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_JavadocFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_JavadocFilter_description;
- }
- public boolean isApplicable(JavaSearchQuery query) {
- return true;
- }
- public String getID() {
- return "filter_javadoc"; //$NON-NLS-1$
- }
-}
-
-class PolymorphicFilter extends JavaMatchFilter {
- public boolean filters(JavaElementMatch match) {
- return match.isSuperInvocation();
- }
-
- public String getName() {
- return SearchMessages.MatchFilter_PolymorphicFilter_name;
- }
-
- public String getActionLabel() {
- return SearchMessages.MatchFilter_PolymorphicFilter_actionLabel;
- }
-
- public String getDescription() {
- return SearchMessages.MatchFilter_PolymorphicFilter_description;
- }
-
- public boolean isApplicable(JavaSearchQuery query) {
- QuerySpecification spec= query.getSpecification();
- switch (spec.getLimitTo()) {
- case IJavaScriptSearchConstants.REFERENCES:
- case IJavaScriptSearchConstants.ALL_OCCURRENCES:
- if (spec instanceof ElementQuerySpecification) {
- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
- return elementSpec.getElement() instanceof IFunction;
- } else if (spec instanceof PatternQuerySpecification) {
- PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
- return patternSpec.getSearchFor() == IJavaScriptSearchConstants.METHOD;
- }
- }
- return false;
- }
-
- public String getID() {
- return "filter_polymorphic"; //$NON-NLS-1$
- }
-}
-
-abstract class GenericTypeFilter extends JavaMatchFilter {
- public boolean isApplicable(JavaSearchQuery query) {
- QuerySpecification spec= query.getSpecification();
- if (spec instanceof ElementQuerySpecification) {
- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
- Object element= elementSpec.getElement();
- ITypeParameter[] typeParameters= null;
- try {
- if (element instanceof IType) {
- typeParameters= ((IType)element).getTypeParameters();
- } else if (element instanceof IFunction) {
- typeParameters= ((IFunction)element).getTypeParameters();
- }
- } catch (JavaScriptModelException e) {
- return false;
- }
- return typeParameters != null && typeParameters.length > 0;
- }
- return false;
- }
-}
-
-class ErasureMatchFilter extends GenericTypeFilter {
- public boolean filters(JavaElementMatch match) {
- return (match.getMatchRule() & (SearchPattern.R_FULL_MATCH | SearchPattern.R_EQUIVALENT_MATCH)) == 0;
- }
- public String getName() {
- return SearchMessages.MatchFilter_ErasureFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_ErasureFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_ErasureFilter_description;
- }
- public String getID() {
- return "filter_erasure"; //$NON-NLS-1$
- }
-}
-
-class InexactMatchFilter extends GenericTypeFilter {
- public boolean filters(JavaElementMatch match) {
- return (match.getMatchRule() & (SearchPattern.R_FULL_MATCH)) == 0;
- }
- public String getName() {
- return SearchMessages.MatchFilter_InexactFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_InexactFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_InexactFilter_description;
- }
- public String getID() {
- return "filter_inexact"; //$NON-NLS-1$
- }
-}
-
-abstract class ModifierFilter extends JavaMatchFilter {
- public boolean isApplicable(JavaSearchQuery query) {
- return true;
- }
-}
-
-class NonPublicFilter extends ModifierFilter {
- public boolean filters(JavaElementMatch match) {
- Object element= match.getElement();
- if (element instanceof IMember) {
- try {
- return ! JdtFlags.isPublic((IMember) element);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return false;
- }
- public String getName() {
- return SearchMessages.MatchFilter_NonPublicFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_NonPublicFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_NonPublicFilter_description;
- }
- public String getID() {
- return "filter_non_public"; //$NON-NLS-1$
- }
-}
-
-class StaticFilter extends ModifierFilter {
- public boolean filters(JavaElementMatch match) {
- Object element= match.getElement();
- if (element instanceof IMember) {
- try {
- return JdtFlags.isStatic((IMember) element);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return false;
- }
- public String getName() {
- return SearchMessages.MatchFilter_StaticFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_StaticFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_StaticFilter_description;
- }
- public String getID() {
- return "filter_static"; //$NON-NLS-1$
- }
-}
-
-class NonStaticFilter extends ModifierFilter {
- public boolean filters(JavaElementMatch match) {
- Object element= match.getElement();
- if (element instanceof IMember) {
- try {
- return ! JdtFlags.isStatic((IMember) element);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return false;
- }
- public String getName() {
- return SearchMessages.MatchFilter_NonStaticFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_NonStaticFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_NonStaticFilter_description;
- }
- public String getID() {
- return "filter_non_static"; //$NON-NLS-1$
- }
-}
-
-class DeprecatedFilter extends ModifierFilter {
- public boolean filters(JavaElementMatch match) {
- Object element= match.getElement();
- if (element instanceof IMember) {
- try {
- return JdtFlags.isDeprecated((IMember) element);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return false;
- }
- public String getName() {
- return SearchMessages.MatchFilter_DeprecatedFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_DeprecatedFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_DeprecatedFilter_description;
- }
- public String getID() {
- return "filter_deprecated"; //$NON-NLS-1$
- }
-}
-
-class NonDeprecatedFilter extends ModifierFilter {
- public boolean filters(JavaElementMatch match) {
- Object element= match.getElement();
- if (element instanceof IMember) {
- try {
- return !JdtFlags.isDeprecated((IMember) element);
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return false;
- }
- public String getName() {
- return SearchMessages.MatchFilter_NonDeprecatedFilter_name;
- }
- public String getActionLabel() {
- return SearchMessages.MatchFilter_NonDeprecatedFilter_actionLabel;
- }
- public String getDescription() {
- return SearchMessages.MatchFilter_NonDeprecatedFilter_description;
- }
- public String getID() {
- return "filter_non_deprecated"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchContentProvider.java
deleted file mode 100644
index 90b5f883..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchContentProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public abstract class JavaSearchContentProvider implements IStructuredContentProvider {
- protected final Object[] EMPTY_ARR= new Object[0];
-
- private JavaSearchResult fResult;
- private JavaSearchResultPage fPage;
-
- JavaSearchContentProvider(JavaSearchResultPage page) {
- fPage= page;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- initialize((JavaSearchResult) newInput);
-
- }
-
- protected void initialize(JavaSearchResult result) {
- fResult= result;
- }
-
- public abstract void elementsChanged(Object[] updatedElements);
- public abstract void clear();
-
- public void dispose() {
- // nothing to do
- }
-
- JavaSearchResultPage getPage() {
- return fPage;
- }
-
- JavaSearchResult getSearchResult() {
- return fResult;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchEditorOpener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchEditorOpener.java
deleted file mode 100644
index fa5a4a29..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchEditorOpener.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.InternalClassFileEditorInput;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavaSearchEditorOpener {
-
- private IEditorReference fReusedEditor;
-
- public IEditorPart openElement(Object element) throws PartInitException, JavaScriptModelException {
- IWorkbenchPage wbPage= JavaScriptPlugin.getActivePage();
- if (NewSearchUI.reuseEditor())
- return showWithReuse(element, wbPage);
- else
- return showWithoutReuse(element, wbPage);
- }
-
- public IEditorPart openMatch(Match match) throws PartInitException, JavaScriptModelException {
- Object element= getElementToOpen(match);
- return openElement(element);
- }
-
- protected Object getElementToOpen(Match match) {
- return match.getElement();
- }
-
- private IEditorPart showWithoutReuse(Object element, IWorkbenchPage wbPage) throws PartInitException, JavaScriptModelException {
- return EditorUtility.openInEditor(element, false);
- }
-
- private IEditorPart showWithReuse(Object element, IWorkbenchPage wbPage) throws JavaScriptModelException, PartInitException {
- IFile file= getFile(element);
- if (file != null) {
- String editorID= getEditorID(file);
- return showInEditor(wbPage, new FileEditorInput(file), editorID);
- } else {
- IClassFile cf= getClassFile(element);
- if (cf != null)
- return showInEditor(wbPage, new InternalClassFileEditorInput(cf), JavaScriptUI.ID_CF_EDITOR);
- }
- return null;
- }
-
- private IFile getFile(Object element) throws JavaScriptModelException {
- if (element instanceof IFile)
- return (IFile) element;
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement jElement= (IJavaScriptElement) element;
- IJavaScriptUnit cu= (IJavaScriptUnit) jElement.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- return (IFile) cu.getCorrespondingResource();
- }
- IClassFile cf= (IClassFile) jElement.getAncestor(IJavaScriptElement.CLASS_FILE);
- if (cf != null)
- return (IFile) cf.getCorrespondingResource();
- }
- return null;
- }
-
- private String getEditorID(IFile file) throws PartInitException {
- IEditorDescriptor desc= IDE.getEditorDescriptor(file);
- if (desc == null)
- return JavaScriptPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
- else
- return desc.getId();
- }
-
- private IEditorPart showInEditor(IWorkbenchPage page, IEditorInput input, String editorId) {
- IEditorPart editor= page.findEditor(input);
- if (editor != null) {
- page.bringToTop(editor);
- return editor;
- }
- IEditorReference reusedEditorRef= fReusedEditor;
- if (reusedEditorRef != null) {
- boolean isOpen= reusedEditorRef.getEditor(false) != null;
- boolean canBeReused= isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
- if (canBeReused) {
- boolean showsSameInputType= reusedEditorRef.getId().equals(editorId);
- if (!showsSameInputType) {
- page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
- fReusedEditor= null;
- } else {
- editor= reusedEditorRef.getEditor(true);
- if (editor instanceof IReusableEditor) {
- ((IReusableEditor) editor).setInput(input);
- page.bringToTop(editor);
- return editor;
- }
- }
- }
- }
- // could not reuse
- try {
- editor= page.openEditor(input, editorId, false);
- if (editor instanceof IReusableEditor) {
- IEditorReference reference= (IEditorReference) page.getReference(editor);
- fReusedEditor= reference;
- } else {
- fReusedEditor= null;
- }
- return editor;
- } catch (PartInitException ex) {
- MessageDialog.openError(JavaScriptPlugin.getActiveWorkbenchShell(), SearchMessages.Search_Error_openEditor_title, SearchMessages.Search_Error_openEditor_message);
- return null;
- }
- }
-
- private IClassFile getClassFile(Object element) {
- if (!(element instanceof IJavaScriptElement))
- return null;
- if (element instanceof IClassFile)
- return (IClassFile) element;
- IJavaScriptElement jElement= (IJavaScriptElement) element;
- if (jElement instanceof IMember)
- return ((IMember) jElement).getClassFile();
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPage.java
deleted file mode 100644
index cf8659de..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPage.java
+++ /dev/null
@@ -1,977 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-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.IStructuredSelection;
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.NewSearchUI;
-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.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.formatter.IndentManipulation;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.TextFieldNavigationHandler;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.QuerySpecification;
-
-public class JavaSearchPage extends DialogPage implements ISearchPage {
-
- private static class SearchPatternData {
- private int searchFor;
- private int limitTo;
- private String pattern;
- private boolean isCaseSensitive;
- private IJavaScriptElement javaElement;
- private int includeMask;
- private int scope;
- private IWorkingSet[] workingSets;
-
- public SearchPatternData(int searchFor, int limitTo, boolean isCaseSensitive, String pattern, IJavaScriptElement element, int includeMask) {
- this(searchFor, limitTo, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null, includeMask);
- }
-
- public SearchPatternData(int searchFor, int limitTo, String pattern, boolean isCaseSensitive, IJavaScriptElement element, int scope, IWorkingSet[] workingSets, int includeMask) {
- this.searchFor= searchFor;
- this.limitTo= limitTo;
- this.pattern= pattern;
- this.isCaseSensitive= isCaseSensitive;
- this.scope= scope;
- this.workingSets= workingSets;
- this.includeMask= includeMask;
-
- setJavaElement(element);
- }
-
- public void setJavaElement(IJavaScriptElement javaElement) {
- this.javaElement= javaElement;
- }
-
- public boolean isCaseSensitive() {
- return isCaseSensitive;
- }
-
- public IJavaScriptElement getJavaElement() {
- return javaElement;
- }
-
- public int getLimitTo() {
- return limitTo;
- }
-
- public String getPattern() {
- return pattern;
- }
-
- public int getScope() {
- return scope;
- }
-
- public int getSearchFor() {
- return searchFor;
- }
-
- public IWorkingSet[] getWorkingSets() {
- return workingSets;
- }
-
- public int getIncludeMask() {
- return includeMask;
- }
-
- public void store(IDialogSettings settings) {
- settings.put("searchFor", searchFor); //$NON-NLS-1$
- settings.put("scope", scope); //$NON-NLS-1$
- settings.put("pattern", pattern); //$NON-NLS-1$
- settings.put("limitTo", limitTo); //$NON-NLS-1$
- settings.put("javaElement", javaElement != null ? javaElement.getHandleIdentifier() : ""); //$NON-NLS-1$ //$NON-NLS-2$
- settings.put("isCaseSensitive", isCaseSensitive); //$NON-NLS-1$
- if (workingSets != null) {
- String[] wsIds= new String[workingSets.length];
- for (int i= 0; i < workingSets.length; i++) {
- wsIds[i]= workingSets[i].getName();
- }
- settings.put("workingSets", wsIds); //$NON-NLS-1$
- } else {
- settings.put("workingSets", new String[0]); //$NON-NLS-1$
- }
- settings.put("includeMask", includeMask); //$NON-NLS-1$
- }
-
- public static SearchPatternData create(IDialogSettings settings) {
- String pattern= settings.get("pattern"); //$NON-NLS-1$
- if (pattern.length() == 0) {
- return null;
- }
- IJavaScriptElement elem= null;
- String handleId= settings.get("javaElement"); //$NON-NLS-1$
- if (handleId != null && handleId.length() > 0) {
- IJavaScriptElement restored= JavaScriptCore.create(handleId);
- if (restored != null && isSearchableType(restored) && restored.exists()) {
- elem= restored;
- }
- }
- String[] wsIds= settings.getArray("workingSets"); //$NON-NLS-1$
- IWorkingSet[] workingSets= null;
- if (wsIds != null && wsIds.length > 0) {
- IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
- workingSets= new IWorkingSet[wsIds.length];
- for (int i= 0; workingSets != null && i < wsIds.length; i++) {
- workingSets[i]= workingSetManager.getWorkingSet(wsIds[i]);
- if (workingSets[i] == null) {
- workingSets= null;
- }
- }
- }
-
- try {
- int searchFor= settings.getInt("searchFor"); //$NON-NLS-1$
- int scope= settings.getInt("scope"); //$NON-NLS-1$
- int limitTo= settings.getInt("limitTo"); //$NON-NLS-1$
- boolean isCaseSensitive= settings.getBoolean("isCaseSensitive"); //$NON-NLS-1$
-
- int includeMask;
- if (settings.get("includeMask") != null) { //$NON-NLS-1$
- includeMask= settings.getInt("includeMask"); //$NON-NLS-1$
- } else {
- includeMask= JavaSearchScopeFactory.NO_JRE;
- if (settings.get("includeJRE") == null ? forceIncludeAll(limitTo, elem) : settings.getBoolean("includeJRE")) { //$NON-NLS-1$ //$NON-NLS-2$
- includeMask= JavaSearchScopeFactory.ALL;
- }
- }
- return new SearchPatternData(searchFor, limitTo, pattern, isCaseSensitive, elem, scope, workingSets, includeMask);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- }
-
- // search for
- private final static int TYPE= IJavaScriptSearchConstants.TYPE;
- private final static int METHOD= IJavaScriptSearchConstants.METHOD;
-// private final static int PACKAGE= IJavaScriptSearchConstants.PACKAGE;
- private final static int CONSTRUCTOR= IJavaScriptSearchConstants.CONSTRUCTOR;
- private final static int FIELD= IJavaScriptSearchConstants.FIELD;
- private final static int VAR= IJavaScriptSearchConstants.VAR;
- private final static int FUNCTION= IJavaScriptSearchConstants.FUNCTION;
-
- // limit to
- private final static int DECLARATIONS= IJavaScriptSearchConstants.DECLARATIONS;
-// private final static int IMPLEMENTORS= IJavaScriptSearchConstants.IMPLEMENTORS;
- private final static int REFERENCES= IJavaScriptSearchConstants.REFERENCES;
- private final static int ALL_OCCURRENCES= IJavaScriptSearchConstants.ALL_OCCURRENCES;
- private final static int READ_ACCESSES= IJavaScriptSearchConstants.READ_ACCESSES;
- private final static int WRITE_ACCESSES= IJavaScriptSearchConstants.WRITE_ACCESSES;
-
- public static final String PARTICIPANT_EXTENSION_POINT= "org.eclipse.wst.jsdt.ui.queryParticipants"; //$NON-NLS-1$
-
- public static final String EXTENSION_POINT_ID= "org.eclipse.wst.jsdt.ui.JavaSearchPage"; //$NON-NLS-1$
-
- private static final int HISTORY_SIZE= 12;
-
- // Dialog store id constants
- private final static String PAGE_NAME= "JavaSearchPage"; //$NON-NLS-1$
- private final static String STORE_CASE_SENSITIVE= "CASE_SENSITIVE"; //$NON-NLS-1$
- private final static String STORE_INCLUDE_MASK= "INCLUDE_MASK"; //$NON-NLS-1$
- private final static String STORE_HISTORY= "HISTORY"; //$NON-NLS-1$
- private final static String STORE_HISTORY_SIZE= "HISTORY_SIZE"; //$NON-NLS-1$
-
- private final List fPreviousSearchPatterns;
-
- private SearchPatternData fInitialData;
- private IJavaScriptElement fJavaElement;
- private boolean fFirstTime= true;
- private IDialogSettings fDialogSettings;
- private boolean fIsCaseSensitive;
-
- private Combo fPattern;
- private ISearchPageContainer fContainer;
- private Button fCaseSensitive;
-
- private Button[] fSearchFor;
- private Button[] fLimitTo;
- private Button[] fIncludeMasks;
-
-
- /**
- *
- */
- public JavaSearchPage() {
- fPreviousSearchPatterns= new ArrayList();
- }
-
-
- //---- Action Handling ------------------------------------------------
-
- public boolean performAction() {
- return performNewSearch();
- }
-
- private boolean performNewSearch() {
- SearchPatternData data= getPatternData();
-
- // Setup search scope
- IJavaScriptSearchScope scope= null;
- String scopeDescription= ""; //$NON-NLS-1$
-
- int searchFor= data.getSearchFor();
- int limitTo= data.getLimitTo();
-
- int includeMask= data.getIncludeMask();
- JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
-
- switch (getContainer().getSelectedScope()) {
- case ISearchPageContainer.WORKSPACE_SCOPE:
- scopeDescription= factory.getWorkspaceScopeDescription(includeMask);
- scope= factory.createWorkspaceScope(includeMask);
- break;
- case ISearchPageContainer.SELECTION_SCOPE:
- IJavaScriptElement[] javaElements= factory.getJavaElements(getContainer().getSelection());
- scope= factory.createJavaSearchScope(javaElements, includeMask);
- scopeDescription= factory.getSelectionScopeDescription(javaElements, includeMask);
- break;
- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: {
- String[] projectNames= getContainer().getSelectedProjectNames();
- scope= factory.createJavaProjectSearchScope(projectNames, includeMask);
- scopeDescription= factory.getProjectScopeDescription(projectNames, includeMask);
- 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= factory.getWorkingSetScopeDescription(workingSets, includeMask);
- scope= factory.createJavaSearchScope(workingSets, includeMask);
- SearchUtil.updateLRUWorkingSets(workingSets);
- }
- }
-
- QuerySpecification querySpec= null;
- if (data.getJavaElement() != null && getPattern().equals(fInitialData.getPattern())) {
- if (limitTo == REFERENCES)
- SearchUtil.warnIfBinaryConstant(data.getJavaElement(), getShell());
- querySpec= new ElementQuerySpecification(data.getJavaElement(), limitTo, scope, scopeDescription);
- } else {
- querySpec= new PatternQuerySpecification(data.getPattern(), searchFor, data.isCaseSensitive(), data.getLimitTo(), scope, scopeDescription);
- data.setJavaElement(null);
- }
-
- JavaSearchQuery textSearchJob= new JavaSearchQuery(querySpec);
- NewSearchUI.runQueryInBackground(textSearchJob);
- return true;
- }
-
- private int getLimitTo() {
- for (int i= 0; i < fLimitTo.length; i++) {
- Button button= fLimitTo[i];
- if (button.getSelection()) {
- return getIntData(button);
- }
- }
- return -1;
- }
-
- private int setLimitTo(int searchFor, int limitTo) {
-// if (searchFor != TYPE && limitTo == IMPLEMENTORS) {
-// limitTo= REFERENCES;
-// }
-
- if ( searchFor != FIELD && searchFor != VAR && (limitTo == READ_ACCESSES || limitTo == WRITE_ACCESSES)) {
- limitTo= REFERENCES;
- }
-
- for (int i= 0; i < fLimitTo.length; i++) {
- Button button= fLimitTo[i];
- int val= getIntData(button);
- button.setSelection(limitTo == val);
-
- switch (val) {
- case DECLARATIONS:
- case REFERENCES:
- case ALL_OCCURRENCES:
- button.setEnabled(true);
- break;
-// case IMPLEMENTORS:
-// button.setEnabled(searchFor == TYPE);
-// break;
- case READ_ACCESSES:
- case WRITE_ACCESSES:
- button.setEnabled(searchFor == FIELD || searchFor==VAR);
- break;
- }
- }
- return limitTo;
- }
-
- private int getIncludeMask() {
- int mask= 0;
- for (int i= 0; i < fIncludeMasks.length; i++) {
- Button button= fIncludeMasks[i];
- if (button.getSelection()) {
- mask |= getIntData(button);
- }
- }
- return mask;
- }
-
- private void setIncludeMask(int includeMask, int limitTo) {
- for (int i= 0; i < fIncludeMasks.length; i++) {
- Button button= fIncludeMasks[i];
- button.setSelection((includeMask & getIntData(button)) != 0);
- }
- }
-
-
- private String[] getPreviousSearchPatterns() {
- // Search results are not persistent
- int patternCount= fPreviousSearchPatterns.size();
- String [] patterns= new String[patternCount];
- for (int i= 0; i < patternCount; i++)
- patterns[i]= ((SearchPatternData) fPreviousSearchPatterns.get(i)).getPattern();
- return patterns;
- }
-
- private int getSearchFor() {
- for (int i= 0; i < fSearchFor.length; i++) {
- Button button= fSearchFor[i];
- if (button.getSelection()) {
- return getIntData(button);
- }
- }
- Assert.isTrue(false, "shouldNeverHappen"); //$NON-NLS-1$
- return -1;
- }
-
- private void setSearchFor(int searchFor) {
- for (int i= 0; i < fSearchFor.length; i++) {
- Button button= fSearchFor[i];
- button.setSelection(searchFor == getIntData(button));
- }
- }
-
- private int getIntData(Button button) {
- return ((Integer) button.getData()).intValue();
- }
-
- private String getPattern() {
- return fPattern.getText();
- }
-
-
- private SearchPatternData findInPrevious(String pattern) {
- for (Iterator iter= fPreviousSearchPatterns.iterator(); iter.hasNext();) {
- SearchPatternData element= (SearchPatternData) iter.next();
- if (pattern.equals(element.getPattern())) {
- return element;
- }
- }
- return null;
- }
-
- /**
- * Return search pattern data and update previous searches.
- * An existing entry will be updated.
- * @return the pattern data
- */
- private SearchPatternData getPatternData() {
- String pattern= getPattern();
- SearchPatternData match= findInPrevious(pattern);
- if (match != null) {
- fPreviousSearchPatterns.remove(match);
- }
- match= new SearchPatternData(
- getSearchFor(),
- getLimitTo(),
- pattern,
- fCaseSensitive.getSelection(),
- fJavaElement,
- getContainer().getSelectedScope(),
- getContainer().getSelectedWorkingSets(),
- getIncludeMask()
- );
-
- fPreviousSearchPatterns.add(0, match); // insert on top
- return match;
- }
-
- /*
- * Implements method from IDialogPage
- */
- 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();
- }
- updateOKStatus();
- super.setVisible(visible);
- }
-
- public boolean isValid() {
- return true;
- }
-
- //---- Widget creation ------------------------------------------------
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- readConfiguration();
-
- Composite result= new Composite(parent, SWT.NONE);
-
- GridLayout layout= new GridLayout(2, false);
- layout.horizontalSpacing= 10;
- result.setLayout(layout);
-
- Control expressionComposite= createExpression(result);
- expressionComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
-
- Label separator= new Label(result, SWT.NONE);
- separator.setVisible(false);
- GridData data= new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1);
- data.heightHint= convertHeightInCharsToPixels(1) / 3;
- separator.setLayoutData(data);
-
- Control searchFor= createSearchFor(result);
- searchFor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
-
- Control limitTo= createLimitTo(result);
- limitTo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
-
- Control includeMask= createIncludeMask(result);
- includeMask.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
-
- //createParticipants(result);
-
- SelectionAdapter javaElementInitializer= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- if (getSearchFor() == fInitialData.getSearchFor())
- fJavaElement= fInitialData.getJavaElement();
- else
- fJavaElement= null;
- int limitToVal= setLimitTo(getSearchFor(), getLimitTo());
- setIncludeMask(getIncludeMask(), limitToVal);
- doPatternModified();
- }
- };
-
- for (int i= 0; i < fSearchFor.length; i++) {
- fSearchFor[i].addSelectionListener(javaElementInitializer);
- }
-
- setControl(result);
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(result, IJavaHelpContextIds.JAVA_SEARCH_PAGE);
- }
-
-
- /*private Control createParticipants(Composite result) {
- if (!SearchParticipantsExtensionPoint.hasAnyParticipants())
- return new Composite(result, SWT.NULL);
- Button selectParticipants= new Button(result, SWT.PUSH);
- selectParticipants.setText(SearchMessages.getString("SearchPage.select_participants.label")); //$NON-NLS-1$
- GridData gd= new GridData();
- gd.verticalAlignment= GridData.VERTICAL_ALIGN_BEGINNING;
- gd.horizontalAlignment= GridData.HORIZONTAL_ALIGN_END;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalAlignment= GridData.END;
- gd.horizontalSpan= 2;
- selectParticipants.setLayoutData(gd);
- selectParticipants.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencePageSupport.showPreferencePage(getShell(), "org.eclipse.wst.jsdt.ui.preferences.SearchParticipantsExtensionPoint", new SearchParticipantsExtensionPoint()); //$NON-NLS-1$
- }
-
- });
- return selectParticipants;
- }*/
-
-
- private Control createExpression(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- result.setLayout(layout);
-
- // Pattern text + info
- Label label= new Label(result, SWT.LEFT);
- label.setText(SearchMessages.SearchPage_expression_label);
- label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));
-
- // Pattern combo
- fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);
- fPattern.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handlePatternSelected();
- updateOKStatus();
- }
- });
- fPattern.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- doPatternModified();
- updateOKStatus();
-
- }
- });
- TextFieldNavigationHandler.install(fPattern);
- GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
- data.widthHint= convertWidthInCharsToPixels(50);
- fPattern.setLayoutData(data);
-
- // Ignore case checkbox
- fCaseSensitive= new Button(result, SWT.CHECK);
- fCaseSensitive.setText(SearchMessages.SearchPage_expression_caseSensitive);
- fCaseSensitive.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fIsCaseSensitive= fCaseSensitive.getSelection();
- }
- });
- fCaseSensitive.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 1, 1));
-
- return result;
- }
-
- final void updateOKStatus() {
- boolean isValid= isValidSearchPattern();
- getContainer().setPerformActionEnabled(isValid);
- }
-
- private boolean isValidSearchPattern() {
- if (getPattern().length() == 0) {
- return false;
- }
- if (fJavaElement != null) {
- return true;
- }
- return SearchPattern.createPattern(getPattern(), getSearchFor(), getLimitTo(), SearchPattern.R_EXACT_MATCH) != null;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- writeConfiguration();
- super.dispose();
- }
-
- private void doPatternModified() {
- if (fInitialData != null && getPattern().equals(fInitialData.getPattern()) && fInitialData.getJavaElement() != null && fInitialData.getSearchFor() == getSearchFor()) {
- fCaseSensitive.setEnabled(false);
- fCaseSensitive.setSelection(true);
- fJavaElement= fInitialData.getJavaElement();
- } else {
- fCaseSensitive.setEnabled(true);
- fCaseSensitive.setSelection(fIsCaseSensitive);
- fJavaElement= null;
- }
- }
-
- private void handlePatternSelected() {
- int selectionIndex= fPattern.getSelectionIndex();
- if (selectionIndex < 0 || selectionIndex >= fPreviousSearchPatterns.size())
- return;
-
- SearchPatternData initialData= (SearchPatternData) fPreviousSearchPatterns.get(selectionIndex);
-
- setSearchFor(initialData.getSearchFor());
- int limitToVal= setLimitTo(initialData.getSearchFor(), initialData.getLimitTo());
- setIncludeMask(initialData.getIncludeMask(), limitToVal);
-
- fPattern.setText(initialData.getPattern());
- fIsCaseSensitive= initialData.isCaseSensitive();
- fJavaElement= initialData.getJavaElement();
- fCaseSensitive.setEnabled(fJavaElement == null);
- fCaseSensitive.setSelection(initialData.isCaseSensitive());
-
-
- if (initialData.getWorkingSets() != null)
- getContainer().setSelectedWorkingSets(initialData.getWorkingSets());
- else
- getContainer().setSelectedScope(initialData.getScope());
-
- fInitialData= initialData;
- }
-
-
- private Control createSearchFor(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText(SearchMessages.SearchPage_searchFor_label);
- result.setLayout(new GridLayout(2, true));
-
- fSearchFor= new Button[] {
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_function, FUNCTION, true),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_var, VAR, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_method, METHOD, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_field, FIELD, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_type, TYPE, false),
-// createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_package, PACKAGE, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_constructor, CONSTRUCTOR, false)
- };
-
- // Fill with dummy radio buttons
- Label filler= new Label(result, SWT.NONE);
- filler.setVisible(false);
- filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
-
- return result;
- }
-
- private Control createLimitTo(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText(SearchMessages.SearchPage_limitTo_label);
- result.setLayout(new GridLayout(2, true));
-
- fLimitTo= new Button[] {
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_declarations, DECLARATIONS, false),
-// createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_implementors, IMPLEMENTORS, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_references, REFERENCES, true),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_allOccurrences, ALL_OCCURRENCES, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_readReferences, READ_ACCESSES, false),
- createButton(result, SWT.RADIO, SearchMessages.SearchPage_limitTo_writeReferences, WRITE_ACCESSES, false)
- };
-
- SelectionAdapter listener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updateUseJRE();
- }
- };
- for (int i= 0; i < fLimitTo.length; i++) {
- fLimitTo[i].addSelectionListener(listener);
- }
- return result;
- }
-
- private Control createIncludeMask(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- result.setText(SearchMessages.SearchPage_searchIn_label);
- result.setLayout(new GridLayout(4, false));
- fIncludeMasks= new Button[] {
- createButton(result, SWT.CHECK, SearchMessages.SearchPage_searchIn_sources, JavaSearchScopeFactory.SOURCES, true),
- createButton(result, SWT.CHECK, SearchMessages.SearchPage_searchIn_projects, JavaSearchScopeFactory.PROJECTS, true),
- createButton(result, SWT.CHECK, SearchMessages.SearchPage_searchIn_jre, JavaSearchScopeFactory.JRE, false),
- createButton(result, SWT.CHECK, SearchMessages.SearchPage_searchIn_libraries, JavaSearchScopeFactory.LIBS, true),
- };
- return result;
- }
-
- private Button createButton(Composite parent, int style, String text, int data, boolean isSelected) {
- Button button= new Button(parent, style);
- button.setText(text);
- button.setData(new Integer(data));
- button.setLayoutData(new GridData());
- button.setSelection(isSelected);
- return button;
- }
-
- private void initSelections() {
- ISelection sel= getContainer().getSelection();
- SearchPatternData initData= null;
-
- if (sel instanceof IStructuredSelection) {
- initData= tryStructuredSelection((IStructuredSelection) sel);
- } else if (sel instanceof ITextSelection) {
- IEditorPart activePart= getActiveEditor();
- if (activePart instanceof JavaEditor) {
- try {
- IJavaScriptElement[] elements= SelectionConverter.codeResolve((JavaEditor) activePart);
- if (elements != null && elements.length > 0) {
- initData= determineInitValuesFrom(elements[0]);
- }
- } catch (JavaScriptModelException e) {
- // ignore
- }
- }
- if (initData == null) {
- initData= trySimpleTextSelection((ITextSelection) sel);
- }
- }
- if (initData == null) {
- initData= getDefaultInitValues();
- }
-
- fInitialData= initData;
- fJavaElement= initData.getJavaElement();
- fCaseSensitive.setSelection(initData.isCaseSensitive());
- fCaseSensitive.setEnabled(fJavaElement == null);
-
- setSearchFor(initData.getSearchFor());
- int limitToVal= setLimitTo(initData.getSearchFor(), initData.getLimitTo());
- setIncludeMask(initData.getIncludeMask(), limitToVal);
-
- fPattern.setText(initData.getPattern());
- }
-
- private void updateUseJRE() {
- setIncludeMask(getIncludeMask(), getLimitTo());
- }
-
- private static boolean forceIncludeAll(int limitTo, IJavaScriptElement elem) {
- return elem != null && (limitTo == DECLARATIONS /*|| limitTo == IMPLEMENTORS*/);
- }
-
- private SearchPatternData tryStructuredSelection(IStructuredSelection selection) {
- if (selection == null || selection.size() > 1)
- return null;
-
- Object o= selection.getFirstElement();
- SearchPatternData res= null;
- if (o instanceof IJavaScriptElement) {
- res= determineInitValuesFrom((IJavaScriptElement) o);
-// } else if (o instanceof LogicalPackage) {
-// LogicalPackage lp= (LogicalPackage)o;
-// return new SearchPatternData(PACKAGE, REFERENCES, fIsCaseSensitive, lp.getElementName(), null, getLastIncludeMask());
- } else if (o instanceof IAdaptable) {
- IJavaScriptElement element= (IJavaScriptElement) ((IAdaptable) o).getAdapter(IJavaScriptElement.class);
- if (element != null) {
- res= determineInitValuesFrom(element);
- }
- }
- if (res == null && o instanceof IAdaptable) {
- IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- return new SearchPatternData(VAR, REFERENCES, fIsCaseSensitive, adapter.getLabel(o), null, getLastIncludeMask());
- }
- }
- return res;
- }
-
- final static boolean isSearchableType(IJavaScriptElement element) {
- switch (element.getElementType()) {
- case IJavaScriptElement.PACKAGE_FRAGMENT:
- case IJavaScriptElement.PACKAGE_DECLARATION:
- case IJavaScriptElement.IMPORT_DECLARATION:
- case IJavaScriptElement.TYPE:
- case IJavaScriptElement.FIELD:
- case IJavaScriptElement.METHOD:
- return true;
- }
- return false;
- }
-
- private SearchPatternData determineInitValuesFrom(IJavaScriptElement element) {
- try {
- //JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
- //boolean isInsideJRE= factory.isInsideJRE(element);
- int includeMask= getLastIncludeMask();
-
- switch (element.getElementType()) {
-// case IJavaScriptElement.PACKAGE_FRAGMENT:
-// case IJavaScriptElement.PACKAGE_DECLARATION:
-// return new SearchPatternData(PACKAGE, REFERENCES, true, element.getElementName(), element, includeMask);
-// case IJavaScriptElement.IMPORT_DECLARATION: {
-// IImportDeclaration declaration= (IImportDeclaration) element;
-// if (declaration.isOnDemand()) {
-// String name= Signature.getQualifier(declaration.getElementName());
-// return new SearchPatternData(PACKAGE, DECLARATIONS, true, name, element, JavaSearchScopeFactory.ALL);
-// }
-// return new SearchPatternData(TYPE, DECLARATIONS, true, element.getElementName(), element, JavaSearchScopeFactory.ALL);
-// }
- case IJavaScriptElement.TYPE:
- return new SearchPatternData(TYPE, REFERENCES, true, PatternStrings.getTypeSignature((IType) element), element, includeMask);
- case IJavaScriptElement.JAVASCRIPT_UNIT: {
- IType mainType= ((IJavaScriptUnit) element).findPrimaryType();
- if (mainType != null) {
- return new SearchPatternData(TYPE, REFERENCES, true, PatternStrings.getTypeSignature(mainType), mainType, includeMask);
- }
- break;
- }
- case IJavaScriptElement.CLASS_FILE: {
- IType mainType= ((IClassFile) element).getType();
- if (mainType.exists()) {
- return new SearchPatternData(TYPE, REFERENCES, true, PatternStrings.getTypeSignature(mainType), mainType, includeMask);
- }
- break;
- }
- case IJavaScriptElement.FIELD:
- IField field = (IField) element;
- return new SearchPatternData(field.getParent().getElementType()==IJavaScriptElement.TYPE?FIELD:VAR, REFERENCES, true,
- PatternStrings.getFieldSignature(field), element, includeMask);
- case IJavaScriptElement.METHOD:
- IFunction method= (IFunction) element;
- int searchFor= method.isConstructor() ? CONSTRUCTOR : METHOD;
- if (method.getParent().getElementType()!=IJavaScriptElement.TYPE)
- searchFor=FUNCTION;
- return new SearchPatternData(searchFor, REFERENCES, true, PatternStrings.getMethodSignature(method), element, includeMask);
- }
-
- } catch (JavaScriptModelException e) {
- if (!e.isDoesNotExist()) {
- ExceptionHandler.handle(e, SearchMessages.Search_Error_javaElementAccess_title, SearchMessages.Search_Error_javaElementAccess_message);
- }
- // element might not exist
- }
- return null;
- }
-
- private SearchPatternData trySimpleTextSelection(ITextSelection selection) {
- String selectedText= selection.getText();
- if (selectedText != null && selectedText.length() > 0) {
- int i= 0;
- while (i < selectedText.length() && !IndentManipulation.isLineDelimiterChar(selectedText.charAt(i))) {
- i++;
- }
- if (i > 0) {
- return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, selectedText.substring(0, i), null, JavaSearchScopeFactory.ALL);
- }
- }
- return null;
- }
-
- private SearchPatternData getDefaultInitValues() {
- if (!fPreviousSearchPatterns.isEmpty()) {
- return (SearchPatternData) fPreviousSearchPatterns.get(0);
- }
-
- return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, "", null, getLastIncludeMask()); //$NON-NLS-1$
- }
-
- private int getLastIncludeMask() {
- try {
- return getDialogSettings().getInt(STORE_INCLUDE_MASK);
- } catch (NumberFormatException e) {
- return JavaSearchScopeFactory.NO_JRE;
- }
- }
-
- /*
- * Implements method from ISearchPage
- */
- public void setContainer(ISearchPageContainer container) {
- fContainer= container;
- }
-
- /**
- * Returns the search page's container.
- * @return the search page container
- */
- private ISearchPageContainer getContainer() {
- return fContainer;
- }
-
- private IEditorPart getActiveEditor() {
- IWorkbenchPage activePage= JavaScriptPlugin.getActivePage();
- if (activePage != null) {
- return activePage.getActiveEditor();
- }
- return null;
- }
-
- //--------------- Configuration handling --------------
-
- /**
- * Returns the page settings for this Java search page.
- *
- * @return the page settings to be used
- */
- private IDialogSettings getDialogSettings() {
- if (fDialogSettings == null) {
- fDialogSettings= JavaScriptPlugin.getDefault().getDialogSettingsSection(PAGE_NAME);
- }
- return fDialogSettings;
- }
-
- /**
- * Initializes itself from the stored page settings.
- */
- private void readConfiguration() {
- IDialogSettings s= getDialogSettings();
- fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE);
-
- try {
- int historySize= s.getInt(STORE_HISTORY_SIZE);
- for (int i= 0; i < historySize; i++) {
- IDialogSettings histSettings= s.getSection(STORE_HISTORY + i);
- if (histSettings != null) {
- SearchPatternData data= SearchPatternData.create(histSettings);
- if (data != null) {
- fPreviousSearchPatterns.add(data);
- }
- }
- }
- } catch (NumberFormatException e) {
- // ignore
- }
- }
-
- /**
- * Stores the current configuration in the dialog store.
- */
- private void writeConfiguration() {
- IDialogSettings s= getDialogSettings();
- s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
- s.put(STORE_INCLUDE_MASK, getIncludeMask());
-
- int historySize= Math.min(fPreviousSearchPatterns.size(), HISTORY_SIZE);
- s.put(STORE_HISTORY_SIZE, historySize);
- for (int i= 0; i < historySize; i++) {
- IDialogSettings histSettings= s.addNewSection(STORE_HISTORY + i);
- SearchPatternData data= ((SearchPatternData) fPreviousSearchPatterns.get(i));
- data.store(histSettings);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPageScoreComputer.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPageScoreComputer.java
deleted file mode 100644
index 7001add8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchPageScoreComputer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-
-public class JavaSearchPageScoreComputer implements ISearchPageScoreComputer {
-
- public int computeScore(String id, Object element) {
- if (!JavaSearchPage.EXTENSION_POINT_ID.equals(id))
- // Can't decide
- return ISearchPageScoreComputer.UNKNOWN;
-
- if (element instanceof IJavaScriptElement || element instanceof IClassFileEditorInput || element instanceof LogicalPackage)
- return 90;
-
- return ISearchPageScoreComputer.LOWEST;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchQuery.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchQuery.java
deleted file mode 100644
index 62cebcba..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchQuery.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.PerformanceStats;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.core.search.SearchParticipant;
-import org.eclipse.wst.jsdt.core.search.SearchPattern;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.SearchUtils;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.IMatchPresentation;
-import org.eclipse.wst.jsdt.ui.search.IQueryParticipant;
-import org.eclipse.wst.jsdt.ui.search.ISearchRequestor;
-import org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification;
-import org.eclipse.wst.jsdt.ui.search.QuerySpecification;
-
-public class JavaSearchQuery implements ISearchQuery {
-
- private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.wst.jsdt.ui/perf/search/participants"; //$NON-NLS-1$
-
- private ISearchResult fResult;
- private final QuerySpecification fPatternData;
-
- public JavaSearchQuery(QuerySpecification data) {
- if (data == null) {
- throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
- }
- fPatternData= data;
- }
-
- private static class SearchRequestor implements ISearchRequestor {
- private IQueryParticipant fParticipant;
- private JavaSearchResult fSearchResult;
- public void reportMatch(Match match) {
- IMatchPresentation participant= fParticipant.getUIParticipant();
- if (participant == null || match.getElement() instanceof IJavaScriptElement || match.getElement() instanceof IResource) {
- fSearchResult.addMatch(match);
- } else {
- fSearchResult.addMatch(match, participant);
- }
- }
-
- protected SearchRequestor(IQueryParticipant participant, JavaSearchResult result) {
- super();
- fParticipant= participant;
- fSearchResult= result;
- }
- }
-
- public IStatus run(IProgressMonitor monitor) {
- final JavaSearchResult textResult= (JavaSearchResult) getSearchResult();
- textResult.removeAll();
- // Don't need to pass in working copies in 3.0 here
- SearchEngine engine= new SearchEngine();
- try {
-
- int totalTicks= 1000;
- IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
- final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects);
- final int[] ticks= new int[participantDescriptors.length];
- for (int i= 0; i < participantDescriptors.length; i++) {
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
- public void handleException(Throwable exception) {
- ticks[iPrime]= 0;
- String message= SearchMessages.JavaSearchQuery_error_participant_estimate;
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, message, exception));
- }
-
- public void run() throws Exception {
- ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData);
- }
- };
-
- SafeRunner.run(runnable);
- totalTicks+= ticks[i];
- }
-
- SearchPattern pattern;
- String stringPattern;
-
- if (fPatternData instanceof ElementQuerySpecification) {
- IJavaScriptElement element= ((ElementQuerySpecification) fPatternData).getElement();
- stringPattern= JavaScriptElementLabels.getElementLabel(element, JavaScriptElementLabels.ALL_DEFAULT);
- if (!element.exists()) {
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
- }
- pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
- } else {
- PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
- stringPattern= patternSpec.getPattern();
- int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
- if (patternSpec.isCaseSensitive())
- matchMode |= SearchPattern.R_CASE_SENSITIVE;
- pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
- }
-
- if (pattern == null) {
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_unsupported_pattern, stringPattern), null);
- }
- monitor.beginTask(Messages.format(SearchMessages.JavaSearchQuery_task_label, stringPattern), totalTicks);
- IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
-
- boolean ignorePotentials= NewSearchUI.arePotentialMatchesIgnored();
- NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
-
-
- engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
- for (int i= 0; i < participantDescriptors.length; i++) {
- final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
- final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
-
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
- public void handleException(Throwable exception) {
- participantDescriptors[iPrime].getDescriptor().disable();
- String message= SearchMessages.JavaSearchQuery_error_participant_search;
- JavaScriptPlugin.log(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, message, exception));
- }
-
- public void run() throws Exception {
-
- final IQueryParticipant participant= participantDescriptors[iPrime].getParticipant();
-
- final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
- stats.startRun();
-
- participant.search(requestor, fPatternData, participantPM);
-
- stats.endRun();
- }
- };
-
- SafeRunner.run(runnable);
- }
-
- } catch (CoreException e) {
- return e.getStatus();
- }
- String message= Messages.format(SearchMessages.JavaSearchQuery_status_ok_message, String.valueOf(textResult.getMatchCount()));
- return new Status(IStatus.OK, JavaScriptPlugin.getPluginId(), 0, message, null);
- }
-
- private int getMatchMode(String pattern) {
- if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
- return SearchPattern.R_PATTERN_MATCH;
- } else if (SearchUtils.isCamelCasePattern(pattern)) {
- return SearchPattern.R_CAMELCASE_MATCH;
- }
- return SearchPattern.R_EXACT_MATCH;
- }
-
- public String getLabel() {
- return SearchMessages.JavaSearchQuery_label;
- }
-
- public String getResultLabel(int nMatches) {
- if (nMatches == 1) {
- String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() };
- switch (fPatternData.getLimitTo()) {
- case IJavaScriptSearchConstants.IMPLEMENTORS:
- return Messages.format(SearchMessages.JavaSearchOperation_singularImplementorsPostfix, args);
- case IJavaScriptSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.JavaSearchOperation_singularDeclarationsPostfix, args);
- case IJavaScriptSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.JavaSearchOperation_singularReferencesPostfix, args);
- case IJavaScriptSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.JavaSearchOperation_singularOccurrencesPostfix, args);
- case IJavaScriptSearchConstants.READ_ACCESSES:
- return Messages.format(SearchMessages.JavaSearchOperation_singularReadReferencesPostfix, args);
- case IJavaScriptSearchConstants.WRITE_ACCESSES:
- return Messages.format(SearchMessages.JavaSearchOperation_singularWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.JavaSearchOperation_singularOccurrencesPostfix, args);
- }
- } else {
- Object[] args= { getSearchPatternDescription(), new Integer(nMatches), fPatternData.getScopeDescription() };
- switch (fPatternData.getLimitTo()) {
- case IJavaScriptSearchConstants.IMPLEMENTORS:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args);
- case IJavaScriptSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralDeclarationsPostfix, args);
- case IJavaScriptSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralReferencesPostfix, args);
- case IJavaScriptSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralOccurrencesPostfix, args);
- case IJavaScriptSearchConstants.READ_ACCESSES:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralReadReferencesPostfix, args);
- case IJavaScriptSearchConstants.WRITE_ACCESSES:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.JavaSearchOperation_pluralOccurrencesPostfix, args);
- }
- }
- }
-
- private String getSearchPatternDescription() {
- if (fPatternData instanceof ElementQuerySpecification) {
- IJavaScriptElement element= ((ElementQuerySpecification) fPatternData).getElement();
- return JavaScriptElementLabels.getElementLabel(element, JavaScriptElementLabels.ALL_DEFAULT
- | JavaScriptElementLabels.ALL_FULLY_QUALIFIED | JavaScriptElementLabels.USE_RESOLVED);
- }
- return ((PatternQuerySpecification) fPatternData).getPattern();
- }
-
- ImageDescriptor getImageDescriptor() {
- if (fPatternData.getLimitTo() == IJavaScriptSearchConstants.IMPLEMENTORS || fPatternData.getLimitTo() == IJavaScriptSearchConstants.DECLARATIONS)
- return JavaPluginImages.DESC_OBJS_SEARCH_DECL;
- else
- return JavaPluginImages.DESC_OBJS_SEARCH_REF;
- }
-
- public boolean canRerun() {
- return true;
- }
-
- public boolean canRunInBackground() {
- return true;
- }
-
- public ISearchResult getSearchResult() {
- if (fResult == null) {
- JavaSearchResult result= new JavaSearchResult(this);
- new SearchResultUpdater(result);
- fResult= result;
- }
- return fResult;
- }
-
- QuerySpecification getSpecification() {
- return fPatternData;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResult.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResult.java
deleted file mode 100644
index 4b60a587..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResult.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.IEditorMatchAdapter;
-import org.eclipse.search.ui.text.IFileMatchAdapter;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.ui.text.MatchFilter;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.search.IMatchPresentation;
-
-public class JavaSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
-
- private static final Match[] NO_MATCHES= new Match[0];
-
- private final JavaSearchQuery fQuery;
- private final Map fElementsToParticipants;
-
- public JavaSearchResult(JavaSearchQuery query) {
- fQuery= query;
- fElementsToParticipants= new HashMap();
- setActiveMatchFilters(JavaMatchFilter.getLastUsedFilters());
- }
-
- public ImageDescriptor getImageDescriptor() {
- return fQuery.getImageDescriptor();
- }
-
- public String getLabel() {
- return fQuery.getResultLabel(getMatchCount());
- }
-
- public String getTooltip() {
- return getLabel();
- }
-
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
- return computeContainedMatches(editor.getEditorInput());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#setMatchFilters(org.eclipse.search.ui.text.MatchFilter[])
- */
- public void setActiveMatchFilters(MatchFilter[] filters) {
- super.setActiveMatchFilters(filters);
- JavaMatchFilter.setLastUsedFilters(filters);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getAllMatchFilters()
- */
- public MatchFilter[] getAllMatchFilters() {
- return JavaMatchFilter.allFilters(fQuery);
- }
-
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
- return computeContainedMatches(file);
- }
-
- private Match[] computeContainedMatches(IAdaptable adaptable) {
- IJavaScriptElement javaElement= (IJavaScriptElement) adaptable.getAdapter(IJavaScriptElement.class);
- Set matches= new HashSet();
- if (javaElement != null) {
- collectMatches(matches, javaElement);
- }
- IFile file= (IFile) adaptable.getAdapter(IFile.class);
- if (file != null) {
- collectMatches(matches, file);
- }
- if (!matches.isEmpty()) {
- return (Match[]) matches.toArray(new Match[matches.size()]);
- }
- return NO_MATCHES;
- }
-
-
- private void collectMatches(Set matches, IFile element) {
- Match[] m= getMatches(element);
- if (m.length != 0) {
- for (int i= 0; i < m.length; i++) {
- matches.add(m[i]);
- }
- }
- }
-
- private void collectMatches(Set matches, IJavaScriptElement element) {
- Match[] m= getMatches(element);
- if (m.length != 0) {
- for (int i= 0; i < m.length; i++) {
- matches.add(m[i]);
- }
- }
- if (element instanceof IParent) {
- IParent parent= (IParent) element;
- try {
- IJavaScriptElement[] children= parent.getChildren();
- for (int i= 0; i < children.length; i++) {
- collectMatches(matches, children[i]);
- }
- } catch (JavaScriptModelException e) {
- // we will not be tracking these results
- }
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResultCategory#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement javaElement= (IJavaScriptElement) element;
- IJavaScriptUnit cu= (IJavaScriptUnit) javaElement.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (cu != null) {
- return (IFile) cu.getResource();
- } else {
- IClassFile cf= (IClassFile) javaElement.getAncestor(IJavaScriptElement.CLASS_FILE);
- if (cf != null)
- return (IFile) cf.getResource();
- }
- return null;
- }
- if (element instanceof IFile)
- return (IFile) element;
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.search2.ui.text.IStructureProvider#isShownInEditor(org.eclipse.search2.ui.text.Match,
- * org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- Object element= match.getElement();
- if (element instanceof IJavaScriptElement) {
- element= ((IJavaScriptElement) element).getOpenable(); // class file or compilation unit
- return element != null && element.equals(editor.getEditorInput().getAdapter(IJavaScriptElement.class));
- } else if (element instanceof IFile) {
- return element.equals(editor.getEditorInput().getAdapter(IFile.class));
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getQuery()
- */
- public ISearchQuery getQuery() {
- return fQuery;
- }
-
- synchronized IMatchPresentation getSearchParticpant(Object element) {
- return (IMatchPresentation) fElementsToParticipants.get(element);
- }
-
- boolean addMatch(Match match, IMatchPresentation participant) {
- Object element= match.getElement();
- if (fElementsToParticipants.get(element) != null) {
- // TODO must access the participant id / label to properly report the error.
- JavaScriptPlugin.log(new Status(IStatus.WARNING, JavaScriptPlugin.getPluginId(), 0, "A second search participant was found for an element", null)); //$NON-NLS-1$
- return false;
- }
- fElementsToParticipants.put(element, participant);
- addMatch(match);
- return true;
- }
-
- public void removeAll() {
- synchronized(this) {
- fElementsToParticipants.clear();
- }
- super.removeAll();
- }
-
- public void removeMatch(Match match) {
- synchronized(this) {
- if (getMatchCount(match.getElement()) == 1)
- fElementsToParticipants.remove(match.getElement());
- }
- super.removeMatch(match);
- }
- public IFileMatchAdapter getFileMatchAdapter() {
- return this;
- }
-
- public IEditorMatchAdapter getEditorMatchAdapter() {
- return this;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResultPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResultPage.java
deleted file mode 100644
index baea1a46..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchResultPage.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.Action;
-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.TransferDragSourceListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.ISearchResultViewPart;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.actions.CopyQualifiedNameAction;
-import org.eclipse.wst.jsdt.internal.ui.dnd.JdtViewerDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.dnd.ResourceTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.packageview.SelectionTransferDragAdapter;
-import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTableViewer;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ProblemTreeViewer;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.wst.jsdt.ui.search.IMatchPresentation;
-
-public class JavaSearchResultPage extends AbstractTextSearchViewPage implements IAdaptable {
-
- public static class DecoratorIgnoringViewerSorter extends ViewerComparator {
-
- private final ILabelProvider fLabelProvider;
-
- public DecoratorIgnoringViewerSorter(ILabelProvider labelProvider) {
- fLabelProvider= labelProvider;
- }
-
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1= fLabelProvider.getText(e1);
- String name2= fLabelProvider.getText(e2);
- if (name1 == null)
- name1 = "";//$NON-NLS-1$
- if (name2 == null)
- name2 = "";//$NON-NLS-1$
- return getComparator().compare(name1, name2);
- }
- }
-
-
- private static final int DEFAULT_ELEMENT_LIMIT = 1000;
- private static final String FALSE = "FALSE"; //$NON-NLS-1$
- private static final String TRUE = "TRUE"; //$NON-NLS-1$
- private static final String KEY_GROUPING= "org.eclipse.wst.jsdt.search.resultpage.grouping"; //$NON-NLS-1$
- private static final String KEY_SORTING= "org.eclipse.wst.jsdt.search.resultpage.sorting"; //$NON-NLS-1$
- private static final String KEY_LIMIT_ENABLED= "org.eclipse.wst.jsdt.search.resultpage.limit_enabled"; //$NON-NLS-1$
- private static final String KEY_LIMIT= "org.eclipse.wst.jsdt.search.resultpage.limit"; //$NON-NLS-1$
-
- private static final String GROUP_GROUPING= "org.eclipse.wst.jsdt.search.resultpage.grouping"; //$NON-NLS-1$
- private static final String GROUP_FILTERING = "org.eclipse.wst.jsdt.search.resultpage.filtering"; //$NON-NLS-1$
-
- private NewSearchViewActionGroup fActionGroup;
- private JavaSearchContentProvider fContentProvider;
- private int fCurrentSortOrder;
- private SortAction fSortByNameAction;
- private SortAction fSortByParentName;
- private SortAction fSortByPathAction;
-
- private GroupAction fGroupTypeAction;
- private GroupAction fGroupFileAction;
- private GroupAction fGroupPackageAction;
- private GroupAction fGroupProjectAction;
-
- private SelectionDispatchAction fCopyQualifiedNameAction;
-
- private SortingLabelProvider fSortingLabelProvider;
-
- private int fCurrentGrouping;
-
- private static final String[] SHOW_IN_TARGETS= new String[] { JavaScriptUI.ID_PACKAGES , IPageLayout.ID_RES_NAV };
- public static final IShowInTargetList SHOW_IN_TARGET_LIST= new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return SHOW_IN_TARGETS;
- }
- };
-
- private JavaSearchEditorOpener fEditorOpener= new JavaSearchEditorOpener();
-
- public JavaSearchResultPage() {
- fCopyQualifiedNameAction= null;
-
- initSortActions();
- initGroupingActions();
- setElementLimit(new Integer(DEFAULT_ELEMENT_LIMIT));
- }
-
- private void initSortActions() {
- fSortByNameAction= new SortAction(SearchMessages.JavaSearchResultPage_sortByName, this, SortingLabelProvider.SHOW_ELEMENT_CONTAINER);
- fSortByPathAction= new SortAction(SearchMessages.JavaSearchResultPage_sortByPath, this, SortingLabelProvider.SHOW_PATH);
- fSortByParentName= new SortAction(SearchMessages.JavaSearchResultPage_sortByParentName, this, SortingLabelProvider.SHOW_CONTAINER_ELEMENT);
- }
-
- private void initGroupingActions() {
- fGroupProjectAction= new GroupAction(SearchMessages.JavaSearchResultPage_groupby_project, SearchMessages.JavaSearchResultPage_groupby_project_tooltip, this, LevelTreeContentProvider.LEVEL_PROJECT);
- JavaPluginImages.setLocalImageDescriptors(fGroupProjectAction, "prj_mode.gif"); //$NON-NLS-1$
- if(JavaScriptCore.IS_ECMASCRIPT4) fGroupPackageAction= new GroupAction(SearchMessages.JavaSearchResultPage_groupby_package, SearchMessages.JavaSearchResultPage_groupby_package_tooltip, this, LevelTreeContentProvider.LEVEL_PACKAGE);
- if(JavaScriptCore.IS_ECMASCRIPT4) JavaPluginImages.setLocalImageDescriptors(fGroupPackageAction, "package_mode.gif"); //$NON-NLS-1$
- fGroupFileAction= new GroupAction(SearchMessages.JavaSearchResultPage_groupby_file, SearchMessages.JavaSearchResultPage_groupby_file_tooltip, this, LevelTreeContentProvider.LEVEL_FILE);
- JavaPluginImages.setLocalImageDescriptors(fGroupFileAction, "file_mode.gif"); //$NON-NLS-1$
- fGroupTypeAction= new GroupAction(SearchMessages.JavaSearchResultPage_groupby_type, SearchMessages.JavaSearchResultPage_groupby_type_tooltip, this, LevelTreeContentProvider.LEVEL_TYPE);
- JavaPluginImages.setLocalImageDescriptors(fGroupTypeAction, "type_mode.gif"); //$NON-NLS-1$
- }
-
- public void setViewPart(ISearchResultViewPart part) {
- super.setViewPart(part);
- fActionGroup= new NewSearchViewActionGroup(part);
- }
-
- public void showMatch(Match match, int offset, int length, boolean activate) throws PartInitException {
- IEditorPart editor;
- try {
- editor= fEditorOpener.openMatch(match);
- } catch (JavaScriptModelException e) {
- throw new PartInitException(e.getStatus());
- }
-
- if (editor != null && activate)
- editor.getEditorSite().getPage().activate(editor);
- Object element= match.getElement();
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor= (ITextEditor) editor;
- textEditor.selectAndReveal(offset, length);
- } else if (editor != null){
- if (element instanceof IFile) {
- IFile file= (IFile) element;
- showWithMarker(editor, file, offset, length);
- }
- } else {
- JavaSearchResult result= (JavaSearchResult) getInput();
- IMatchPresentation participant= result.getSearchParticpant(element);
- if (participant != null)
- participant.showMatch(match, offset, length, activate);
- }
- }
-
- private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
- try {
- IMarker marker= file.createMarker(NewSearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
- attributes.put(IMarker.CHAR_START, new Integer(offset));
- attributes.put(IMarker.CHAR_END, new Integer(offset + length));
- marker.setAttributes(attributes);
- IDE.gotoMarker(editor, marker);
- marker.delete();
- } catch (CoreException e) {
- throw new PartInitException(SearchMessages.JavaSearchResultPage_error_marker, e);
- }
- }
-
- private SelectionDispatchAction getCopyQualifiedNameAction() {
- if (fCopyQualifiedNameAction == null) {
- fCopyQualifiedNameAction= new CopyQualifiedNameAction(getSite());
- }
- return fCopyQualifiedNameAction;
- }
-
- protected void fillContextMenu(IMenuManager mgr) {
- super.fillContextMenu(mgr);
- addSortActions(mgr);
-
- mgr.appendToGroup(IContextMenuConstants.GROUP_EDIT, getCopyQualifiedNameAction());
-
- fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroup.fillContextMenu(mgr);
- }
-
- private void addSortActions(IMenuManager mgr) {
- if (getLayout() != FLAG_LAYOUT_FLAT)
- return;
- MenuManager sortMenu= new MenuManager(SearchMessages.JavaSearchResultPage_sortBylabel);
- sortMenu.add(fSortByNameAction);
- sortMenu.add(fSortByPathAction);
- sortMenu.add(fSortByParentName);
-
- fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
- fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());
- fSortByParentName.setChecked(fCurrentSortOrder == fSortByParentName.getSortOrder());
-
- mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
- }
-
- protected void fillToolbar(IToolBarManager tbm) {
- super.fillToolbar(tbm);
-
- IActionBars actionBars = getSite().getActionBars();
- if (actionBars != null) {
- actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, getCopyQualifiedNameAction());
- }
-
- if (getLayout() != FLAG_LAYOUT_FLAT)
- addGroupActions(tbm);
- }
-
- private void addGroupActions(IToolBarManager mgr) {
- mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, new Separator(GROUP_GROUPING));
- mgr.appendToGroup(GROUP_GROUPING, fGroupProjectAction);
- if(JavaScriptCore.IS_ECMASCRIPT4) mgr.appendToGroup(GROUP_GROUPING, fGroupPackageAction);
- mgr.appendToGroup(GROUP_GROUPING, fGroupFileAction);
- mgr.appendToGroup(GROUP_GROUPING, fGroupTypeAction);
-
- updateGroupingActions();
- }
-
-
- private void updateGroupingActions() {
- fGroupProjectAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PROJECT);
- if(JavaScriptCore.IS_ECMASCRIPT4) fGroupPackageAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PACKAGE);
- fGroupFileAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_FILE);
- fGroupTypeAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_TYPE);
- }
-
-
- public void dispose() {
- fActionGroup.dispose();
- super.dispose();
- }
-
- protected void elementsChanged(Object[] objects) {
- if (fContentProvider != null)
- fContentProvider.elementsChanged(objects);
- }
-
- protected void clear() {
- if (fContentProvider != null)
- fContentProvider.clear();
- }
-
- private void addDragAdapters(StructuredViewer viewer) {
- Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance() };
- int ops= DND.DROP_COPY | DND.DROP_LINK;
-
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(viewer),
- new ResourceTransferDragAdapter(viewer)
- };
-
- viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners));
- }
-
- protected void configureTableViewer(TableViewer viewer) {
- viewer.setUseHashlookup(true);
- fSortingLabelProvider= new SortingLabelProvider(this);
- viewer.setLabelProvider(new DecoratingJavaLabelProvider(fSortingLabelProvider, false));
- fContentProvider=new JavaSearchTableContentProvider(this);
- viewer.setContentProvider(fContentProvider);
- viewer.setComparator(new DecoratorIgnoringViewerSorter(fSortingLabelProvider));
- setSortOrder(fCurrentSortOrder);
- addDragAdapters(viewer);
- }
-
- protected void configureTreeViewer(TreeViewer viewer) {
- PostfixLabelProvider postfixLabelProvider= new PostfixLabelProvider(this);
- viewer.setUseHashlookup(true);
- viewer.setComparator(new DecoratorIgnoringViewerSorter(postfixLabelProvider));
- viewer.setLabelProvider(new DecoratingJavaLabelProvider(postfixLabelProvider, false));
- fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping);
- viewer.setContentProvider(fContentProvider);
- addDragAdapters(viewer);
- }
-
- protected TreeViewer createTreeViewer(Composite parent) {
- ProblemTreeViewer problemTreeViewer= new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- ColoredViewersManager.install(problemTreeViewer);
- return problemTreeViewer;
- }
-
- protected TableViewer createTableViewer(Composite parent) {
- ProblemTableViewer problemTableViewer= new ProblemTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- ColoredViewersManager.install(problemTableViewer);
- return problemTableViewer;
- }
-
- void setSortOrder(int order) {
- if (fSortingLabelProvider != null) {
- fCurrentSortOrder= order;
- StructuredViewer viewer= getViewer();
- //viewer.getControl().setRedraw(false);
- fSortingLabelProvider.setOrder(order);
- //viewer.getControl().setRedraw(true);
- viewer.refresh();
- getSettings().put(KEY_SORTING, fCurrentSortOrder);
- }
- }
-
- public void init(IPageSite site) {
- super.init(site);
- IMenuManager menuManager = site.getActionBars().getMenuManager();
- menuManager.insertBefore(IContextMenuConstants.GROUP_PROPERTIES, new Separator(GROUP_FILTERING));
- fActionGroup.fillActionBars(site.getActionBars());
- menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new Action(SearchMessages.JavaSearchResultPage_preferences_label) {
- public void run() {
- String pageId= "org.eclipse.search.preferences.SearchPreferencePage"; //$NON-NLS-1$
- PreferencesUtil.createPreferenceDialogOn(JavaScriptPlugin.getActiveWorkbenchShell(), pageId, null, null).open();
- }
- });
- }
-
- /**
- * Precondition here: the viewer must be showing a tree with a LevelContentProvider.
- * @param grouping
- */
- void setGrouping(int grouping) {
- fCurrentGrouping= grouping;
- StructuredViewer viewer= getViewer();
- LevelTreeContentProvider cp= (LevelTreeContentProvider) viewer.getContentProvider();
- cp.setLevel(grouping);
- updateGroupingActions();
- getSettings().put(KEY_GROUPING, fCurrentGrouping);
- getViewPart().updateLabel();
- }
-
- protected StructuredViewer getViewer() {
- // override so that it's visible in the package.
- return super.getViewer();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#restoreState(org.eclipse.ui.IMemento)
- */
- public void restoreState(IMemento memento) {
- super.restoreState(memento);
-
- int sortOrder= SortingLabelProvider.SHOW_ELEMENT_CONTAINER;
- int grouping= LevelTreeContentProvider.LEVEL_PACKAGE;
- int elementLimit= DEFAULT_ELEMENT_LIMIT;
-
- try {
- sortOrder= getSettings().getInt(KEY_SORTING);
- } catch (NumberFormatException e) {
- }
- try {
- grouping= getSettings().getInt(KEY_GROUPING);
- } catch (NumberFormatException e) {
- }
- if (FALSE.equals(getSettings().get(KEY_LIMIT_ENABLED))) {
- elementLimit= -1;
- } else {
- try {
- elementLimit= getSettings().getInt(KEY_LIMIT);
- } catch (NumberFormatException e) {
- }
- }
- if (memento != null) {
- Integer value= memento.getInteger(KEY_GROUPING);
- if (value != null)
- grouping= value.intValue();
- value= memento.getInteger(KEY_SORTING);
- if (value != null)
- sortOrder= value.intValue();
- boolean limitElements= !FALSE.equals(memento.getString(KEY_LIMIT_ENABLED));
- value= memento.getInteger(KEY_LIMIT);
- if (value != null)
- elementLimit= limitElements ? value.intValue() : -1;
- }
-
- fCurrentGrouping= grouping;
- fCurrentSortOrder= sortOrder;
- setElementLimit(new Integer(elementLimit));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#saveState(org.eclipse.ui.IMemento)
- */
- public void saveState(IMemento memento) {
- super.saveState(memento);
- memento.putInteger(KEY_GROUPING, fCurrentGrouping);
- memento.putInteger(KEY_SORTING, fCurrentSortOrder);
- int limit= getElementLimit().intValue();
- if (limit != -1)
- memento.putString(KEY_LIMIT_ENABLED, TRUE);
- else
- memento.putString(KEY_LIMIT_ENABLED, FALSE);
- memento.putInteger(KEY_LIMIT, limit);
- }
-
- private boolean isQueryRunning() {
- AbstractTextSearchResult result= getInput();
- if (result != null) {
- return NewSearchUI.isQueryRunning(result.getQuery());
- }
- return false;
- }
-
- public String getLabel() {
- String label= super.getLabel();
- AbstractTextSearchResult input= getInput();
- if (input != null && input.getActiveMatchFilters() != null && input.getActiveMatchFilters().length > 0) {
- if (isQueryRunning()) {
- String message= SearchMessages.JavaSearchResultPage_filtered_message;
- return Messages.format(message, new Object[] { label });
-
- } else {
- int filteredOut= input.getMatchCount() - getFilteredMatchCount();
- String message= SearchMessages.JavaSearchResultPage_filteredWithCount_message;
- return Messages.format(message, new Object[] { label, String.valueOf(filteredOut) });
- }
- }
- return label;
- }
-
- private int getFilteredMatchCount() {
- StructuredViewer viewer= getViewer();
- if (viewer instanceof TreeViewer) {
- ITreeContentProvider tp= (ITreeContentProvider) viewer.getContentProvider();
- return getMatchCount(tp, getRootElements((TreeViewer) getViewer()));
- } else {
- return getMatchCount((TableViewer) viewer);
- }
- }
-
- private Object[] getRootElements(TreeViewer viewer) {
- Tree t= viewer.getTree();
- Item[] roots= t.getItems();
- Object[] elements= new Object[roots.length];
- for (int i = 0; i < elements.length; i++) {
- elements[i]= roots[i].getData();
- }
- return elements;
- }
-
- private Object[] getRootElements(TableViewer viewer) {
- Table t= viewer.getTable();
- Item[] roots= t.getItems();
- Object[] elements= new Object[roots.length];
- for (int i = 0; i < elements.length; i++) {
- elements[i]= roots[i].getData();
- }
- return elements;
- }
-
-
- private int getMatchCount(ITreeContentProvider cp, Object[] elements) {
- int count= 0;
- for (int j = 0; j < elements.length; j++) {
- count+= getDisplayedMatchCount(elements[j]);
- Object[] children = cp.getChildren(elements[j]);
- count+= getMatchCount(cp, children);
- }
- return count;
- }
-
- private int getMatchCount(TableViewer viewer) {
- Object[] elements= getRootElements(viewer);
- int count= 0;
- for (int i = 0; i < elements.length; i++) {
- count+= getDisplayedMatchCount(elements[i]);
- }
- return count;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (IShowInTargetList.class.equals(adapter)) {
- return SHOW_IN_TARGET_LIST;
- }
- return null;
- }
-
- protected void handleOpen(OpenEvent event) {
- Object firstElement= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (firstElement instanceof IJavaScriptUnit ||
- firstElement instanceof IClassFile ||
- firstElement instanceof IMember) {
- if (getDisplayedMatchCount(firstElement) == 0) {
- try {
- fEditorOpener.openElement(firstElement);
- } catch (CoreException e) {
- ExceptionHandler.handle(e, getSite().getShell(), SearchMessages.JavaSearchResultPage_open_editor_error_title, SearchMessages.JavaSearchResultPage_open_editor_error_message);
- }
- return;
- }
- }
- super.handleOpen(event);
- }
-
- public void setElementLimit(Integer elementLimit) {
- super.setElementLimit(elementLimit);
- int limit= elementLimit.intValue();
- getSettings().put(KEY_LIMIT, limit);
- getSettings().put(KEY_LIMIT_ENABLED, limit != -1 ? TRUE : FALSE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchScopeFactory.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchScopeFactory.java
deleted file mode 100644
index bc7a74be..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchScopeFactory.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
-import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
-import org.eclipse.wst.jsdt.core.search.SearchEngine;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-public class JavaSearchScopeFactory {
-
- public static final int JRE= IJavaScriptSearchScope.SYSTEM_LIBRARIES;
- public static final int LIBS= IJavaScriptSearchScope.APPLICATION_LIBRARIES;
- public static final int PROJECTS= IJavaScriptSearchScope.REFERENCED_PROJECTS;
- public static final int SOURCES= IJavaScriptSearchScope.SOURCES;
-
- public static final int ALL= JRE | LIBS | PROJECTS | SOURCES;
- public static final int NO_PROJ= JRE | LIBS | SOURCES;
- public static final int NO_JRE= LIBS | PROJECTS | SOURCES;
- public static final int NO_JRE_NO_PROJ= LIBS | PROJECTS | SOURCES;
-
- private static JavaSearchScopeFactory fgInstance;
- private final IJavaScriptSearchScope EMPTY_SCOPE= SearchEngine.createJavaSearchScope(new IJavaScriptElement[] {});
-
- private JavaSearchScopeFactory() {
- }
-
- public static JavaSearchScopeFactory getInstance() {
- if (fgInstance == null)
- fgInstance= new JavaSearchScopeFactory();
- return fgInstance;
- }
-
- public IWorkingSet[] queryWorkingSets() throws JavaScriptModelException, InterruptedException {
- Shell shell= JavaScriptPlugin.getActiveWorkbenchShell();
- if (shell == null)
- return null;
- IWorkingSetSelectionDialog dialog= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, true);
- if (dialog.open() != Window.OK) {
- throw new InterruptedException();
- }
-
- IWorkingSet[] workingSets= dialog.getSelection();
- if (workingSets.length > 0)
- return workingSets;
- return null; // 'no working set' selected
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IWorkingSet[] workingSets, boolean includeJRE) {
- return createJavaSearchScope(workingSets, includeJRE ? ALL : NO_JRE);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IWorkingSet[] workingSets, int includeMask) {
- if (workingSets == null || workingSets.length < 1)
- return EMPTY_SCOPE;
-
- Set javaElements= new HashSet(workingSets.length * 10);
- for (int i= 0; i < workingSets.length; i++) {
- IWorkingSet workingSet= workingSets[i];
- if (workingSet.isEmpty() && workingSet.isAggregateWorkingSet()) {
- return createWorkspaceScope(includeMask);
- }
- addJavaElements(javaElements, workingSet);
- }
- return createJavaSearchScope(javaElements, includeMask);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IWorkingSet workingSet, boolean includeJRE) {
- return createJavaSearchScope(workingSet, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IWorkingSet workingSet, int includeMask) {
- Set javaElements= new HashSet(10);
- if (workingSet.isEmpty() && workingSet.isAggregateWorkingSet()) {
- return createWorkspaceScope(includeMask);
- }
- addJavaElements(javaElements, workingSet);
- return createJavaSearchScope(javaElements, includeMask);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IResource[] resources, boolean includeJRE) {
- return createJavaSearchScope(resources, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IResource[] resources, int includeMask) {
- if (resources == null)
- return EMPTY_SCOPE;
- Set javaElements= new HashSet(resources.length);
- addJavaElements(javaElements, resources);
- return createJavaSearchScope(javaElements, includeMask);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(ISelection selection, boolean includeJRE) {
- return createJavaSearchScope(selection, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(ISelection selection, int includeMask) {
- return createJavaSearchScope(getJavaElements(selection), includeMask);
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(String[] projectNames, boolean includeJRE) {
- return createJavaProjectSearchScope(projectNames, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(String[] projectNames, int includeMask) {
- ArrayList res= new ArrayList();
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- for (int i= 0; i < projectNames.length; i++) {
- IJavaScriptProject project= JavaScriptCore.create(root.getProject(projectNames[i]));
- if (project.exists()) {
- res.add(project);
- }
- }
- return createJavaSearchScope(res, includeMask);
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(IJavaScriptProject project, boolean includeJRE) {
- return createJavaProjectSearchScope(project, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(IJavaScriptProject project, int includeMask) {
- return SearchEngine.createJavaSearchScope(new IJavaScriptElement[] { project }, getSearchFlags(includeMask));
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(IEditorInput editorInput, boolean includeJRE) {
- return createJavaProjectSearchScope(editorInput, includeJRE ? ALL : NO_JRE);
- }
-
- public IJavaScriptSearchScope createJavaProjectSearchScope(IEditorInput editorInput, int includeMask) {
- IJavaScriptElement elem= JavaScriptUI.getEditorInputJavaElement(editorInput);
- if (elem != null) {
- IJavaScriptProject project= elem.getJavaScriptProject();
- if (project != null) {
- return createJavaProjectSearchScope(project, includeMask);
- }
- }
- return EMPTY_SCOPE;
- }
-
- public String getWorkspaceScopeDescription(boolean includeJRE) {
- return includeJRE ? SearchMessages.WorkspaceScope : SearchMessages.WorkspaceScopeNoJRE;
- }
-
- public String getWorkspaceScopeDescription(int includeMask) {
- return getWorkspaceScopeDescription((includeMask & JRE) != 0);
- }
-
- public String getProjectScopeDescription(String[] projectNames, int includeMask) {
- if (projectNames.length == 0) {
- return SearchMessages.JavaSearchScopeFactory_undefined_projects;
- }
- boolean includeJRE= (includeMask & JRE) != 0;
- String scopeDescription;
- if (projectNames.length == 1) {
- String label= includeJRE ? SearchMessages.EnclosingProjectScope : SearchMessages.EnclosingProjectScopeNoJRE;
- scopeDescription= Messages.format(label, projectNames[0]);
- } else if (projectNames.length == 2) {
- String label= includeJRE ? SearchMessages.EnclosingProjectsScope2 : SearchMessages.EnclosingProjectsScope2NoJRE;
- scopeDescription= Messages.format(label, new String[] { projectNames[0], projectNames[1]});
- } else {
- String label= includeJRE ? SearchMessages.EnclosingProjectsScope : SearchMessages.EnclosingProjectsScopeNoJRE;
- scopeDescription= Messages.format(label, new String[] { projectNames[0], projectNames[1]});
- }
- return scopeDescription;
- }
-
- public String getProjectScopeDescription(IJavaScriptProject project, boolean includeJRE) {
- if (includeJRE) {
- return Messages.format(SearchMessages.ProjectScope, project.getElementName());
- } else {
- return Messages.format(SearchMessages.ProjectScopeNoJRE, project.getElementName());
- }
- }
-
- public String getProjectScopeDescription(IEditorInput editorInput, boolean includeJRE) {
- IJavaScriptElement elem= JavaScriptUI.getEditorInputJavaElement(editorInput);
- if (elem != null) {
- IJavaScriptProject project= elem.getJavaScriptProject();
- if (project != null) {
- return getProjectScopeDescription(project, includeJRE);
- }
- }
- return Messages.format(SearchMessages.ProjectScope, ""); //$NON-NLS-1$
- }
-
- public String getHierarchyScopeDescription(IType type) {
- return Messages.format(SearchMessages.HierarchyScope, new String[] { type.getElementName() });
- }
-
- public String getSelectionScopeDescription(IJavaScriptElement[] javaElements, int includeMask) {
- return getSelectionScopeDescription(javaElements, (includeMask & JRE) != 0);
- }
-
-
- public String getSelectionScopeDescription(IJavaScriptElement[] javaElements, boolean includeJRE) {
- if (javaElements.length == 0) {
- return SearchMessages.JavaSearchScopeFactory_undefined_selection;
- }
- String scopeDescription;
- if (javaElements.length == 1) {
- String label= includeJRE ? SearchMessages.SingleSelectionScope : SearchMessages.SingleSelectionScopeNoJRE;
- scopeDescription= Messages.format(label, javaElements[0].getElementName());
- } else if (javaElements.length == 1) {
- String label= includeJRE ? SearchMessages.DoubleSelectionScope : SearchMessages.DoubleSelectionScopeNoJRE;
- scopeDescription= Messages.format(label, new String[] { javaElements[0].getElementName(), javaElements[1].getElementName()});
- } else {
- String label= includeJRE ? SearchMessages.SelectionScope : SearchMessages.SelectionScopeNoJRE;
- scopeDescription= Messages.format(label, new String[] { javaElements[0].getElementName(), javaElements[1].getElementName()});
- }
- return scopeDescription;
- }
-
- public String getWorkingSetScopeDescription(IWorkingSet[] workingSets, int includeMask) {
- return getWorkingSetScopeDescription(workingSets, (includeMask & JRE) != 0);
- }
-
- public String getWorkingSetScopeDescription(IWorkingSet[] workingSets, boolean includeJRE) {
- if (workingSets.length == 0) {
- return SearchMessages.JavaSearchScopeFactory_undefined_workingsets;
- }
- if (workingSets.length == 1) {
- String label= includeJRE ? SearchMessages.SingleWorkingSetScope : SearchMessages.SingleWorkingSetScopeNoJRE;
- return Messages.format(label, workingSets[0].getLabel());
- }
- Arrays.sort(workingSets, new WorkingSetComparator());
- if (workingSets.length == 2) {
- String label= includeJRE ? SearchMessages.DoubleWorkingSetScope : SearchMessages.DoubleWorkingSetScopeNoJRE;
- return Messages.format(label, new String[] { workingSets[0].getLabel(), workingSets[1].getLabel()});
- }
- String label= includeJRE ? SearchMessages.WorkingSetsScope : SearchMessages.WorkingSetsScopeNoJRE;
- return Messages.format(label, new String[] { workingSets[0].getLabel(), workingSets[1].getLabel()});
- }
-
- public IProject[] getProjects(IJavaScriptSearchScope scope) {
- IPath[] paths= scope.enclosingProjectsAndJars();
- HashSet temp= new HashSet();
- for (int i= 0; i < paths.length; i++) {
- IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(paths[i]);
- if (resource != null && resource.getType() == IResource.PROJECT)
- temp.add(resource);
- }
- return (IProject[]) temp.toArray(new IProject[temp.size()]);
- }
-
- public IJavaScriptElement[] getJavaElements(ISelection selection) {
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- return getJavaElements(((IStructuredSelection)selection).toArray());
- } else {
- return new IJavaScriptElement[0];
- }
- }
-
- private IJavaScriptElement[] getJavaElements(Object[] elements) {
- if (elements.length == 0)
- return new IJavaScriptElement[0];
-
- Set result= new HashSet(elements.length);
- for (int i= 0; i < elements.length; i++) {
- Object selectedElement= elements[i];
- if (selectedElement instanceof IJavaScriptElement) {
- addJavaElements(result, (IJavaScriptElement) selectedElement);
- } else if (selectedElement instanceof IResource) {
- addJavaElements(result, (IResource) selectedElement);
- } else if (selectedElement instanceof LogicalPackage) {
- addJavaElements(result, (LogicalPackage) selectedElement);
- } else if (selectedElement instanceof IWorkingSet) {
- IWorkingSet ws= (IWorkingSet)selectedElement;
- addJavaElements(result, ws);
- } else if (selectedElement instanceof IAdaptable) {
- IResource resource= (IResource) ((IAdaptable) selectedElement).getAdapter(IResource.class);
- if (resource != null)
- addJavaElements(result, resource);
- }
-
- }
- return (IJavaScriptElement[]) result.toArray(new IJavaScriptElement[result.size()]);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IJavaScriptElement[] javaElements, boolean includeJRE) {
- return createJavaSearchScope(javaElements, includeJRE ? NO_PROJ : NO_JRE_NO_PROJ);
- }
-
- public IJavaScriptSearchScope createJavaSearchScope(IJavaScriptElement[] javaElements, int includeMask) {
- if (javaElements.length == 0)
- return EMPTY_SCOPE;
- return SearchEngine.createJavaSearchScope(javaElements, getSearchFlags(includeMask));
- }
-
- private IJavaScriptSearchScope createJavaSearchScope(Collection javaElements, int includeMask) {
- if (javaElements.isEmpty())
- return EMPTY_SCOPE;
- IJavaScriptElement[] elementArray= (IJavaScriptElement[]) javaElements.toArray(new IJavaScriptElement[javaElements.size()]);
- return SearchEngine.createJavaSearchScope(elementArray, getSearchFlags(includeMask));
- }
-
- private static int getSearchFlags(int includeMask) {
- return includeMask;
- }
-
- private void addJavaElements(Set javaElements, IResource[] resources) {
- for (int i= 0; i < resources.length; i++)
- addJavaElements(javaElements, resources[i]);
- }
-
- private void addJavaElements(Set javaElements, IResource resource) {
- IJavaScriptElement javaElement= (IJavaScriptElement)resource.getAdapter(IJavaScriptElement.class);
- if (javaElement == null)
- // not a Java resource
- return;
-
- if (javaElement.getElementType() == IJavaScriptElement.PACKAGE_FRAGMENT) {
- // add other possible package fragments
- try {
- addJavaElements(javaElements, ((IFolder)resource).members());
- } catch (CoreException ex) {
- // don't add elements
- }
- }
-
- javaElements.add(javaElement);
- }
-
- private void addJavaElements(Set javaElements, IJavaScriptElement javaElement) {
- javaElements.add(javaElement);
- }
-
- private void addJavaElements(Set javaElements, IWorkingSet workingSet) {
- if (workingSet == null)
- return;
-
- if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
- try {
- IJavaScriptProject[] projects= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaScriptProjects();
- javaElements.addAll(Arrays.asList(projects));
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- return;
- }
-
- IAdaptable[] elements= workingSet.getElements();
- for (int i= 0; i < elements.length; i++) {
- IJavaScriptElement javaElement=(IJavaScriptElement) elements[i].getAdapter(IJavaScriptElement.class);
- if (javaElement != null) {
- addJavaElements(javaElements, javaElement);
- continue;
- }
- IResource resource= (IResource)elements[i].getAdapter(IResource.class);
- if (resource != null) {
- addJavaElements(javaElements, resource);
- }
-
- // else we don't know what to do with it, ignore.
- }
- }
-
- private void addJavaElements(Set javaElements, LogicalPackage selectedElement) {
- IPackageFragment[] packages= selectedElement.getFragments();
- for (int i= 0; i < packages.length; i++)
- addJavaElements(javaElements, packages[i]);
- }
-
- public IJavaScriptSearchScope createWorkspaceScope(boolean includeJRE) {
- return createWorkspaceScope(includeJRE ? ALL : NO_JRE);
- }
-
- public IJavaScriptSearchScope createWorkspaceScope(int includeMask) {
- if ((includeMask & NO_PROJ) != NO_PROJ) {
- try {
- IJavaScriptProject[] projects= JavaScriptCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaScriptProjects();
- return SearchEngine.createJavaSearchScope(projects, getSearchFlags(includeMask));
- } catch (JavaScriptModelException e) {
- // ignore, use workspace scope instead
- }
- }
- return SearchEngine.createWorkspaceScope();
- }
-
- public boolean isInsideJRE(IJavaScriptElement element) {
- IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT_ROOT);
- if (root != null) {
- try {
- IIncludePathEntry entry= root.getRawIncludepathEntry();
- if (entry.getEntryKind() == IIncludePathEntry.CPE_CONTAINER) {
- IJsGlobalScopeContainer container= JavaScriptCore.getJsGlobalScopeContainer(entry.getPath(), root.getJavaScriptProject());
- return container != null && container.getKind() == IJsGlobalScopeContainer.K_DEFAULT_SYSTEM;
- }
- return false;
- } catch (JavaScriptModelException e) {
- JavaScriptPlugin.log(e);
- }
- }
- return true; // include JRE in doubt
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchTableContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchTableContentProvider.java
deleted file mode 100644
index e3e72a94..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/JavaSearchTableContentProvider.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Table;
-
-public class JavaSearchTableContentProvider extends JavaSearchContentProvider implements IStructuredContentProvider {
- public JavaSearchTableContentProvider(JavaSearchResultPage page) {
- super(page);
- }
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof JavaSearchResult) {
- Set filteredElements= new HashSet();
- Object[] rawElements= ((JavaSearchResult)inputElement).getElements();
- int limit= getPage().getElementLimit().intValue();
- for (int i= 0; i < rawElements.length; i++) {
- if (getPage().getDisplayedMatchCount(rawElements[i]) > 0) {
- filteredElements.add(rawElements[i]);
- if (limit != -1 && limit < filteredElements.size()) {
- break;
- }
- }
- }
- return filteredElements.toArray();
- }
- return EMPTY_ARR;
- }
-
- public void elementsChanged(Object[] updatedElements) {
- if (getSearchResult() == null)
- return;
-
- int addCount= 0;
- int removeCount= 0;
- int addLimit= getAddLimit();
-
- TableViewer viewer= (TableViewer) getPage().getViewer();
- Set updated= new HashSet();
- Set added= new HashSet();
- Set removed= new HashSet();
- for (int i= 0; i < updatedElements.length; i++) {
- if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0) {
- if (viewer.testFindItem(updatedElements[i]) != null)
- updated.add(updatedElements[i]);
- else {
- if (addLimit > 0) {
- added.add(updatedElements[i]);
- addLimit--;
- addCount++;
- }
- }
- } else {
- removed.add(updatedElements[i]);
- removeCount++;
- }
- }
-
- viewer.add(added.toArray());
- viewer.update(updated.toArray(), new String[] { SearchLabelProvider.PROPERTY_MATCH_COUNT });
- viewer.remove(removed.toArray());
- }
-
- private int getAddLimit() {
- int limit= getPage().getElementLimit().intValue();
- if (limit != -1) {
- Table table= (Table) getPage().getViewer().getControl();
- int itemCount= table.getItemCount();
- if (itemCount >= limit) {
- return 0;
- }
- return limit - itemCount;
- }
- return Integer.MAX_VALUE;
- }
-
- public void clear() {
- getPage().getViewer().refresh();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LRUWorkingSetsList.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LRUWorkingSetsList.java
deleted file mode 100644
index d7ec1fb6..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LRUWorkingSetsList.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-
-public class LRUWorkingSetsList {
-
- private final ArrayList fLRUList;
- private final int fSize;
- private final WorkingSetsComparator fComparator= new WorkingSetsComparator();
-
- public LRUWorkingSetsList(int size) {
- fSize= size;
- fLRUList= new ArrayList(size);
- }
-
- public void add(IWorkingSet[] workingSets) {
- removeDeletedWorkingSets();
- IWorkingSet[] existingWorkingSets= find(fLRUList, workingSets);
- if (existingWorkingSets != null)
- fLRUList.remove(existingWorkingSets);
- else if (fLRUList.size() == fSize)
- fLRUList.remove(fSize - 1);
- fLRUList.add(0, workingSets);
-
- }
-
- public Iterator iterator() {
- removeDeletedWorkingSets();
- return fLRUList.iterator();
- }
-
- public Iterator sortedIterator() {
- removeDeletedWorkingSets();
- ArrayList sortedList= new ArrayList(fLRUList);
- Collections.sort(sortedList, fComparator);
- return sortedList.iterator();
- }
-
- private void removeDeletedWorkingSets() {
- Iterator iter= new ArrayList(fLRUList).iterator();
- while (iter.hasNext()) {
- IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
- for (int i= 0; i < workingSets.length; i++) {
- if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSets[i].getName()) == null) {
- fLRUList.remove(workingSets);
- break;
- }
- }
- }
- }
-
- private IWorkingSet[] find(ArrayList list, IWorkingSet[] workingSets) {
- Set workingSetList= new HashSet(Arrays.asList(workingSets));
- Iterator iter= list.iterator();
- while (iter.hasNext()) {
- IWorkingSet[] lruWorkingSets= (IWorkingSet[])iter.next();
- Set lruWorkingSetList= new HashSet(Arrays.asList(lruWorkingSets));
- if (lruWorkingSetList.equals(workingSetList))
- return lruWorkingSets;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LevelTreeContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LevelTreeContentProvider.java
deleted file mode 100644
index d38724f8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/LevelTreeContentProvider.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-public class LevelTreeContentProvider extends JavaSearchContentProvider implements ITreeContentProvider {
- private Map fChildrenMap;
- private StandardJavaScriptElementContentProvider fContentProvider;
-
- public static final int LEVEL_TYPE= 1;
- public static final int LEVEL_FILE= 2;
- public static final int LEVEL_PACKAGE= 3;
- public static final int LEVEL_PROJECT= 4;
-
- private static final int[][] JAVA_ELEMENT_TYPES= {{IJavaScriptElement.TYPE},
- {IJavaScriptElement.CLASS_FILE, IJavaScriptElement.JAVASCRIPT_UNIT},
- {IJavaScriptElement.PACKAGE_FRAGMENT},
- {IJavaScriptElement.JAVASCRIPT_PROJECT, IJavaScriptElement.PACKAGE_FRAGMENT_ROOT},
- {IJavaScriptElement.JAVASCRIPT_MODEL}};
- private static final int[][] RESOURCE_TYPES= {
- {},
- {IResource.FILE},
- {IResource.FOLDER},
- {IResource.PROJECT},
- {IResource.ROOT}};
-
- private static final int MAX_LEVEL= JAVA_ELEMENT_TYPES.length - 1;
- private int fCurrentLevel;
- static class FastJavaElementProvider extends StandardJavaScriptElementContentProvider {
- public Object getParent(Object element) {
- return internalGetParent(element);
- }
- }
-
- public LevelTreeContentProvider(JavaSearchResultPage page, int level) {
- super(page);
- fCurrentLevel= level;
- fContentProvider= new FastJavaElementProvider();
- }
-
- public Object getParent(Object child) {
- Object possibleParent= internalGetParent(child);
- if (possibleParent instanceof IJavaScriptElement) {
- IJavaScriptElement javaElement= (IJavaScriptElement) possibleParent;
- for (int j= fCurrentLevel; j < MAX_LEVEL + 1; j++) {
- for (int i= 0; i < JAVA_ELEMENT_TYPES[j].length; i++) {
- if (javaElement.getElementType() == JAVA_ELEMENT_TYPES[j][i]) {
- return null;
- }
- }
- }
- } else if (possibleParent instanceof IResource) {
- IResource resource= (IResource) possibleParent;
- for (int j= fCurrentLevel; j < MAX_LEVEL + 1; j++) {
- for (int i= 0; i < RESOURCE_TYPES[j].length; i++) {
- if (resource.getType() == RESOURCE_TYPES[j][i]) {
- return null;
- }
- }
- }
- }
- if (fCurrentLevel != LEVEL_FILE && child instanceof IType) {
- IType type= (IType) child;
- if (possibleParent instanceof IJavaScriptUnit
- || possibleParent instanceof IClassFile)
- possibleParent= type.getPackageFragment();
- }
- return possibleParent;
- }
-
- private Object internalGetParent(Object child) {
- return fContentProvider.getParent(child);
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- protected synchronized void initialize(JavaSearchResult result) {
- super.initialize(result);
- fChildrenMap= new HashMap();
- if (result != null) {
- Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
- if (getPage().getDisplayedMatchCount(elements[i]) > 0) {
- insert(null, null, elements[i]);
- }
- }
- }
- }
-
- protected void insert(Map toAdd, Set toUpdate, Object child) {
- Object parent= getParent(child);
- while (parent != null) {
- if (insertChild(parent, child)) {
- if (toAdd != null)
- insertInto(parent, child, toAdd);
- } else {
- if (toUpdate != null)
- toUpdate.add(parent);
- return;
- }
- child= parent;
- parent= getParent(child);
- }
- if (insertChild(getSearchResult(), child)) {
- if (toAdd != null)
- insertInto(getSearchResult(), child, toAdd);
- }
- }
-
- private boolean insertChild(Object parent, Object child) {
- return insertInto(parent, child, fChildrenMap);
- }
-
- private boolean insertInto(Object parent, Object child, Map map) {
- Set children= (Set) map.get(parent);
- if (children == null) {
- children= new HashSet();
- map.put(parent, children);
- }
- return children.add(child);
- }
-
- protected void remove(Set toRemove, Set toUpdate, Object element) {
- // precondition here: fResult.getMatchCount(child) <= 0
-
- if (hasChildren(element)) {
- if (toUpdate != null)
- toUpdate.add(element);
- } else {
- if (getPage().getDisplayedMatchCount(element) == 0) {
- fChildrenMap.remove(element);
- Object parent= getParent(element);
- if (parent != null) {
- if (removeFromSiblings(element, parent)) {
- remove(toRemove, toUpdate, parent);
- }
- } else {
- if (removeFromSiblings(element, getSearchResult())) {
- if (toRemove != null)
- toRemove.add(element);
- }
- }
- } else {
- if (toUpdate != null) {
- toUpdate.add(element);
- }
- }
- }
- }
-
- /**
- * @param element
- * @param parent
- * @return returns true if it really was a remove (i.e. element was a child of parent).
- */
- private boolean removeFromSiblings(Object element, Object parent) {
- Set siblings= (Set) fChildrenMap.get(parent);
- if (siblings != null) {
- return siblings.remove(element);
- } else {
- return false;
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- Set children= (Set) fChildrenMap.get(parentElement);
- if (children == null)
- return EMPTY_ARR;
- int limit= getPage().getElementLimit().intValue();
- if (limit != -1 && limit < children.size()) {
- Object[] limitedArray= new Object[limit];
- Iterator iterator= children.iterator();
- for (int i= 0; i < limit; i++) {
- limitedArray[i]= iterator.next();
- }
- return limitedArray;
- }
-
- return children.toArray();
- }
-
- public boolean hasChildren(Object element) {
- Set children= (Set) fChildrenMap.get(element);
- return children != null && !children.isEmpty();
- }
-
- public synchronized void elementsChanged(Object[] updatedElements) {
- if (getSearchResult() == null)
- return;
-
- AbstractTreeViewer viewer= (AbstractTreeViewer) getPage().getViewer();
-
- Set toRemove= new HashSet();
- Set toUpdate= new HashSet();
- Map toAdd= new HashMap();
- for (int i= 0; i < updatedElements.length; i++) {
- if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0)
- insert(toAdd, toUpdate, updatedElements[i]);
- else
- remove(toRemove, toUpdate, updatedElements[i]);
- }
-
- viewer.remove(toRemove.toArray());
- for (Iterator iter= toAdd.keySet().iterator(); iter.hasNext();) {
- Object parent= iter.next();
- HashSet children= (HashSet) toAdd.get(parent);
- viewer.add(parent, children.toArray());
- }
- for (Iterator elementsToUpdate= toUpdate.iterator(); elementsToUpdate.hasNext();) {
- viewer.refresh(elementsToUpdate.next());
- }
-
- }
-
- public void clear() {
- initialize(getSearchResult());
- getPage().getViewer().refresh();
- }
-
- public void setLevel(int level) {
- fCurrentLevel= level;
- initialize(getSearchResult());
- getPage().getViewer().refresh();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/MethodExitsFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/MethodExitsFinder.java
deleted file mode 100644
index 7b7f7b59..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/MethodExitsFinder.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Block;
-import org.eclipse.wst.jsdt.core.dom.CatchClause;
-import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.Statement;
-import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
-import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
-import org.eclipse.wst.jsdt.core.dom.ThrowStatement;
-import org.eclipse.wst.jsdt.core.dom.TryStatement;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.dom.LocalVariableIndex;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.flow.FlowContext;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.flow.FlowInfo;
-import org.eclipse.wst.jsdt.internal.corext.refactoring.code.flow.InOutFlowAnalyzer;
-
-
-public class MethodExitsFinder extends ASTVisitor {
-
- private AST fAST;
- private FunctionDeclaration fMethodDeclaration;
- private List fResult;
- private List fCatchedExceptions;
-
- public String initialize(JavaScriptUnit root, int offset, int length) {
- return initialize(root, NodeFinder.perform(root, offset, length));
- }
-
- public String initialize(JavaScriptUnit root, ASTNode node) {
- fAST= root.getAST();
-
- if (node instanceof ReturnStatement) {
- fMethodDeclaration= (FunctionDeclaration)ASTNodes.getParent(node, ASTNode.FUNCTION_DECLARATION);
- if (fMethodDeclaration == null)
- return SearchMessages.MethodExitsFinder_no_return_type_selected;
- return null;
-
- }
-
- Type type= null;
- if (node instanceof Type) {
- type= (Type)node;
- } else if (node instanceof Name) {
- Name name= ASTNodes.getTopMostName((Name)node);
- if (name.getParent() instanceof Type) {
- type= (Type)name.getParent();
- }
- }
- if (type == null)
- return SearchMessages.MethodExitsFinder_no_return_type_selected;
- type= ASTNodes.getTopMostType(type);
- if (!(type.getParent() instanceof FunctionDeclaration))
- return SearchMessages.MethodExitsFinder_no_return_type_selected;
- fMethodDeclaration= (FunctionDeclaration)type.getParent();
- return null;
- }
-
- public List perform() {
- fResult= new ArrayList();
- markReferences();
- if (fResult.size() > 0) {
- Type returnType= fMethodDeclaration.getReturnType2();
- if (returnType != null)
- fResult.add(fMethodDeclaration.getReturnType2());
- }
- return fResult;
- }
-
- private void markReferences() {
- fCatchedExceptions= new ArrayList();
- boolean isVoid= true;
- Type returnType= fMethodDeclaration.getReturnType2();
- if (returnType != null) {
- ITypeBinding returnTypeBinding= returnType.resolveBinding();
- isVoid= returnTypeBinding != null && Bindings.isVoidType(returnTypeBinding);
- }
- fMethodDeclaration.accept(this);
- Block block= fMethodDeclaration.getBody();
- if (block != null) {
- List statements= block.statements();
- if (statements.size() > 0) {
- Statement last= (Statement)statements.get(statements.size() - 1);
- int maxVariableId= LocalVariableIndex.perform(fMethodDeclaration);
- FlowContext flowContext= new FlowContext(0, maxVariableId + 1);
- flowContext.setConsiderAccessMode(false);
- flowContext.setComputeMode(FlowContext.ARGUMENTS);
- InOutFlowAnalyzer flowAnalyzer= new InOutFlowAnalyzer(flowContext);
- FlowInfo info= flowAnalyzer.perform(new ASTNode[] {last});
- if (!info.isNoReturn() && !isVoid) {
- if (!info.isPartialReturn())
- return;
- }
- }
- SimpleName name= fAST.newSimpleName("x"); //$NON-NLS-1$
- name.setSourceRange(fMethodDeclaration.getStartPosition() + fMethodDeclaration.getLength() - 1, 1);
- fResult.add(name);
- }
- }
-
- public boolean visit(TypeDeclaration node) {
- // Don't dive into a local type.
- return false;
- }
-
- public boolean visit(AnonymousClassDeclaration node) {
- // Don't dive into a local type.
- return false;
- }
-
-
- public boolean visit(ReturnStatement node) {
- fResult.add(node);
- return super.visit(node);
- }
-
- public boolean visit(TryStatement node) {
- int currentSize= fCatchedExceptions.size();
- List catchClauses= node.catchClauses();
- for (Iterator iter= catchClauses.iterator(); iter.hasNext();) {
- IVariableBinding variable= ((CatchClause)iter.next()).getException().resolveBinding();
- if (variable != null && variable.getType() != null) {
- fCatchedExceptions.add(variable.getType());
- }
- }
- node.getBody().accept(this);
- int toRemove= fCatchedExceptions.size() - currentSize;
- for(int i= toRemove; i > 0; i--) {
- fCatchedExceptions.remove(currentSize);
- }
-
- // visit catch and finally
- for (Iterator iter= catchClauses.iterator(); iter.hasNext(); ) {
- ((CatchClause)iter.next()).accept(this);
- }
- if (node.getFinally() != null)
- node.getFinally().accept(this);
-
- // return false. We have visited the body by ourselves.
- return false;
- }
-
- public boolean visit(ThrowStatement node) {
- ITypeBinding exception= node.getExpression().resolveTypeBinding();
- if (isExitPoint(exception)) {
- SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 5);
- fResult.add(name);
- }
- return true;
- }
-
- public boolean visit(FunctionInvocation node) {
- if (isExitPoint(node.resolveMethodBinding())) {
- fResult.add(node.getName());
- }
- return true;
- }
-
- public boolean visit(SuperMethodInvocation node) {
- if (isExitPoint(node.resolveMethodBinding())) {
- fResult.add(node.getName());
- }
- return true;
- }
-
- public boolean visit(ClassInstanceCreation node) {
- if (isExitPoint(node.resolveConstructorBinding())) {
- fResult.add(node.getType());
- }
- return true;
- }
-
- public boolean visit(ConstructorInvocation node) {
- if (isExitPoint(node.resolveConstructorBinding())) {
- // mark this
- SimpleName name= fAST.newSimpleName("xxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 4);
- fResult.add(name);
- }
- return true;
- }
-
- public boolean visit(SuperConstructorInvocation node) {
- if (isExitPoint(node.resolveConstructorBinding())) {
- SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
- name.setSourceRange(node.getStartPosition(), 5);
- fResult.add(name);
- }
- return true;
- }
-
- private boolean isExitPoint(ITypeBinding binding) {
- if (binding == null)
- return false;
- return !isCatched(binding);
- }
-
- private boolean isExitPoint(IFunctionBinding binding) {
- if (binding == null)
- return false;
- ITypeBinding[] exceptions= binding.getExceptionTypes();
- for (int i= 0; i < exceptions.length; i++) {
- if (!isCatched(exceptions[i]))
- return true;
- }
- return false;
- }
-
- private boolean isCatched(ITypeBinding binding) {
- for (Iterator iter= fCatchedExceptions.iterator(); iter.hasNext();) {
- ITypeBinding catchException= (ITypeBinding)iter.next();
- if (catches(catchException, binding))
- return true;
- }
- return false;
- }
-
- private boolean catches(ITypeBinding catchTypeBinding, ITypeBinding throwTypeBinding) {
- while(throwTypeBinding != null) {
- if (throwTypeBinding == catchTypeBinding)
- return true;
- throwTypeBinding= throwTypeBinding.getSuperclass();
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchResultCollector.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchResultCollector.java
deleted file mode 100644
index 18bb876f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchResultCollector.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.search.FieldReferenceMatch;
-import org.eclipse.wst.jsdt.core.search.LocalVariableReferenceMatch;
-import org.eclipse.wst.jsdt.core.search.MethodReferenceMatch;
-import org.eclipse.wst.jsdt.core.search.SearchMatch;
-import org.eclipse.wst.jsdt.core.search.SearchParticipant;
-import org.eclipse.wst.jsdt.core.search.SearchRequestor;
-
-public class NewSearchResultCollector extends SearchRequestor {
- private JavaSearchResult fSearch;
- private boolean fIgnorePotentials;
-
- public NewSearchResultCollector(JavaSearchResult search, boolean ignorePotentials) {
- super();
- fSearch= search;
- fIgnorePotentials= ignorePotentials;
- }
-
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- IJavaScriptElement enclosingElement= (IJavaScriptElement) match.getElement();
- if (enclosingElement != null) {
- if (fIgnorePotentials && (match.getAccuracy() == SearchMatch.A_INACCURATE))
- return;
- boolean isWriteAccess= false;
- boolean isReadAccess= false;
- if (match instanceof FieldReferenceMatch) {
- FieldReferenceMatch fieldRef= ((FieldReferenceMatch) match);
- isWriteAccess= fieldRef.isWriteAccess();
- isReadAccess= fieldRef.isReadAccess();
- } else if (match instanceof LocalVariableReferenceMatch) {
- LocalVariableReferenceMatch localVarRef= ((LocalVariableReferenceMatch) match);
- isWriteAccess= localVarRef.isWriteAccess();
- isReadAccess= localVarRef.isReadAccess();
- }
- boolean isSuperInvocation= false;
- if (match instanceof MethodReferenceMatch) {
- MethodReferenceMatch methodRef= (MethodReferenceMatch) match;
- isSuperInvocation= methodRef.isSuperInvocation();
- }
- fSearch.addMatch(new JavaElementMatch(enclosingElement, match.getRule(), match.getOffset(), match.getLength(), match.getAccuracy(), isReadAccess, isWriteAccess, match.isInsideDocComment(), isSuperInvocation));
- }
- }
-
- public void beginReporting() {
- }
-
- public void endReporting() {
- }
-
- public void enterParticipant(SearchParticipant participant) {
- }
-
- public void exitParticipant(SearchParticipant participant) {
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchViewActionGroup.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchViewActionGroup.java
deleted file mode 100644
index d9e4995f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/NewSearchViewActionGroup.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.GenerateActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenEditorActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
-
-class NewSearchViewActionGroup extends CompositeActionGroup {
- private OpenEditorActionGroup fOpenEditorActionGroup;
-
- public NewSearchViewActionGroup(IViewPart part) {
- Assert.isNotNull(part);
- OpenViewActionGroup openViewActionGroup;
- setGroups(new ActionGroup[]{
- fOpenEditorActionGroup= new OpenEditorActionGroup(part),
- openViewActionGroup= new OpenViewActionGroup(part),
- new GenerateActionGroup(part),
- new RefactorActionGroup(part),
- new JavaSearchActionGroup(part)
- });
- openViewActionGroup.containsShowInMenu(false);
- }
-
- public void handleOpen(OpenEvent event) {
- IAction openAction= fOpenEditorActionGroup.getOpenAction();
- if (openAction != null && openAction.isEnabled()) {
- openAction.run();
- return;
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesFinder.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesFinder.java
deleted file mode 100644
index 55c2872d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesFinder.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
-import org.eclipse.wst.jsdt.core.dom.Assignment;
-import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
-import org.eclipse.wst.jsdt.core.dom.Expression;
-import org.eclipse.wst.jsdt.core.dom.FieldAccess;
-import org.eclipse.wst.jsdt.core.dom.IBinding;
-import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
-import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
-import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
-import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
-import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
-import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
-import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
-import org.eclipse.wst.jsdt.core.dom.QualifiedName;
-import org.eclipse.wst.jsdt.core.dom.SimpleName;
-import org.eclipse.wst.jsdt.core.dom.SimpleType;
-import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Type;
-import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.wst.jsdt.core.dom.PrefixExpression.Operator;
-import org.eclipse.wst.jsdt.internal.corext.dom.ASTNodes;
-import org.eclipse.wst.jsdt.internal.corext.dom.Bindings;
-import org.eclipse.wst.jsdt.internal.corext.dom.NodeFinder;
-
-public class OccurrencesFinder extends ASTVisitor implements IOccurrencesFinder {
-
- public static final String IS_WRITEACCESS= "writeAccess"; //$NON-NLS-1$
- public static final String IS_VARIABLE= "variable"; //$NON-NLS-1$
-
- private JavaScriptUnit fRoot;
- private Name fSelectedNode;
- private IBinding fTarget;
- private List fUsages= new ArrayList/*<ASTNode>*/();
- private List fWriteUsages= new ArrayList/*<ASTNode>*/();
- private boolean fTargetIsStaticMethodImport;
-
- public OccurrencesFinder(IBinding target) {
- super(true);
- fTarget= target;
- }
-
- public OccurrencesFinder() {
- super(true);
- }
-
- public String initialize(JavaScriptUnit root, int offset, int length) {
- return initialize(root, NodeFinder.perform(root, offset, length));
- }
-
- public String initialize(JavaScriptUnit root, ASTNode node) {
- if (!(node instanceof Name))
- return SearchMessages.OccurrencesFinder_no_element;
- fRoot= root;
- fSelectedNode= (Name)node;
- fTarget= fSelectedNode.resolveBinding();
- if (fTarget == null)
- return SearchMessages.OccurrencesFinder_no_binding;
- fTarget= getBindingDeclaration(fTarget);
-
- fTargetIsStaticMethodImport= isStaticImport(fSelectedNode.getParent());
- return null;
- }
-
- public List perform() {
- fRoot.accept(this);
- return fUsages;
- }
-
- public void collectOccurrenceMatches(IJavaScriptElement element, IDocument document, Collection resultingMatches) {
- boolean isVariable= fTarget instanceof IVariableBinding;
- HashMap lineToGroup= new HashMap();
-
- for (Iterator iter= fUsages.iterator(); iter.hasNext();) {
- ASTNode node= (ASTNode) iter.next();
- int startPosition= node.getStartPosition();
- int length= node.getLength();
- try {
- boolean isWriteAccess= fWriteUsages.contains(node);
- int line= document.getLineOfOffset(startPosition);
- Integer lineInteger= new Integer(line);
- OccurrencesGroupKey groupKey= (OccurrencesGroupKey) lineToGroup.get(lineInteger);
- if (groupKey == null) {
- IRegion region= document.getLineInformation(line);
- String lineContents= document.get(region.getOffset(), region.getLength()).trim();
- groupKey= new OccurrencesGroupKey(element, line, lineContents, isWriteAccess, isVariable);
- lineToGroup.put(lineInteger, groupKey);
- } else if (isWriteAccess) {
- // a line with read an write access is considered as write access:
- groupKey.setWriteAccess(true);
- }
- Match match= new Match(groupKey, startPosition, length);
- resultingMatches.add(match);
- } catch (BadLocationException e) {
- //nothing
- }
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.search.IOccurrencesFinder#getJobLabel()
- */
- public String getJobLabel() {
- return SearchMessages.OccurrencesFinder_searchfor ;
- }
-
- public String getElementName() {
- if (fSelectedNode != null) {
- return ASTNodes.asString(fSelectedNode);
- }
- return null;
- }
-
- public String getUnformattedPluralLabel() {
- return SearchMessages.OccurrencesFinder_label_plural;
- }
-
- public String getUnformattedSingularLabel() {
- return SearchMessages.OccurrencesFinder_label_singular;
- }
-
- public boolean visit(QualifiedName node) {
- final IBinding binding= node.resolveBinding();
- if (binding instanceof IVariableBinding && ((IVariableBinding)binding).isField()) {
- SimpleName name= node.getName();
- return !match(name, fUsages, name.resolveBinding());
- }
- if (binding instanceof IFunctionBinding) {
- if (isStaticImport(node)) {
- SimpleName name= node.getName();
- return !matchStaticImport(name, fUsages, (IFunctionBinding)binding);
- }
- }
- return !match(node, fUsages, binding);
- }
-
- private static boolean isStaticImport(ASTNode node) {
- if (!(node instanceof QualifiedName))
- return false;
-
- ASTNode parent= ((QualifiedName)node).getParent();
- return parent instanceof ImportDeclaration && ((ImportDeclaration)parent).isStatic();
- }
-
- public boolean visit(FunctionInvocation node) {
- if (fTargetIsStaticMethodImport)
- return !matchStaticImport(node.getName(), fUsages, node.resolveMethodBinding());
-
- return true;
- }
-
- public boolean visit(SimpleName node) {
- return !match(node, fUsages, node.resolveBinding());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#visit(org.eclipse.wst.jsdt.core.dom.ConstructorInvocation)
- */
- public boolean visit(ClassInstanceCreation node) {
- // match with the constructor and the type.
- Type type= node.getType();
- if (type!=null)
- {
- if (type instanceof ParameterizedType) {
- type= ((ParameterizedType) type).getType();
- }
- if (type instanceof SimpleType) {
- Name name= ((SimpleType) type).getName();
- if (name instanceof QualifiedName)
- name= ((QualifiedName)name).getName();
- match(name, fUsages, node.resolveConstructorBinding());
- }
-
- }
- else
- {
- Expression member = node.getMember();
- if (member instanceof SimpleName)
- {
- SimpleName name=(SimpleName)member;
- match(name,fUsages,node.resolveConstructorBinding());
- }
- }
-
- return super.visit(node);
- }
-
- public boolean visit(Assignment node) {
- Expression lhs= node.getLeftHandSide();
- SimpleName name= getSimpleName(lhs);
- if (name != null)
- match(name, fWriteUsages, name.resolveBinding());
- lhs.accept(this);
- node.getRightHandSide().accept(this);
- return false;
- }
-
- public boolean visit(SingleVariableDeclaration node) {
- match(node.getName(), fWriteUsages, node.resolveBinding());
- return super.visit(node);
- }
-
- public boolean visit(VariableDeclarationFragment node) {
- if (node.getParent().getNodeType() == ASTNode.FIELD_DECLARATION || node.getInitializer() != null)
- match(node.getName(), fWriteUsages, node.resolveBinding());
- return super.visit(node);
- }
-
- public boolean visit(PrefixExpression node) {
- PrefixExpression.Operator operator= node.getOperator();
- if (operator == Operator.INCREMENT || operator == Operator.DECREMENT) {
- Expression operand= node.getOperand();
- SimpleName name= getSimpleName(operand);
- if (name != null)
- match(name, fWriteUsages, name.resolveBinding());
- }
- return super.visit(node);
- }
-
- public boolean visit(PostfixExpression node) {
- Expression operand= node.getOperand();
- SimpleName name= getSimpleName(operand);
- if (name != null)
- match(name, fWriteUsages, name.resolveBinding());
- return super.visit(node);
- }
-
- private boolean match(Name node, List result, IBinding binding) {
- if (binding != null && Bindings.equals(getBindingDeclaration(binding), fTarget)) {
- result.add(node);
- return true;
- }
- return false;
- }
-
- private boolean matchStaticImport(Name node, List result, IFunctionBinding binding) {
- if (binding == null || node == null || !(fTarget instanceof IFunctionBinding) || !Modifier.isStatic(binding.getModifiers()))
- return false;
-
- IFunctionBinding targetMethodBinding= (IFunctionBinding)fTarget;
- if ((fTargetIsStaticMethodImport || Modifier.isStatic(targetMethodBinding.getModifiers())) && (targetMethodBinding.getDeclaringClass().getTypeDeclaration() == binding.getDeclaringClass().getTypeDeclaration())) {
- if (node.getFullyQualifiedName().equals(targetMethodBinding.getName())) {
- result.add(node);
- return true;
- }
- }
- return false;
- }
-
- private SimpleName getSimpleName(Expression expression) {
- if (expression instanceof SimpleName)
- return ((SimpleName)expression);
- else if (expression instanceof QualifiedName)
- return (((QualifiedName) expression).getName());
- else if (expression instanceof FieldAccess)
- return ((FieldAccess)expression).getName();
- return null;
- }
-
- private IBinding getBindingDeclaration(IBinding binding) {
- switch (binding.getKind()) {
- case IBinding.TYPE :
- return ((ITypeBinding)binding).getTypeDeclaration();
- case IBinding.METHOD :
- return ((IFunctionBinding)binding).getMethodDeclaration();
- case IBinding.VARIABLE :
- return ((IVariableBinding)binding).getVariableDeclaration();
- default:
- return binding;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesGroupKey.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesGroupKey.java
deleted file mode 100644
index 8aea0b5c..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesGroupKey.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-public class OccurrencesGroupKey extends JavaElementLine {
- private boolean fIsWriteAccess;
- private boolean fIsVariable;
-
- /**
- * Create a new occurrences group key.
- *
- * @param element either an IJavaScriptUnit or an IClassFile
- * @param line the line number
- * @param lineContents the line contents
- * @param isWriteAccess <code>true</code> if it groups writable occurrences
- * @param isVariable <code>true</code> if it groups variable occurrences
- */
- public OccurrencesGroupKey(IJavaScriptElement element, int line, String lineContents, boolean isWriteAccess, boolean isVariable) {
- super(element, line, lineContents);
- fIsWriteAccess= isWriteAccess;
- fIsVariable= isVariable;
- }
-
- public boolean isVariable() {
- return fIsVariable;
- }
-
- public boolean isWriteAccess() {
- return fIsWriteAccess;
- }
-
- public void setWriteAccess(boolean isWriteAccess) {
- fIsWriteAccess= isWriteAccess;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchLabelProvider.java
deleted file mode 100644
index cce21299..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchLabelProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-
-class OccurrencesSearchLabelProvider extends TextSearchLabelProvider {
-
- public OccurrencesSearchLabelProvider(AbstractTextSearchViewPage page) {
- super(page);
- }
-
- protected String doGetText(Object element) {
- JavaElementLine jel= (JavaElementLine) element;
- return jel.getLineContents().replace('\t', ' ');
- }
-
- public Image getImage(Object element) {
- if (element instanceof OccurrencesGroupKey) {
- OccurrencesGroupKey group= (OccurrencesGroupKey) element;
- if (group.isVariable()) {
- if (group.isWriteAccess())
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_WRITEACCESS);
- else
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_READACCESS);
- }
-
- } else if (element instanceof ExceptionOccurrencesGroupKey) {
- ExceptionOccurrencesGroupKey group= (ExceptionOccurrencesGroupKey) element;
- if (group.isException())
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
- }
-
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchQuery.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchQuery.java
deleted file mode 100644
index c4834a35..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchQuery.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.StatusInfo;
-
-
-public class OccurrencesSearchQuery implements ISearchQuery {
-
- private final OccurrencesSearchResult fResult;
- private IOccurrencesFinder fFinder;
- private IDocument fDocument;
- private final IJavaScriptElement fElement;
- private final String fJobLabel;
- private final String fSingularLabel;
- private final String fPluralLabel;
- private final String fName;
-
- public OccurrencesSearchQuery(IOccurrencesFinder finder, IDocument document, IJavaScriptElement element) {
- fFinder= finder;
- fDocument= document;
- fElement= element;
- fJobLabel= fFinder.getJobLabel();
- fResult= new OccurrencesSearchResult(this);
- fSingularLabel= fFinder.getUnformattedSingularLabel();
- fPluralLabel= fFinder.getUnformattedPluralLabel();
- fName= fFinder.getElementName();
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus run(IProgressMonitor monitor) {
- if (fFinder == null) {
- return new StatusInfo(IStatus.ERROR, "Query has already been running"); //$NON-NLS-1$
- }
- try {
- fFinder.perform();
- ArrayList resultingMatches= new ArrayList();
- fFinder.collectOccurrenceMatches(fElement, fDocument, resultingMatches);
- if (!resultingMatches.isEmpty()) {
- fResult.addMatches((Match[]) resultingMatches.toArray(new Match[resultingMatches.size()]));
- }
- //Don't leak AST:
- fFinder= null;
- fDocument= null;
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#getLabel()
- */
- public String getLabel() {
- return fJobLabel;
- }
-
- public String getResultLabel(int nMatches) {
- if (nMatches == 1) {
- return Messages.format(fSingularLabel, new Object[] { fName, fElement.getElementName() });
- } else {
- return Messages.format(fPluralLabel, new Object[] { fName, new Integer(nMatches), fElement.getElementName() });
- }
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#canRerun()
- */
- public boolean canRerun() {
- return false; // must release finder to not keep AST reference
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
- */
- public boolean canRunInBackground() {
- return true;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
- */
- public ISearchResult getSearchResult() {
- return fResult;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResult.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResult.java
deleted file mode 100644
index 2005ec82..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResult.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.IEditorMatchAdapter;
-import org.eclipse.search.ui.text.IFileMatchAdapter;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.IClassFileEditorInput;
-
-
-public class OccurrencesSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
-
- protected static final Match[] NO_MATCHES= new Match[0];
- private OccurrencesSearchQuery fQuery;
-
- public OccurrencesSearchResult(OccurrencesSearchQuery query) {
- fQuery= query;
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.core.resources.IFile)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
- Object[] elements= getElements();
- if (elements.length == 0)
- return NO_MATCHES;
- //all matches from same file:
- JavaElementLine jel= (JavaElementLine) elements[0];
- try {
- if (file.equals(jel.getJavaElement().getCorrespondingResource()))
- return collectMatches(elements);
- } catch (JavaScriptModelException e) {
- // no resource
- }
- return NO_MATCHES;
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.ui.IEditorPart)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
- //TODO same code in JavaSearchResult
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
- return computeContainedMatches(result, fileEditorInput.getFile());
-
- } else if (editorInput instanceof IClassFileEditorInput) {
- IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
- IClassFile classFile= classFileEditorInput.getClassFile();
-
- Object[] elements= getElements();
- if (elements.length == 0)
- return NO_MATCHES;
- //all matches from same file:
- JavaElementLine jel= (JavaElementLine) elements[0];
- if (jel.getJavaElement().equals(classFile))
- return collectMatches(elements);
- }
- return NO_MATCHES;
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- JavaElementLine jel= (JavaElementLine) element;
- IResource resource= null;
- try {
- resource= jel.getJavaElement().getCorrespondingResource();
- } catch (JavaScriptModelException e) {
- // no resource
- }
- if (resource instanceof IFile)
- return (IFile) resource;
- else
- return null;
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#isShownInEditor(org.eclipse.search.ui.text.Match, org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- Object element= match.getElement();
- IJavaScriptElement je= ((JavaElementLine) element).getJavaElement();
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- try {
- return ((IFileEditorInput)editorInput).getFile().equals(je.getCorrespondingResource());
- } catch (JavaScriptModelException e) {
- return false;
- }
- } else if (editorInput instanceof IClassFileEditorInput) {
- return ((IClassFileEditorInput)editorInput).getClassFile().equals(je);
- }
-
- return false;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getLabel()
- */
- public String getLabel() {
- return fQuery.getResultLabel(getMatchCount());
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getTooltip()
- */
- public String getTooltip() {
- return getLabel();
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return JavaPluginImages.DESC_OBJS_SEARCH_REF;
- }
-
- /*
- * @see org.eclipse.search.ui.ISearchResult#getQuery()
- */
- public ISearchQuery getQuery() {
- return fQuery;
- }
-
- public IFileMatchAdapter getFileMatchAdapter() {
- return this;
- }
-
- public IEditorMatchAdapter getEditorMatchAdapter() {
- return this;
- }
-
- private Match[] collectMatches(Object[] elements) {
- Match[] matches= new Match[getMatchCount()];
- int writeIndex= 0;
- for (int i= 0; i < elements.length; i++) {
- Match[] perElement= getMatches(elements[i]);
- for (int j= 0; j < perElement.length; j++) {
- matches[writeIndex++]= perElement[j];
- }
- }
- return matches;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResultPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResultPage.java
deleted file mode 100644
index 862875bb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OccurrencesSearchResultPage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public class OccurrencesSearchResultPage extends AbstractTextSearchViewPage {
-
- private TextSearchTableContentProvider fContentProvider;
-
- public OccurrencesSearchResultPage() {
- super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#showMatch(org.eclipse.search.ui.text.Match, int, int)
- */
- protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
- JavaElementLine element= (JavaElementLine) match.getElement();
- IJavaScriptElement javaElement= element.getJavaElement();
- try {
- IEditorPart editor= JavaScriptUI.openInEditor(javaElement, activate, false);
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor= (ITextEditor) editor;
- textEditor.selectAndReveal(currentOffset, currentLength);
- }
- } catch (PartInitException e1) {
- return;
- } catch (JavaScriptModelException e1) {
- return;
- }
-
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#elementsChanged(java.lang.Object[])
- */
- protected void elementsChanged(Object[] objects) {
- if (fContentProvider != null)
- fContentProvider.elementsChanged(objects);
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#clear()
- */
- protected void clear() {
- if (fContentProvider != null)
- fContentProvider.clear();
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTreeViewer(org.eclipse.jface.viewers.TreeViewer)
- */
- protected void configureTreeViewer(TreeViewer viewer) {
- throw new IllegalStateException("Doesn't support tree mode."); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
- */
- protected void configureTableViewer(TableViewer viewer) {
- viewer.setComparator(new ViewerComparator() {
- public int compare(Viewer v, Object e1, Object e2) {
- JavaElementLine jel1= (JavaElementLine) e1;
- JavaElementLine jel2= (JavaElementLine) e2;
- return jel1.getLine() - jel2.getLine();
- }
- });
- viewer.setLabelProvider(new OccurrencesSearchLabelProvider(this));
- fContentProvider= new TextSearchTableContentProvider();
- viewer.setContentProvider(fContentProvider);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OpenJavaSearchPageAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OpenJavaSearchPageAction.java
deleted file mode 100644
index 665b0e75..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/OpenJavaSearchPageAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-/**
- * Opens the Search Dialog and brings the Java search page to front
- */
-public class OpenJavaSearchPageAction implements IWorkbenchWindowActionDelegate {
-
- private static final String JAVA_SEARCH_PAGE_ID= "org.eclipse.wst.jsdt.ui.JavaSearchPage"; //$NON-NLS-1$
-
- private IWorkbenchWindow fWindow;
-
- public OpenJavaSearchPageAction() {
- }
-
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- public void run(IAction action) {
- if (fWindow == null || fWindow.getActivePage() == null) {
- beep();
- JavaScriptPlugin.logErrorMessage("Could not open the search dialog - for some reason the window handle was null"); //$NON-NLS-1$
- return;
- }
- NewSearchUI.openSearchDialog(fWindow, JAVA_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= JavaScriptPlugin.getActiveWorkbenchShell();
- if (shell != null && shell.getDisplay() != null)
- shell.getDisplay().beep();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PatternStrings.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PatternStrings.java
deleted file mode 100644
index cf4883e4..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PatternStrings.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class PatternStrings {
-
- public static String getSignature(IJavaScriptElement element) {
- if (element == null)
- return null;
- else
- switch (element.getElementType()) {
- case IJavaScriptElement.METHOD:
- return getMethodSignature((IFunction)element);
- case IJavaScriptElement.TYPE:
- return getTypeSignature((IType) element);
- case IJavaScriptElement.FIELD:
- return getFieldSignature((IField) element);
- default:
- return element.getElementName();
- }
- }
-
- public static String getMethodSignature(IFunction method) {
- StringBuffer buffer= new StringBuffer();
- if (method.getDeclaringType()!=null)
- {
- buffer.append(JavaScriptElementLabels.getElementLabel(
- method.getDeclaringType(),
- JavaScriptElementLabels.T_FULLY_QUALIFIED | JavaScriptElementLabels.USE_RESOLVED));
- boolean isConstructor= method.getElementName().equals(method.getDeclaringType().getElementName());
- if (!isConstructor) {
- buffer.append('.');
- }
-
- buffer.append(getUnqualifiedMethodSignature(method, !isConstructor));
-
- }
-
-
- return buffer.toString();
- }
-
- private static String getUnqualifiedMethodSignature(IFunction method, boolean includeName) {
- StringBuffer buffer= new StringBuffer();
- if (includeName) {
- buffer.append(method.getElementName());
- }
- buffer.append('(');
-
- String[] types= method.getParameterTypes();
- for (int i= 0; i < types.length; i++) {
- if (i > 0)
- buffer.append(", "); //$NON-NLS-1$
- String typeSig= Signature.toString(types[i]);
- buffer.append(typeSig);
- }
- buffer.append(')');
-
- return buffer.toString();
- }
-
- public static String getUnqualifiedMethodSignature(IFunction method) {
- return getUnqualifiedMethodSignature(method, true);
- }
-
- public static String getTypeSignature(IType field) {
- return JavaScriptElementLabels.getElementLabel(field,
- JavaScriptElementLabels.T_FULLY_QUALIFIED | JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.USE_RESOLVED);
- }
-
- public static String getFieldSignature(IField field) {
- return JavaScriptElementLabels.getElementLabel(field, JavaScriptElementLabels.F_FULLY_QUALIFIED);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PostfixLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PostfixLabelProvider.java
deleted file mode 100644
index 5749a59b..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/PostfixLabelProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredJavaElementLabels;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class PostfixLabelProvider extends SearchLabelProvider {
- private ITreeContentProvider fContentProvider;
-
- public PostfixLabelProvider(JavaSearchResultPage page) {
- super(page);
- fContentProvider= new LevelTreeContentProvider.FastJavaElementProvider();
- }
-
- public Image getImage(Object element) {
- Image image= super.getImage(element);
- if (image != null)
- return image;
- return getParticipantImage(element);
- }
-
- public String getText(Object element) {
- String labelWithCounts= getLabelWithCounts(element, internalGetText(element));
- return labelWithCounts + getQualification(element);
- }
-
- private String getQualification(Object element) {
- StringBuffer res= new StringBuffer();
-
- ITreeContentProvider provider= (ITreeContentProvider) fPage.getViewer().getContentProvider();
- Object visibleParent= provider.getParent(element);
- Object realParent= fContentProvider.getParent(element);
- Object lastElement= element;
- while (realParent != null && !(realParent instanceof IJavaScriptModel) && !realParent.equals(visibleParent)) {
- if (!isSameInformation(realParent, lastElement)) {
- res.append(JavaScriptElementLabels.CONCAT_STRING).append(internalGetText(realParent));
- }
- lastElement= realParent;
- realParent= fContentProvider.getParent(realParent);
- }
- return res.toString();
- }
-
- protected boolean hasChildren(Object element) {
- ITreeContentProvider contentProvider= (ITreeContentProvider) fPage.getViewer().getContentProvider();
- return contentProvider.hasChildren(element);
- }
-
- private String internalGetText(Object element) {
- String text= super.getText(element);
- if (text != null && text.length() > 0)
- return text;
- return getParticipantText(element);
- }
-
- private boolean isSameInformation(Object realParent, Object lastElement) {
- if (lastElement instanceof IType) {
- IType type= (IType) lastElement;
- if (realParent instanceof IClassFile) {
- if (type.getClassFile().equals(realParent))
- return true;
- } else if (realParent instanceof IJavaScriptUnit) {
- if (type.getJavaScriptUnit().equals(realParent))
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.IRichLabelProvider#getRichTextLabel(java.lang.Object)
- */
- public ColoredString getRichTextLabel(Object element) {
- ColoredString coloredString= getColoredLabelWithCounts(element, super.getRichTextLabel(element));
- coloredString.append(getQualification(element), ColoredJavaElementLabels.QUALIFIER_STYLE);
- return coloredString;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchLabelProvider.java
deleted file mode 100644
index f01b8717..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchLabelProvider.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
-import org.eclipse.wst.jsdt.core.search.SearchMatch;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredJavaElementLabels;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator;
-import org.eclipse.wst.jsdt.ui.search.IMatchPresentation;
-
-public abstract class SearchLabelProvider extends AppearanceAwareLabelProvider {
-
- public static final String PROPERTY_MATCH_COUNT= "org.eclipse.wst.jsdt.search.matchCount"; //$NON-NLS-1$
-
- // copied from SearchPreferencePage
- private static final String EMPHASIZE_POTENTIAL_MATCHES= "org.eclipse.search.potentialMatch.emphasize"; //$NON-NLS-1$
- private static final String POTENTIAL_MATCH_FG_COLOR= "org.eclipse.search.potentialMatch.fgColor"; //$NON-NLS-1$
-
- protected static final long DEFAULT_SEARCH_TEXTFLAGS= (DEFAULT_TEXTFLAGS | JavaScriptElementLabels.P_COMPRESSED) & ~JavaScriptElementLabels.M_APP_RETURNTYPE;
- protected static final int DEFAULT_SEARCH_IMAGEFLAGS= DEFAULT_IMAGEFLAGS;
-
- private Color fPotentialMatchFgColor;
- private Map fLabelProviderMap;
-
- protected JavaSearchResultPage fPage;
-
- private ScopedPreferenceStore fSearchPreferences;
- private IPropertyChangeListener fSearchPropertyListener;
-
- public SearchLabelProvider(JavaSearchResultPage page) {
- super(DEFAULT_SEARCH_TEXTFLAGS, DEFAULT_SEARCH_IMAGEFLAGS);
- addLabelDecorator(new ProblemsLabelDecorator(null));
-
- fPage= page;
- fLabelProviderMap= new HashMap(5);
-
- fSearchPreferences= new ScopedPreferenceStore(new InstanceScope(), NewSearchUI.PLUGIN_ID);
- fSearchPropertyListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doSearchPropertyChange(event);
- }
- };
- fSearchPreferences.addPropertyChangeListener(fSearchPropertyListener);
- }
-
- final void doSearchPropertyChange(PropertyChangeEvent event) {
- if (fPotentialMatchFgColor == null)
- return;
- if (POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty())) {
- fPotentialMatchFgColor.dispose();
- fPotentialMatchFgColor= null;
- LabelProviderChangedEvent lpEvent= new LabelProviderChangedEvent(SearchLabelProvider.this, null); // refresh all
- fireLabelProviderChanged(lpEvent);
- }
- }
-
- public Color getForeground(Object element) {
- if (arePotentialMatchesEmphasized()) {
- if (getNumberOfPotentialMatches(element) > 0)
- return getForegroundColor();
- }
- return super.getForeground(element);
- }
-
- private Color getForegroundColor() {
- if (fPotentialMatchFgColor == null) {
- fPotentialMatchFgColor= new Color(JavaScriptPlugin.getActiveWorkbenchShell().getDisplay(), getPotentialMatchForegroundColor());
- }
- return fPotentialMatchFgColor;
- }
-
- protected final int getNumberOfPotentialMatches(Object element) {
- int res= 0;
- AbstractTextSearchResult result= fPage.getInput();
- if (result != null) {
- Match[] matches= result.getMatches(element);
- for (int i = 0; i < matches.length; i++) {
- if ((matches[i]) instanceof JavaElementMatch) {
- if (((JavaElementMatch)matches[i]).getAccuracy() == SearchMatch.A_INACCURATE)
- res++;
- }
- }
- }
- return res;
- }
-
- protected final ColoredString getColoredLabelWithCounts(Object element, ColoredString coloredName) {
- String name= coloredName.getString();
- String decorated= getLabelWithCounts(element, name);
- if (decorated.length() > name.length()) {
- ColoredJavaElementLabels.decorateColoredString(coloredName, decorated, ColoredJavaElementLabels.COUNTER_STYLE);
- }
- return coloredName;
- }
-
- protected final String getLabelWithCounts(Object element, String elementName) {
- int matchCount= fPage.getDisplayedMatchCount(element);
- int potentialCount= getNumberOfPotentialMatches(element);
-
- if (matchCount < 2) {
- if (matchCount == 1 && hasChildren(element)) {
- if (potentialCount > 0)
- return Messages.format(SearchMessages.SearchLabelProvider_potential_singular, elementName);
- return Messages.format(SearchMessages.SearchLabelProvider_exact_singular, elementName);
- }
- if (potentialCount > 0)
- return Messages.format(SearchMessages.SearchLabelProvider_potential_noCount, elementName);
- return Messages.format(SearchMessages.SearchLabelProvider_exact_noCount, elementName);
- } else {
- int exactCount= matchCount - potentialCount;
-
- if (potentialCount > 0 && exactCount > 0) {
- String[] args= new String[] { elementName, String.valueOf(matchCount), String.valueOf(exactCount), String.valueOf(potentialCount) };
- return Messages.format(SearchMessages.SearchLabelProvider_exact_and_potential_plural, args);
- } else if (exactCount == 0) {
- String[] args= new String[] { elementName, String.valueOf(matchCount) };
- return Messages.format(SearchMessages.SearchLabelProvider_potential_plural, args);
- }
- String[] args= new String[] { elementName, String.valueOf(matchCount) };
- return Messages.format(SearchMessages.SearchLabelProvider_exact_plural, args);
- }
- }
-
- protected boolean hasChildren(Object elem) {
- return false;
- }
-
- public void dispose() {
- if (fPotentialMatchFgColor != null) {
- fPotentialMatchFgColor.dispose();
- fPotentialMatchFgColor= null;
- }
- fSearchPreferences.removePropertyChangeListener(fSearchPropertyListener);
- for (Iterator labelProviders = fLabelProviderMap.values().iterator(); labelProviders.hasNext();) {
- ILabelProvider labelProvider = (ILabelProvider) labelProviders.next();
- labelProvider.dispose();
- }
- fSearchPreferences= null;
- fSearchPropertyListener= null;
- fLabelProviderMap.clear();
-
- super.dispose();
- }
-
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- for (Iterator labelProviders = fLabelProviderMap.values().iterator(); labelProviders.hasNext();) {
- ILabelProvider labelProvider = (ILabelProvider) labelProviders.next();
- labelProvider.addListener(listener);
- }
- }
-
- public boolean isLabelProperty(Object element, String property) {
- if (PROPERTY_MATCH_COUNT.equals(property))
- return true;
- return getLabelProvider(element).isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- for (Iterator labelProviders = fLabelProviderMap.values().iterator(); labelProviders.hasNext();) {
- ILabelProvider labelProvider = (ILabelProvider) labelProviders.next();
- labelProvider.removeListener(listener);
- }
- }
-
- protected String getParticipantText(Object element) {
- ILabelProvider labelProvider= getLabelProvider(element);
- if (labelProvider != null)
- return labelProvider.getText(element);
- return ""; //$NON-NLS-1$
-
- }
-
- protected Image getParticipantImage(Object element) {
- ILabelProvider lp= getLabelProvider(element);
- if (lp == null)
- return null;
- return lp.getImage(element);
- }
-
-
- private ILabelProvider getLabelProvider(Object element) {
- IMatchPresentation participant= ((JavaSearchResult) fPage.getInput()).getSearchParticpant(element);
- if (participant == null)
- return null;
-
- ILabelProvider lp= (ILabelProvider) fLabelProviderMap.get(participant);
- if (lp == null) {
- lp= participant.createLabelProvider();
- fLabelProviderMap.put(participant, lp);
-
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- lp.addListener((ILabelProviderListener) listeners[i]);
- }
- }
- return lp;
- }
-
- private boolean arePotentialMatchesEmphasized() {
- return fSearchPreferences.getBoolean(EMPHASIZE_POTENTIAL_MATCHES);
- }
-
- private RGB getPotentialMatchForegroundColor() {
- return PreferenceConverter.getColor(fSearchPreferences, POTENTIAL_MATCH_FG_COLOR);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.java
deleted file mode 100644
index 0808b063..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class SearchMessages extends NLS {
-
- private static final String BUNDLE_NAME= "org.eclipse.wst.jsdt.internal.ui.search.SearchMessages";//$NON-NLS-1$
-
- private SearchMessages() {
- // Do not instantiate
- }
-
- public static String JavaSearchResultPage_preferences_label;
- public static String JavaSearchScopeFactory_undefined_projects;
- public static String JavaSearchScopeFactory_undefined_selection;
- public static String JavaSearchScopeFactory_undefined_workingsets;
- public static String MatchFilter_DeprecatedFilter_actionLabel;
- public static String MatchFilter_DeprecatedFilter_description;
- public static String MatchFilter_DeprecatedFilter_name;
- public static String MatchFilter_NonDeprecatedFilter_actionLabel;
- public static String MatchFilter_NonDeprecatedFilter_description;
- public static String MatchFilter_NonDeprecatedFilter_name;
- public static String MatchFilter_NonPublicFilter_actionLabel;
- public static String MatchFilter_NonPublicFilter_description;
- public static String MatchFilter_NonPublicFilter_name;
- public static String MatchFilter_NonStaticFilter_actionLabel;
- public static String MatchFilter_NonStaticFilter_description;
- public static String MatchFilter_NonStaticFilter_name;
- public static String MatchFilter_StaticFilter_actionLabel;
- public static String MatchFilter_StaticFilter_description;
- public static String MatchFilter_StaticFilter_name;
- public static String SearchLabelProvider_exact_singular;
- public static String SearchLabelProvider_exact_noCount;
- public static String SearchLabelProvider_exact_and_potential_plural;
- public static String SearchLabelProvider_potential_singular;
- public static String SearchLabelProvider_potential_noCount;
- public static String SearchLabelProvider_potential_plural;
- public static String SearchLabelProvider_exact_plural;
- public static String group_search;
- public static String group_declarations;
- public static String group_references;
- public static String group_readReferences;
- public static String group_writeReferences;
- public static String group_implementors;
- public static String group_occurrences;
- public static String group_occurrences_quickMenu_noEntriesAvailable;
- public static String Search_Error_search_title;
- public static String Search_Error_search_message;
- public static String Search_Error_search_notsuccessful_message;
- public static String Search_Error_javaElementAccess_title;
- public static String Search_Error_javaElementAccess_message;
- public static String Search_Error_search_notsuccessful_title;
- public static String Search_Error_openEditor_title;
- public static String Search_Error_openEditor_message;
- public static String Search_Error_codeResolve;
- public static String SearchElementSelectionDialog_title;
- public static String SearchElementSelectionDialog_message;
- public static String SearchPage_searchFor_label;
- public static String SearchPage_searchFor_type;
- public static String SearchPage_searchFor_method;
- public static String SearchPage_searchFor_function;
- public static String SearchPage_searchFor_var;
- public static String SearchPage_searchFor_field;
- public static String SearchPage_searchFor_constructor;
- public static String SearchPage_limitTo_label;
- public static String SearchPage_limitTo_declarations;
- public static String SearchPage_limitTo_references;
- public static String SearchPage_limitTo_allOccurrences;
- public static String SearchPage_limitTo_readReferences;
- public static String SearchPage_limitTo_writeReferences;
- public static String SearchPage_expression_label;
- public static String SearchPage_expression_caseSensitive;
- public static String SearchPage_searchIn_jre;
- public static String SearchPage_searchIn_label;
- public static String SearchPage_searchIn_libraries;
- public static String SearchPage_searchIn_projects;
- public static String SearchPage_searchIn_sources;
- public static String SearchUtil_workingSetConcatenation;
- public static String Search_FindDeclarationAction_label;
- public static String Search_FindDeclarationAction_tooltip;
- public static String Search_FindDeclarationsInProjectAction_label;
- public static String Search_FindDeclarationsInProjectAction_tooltip;
- public static String Search_FindDeclarationsInWorkingSetAction_label;
- public static String Search_FindDeclarationsInWorkingSetAction_tooltip;
- public static String Search_FindHierarchyDeclarationsAction_label;
- public static String Search_FindHierarchyDeclarationsAction_tooltip;
- public static String Search_FindImplementorsAction_label;
- public static String Search_FindImplementorsAction_tooltip;
- public static String Search_FindImplementorsInProjectAction_label;
- public static String Search_FindImplementorsInProjectAction_tooltip;
- public static String Search_FindImplementorsInWorkingSetAction_label;
- public static String Search_FindImplementorsInWorkingSetAction_tooltip;
- public static String Search_FindReferencesAction_label;
- public static String Search_FindReferencesAction_tooltip;
- public static String Search_FindReferencesAction_BinPrimConstWarnDialog_title;
- public static String Search_FindReferencesAction_BinPrimConstWarnDialog_message;
- public static String Search_FindReferencesInProjectAction_label;
- public static String Search_FindReferencesInProjectAction_tooltip;
- public static String Search_FindReferencesInWorkingSetAction_label;
- public static String Search_FindReferencesInWorkingSetAction_tooltip;
- public static String Search_FindHierarchyReferencesAction_label;
- public static String Search_FindHierarchyReferencesAction_tooltip;
- public static String Search_FindReadReferencesAction_label;
- public static String Search_FindReadReferencesAction_tooltip;
- public static String Search_FindReadReferencesInProjectAction_label;
- public static String Search_FindReadReferencesInProjectAction_tooltip;
- public static String Search_FindReadReferencesInWorkingSetAction_label;
- public static String Search_FindReadReferencesInWorkingSetAction_tooltip;
- public static String Search_FindReadReferencesInHierarchyAction_label;
- public static String Search_FindReadReferencesInHierarchyAction_tooltip;
- public static String Search_FindWriteReferencesAction_label;
- public static String Search_FindWriteReferencesAction_tooltip;
- public static String Search_FindWriteReferencesInProjectAction_label;
- public static String Search_FindWriteReferencesInProjectAction_tooltip;
- public static String Search_FindWriteReferencesInWorkingSetAction_label;
- public static String Search_FindWriteReferencesInWorkingSetAction_tooltip;
- public static String Search_FindWriteReferencesInHierarchyAction_label;
- public static String Search_FindWriteReferencesInHierarchyAction_tooltip;
- public static String Search_FindOccurrencesInFile_shortLabel;
- public static String Search_FindOccurrencesInFile_label;
- public static String Search_FindOccurrencesInFile_tooltip;
- public static String FindOccurrencesEngine_noSource_text;
- public static String FindOccurrencesEngine_cannotParse_text;
- public static String OccurrencesFinder_no_element;
- public static String OccurrencesFinder_no_binding;
- public static String OccurrencesFinder_searchfor;
- public static String OccurrencesFinder_label_singular;
- public static String OccurrencesFinder_label_plural;
- public static String ExceptionOccurrencesFinder_no_exception;
- public static String ExceptionOccurrencesFinder_searchfor;
- public static String ExceptionOccurrencesFinder_label_singular;
- public static String ExceptionOccurrencesFinder_label_plural;
- public static String ImplementOccurrencesFinder_invalidTarget;
- public static String ImplementOccurrencesFinder_searchfor;
- public static String ImplementOccurrencesFinder_label_singular;
- public static String ImplementOccurrencesFinder_label_plural;
- public static String JavaSearchOperation_singularDeclarationsPostfix;
- public static String JavaSearchOperation_singularReferencesPostfix;
- public static String JavaSearchOperation_singularReadReferencesPostfix;
- public static String JavaSearchOperation_singularWriteReferencesPostfix;
- public static String JavaSearchOperation_singularImplementorsPostfix;
- public static String JavaSearchOperation_singularOccurrencesPostfix;
- public static String JavaSearchOperation_pluralDeclarationsPostfix;
- public static String JavaSearchOperation_pluralReferencesPostfix;
- public static String JavaSearchOperation_pluralReadReferencesPostfix;
- public static String JavaSearchOperation_pluralWriteReferencesPostfix;
- public static String JavaSearchOperation_pluralImplementorsPostfix;
- public static String JavaSearchOperation_pluralOccurrencesPostfix;
- public static String JavaElementAction_typeSelectionDialog_title;
- public static String JavaElementAction_typeSelectionDialog_message;
- public static String JavaElementAction_error_open_message;
- public static String JavaElementAction_operationUnavailable_title;
- public static String JavaElementAction_operationUnavailable_generic;
- public static String JavaElementAction_operationUnavailable_field;
- public static String JavaElementAction_operationUnavailable_interface;
- public static String WorkspaceScope;
- public static String WorkspaceScopeNoJRE;
- public static String SingleWorkingSetScope;
- public static String SingleWorkingSetScopeNoJRE;
- public static String DoubleWorkingSetScope;
- public static String DoubleWorkingSetScopeNoJRE;
- public static String WorkingSetsScope;
- public static String WorkingSetsScopeNoJRE;
-
- public static String SelectionScope;
- public static String SelectionScopeNoJRE;
- public static String SingleSelectionScope;
- public static String SingleSelectionScopeNoJRE;
- public static String DoubleSelectionScope;
- public static String DoubleSelectionScopeNoJRE;
- public static String EnclosingProjectsScope;
- public static String EnclosingProjectsScopeNoJRE;
- public static String EnclosingProjectsScope2;
- public static String EnclosingProjectsScope2NoJRE;
- public static String EnclosingProjectScope;
- public static String EnclosingProjectScopeNoJRE;
- public static String ProjectScope;
- public static String ProjectScopeNoJRE;
- public static String HierarchyScope;
- public static String JavaSearchResultPage_sortByName;
- public static String JavaSearchResultPage_sortByPath;
- public static String JavaSearchResultPage_open_editor_error_title;
- public static String JavaSearchResultPage_open_editor_error_message;
- public static String JavaSearchResultPage_sortByParentName;
- public static String JavaSearchResultPage_filtered_message;
- public static String JavaSearchResultPage_sortBylabel;
- public static String JavaSearchResultPage_error_marker;
- public static String JavaSearchResultPage_groupby_project;
- public static String JavaSearchResultPage_groupby_project_tooltip;
- public static String JavaSearchResultPage_groupby_package;
- public static String JavaSearchResultPage_groupby_package_tooltip;
- public static String JavaSearchResultPage_filteredWithCount_message;
- public static String JavaSearchResultPage_groupby_file;
- public static String JavaSearchResultPage_groupby_file_tooltip;
- public static String JavaSearchResultPage_groupby_type;
- public static String JavaSearchResultPage_groupby_type_tooltip;
- public static String JavaSearchQuery_task_label;
- public static String JavaSearchQuery_label;
- public static String JavaSearchQuery_error_unsupported_pattern;
- public static String JavaSearchQuery_status_ok_message;
- public static String JavaSearchQuery_error_participant_estimate;
- public static String JavaSearchQuery_error_participant_search;
- public static String SearchParticipant_error_noID;
- public static String SearchParticipant_error_noNature;
- public static String SearchParticipant_error_noClass;
- public static String SearchParticipant_error_classCast;
- public static String MatchFilter_ImportFilter_name;
- public static String MatchFilter_ImportFilter_actionLabel;
- public static String MatchFilter_ImportFilter_description;
- public static String MatchFilter_WriteFilter_name;
- public static String MatchFilter_WriteFilter_actionLabel;
- public static String MatchFilter_WriteFilter_description;
- public static String MatchFilter_ReadFilter_name;
- public static String MatchFilter_ReadFilter_actionLabel;
- public static String MatchFilter_ReadFilter_description;
- public static String MatchFilter_JavadocFilter_name;
- public static String MatchFilter_JavadocFilter_actionLabel;
- public static String MatchFilter_JavadocFilter_description;
- public static String MatchFilter_PolymorphicFilter_name;
- public static String MatchFilter_PolymorphicFilter_actionLabel;
- public static String MatchFilter_PolymorphicFilter_description;
- public static String MatchFilter_ErasureFilter_name;
- public static String MatchFilter_ErasureFilter_actionLabel;
- public static String MatchFilter_ErasureFilter_description;
- public static String MatchFilter_InexactFilter_name;
- public static String MatchFilter_InexactFilter_actionLabel;
- public static String MatchFilter_InexactFilter_description;
- public static String MethodExitsFinder_no_return_type_selected;
- public static String BreakContinueTargetFinder_cannot_highlight;
- public static String BreakContinueTargetFinder_no_break_or_continue_selected;
- public static String TextSearchLabelProvider_matchCountFormat;
- static {
- NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class);
- }
-
- public static String JavaSearchQuery_error_element_does_not_exist;
- public static String MatchFilter_PotentialFilter_name;
- public static String MatchFilter_PotentialFilter_actionLabel;
- public static String MatchFilter_PotentialFilter_description;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.properties
deleted file mode 100644
index 1f8c144a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchMessages.properties
+++ /dev/null
@@ -1,312 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-SearchLabelProvider_exact_singular={0} (1 match)
-SearchLabelProvider_exact_noCount={0}
-SearchLabelProvider_exact_and_potential_plural={0} ({1} matches: {2} exact, {3} potential)
-SearchLabelProvider_potential_singular={0} (potential match)
-SearchLabelProvider_potential_noCount={0} (potential match)
-SearchLabelProvider_potential_plural={0} ({1} potential matches)
-SearchLabelProvider_exact_plural={0} ({1} matches)
-
-group_search=S&earch
-group_declarations= Dec&larations
-group_references= Re&ferences
-group_readReferences= &Read Access
-group_writeReferences= &Write Access
-group_implementors= &Implementors
-group_occurrences= Occurre&nces in File
-group_occurrences_quickMenu_noEntriesAvailable= <no entries available>
-
-Search_Error_search_title=Search Error
-Search_Error_search_message=The search operation has reported problems
-Search_Error_search_notsuccessful_message=The search operation has reported problems
-Search_Error_javaElementAccess_title=Search Error
-Search_Error_javaElementAccess_message=An error occurred while accessing a JavaScript element
-
-Search_Error_search_notsuccessful_title=Search
-
-Search_Error_openEditor_title=Search Error
-Search_Error_openEditor_message=Could not open the editor
-
-Search_Error_codeResolve= Code resolve error
-
-SearchElementSelectionDialog_title=Search
-SearchElementSelectionDialog_message=Select the element to search for.
-
-SearchPage_searchFor_label= Search For
-SearchPage_searchFor_type= &Type
-SearchPage_searchIn_label=Search In
-SearchPage_searchIn_jre=Browser libraries
-SearchPage_searchFor_method= &Method
-SearchPage_searchFor_function= Fu&nction
-SearchPage_searchIn_sources=Sourc&es
-SearchPage_searchFor_field= &Field
-SearchPage_searchFor_var= &Var
-SearchPage_searchIn_projects=Re&quired projects
-SearchPage_searchIn_libraries=Applicatio&n libraries
-SearchPage_searchFor_constructor= Constr&uctor
-
-SearchPage_limitTo_label= Limit To
-SearchPage_limitTo_declarations= Dec&larations
-SearchPage_limitTo_references= &References
-SearchPage_limitTo_allOccurrences= All &occurrences
-SearchPage_limitTo_readReferences= Read a&ccesses
-SearchPage_limitTo_writeReferences= Wr&ite accesses
-
-SearchPage_expression_label= Se&arch string (* = any string, ? = any character):
-SearchPage_expression_caseSensitive= Case sensiti&ve
-
-
-# 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_FindDeclarationsInProjectAction_label= &Project
-Search_FindDeclarationsInProjectAction_tooltip= Search for Declarations of the Selected Element in Resources in the Enclosing Project of the Selected Element
-
-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_FindImplementorsInProjectAction_label= &Project
-Search_FindImplementorsInProjectAction_tooltip= Search for Implementors of the Selected Interface in Resources in the Enclosing Project of the Selected Element
-
-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_FindReferencesInProjectAction_label= &Project
-Search_FindReferencesInProjectAction_tooltip= Search for References to the Selected Element in Resources in the Enclosing Project of the Selected Element
-
-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_FindReadReferencesInProjectAction_label= &Project
-Search_FindReadReferencesInProjectAction_tooltip= Search for Read References to the Selected Element in Resources in the Enclosing Project of the Selected Element
-
-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_FindWriteReferencesInProjectAction_label= &Project
-Search_FindWriteReferencesInProjectAction_tooltip= Search for Write References to the Selected Element in Resources in the Enclosing Project of the Selected Element
-
-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_shortLabel= &Identifier
-Search_FindOccurrencesInFile_label= I&dentifiers in File
-Search_FindOccurrencesInFile_tooltip= Find Occurrences of the Selected Element in the Editor
-
-FindOccurrencesEngine_noSource_text= No source available. To perform this operation you need to attach source.
-FindOccurrencesEngine_cannotParse_text= Cannot analyze the JavaScript file or class file.
-
-OccurrencesFinder_no_element= Cannot search for the current selection. Please select a valid JavaScript element name.
-OccurrencesFinder_no_binding= Selected JavaScript element is unknown.
-OccurrencesFinder_searchfor=Search for Occurrences in File
-# The first argument will be replaced by the element name and the second one by the file name
-OccurrencesFinder_label_singular=''{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
-OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
-
-ExceptionOccurrencesFinder_no_exception= Cannot search for current selection. Please select an exception.
-ExceptionOccurrencesFinder_searchfor= Search for Exception Occurrences
-
-# The first argument will be replaced by the element name and the second one by the file name
-ExceptionOccurrencesFinder_label_singular=''{0}'' - 1 exception 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
-ExceptionOccurrencesFinder_label_plural=''{0}'' - {1} exception occurrences in ''{2}''
-
-ImplementOccurrencesFinder_invalidTarget= Cannot search for current selection. Please select a type behind 'implements' or 'extends'.
-ImplementOccurrencesFinder_searchfor= Search for Implement Occurrences
-
-# The first argument will be replaced by the element name and the second one by the file name
-ImplementOccurrencesFinder_label_singular=''{0}'' - 1 implement 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
-ImplementOccurrencesFinder_label_plural=''{0}'' - {1} implement occurrences in ''{2}''
-
-
-# The first argument will be replaced by the pattern and the second by the scope
-JavaSearchOperation_singularDeclarationsPostfix=''{0}'' - 1 declaration in {1}
-JavaSearchOperation_singularReferencesPostfix=''{0}'' - 1 reference in {1}
-JavaSearchOperation_singularReadReferencesPostfix=''{0}'' - 1 read reference in {1}
-JavaSearchOperation_singularWriteReferencesPostfix=''{0}'' - 1 write reference in {1}
-JavaSearchOperation_singularImplementorsPostfix=''{0}'' - 1 implementor in {1}
-JavaSearchOperation_singularOccurrencesPostfix=''{0}'' - 1 occurrence in {1}
-
-JavaSearchOperation_pluralDeclarationsPostfix=''{0}'' - {1} declarations in {2}
-JavaSearchOperation_pluralReferencesPostfix=''{0}'' - {1} references in {2}
-JavaSearchOperation_pluralReadReferencesPostfix=''{0}'' - {1} read references in {2}
-JavaSearchOperation_pluralWriteReferencesPostfix=''{0}'' - {1} write references in {2}
-JavaSearchOperation_pluralImplementorsPostfix=''{0}'' - {1} implementors in {2}
-JavaSearchOperation_pluralOccurrencesPostfix=''{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 JavaScript element name.
-JavaElementAction_operationUnavailable_field= The operation is unavailable on the current selection. Please select the name of a field or local variable.
-JavaElementAction_operationUnavailable_interface= The operation is unavailable on the current selection. Please select the name of an interface.
-
-WorkspaceScope= workspace
-WorkspaceScopeNoJRE= workspace (no Browser Library)
-
-SingleWorkingSetScope= working set ''{0}''
-SingleWorkingSetScopeNoJRE= working set ''{0}'' (no Browser Library)
-DoubleWorkingSetScope= working sets ''{0}'', ''{1}''
-DoubleWorkingSetScopeNoJRE= working set ''{0}'', ''{1}'' (no Browser Library)
-WorkingSetsScope= working set ''{0}'', ''{1}'', ...
-WorkingSetsScopeNoJRE= working set ''{0}'', ''{1}'', ... (no Browser Library)
-
-SingleSelectionScope= ''{0}''
-SingleSelectionScopeNoJRE= ''{0}'' (no Browser Library)
-DoubleSelectionScope= ''{0}'', ''{1}''
-DoubleSelectionScopeNoJRE= ''{0}'', ''{1}'' (no Browser Library)
-SelectionScope= ''{0}'', ''{1}'', ...
-SelectionScopeNoJRE= ''{0}'', ''{1}'', ... (no Browser Library)
-
-EnclosingProjectsScope=projects ''{0}'', ''{1}'', ...
-EnclosingProjectsScopeNoJRE=projects ''{0}'', ''{1}'', ... (no Browser Library)
-EnclosingProjectScope=project ''{0}''
-EnclosingProjectScopeNoJRE=project ''{0}'' (no Browser Library)
-EnclosingProjectsScope2=projects ''{0}'', ''{1}''
-EnclosingProjectsScope2NoJRE=projects ''{0}'', ''{1}'' (no Browser Library)
-
-ProjectScope= project ''{0}''
-ProjectScopeNoJRE= project ''{0}'' (no Browser Library)
-HierarchyScope= hierarchy of ''{0}''
-
-JavaSearchResultPage_sortByName=Name
-JavaSearchResultPage_sortByPath=Path
-JavaSearchResultPage_open_editor_error_title=Open Element
-JavaSearchResultPage_open_editor_error_message=Opening element failed.
-JavaSearchResultPage_sortByParentName=Parent Name
-JavaSearchResultPage_filtered_message={0} (Filtered)
-JavaSearchResultPage_preferences_label=Preferences...
-JavaSearchResultPage_sortBylabel=Sort By
-JavaSearchResultPage_error_marker=Could not create marker
-
-JavaSearchResultPage_groupby_project=Project
-JavaSearchResultPage_groupby_project_tooltip=Group by Project
-JavaSearchResultPage_groupby_package=Namespace
-JavaSearchResultPage_groupby_package_tooltip=Group by NameSpace
-JavaSearchResultPage_filteredWithCount_message={0} ({1} matches filtered from view)
-JavaSearchResultPage_groupby_file=File
-JavaSearchResultPage_groupby_file_tooltip=Group by File
-JavaSearchResultPage_groupby_type=Type
-JavaSearchResultPage_groupby_type_tooltip=Group by Type
-
-JavaSearchQuery_task_label=Searching for ''{0}''...
-JavaSearchQuery_label=JavaScript Search
-JavaSearchQuery_error_unsupported_pattern=Unsupported search pattern: "{0}"
-JavaSearchScopeFactory_undefined_projects=empty scope
-JavaSearchQuery_status_ok_message=Found {0} matches.
-
-JavaSearchQuery_error_participant_estimate=An error occurred while estimating progress data
-JavaSearchScopeFactory_undefined_selection=empty scope
-JavaSearchQuery_error_element_does_not_exist=Element ''{0}'' does not exist anymore
-JavaSearchScopeFactory_undefined_workingsets=empty scope
-JavaSearchQuery_error_participant_search=An error occurred during participant search
-
-SearchParticipant_error_noID=Missing id attribute on search participant extension {0}
-SearchParticipant_error_noNature=Missing nature attribute on search participant {0}
-SearchParticipant_error_noClass=Missing class attribute on search participant {0}
-SearchParticipant_error_classCast=Search participant doesn't implement IQueryParticipant
-
-
-MatchFilter_ImportFilter_name=In imports
-MatchFilter_ImportFilter_actionLabel=In &Imports
-MatchFilter_ImportFilter_description=Filters matches that are in import statements
-
-
-MatchFilter_WriteFilter_name=Writes
-MatchFilter_WriteFilter_actionLabel=&Writes
-MatchFilter_WriteFilter_description=Filters matches that are write accesses
-
-MatchFilter_ReadFilter_name=Reads
-MatchFilter_ReadFilter_actionLabel=&Reads
-MatchFilter_ReadFilter_description=Filters matches that are not write accesses
-
-MatchFilter_JavadocFilter_name=In JsDoc
-MatchFilter_JavadocFilter_actionLabel=In &JsDoc
-MatchFilter_JavadocFilter_description=Filters matches that are inside JsDoc comments
-
-MatchFilter_PolymorphicFilter_name=References to overridden
-MatchFilter_PolymorphicFilter_actionLabel=References to &Overridden
-MatchFilter_PolymorphicFilter_description=Filters references to methods that are declared in a supertype. Calling these methods may or may not invoke the search target at run time.
-
-MatchFilter_ErasureFilter_name=Incompatible type arguments
-MatchFilter_ErasureFilter_actionLabel=In&compatible Type Arguments
-MatchFilter_ErasureFilter_description=Filters parameterized type matches that are not assignment compatible with the search pattern
-
-MatchFilter_InexactFilter_name=Inexact type arguments
-MatchFilter_InexactFilter_actionLabel=Ine&xact Type Arguments
-MatchFilter_InexactFilter_description=Filters parameterized type matches where the type arguments don't exactly match the search pattern's type arguments
-
-MatchFilter_PotentialFilter_name=Potential matches
-MatchFilter_PotentialFilter_actionLabel=&Potential matches
-MatchFilter_PotentialFilter_description=Filters potential matches (usually due to a problem with the include path).
-
-MatchFilter_NonPublicFilter_name=In non-public
-MatchFilter_NonPublicFilter_actionLabel=In &Non-Public
-MatchFilter_NonPublicFilter_description=Filters matches that are inside non-public members
-
-MatchFilter_StaticFilter_name=In static
-MatchFilter_StaticFilter_actionLabel=In &Static
-MatchFilter_StaticFilter_description=Filters matches that are inside static members
-
-MatchFilter_NonStaticFilter_name=In non-static
-MatchFilter_NonStaticFilter_actionLabel=In Non-St&atic
-MatchFilter_NonStaticFilter_description=Filters matches that are inside non-static members
-
-MatchFilter_DeprecatedFilter_name=In deprecated
-MatchFilter_DeprecatedFilter_actionLabel=In &Deprecated
-MatchFilter_DeprecatedFilter_description=Filters matches that are inside deprecated members
-
-MatchFilter_NonDeprecatedFilter_name=In non-deprecated
-MatchFilter_NonDeprecatedFilter_actionLabel=In Non-Dep&recated
-MatchFilter_NonDeprecatedFilter_description=Filters matches that are inside non-deprecated members
-
-MethodExitsFinder_no_return_type_selected=No return type selected
-
-BreakContinueTargetFinder_cannot_highlight=Occurrences in this element cannot be highlighted
-BreakContinueTargetFinder_no_break_or_continue_selected=No break or continue selected
-
-TextSearchLabelProvider_matchCountFormat={0} ({1} matches)
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantDescriptor.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantDescriptor.java
deleted file mode 100644
index 26b508a5..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantDescriptor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.ui.search.IQueryParticipant;
-
-/**
- */
-public class SearchParticipantDescriptor {
- private static final String CLASS= "class"; //$NON-NLS-1$
- private static final String NATURE= "nature"; //$NON-NLS-1$
- private static final String ID= "id"; //$NON-NLS-1$
-
- private IConfigurationElement fConfigurationElement;
- private boolean fEnabled; //
-
- protected SearchParticipantDescriptor(IConfigurationElement configElement) {
- fConfigurationElement= configElement;
- fEnabled= true;
- }
-
- /**
- * checks whether a participant has all the proper attributes.
- *
- * @return returns a status describing the result of the validation
- */
- protected IStatus checkSyntax() {
- if (fConfigurationElement.getAttribute(ID) == null) {
- String format= SearchMessages.SearchParticipant_error_noID;
- String message= Messages.format(format, new String[] { fConfigurationElement.getDeclaringExtension().getUniqueIdentifier() });
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, message, null);
- }
- if (fConfigurationElement.getAttribute(NATURE) == null) {
- String format= SearchMessages.SearchParticipant_error_noNature;
- String message= Messages.format(format, new String[] { fConfigurationElement.getAttribute(ID)});
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, message, null);
- }
-
- if (fConfigurationElement.getAttribute(CLASS) == null) {
- String format= SearchMessages.SearchParticipant_error_noClass;
- String message= Messages.format(format, new String[] { fConfigurationElement.getAttribute(ID)});
- return new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, message, null);
- }
- return Status.OK_STATUS;
- }
-
- public String getID() {
- return fConfigurationElement.getAttribute(ID);
- }
-
- public void disable() {
- fEnabled= false;
- }
-
- public boolean isEnabled() {
- return fEnabled;
- }
-
- protected IQueryParticipant create() throws CoreException {
- try {
- return (IQueryParticipant) fConfigurationElement.createExecutableExtension(CLASS);
- } catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR, JavaScriptPlugin.getPluginId(), 0, SearchMessages.SearchParticipant_error_classCast, e));
- }
- }
-
- protected String getNature() {
- return fConfigurationElement.getAttribute(NATURE);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantRecord.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantRecord.java
deleted file mode 100644
index 27823bd8..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantRecord.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.wst.jsdt.ui.search.IQueryParticipant;
-
-/**
- */
-public class SearchParticipantRecord {
- private SearchParticipantDescriptor fDescriptor;
- private IQueryParticipant fParticipant;
-
- public SearchParticipantRecord(SearchParticipantDescriptor descriptor, IQueryParticipant participant) {
- super();
- fDescriptor= descriptor;
- fParticipant= participant;
- }
- /**
- * @return Returns the descriptor.
- */
- public SearchParticipantDescriptor getDescriptor() {
- return fDescriptor;
- }
- /**
- * @return Returns the participant.
- */
- public IQueryParticipant getParticipant() {
- return fParticipant;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantsExtensionPoint.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantsExtensionPoint.java
deleted file mode 100644
index 3c5e4d26..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchParticipantsExtensionPoint.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 13, 2004
- *
- * TODO To change the template for this generated file go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-public class SearchParticipantsExtensionPoint {
-
- private Set fActiveParticipants= null;
- private static SearchParticipantsExtensionPoint fgInstance;
-
- public boolean hasAnyParticipants() {
- return Platform.getExtensionRegistry().getConfigurationElementsFor(JavaSearchPage.PARTICIPANT_EXTENSION_POINT).length > 0;
- }
-
- private synchronized Set getAllParticipants() {
- if (fActiveParticipants != null)
- return fActiveParticipants;
- IConfigurationElement[] allParticipants= Platform.getExtensionRegistry().getConfigurationElementsFor(JavaSearchPage.PARTICIPANT_EXTENSION_POINT);
- fActiveParticipants= new HashSet(allParticipants.length);
- for (int i= 0; i < allParticipants.length; i++) {
- SearchParticipantDescriptor descriptor= new SearchParticipantDescriptor(allParticipants[i]);
- IStatus status= descriptor.checkSyntax();
- if (status.isOK()) {
- fActiveParticipants.add(descriptor);
- } else {
- JavaScriptPlugin.log(status);
- }
- }
- return fActiveParticipants;
- }
-
- private void collectParticipants(Set participants, IProject[] projects) {
- Iterator activeParticipants= getAllParticipants().iterator();
- Set seenParticipants= new HashSet();
- while (activeParticipants.hasNext()) {
- SearchParticipantDescriptor participant= (SearchParticipantDescriptor) activeParticipants.next();
- if (participant.isEnabled()) {
- String id= participant.getID();
- for (int i= 0; i < projects.length; i++) {
- if (seenParticipants.contains(id))
- continue;
- try {
- if (projects[i].hasNature(participant.getNature())) {
- participants.add(new SearchParticipantRecord(participant, participant.create()));
- seenParticipants.add(id);
- }
- } catch (CoreException e) {
- JavaScriptPlugin.log(e.getStatus());
- participant.disable();
- }
- }
- }
- }
- }
-
-
-
- public SearchParticipantRecord[] getSearchParticipants(IProject[] concernedProjects) throws CoreException {
- Set participantSet= new HashSet();
- collectParticipants(participantSet, concernedProjects);
- SearchParticipantRecord[] participants= new SearchParticipantRecord[participantSet.size()];
- return (SearchParticipantRecord[]) participantSet.toArray(participants);
- }
-
- public static SearchParticipantsExtensionPoint getInstance() {
- if (fgInstance == null)
- fgInstance= new SearchParticipantsExtensionPoint();
- return fgInstance;
- }
-
- public static void debugSetInstance(SearchParticipantsExtensionPoint instance) {
- fgInstance= instance;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchResultUpdater.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchResultUpdater.java
deleted file mode 100644
index cff0e3ab..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchResultUpdater.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.search.ui.IQueryListener;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-public class SearchResultUpdater implements IElementChangedListener, IQueryListener {
-
- JavaSearchResult fResult;
- private static final int REMOVED_FLAGS= IJavaScriptElementDelta.F_MOVED_TO |
- IJavaScriptElementDelta.F_REMOVED_FROM_CLASSPATH |
- IJavaScriptElementDelta.F_CLOSED |
- IJavaScriptElementDelta.F_CONTENT;
-
- public SearchResultUpdater(JavaSearchResult result) {
- fResult= result;
- NewSearchUI.addQueryListener(this);
- JavaScriptCore.addElementChangedListener(this);
- // TODO make this work with resources
- }
-
- public void elementChanged(ElementChangedEvent event) {
- //long t0= System.currentTimeMillis();
- IJavaScriptElementDelta delta= event.getDelta();
- Set removedElements= new HashSet();
- Set potentiallyRemovedElements= new HashSet();
- collectRemoved(potentiallyRemovedElements, removedElements, delta);
- if (removedElements.size() > 0)
- handleRemoved(removedElements);
- if (potentiallyRemovedElements.size() > 0)
- handleRemoved(potentiallyRemovedElements);
- //System.out.println(this+"handled delta in: "+(System.currentTimeMillis()-t0));
- }
-
- private void handleRemoved(Set removedElements) {
- Object[] elements= fResult.getElements();
- for (int i= 0; i < elements.length; i++) {
- if (isContainedInRemoved(removedElements, elements[i])) {
- if (elements[i] instanceof IJavaScriptElement) {
- IJavaScriptElement je= (IJavaScriptElement)elements[i];
- if (!je.exists()) {
- //System.out.println("removing: "+je+" in "+fResult.getUserData());
- Match[] matches= fResult.getMatches(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- fResult.removeMatch(matches[j]);
- }
- }
- } else if (elements[i] instanceof IResource) {
- IResource resource= (IResource)elements[i];
- if (!resource.exists()) {
- //System.out.println("removing: "+resource+" in "+fResult.getUserData());
- Match[] matches= fResult.getMatches(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- fResult.removeMatch(matches[j]);
- }
- }
-
- }
- }
- }
- }
-
- private boolean isContainedInRemoved(Set removedElements, Object object) {
- for (Iterator elements= removedElements.iterator(); elements.hasNext();) {
- if (isParentOf(elements.next(), object))
- return true;
- }
- return false;
- }
-
- private boolean isParentOf(Object ancestor, Object descendant) {
- while (descendant != null && !ancestor.equals(descendant))
- descendant= getParent(descendant);
- return descendant != null;
- }
-
- private Object getParent(Object object) {
- if (object instanceof IJavaScriptElement)
- return ((IJavaScriptElement)object).getParent();
- else if (object instanceof IResource)
- return ((IResource)object).getParent();
- return null;
- }
-
- private void collectRemoved(Set potentiallyRemovedSet, Set removedElements, IJavaScriptElementDelta delta) {
- if (delta.getKind() == IJavaScriptElementDelta.REMOVED)
- removedElements.add(delta.getElement());
- else if (delta.getKind() == IJavaScriptElementDelta.CHANGED) {
- int flags= delta.getFlags();
- if ((flags & REMOVED_FLAGS) != 0) {
- potentiallyRemovedSet.add(delta.getElement());
- } else {
- IJavaScriptElementDelta[] childDeltas= delta.getAffectedChildren();
- for (int i= 0; i < childDeltas.length; i++) {
- collectRemoved(potentiallyRemovedSet, removedElements, childDeltas[i]);
- }
- }
- }
- IResourceDelta[] resourceDeltas= delta.getResourceDeltas();
- if (resourceDeltas != null) {
- for (int i= 0; i < resourceDeltas.length; i++) {
- collectRemovals(removedElements, resourceDeltas[i]);
- }
- }
- }
-
- public void queryAdded(ISearchQuery query) {
- // don't care
- }
-
- public void queryRemoved(ISearchQuery query) {
- if (fResult.equals(query.getSearchResult())) {
- JavaScriptCore.removeElementChangedListener(this);
- NewSearchUI.removeQueryListener(this);
- }
- }
-
- private void collectRemovals(Set removals, IResourceDelta delta) {
- if (delta.getKind() == IResourceDelta.REMOVED)
- removals.add(delta.getResource());
- else {
- IResourceDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
- collectRemovals(removals, children[i]);
- }
- }
- }
-
- public void queryStarting(ISearchQuery query) {
- // not interested
- }
-
- public void queryFinished(ISearchQuery query) {
- // not interested
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchUtil.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchUtil.java
deleted file mode 100644
index 8872edfb..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SearchUtil.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.dialogs.OptionalMessageDialog;
-import org.osgi.framework.Bundle;
-
-/**
- * This class contains some utility methods for J Search.
- */
-public class SearchUtil {
-
- // LRU working sets
- public static final int LRU_WORKINGSET_LIST_SIZE= 3;
- private static LRUWorkingSetsList fgLRUWorkingSets;
-
- // Settings store
- private static final String DIALOG_SETTINGS_KEY= "JavaElementSearchActions"; //$NON-NLS-1$
- private static final String STORE_LRU_WORKING_SET_NAMES= "lastUsedWorkingSetNames"; //$NON-NLS-1$
-
- private static final String BIN_PRIM_CONST_WARN_DIALOG_ID= "BinaryPrimitiveConstantWarningDialog"; //$NON-NLS-1$
-
- public static boolean isSearchPlugInActivated() {
- return Platform.getBundle("org.eclipse.search").getState() == Bundle.ACTIVE; //$NON-NLS-1$
- }
-
-
- /**
- * This helper method with Object as parameter is needed to prevent the loading
- * of the Search plug-in: the VM verifies the method call and hence loads the
- * types used in the method signature, eventually triggering the loading of
- * a plug-in (in this case ISearchQuery results in Search plug-in being loaded).
- */
- public static void runQueryInBackground(Object query) {
- NewSearchUI.runQueryInBackground((ISearchQuery)query);
- }
-
- /**
- * This helper method with Object as parameter is needed to prevent the loading
- * of the Search plug-in: the VM verifies the method call and hence loads the
- * types used in the method signature, eventually triggering the loading of
- * a plug-in (in this case ISearchQuery results in Search plug-in being loaded).
- */
- public static IStatus runQueryInForeground(IRunnableContext context, Object query) {
- return NewSearchUI.runQueryInForeground(context, (ISearchQuery)query);
- }
-
- /**
- * Returns the compilation unit for the given java element.
- *
- * @param element the java element whose compilation unit is searched for
- * @return the compilation unit of the given java element
- */
- static IJavaScriptUnit findCompilationUnit(IJavaScriptElement element) {
- if (element == null)
- return null;
- return (IJavaScriptUnit) element.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- }
-
-
- public static String toString(IWorkingSet[] workingSets) {
- Arrays.sort(workingSets, new WorkingSetComparator());
- String result= ""; //$NON-NLS-1$
- if (workingSets != null && workingSets.length > 0) {
- boolean firstFound= false;
- for (int i= 0; i < workingSets.length; i++) {
- String workingSetLabel= workingSets[i].getLabel();
- if (firstFound)
- result= Messages.format(SearchMessages.SearchUtil_workingSetConcatenation, new String[] {result, workingSetLabel});
- else {
- result= workingSetLabel;
- firstFound= true;
- }
- }
- }
- return result;
- }
-
- // ---------- LRU working set handling ----------
-
- /**
- * Updates the LRU list of working sets.
- *
- * @param workingSets the workings sets to be added to the LRU list
- */
- public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
- if (workingSets == null || workingSets.length < 1)
- return;
-
- getLRUWorkingSets().add(workingSets);
- saveState(getDialogStoreSection());
- }
-
- private static void saveState(IDialogSettings settingsStore) {
- IWorkingSet[] workingSets;
- Iterator iter= fgLRUWorkingSets.iterator();
- int i= 0;
- while (iter.hasNext()) {
- workingSets= (IWorkingSet[])iter.next();
- String[] names= new String[workingSets.length];
- for (int j= 0; j < workingSets.length; j++)
- names[j]= workingSets[j].getName();
- settingsStore.put(STORE_LRU_WORKING_SET_NAMES + i, names);
- i++;
- }
- }
-
- public static LRUWorkingSetsList getLRUWorkingSets() {
- if (fgLRUWorkingSets == null) {
- restoreState();
- }
- return fgLRUWorkingSets;
- }
-
- private static void restoreState() {
- fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
- IDialogSettings settingsStore= getDialogStoreSection();
-
- boolean foundLRU= false;
- for (int i= LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) {
- String[] lruWorkingSetNames= settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES + i);
- if (lruWorkingSetNames != null) {
- Set workingSets= new HashSet(2);
- for (int j= 0; j < lruWorkingSetNames.length; j++) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[j]);
- if (workingSet != null) {
- workingSets.add(workingSet);
- }
- }
- foundLRU= true;
- if (!workingSets.isEmpty())
- fgLRUWorkingSets.add((IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]));
- }
- }
- if (!foundLRU)
- // try old preference format
- restoreFromOldFormat();
- }
-
- private static IDialogSettings getDialogStoreSection() {
- IDialogSettings settingsStore= JavaScriptPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
- if (settingsStore == null)
- settingsStore= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
- return settingsStore;
- }
-
- private static void restoreFromOldFormat() {
- fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
- IDialogSettings settingsStore= getDialogStoreSection();
-
- boolean foundLRU= false;
- String[] lruWorkingSetNames= settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES);
- if (lruWorkingSetNames != null) {
- for (int i= lruWorkingSetNames.length - 1; i >= 0; i--) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[i]);
- if (workingSet != null) {
- foundLRU= true;
- fgLRUWorkingSets.add(new IWorkingSet[]{workingSet});
- }
- }
- }
- if (foundLRU)
- // save in new format
- saveState(settingsStore);
- }
-
- public static void warnIfBinaryConstant(IJavaScriptElement element, Shell shell) {
- if (isBinaryPrimitiveConstantOrString(element))
- OptionalMessageDialog.open(
- BIN_PRIM_CONST_WARN_DIALOG_ID,
- shell,
- SearchMessages.Search_FindReferencesAction_BinPrimConstWarnDialog_title,
- null,
- SearchMessages.Search_FindReferencesAction_BinPrimConstWarnDialog_message,
- MessageDialog.INFORMATION,
- new String[] { IDialogConstants.OK_LABEL },
- 0);
- }
-
- private static boolean isBinaryPrimitiveConstantOrString(IJavaScriptElement element) {
- if (element != null && element.getElementType() == IJavaScriptElement.FIELD) {
- IField field= (IField)element;
- int flags;
- try {
- flags= field.getFlags();
- } catch (JavaScriptModelException ex) {
- return false;
- }
- return field.isBinary() && Flags.isStatic(flags) && Flags.isFinal(flags) && isPrimitiveOrString(field);
- }
- return false;
- }
-
- private static boolean isPrimitiveOrString(IField field) {
- String fieldType;
- try {
- fieldType= field.getTypeSignature();
- } catch (JavaScriptModelException ex) {
- return false;
- }
- char first= fieldType.charAt(0);
- return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED && first != Signature.C_ARRAY)
- || (first == Signature.C_RESOLVED && fieldType.substring(1, fieldType.length() - 1).equals(String.class.getName()));
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortAction.java
deleted file mode 100644
index 3fc25e91..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.custom.BusyIndicator;
-
-
-public class SortAction extends Action {
- private int fSortOrder;
- private JavaSearchResultPage fPage;
-
- public SortAction(String label, JavaSearchResultPage page, int sortOrder) {
- super(label);
- fPage= page;
- fSortOrder= sortOrder;
- }
-
- public void run() {
- BusyIndicator.showWhile(fPage.getViewer().getControl().getDisplay(), new Runnable() {
- public void run() {
- fPage.setSortOrder(fSortOrder);
- }
- });
- }
-
- public int getSortOrder() {
- return fSortOrder;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortingLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortingLabelProvider.java
deleted file mode 100644
index b1cfa089..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/SortingLabelProvider.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredJavaElementLabels;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredString;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-public class SortingLabelProvider extends SearchLabelProvider {
-
- public static final int SHOW_ELEMENT_CONTAINER= 1; // default
- public static final int SHOW_CONTAINER_ELEMENT= 2;
- public static final int SHOW_PATH= 3;
-
- private static final long FLAGS_QUALIFIED= DEFAULT_SEARCH_TEXTFLAGS | JavaScriptElementLabels.F_FULLY_QUALIFIED | JavaScriptElementLabels.M_FULLY_QUALIFIED | JavaScriptElementLabels.I_FULLY_QUALIFIED
- | JavaScriptElementLabels.T_FULLY_QUALIFIED | JavaScriptElementLabels.D_QUALIFIED | JavaScriptElementLabels.CF_QUALIFIED | JavaScriptElementLabels.CU_QUALIFIED | ColoredJavaElementLabels.COLORIZE;
-
-
- private int fCurrentOrder;
-
- public SortingLabelProvider(JavaSearchResultPage page) {
- super(page);
- fCurrentOrder= SHOW_ELEMENT_CONTAINER;
- }
-
- public Image getImage(Object element) {
- Image image= null;
- if (element instanceof IJavaScriptElement || element instanceof IResource)
- image= super.getImage(element);
- if (image != null)
- return image;
- return getParticipantImage(element);
- }
-
- public final String getText(Object element) {
- if (element instanceof IImportDeclaration)
- element= ((IImportDeclaration)element).getParent().getParent();
-
- String text= super.getText(element);
- if (text.length() > 0) {
- String labelWithCount= getLabelWithCounts(element, text);
- if (fCurrentOrder == SHOW_ELEMENT_CONTAINER) {
- labelWithCount += getPostQualification(element, text);
- }
- return labelWithCount;
- }
- return getParticipantText(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider#getRichTextLabel(java.lang.Object)
- */
- public ColoredString getRichTextLabel(Object element) {
- if (element instanceof IImportDeclaration)
- element= ((IImportDeclaration)element).getParent().getParent();
-
- ColoredString text= super.getRichTextLabel(element);
- if (text.length() > 0) {
- ColoredString countLabel= getColoredLabelWithCounts(element, text);
- if (fCurrentOrder == SHOW_ELEMENT_CONTAINER) {
- countLabel.append(getPostQualification(element, text.getString()), ColoredJavaElementLabels.QUALIFIER_STYLE);
- }
- return countLabel;
- }
- return new ColoredString(getParticipantText(element));
- }
-
- private String getPostQualification(Object element, String text) {
- String textLabel= JavaScriptElementLabels.getTextLabel(element, JavaScriptElementLabels.ALL_POST_QUALIFIED);
- int indexOf= textLabel.indexOf(JavaScriptElementLabels.CONCAT_STRING);
- if (indexOf != -1) {
- return textLabel.substring(indexOf);
- }
- return new String();
- }
-
- public void setOrder(int orderFlag) {
- fCurrentOrder= orderFlag;
- long flags= 0;
- if (orderFlag == SHOW_ELEMENT_CONTAINER)
- flags= DEFAULT_SEARCH_TEXTFLAGS;
- else if (orderFlag == SHOW_CONTAINER_ELEMENT)
- flags= FLAGS_QUALIFIED;
- else if (orderFlag == SHOW_PATH) {
- flags= FLAGS_QUALIFIED | JavaScriptElementLabels.PREPEND_ROOT_PATH;
- }
- setTextFlags(flags);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchLabelProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchLabelProvider.java
deleted file mode 100644
index f7c55f45..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchLabelProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-
-public abstract class TextSearchLabelProvider extends LabelProvider {
-
- private AbstractTextSearchViewPage fPage;
- private String fMatchCountFormat;
-
- public TextSearchLabelProvider(AbstractTextSearchViewPage page) {
- fPage= page;
- fMatchCountFormat= SearchMessages.TextSearchLabelProvider_matchCountFormat;
- }
-
- public final String getText(Object element) {
- int matchCount= fPage.getInput().getMatchCount(element);
- String text= doGetText(element);
- if (matchCount < 2)
- return text;
- else {
- return Messages.format(fMatchCountFormat, new Object[] { text, new Integer(matchCount) });
- }
- }
-
- protected abstract String doGetText(Object element);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchTableContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchTableContentProvider.java
deleted file mode 100644
index a759f60e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/TextSearchTableContentProvider.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-
-/**
- * TODO: this class should replace JavaSearchTableContentProvider
- * (must generalize type of fResult to AbstractTextSearchResult in JavaSearchContentProvider)
- */
-public class TextSearchTableContentProvider implements IStructuredContentProvider {
- protected final Object[] EMPTY_ARRAY= new Object[0];
- private AbstractTextSearchResult fSearchResult;
- private TableViewer fTableViewer;
-
- /*
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof AbstractTextSearchResult)
- return ((AbstractTextSearchResult) inputElement).getElements();
- return EMPTY_ARRAY;
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- //nothing
- }
-
- /*
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fTableViewer= (TableViewer) viewer;
- fSearchResult= (AbstractTextSearchResult) newInput;
- }
-
- public void elementsChanged(Object[] updatedElements) {
- //TODO: copied from JavaSearchTableContentProvider
- int addCount= 0;
- int removeCount= 0;
- for (int i= 0; i < updatedElements.length; i++) {
- if (fSearchResult.getMatchCount(updatedElements[i]) > 0) {
- if (fTableViewer.testFindItem(updatedElements[i]) != null)
- fTableViewer.refresh(updatedElements[i]);
- else
- fTableViewer.add(updatedElements[i]);
- addCount++;
- } else {
- fTableViewer.remove(updatedElements[i]);
- removeCount++;
- }
- }
- }
-
- public void clear() {
- //TODO: copied from JavaSearchTableContentProvider
- fTableViewer.refresh();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetComparator.java
deleted file mode 100644
index 31d40770..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetComparator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.Comparator;
-
-import org.eclipse.ui.IWorkingSet;
-
-import com.ibm.icu.text.Collator;
-
-public class WorkingSetComparator implements Comparator {
-
- private Collator fCollator= Collator.getInstance();
-
- /*
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- String name1= null;
- String name2= null;
-
- if (o1 instanceof IWorkingSet)
- name1= ((IWorkingSet)o1).getLabel();
-
- if (o2 instanceof IWorkingSet)
- name2= ((IWorkingSet)o2).getLabel();
-
- return fCollator.compare(name1, name2);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetsComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetsComparator.java
deleted file mode 100644
index 4cb06218..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/search/WorkingSetsComparator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.search;
-
-import java.util.Comparator;
-
-import org.eclipse.ui.IWorkingSet;
-
-import com.ibm.icu.text.Collator;
-
-class WorkingSetsComparator implements Comparator {
-
- private Collator fCollator= Collator.getInstance();
-
- /*
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- String name1= null;
- String name2= null;
-
- if (o1 instanceof IWorkingSet[]) {
- IWorkingSet[] workingSets= (IWorkingSet[])o1;
- if (workingSets.length > 0)
- name1= workingSets[0].getLabel();
- }
-
- if (o2 instanceof IWorkingSet[]) {
- IWorkingSet[] workingSets= (IWorkingSet[])o1;
- if (workingSets.length > 0)
- name2= workingSets[0].getLabel();
- }
-
- return fCollator.compare(name1, name2);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractInformationControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractInformationControl.java
deleted file mode 100644
index b16e86dc..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractInformationControl.java
+++ /dev/null
@@ -1,775 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.PopupDialog;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.IInformationControlExtension2;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-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.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Item;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ActionHandler;
-import org.eclipse.ui.commands.HandlerSubmission;
-import org.eclipse.ui.commands.ICommand;
-import org.eclipse.ui.commands.ICommandManager;
-import org.eclipse.ui.commands.IKeySequenceBinding;
-import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.keys.KeySequence;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.util.StringMatcher;
-import org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup;
-
-/**
- * Abstract class for Show hierarchy in light-weight controls.
- *
- *
- */
-public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
-
- /**
- * The NamePatternFilter selects the elements which
- * match the given string patterns.
- *
- *
- */
- protected class NamePatternFilter extends ViewerFilter {
-
- public NamePatternFilter() {
- }
-
- /* (non-Javadoc)
- * Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- StringMatcher matcher= getMatcher();
- if (matcher == null || !(viewer instanceof TreeViewer))
- return true;
- TreeViewer treeViewer= (TreeViewer) viewer;
-
- String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
- if (matchName != null && matcher.match(matchName))
- return true;
-
- return hasUnfilteredChild(treeViewer, element);
- }
-
- private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
- if (element instanceof IParent) {
- Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
- for (int i= 0; i < children.length; i++)
- if (select(viewer, element, children[i]))
- return true;
- }
- return false;
- }
- }
-
- /** The control's text widget */
- private Text fFilterText;
- /** The control's tree widget */
- private TreeViewer fTreeViewer;
- /** The current string matcher */
- protected StringMatcher fStringMatcher;
- private ICommand fInvokingCommand;
- private KeySequence[] fInvokingCommandKeySequences;
-
- /**
- * Fields that support the dialog menu
- *
- * - now appended to framework menu
- */
- private Composite fViewMenuButtonComposite;
-
- private CustomFiltersActionGroup fCustomFiltersActionGroup;
-
- private IAction fShowViewMenuAction;
- private HandlerSubmission fShowViewMenuHandlerSubmission;
-
- /**
- * Field for tree style since it must be remembered by the instance.
- *
- *
- */
- private int fTreeStyle;
-
- /**
- * Creates a tree information control with the given shell as parent. The given
- * styles are applied to the shell and the tree widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param treeStyle the additional styles for the tree widget
- * @param invokingCommandId the id of the command that invoked this control or <code>null</code>
- * @param showStatusField <code>true</code> iff the control has a status field at the bottom
- */
- public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle, String invokingCommandId, boolean showStatusField) {
- super(parent, shellStyle, true, true, true, true, null, null);
- if (invokingCommandId != null) {
- ICommandManager commandManager= PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
- fInvokingCommand= commandManager.getCommand(invokingCommandId);
- if (fInvokingCommand != null && !fInvokingCommand.isDefined())
- fInvokingCommand= null;
- else
- // Pre-fetch key sequence - do not change because scope will change later.
- getInvokingCommandKeySequences();
- }
- fTreeStyle= treeStyle;
- // Title and status text must be set to get the title label created, so force empty values here.
- if (hasHeader())
- setTitleText(""); //$NON-NLS-1$
- setInfoText(""); // //$NON-NLS-1$
-
- // Create all controls early to preserve the life cycle of the original implementation.
- create();
-
- // Status field text can only be computed after widgets are created.
- setInfoText(getStatusFieldText());
- }
-
- /**
- * Create the main content for this information control.
- *
- * @param parent The parent composite
- * @return The control representing the main content.
- *
- */
- protected Control createDialogArea(Composite parent) {
- fTreeViewer= createTreeViewer(parent, fTreeStyle);
-
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(getId(), fTreeViewer);
-
- final Tree tree= fTreeViewer.getTree();
- tree.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (e.character == 0x1B) // ESC
- dispose();
- }
- public void keyReleased(KeyEvent e) {
- // do nothing
- }
- });
-
- tree.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- gotoSelectedElement();
- }
- });
-
- tree.addMouseMoveListener(new MouseMoveListener() {
- TreeItem fLastItem= null;
- public void mouseMove(MouseEvent e) {
- if (tree.equals(e.getSource())) {
- Object o= tree.getItem(new Point(e.x, e.y));
- if (o instanceof TreeItem) {
- if (!o.equals(fLastItem)) {
- fLastItem= (TreeItem)o;
- tree.setSelection(new TreeItem[] { fLastItem });
- } else if (e.y < tree.getItemHeight() / 4) {
- // Scroll up
- Point p= tree.toDisplay(e.x, e.y);
- Item item= fTreeViewer.scrollUp(p.x, p.y);
- if (item instanceof TreeItem) {
- fLastItem= (TreeItem)item;
- tree.setSelection(new TreeItem[] { fLastItem });
- }
- } else if (e.y > tree.getBounds().height - tree.getItemHeight() / 4) {
- // Scroll down
- Point p= tree.toDisplay(e.x, e.y);
- Item item= fTreeViewer.scrollDown(p.x, p.y);
- if (item instanceof TreeItem) {
- fLastItem= (TreeItem)item;
- tree.setSelection(new TreeItem[] { fLastItem });
- }
- }
- }
- }
- }
- });
-
- tree.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
-
- if (tree.getSelectionCount() < 1)
- return;
-
- if (e.button != 1)
- return;
-
- if (tree.equals(e.getSource())) {
- Object o= tree.getItem(new Point(e.x, e.y));
- TreeItem selection= tree.getSelection()[0];
- if (selection.equals(o))
- gotoSelectedElement();
- }
- }
- });
-
- installFilter();
-
- addDisposeListener(this);
- return fTreeViewer.getControl();
- }
-
- /**
- * Creates a tree information control with the given shell as parent. The given
- * styles are applied to the shell and the tree widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param treeStyle the additional styles for the tree widget
- */
- public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle) {
- this(parent, shellStyle, treeStyle, null, false);
- }
-
- protected abstract TreeViewer createTreeViewer(Composite parent, int style);
-
- /**
- * Returns the name of the dialog settings section.
- *
- * @return the name of the dialog settings section
- */
- protected abstract String getId();
-
- protected TreeViewer getTreeViewer() {
- return fTreeViewer;
- }
-
- /**
- * Returns <code>true</code> if the control has a header, <code>false</code> otherwise.
- * <p>
- * The default is to return <code>false</code>.
- * </p>
- *
- * @return <code>true</code> if the control has a header
- */
- protected boolean hasHeader() {
- // default is to have no header
- return false;
- }
-
- protected Text getFilterText() {
- return fFilterText;
- }
-
- protected Text createFilterText(Composite parent) {
- fFilterText= new Text(parent, SWT.NONE);
- Dialog.applyDialogFont(fFilterText);
-
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalAlignment= GridData.FILL;
- data.verticalAlignment= GridData.CENTER;
- fFilterText.setLayoutData(data);
-
- fFilterText.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == 0x0D) // return
- gotoSelectedElement();
- if (e.keyCode == SWT.ARROW_DOWN)
- fTreeViewer.getTree().setFocus();
- if (e.keyCode == SWT.ARROW_UP)
- fTreeViewer.getTree().setFocus();
- if (e.character == 0x1B) // ESC
- dispose();
- }
- public void keyReleased(KeyEvent e) {
- // do nothing
- }
- });
-
- return fFilterText;
- }
-
- protected void createHorizontalSeparator(Composite parent) {
- Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- protected void updateStatusFieldText() {
- setInfoText(getStatusFieldText());
- }
-
- /**
- * Handles click in status field.
- * <p>
- * Default does nothing.
- * </p>
- */
- protected void handleStatusFieldClicked() {
- }
-
- protected String getStatusFieldText() {
- return ""; //$NON-NLS-1$
- }
-
- private void installFilter() {
- fFilterText.setText(""); //$NON-NLS-1$
-
- fFilterText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String text= ((Text) e.widget).getText();
- int length= text.length();
- if (length > 0 && text.charAt(length -1 ) != '*') {
- text= text + '*';
- }
- setMatcherString(text, true);
- }
- });
- }
-
- /**
- * The string matcher has been modified. The default implementation
- * refreshes the view and selects the first matched element
- */
- protected void stringMatcherUpdated() {
- // refresh viewer to re-filter
- fTreeViewer.getControl().setRedraw(false);
- fTreeViewer.refresh();
- fTreeViewer.expandAll();
- selectFirstMatch();
- fTreeViewer.getControl().setRedraw(true);
- }
-
- /**
- * Sets the patterns to filter out for the receiver.
- * <p>
- * The following characters have special meaning:
- * ? => any character
- * * => any string
- * </p>
- *
- * @param pattern the pattern
- * @param update <code>true</code> if the viewer should be updated
- */
- protected void setMatcherString(String pattern, boolean update) {
- if (pattern.length() == 0) {
- fStringMatcher= null;
- } else {
- boolean ignoreCase= pattern.toLowerCase().equals(pattern);
- fStringMatcher= new StringMatcher(pattern, ignoreCase, false);
- }
-
- if (update)
- stringMatcherUpdated();
- }
-
- protected StringMatcher getMatcher() {
- return fStringMatcher;
- }
-
- /**
- * Implementers can modify
- *
- * @return the selected element
- */
- protected Object getSelectedElement() {
- if (fTreeViewer == null)
- return null;
-
- return ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
- }
-
- private void gotoSelectedElement() {
- Object selectedElement= getSelectedElement();
- if (selectedElement != null) {
- try {
- dispose();
- IEditorPart part= EditorUtility.openInEditor(selectedElement, true);
- if (part != null && selectedElement instanceof IJavaScriptElement)
- EditorUtility.revealInEditor(part, (IJavaScriptElement) selectedElement);
- } catch (CoreException ex) {
- JavaScriptPlugin.log(ex);
- }
- }
- }
-
- /**
- * Selects the first element in the tree which
- * matches the current filter pattern.
- */
- protected void selectFirstMatch() {
- Tree tree= fTreeViewer.getTree();
- Object element= findElement(tree.getItems());
- if (element != null)
- fTreeViewer.setSelection(new StructuredSelection(element), true);
- else
- fTreeViewer.setSelection(StructuredSelection.EMPTY);
- }
-
- private IJavaScriptElement findElement(TreeItem[] items) {
- ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
- for (int i= 0; i < items.length; i++) {
- IJavaScriptElement element= (IJavaScriptElement)items[i].getData();
- if (fStringMatcher == null)
- return element;
-
- if (element != null) {
- String label= labelProvider.getText(element);
- if (fStringMatcher.match(label))
- return element;
- }
-
- element= findElement(items[i].getItems());
- if (element != null)
- return element;
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setInformation(String information) {
- // this method is ignored, see IInformationControlExtension2
- }
-
- /**
- * {@inheritDoc}
- */
- public abstract void setInput(Object information);
-
- /**
- * Fills the view menu.
- * Clients can extend or override.
- *
- * @param viewMenu the menu manager that manages the menu
- *
- */
- protected void fillViewMenu(IMenuManager viewMenu) {
- fCustomFiltersActionGroup.fillViewMenu(viewMenu);
- }
-
- /*
- * Overridden to call the old framework method.
- *
- * @see org.eclipse.jface.dialogs.PopupDialog#fillDialogMenu(IMenuManager)
- *
- */
- protected void fillDialogMenu(IMenuManager dialogMenu) {
- super.fillDialogMenu(dialogMenu);
- fillViewMenu(dialogMenu);
- }
-
- protected void inputChanged(Object newInput, Object newSelection) {
- fFilterText.setText(""); //$NON-NLS-1$
- fTreeViewer.setInput(newInput);
- if (newSelection != null) {
- fTreeViewer.setSelection(new StructuredSelection(newSelection));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setVisible(boolean visible) {
- if (visible) {
- open();
- } else {
- removeHandlerAndKeyBindingSupport();
- saveDialogBounds(getShell());
- getShell().setVisible(false);
- removeHandlerAndKeyBindingSupport();
- }
- }
-
- /*
- * @see org.eclipse.jface.dialogs.PopupDialog#open()
- *
- */
- public int open() {
- addHandlerAndKeyBindingSupport();
- return super.open();
- }
-
- /**
- * {@inheritDoc}
- */
- public final void dispose() {
- close();
- }
-
- /**
- * {@inheritDoc}
- * @param event can be null
- * <p>
- * Subclasses may extend.
- * </p>
- */
- public void widgetDisposed(DisposeEvent event) {
- removeHandlerAndKeyBindingSupport();
- fTreeViewer= null;
- fFilterText= null;
- }
-
- /**
- * Adds handler and key binding support.
- *
- *
- */
- protected void addHandlerAndKeyBindingSupport() {
- // Register action with command support
- if (fShowViewMenuHandlerSubmission == null) {
- fShowViewMenuHandlerSubmission= new HandlerSubmission(null, getShell(), null, fShowViewMenuAction.getActionDefinitionId(), new ActionHandler(fShowViewMenuAction), Priority.MEDIUM);
- PlatformUI.getWorkbench().getCommandSupport().addHandlerSubmission(fShowViewMenuHandlerSubmission);
- }
- }
-
- /**
- * Removes handler and key binding support.
- *
- *
- */
- protected void removeHandlerAndKeyBindingSupport() {
- // Remove handler submission
- if (fShowViewMenuHandlerSubmission != null)
- PlatformUI.getWorkbench().getCommandSupport().removeHandlerSubmission(fShowViewMenuHandlerSubmission);
-
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasContents() {
- return fTreeViewer != null && fTreeViewer.getInput() != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- public Point computeSizeHint() {
- // return the shell's size - note that it already has the persisted size if persisting
- // is enabled.
- return getShell().getSize();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLocation(Point location) {
- /*
- * If the location is persisted, it gets managed by PopupDialog - fine. Otherwise, the location is
- * computed in Window#getInitialLocation, which will center it in the parent shell / main
- * monitor, which is wrong for two reasons:
- * - we want to center over the editor / subject control, not the parent shell
- * - the center is computed via the initalSize, which may be also wrong since the size may
- * have been updated since via min/max sizing of AbstractInformationControlManager.
- * In that case, override the location with the one computed by the manager. Note that
- * the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
- * entirely visible.
- */
- if (!getPersistBounds() || getDialogSettings() == null)
- getShell().setLocation(location);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setSize(int width, int height) {
- getShell().setSize(width, height);
- }
-
- /**
- * {@inheritDoc}
- */
- public void addDisposeListener(DisposeListener listener) {
- getShell().addDisposeListener(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeDisposeListener(DisposeListener listener) {
- getShell().removeDisposeListener(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setForegroundColor(Color foreground) {
- applyForegroundColor(foreground, getContents());
- }
-
- /**
- * {@inheritDoc}
- */
- public void setBackgroundColor(Color background) {
- applyBackgroundColor(background, getContents());
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isFocusControl() {
- return fTreeViewer.getControl().isFocusControl() || fFilterText.isFocusControl();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setFocus() {
- getShell().forceFocus();
- fFilterText.setFocus();
- }
-
- /**
- * {@inheritDoc}
- */
- public void addFocusListener(FocusListener listener) {
- getShell().addFocusListener(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeFocusListener(FocusListener listener) {
- getShell().removeFocusListener(listener);
- }
-
- final protected ICommand getInvokingCommand() {
- return fInvokingCommand;
- }
-
- final protected KeySequence[] getInvokingCommandKeySequences() {
- if (fInvokingCommandKeySequences == null) {
- if (getInvokingCommand() != null) {
- List list= getInvokingCommand().getKeySequenceBindings();
- if (!list.isEmpty()) {
- fInvokingCommandKeySequences= new KeySequence[list.size()];
- for (int i= 0; i < fInvokingCommandKeySequences.length; i++) {
- fInvokingCommandKeySequences[i]= ((IKeySequenceBinding) list.get(i)).getKeySequence();
- }
- return fInvokingCommandKeySequences;
- }
- }
- }
- return fInvokingCommandKeySequences;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.PopupDialog#getDialogSettings()
- */
- protected IDialogSettings getDialogSettings() {
- String sectionName= getId();
-
- IDialogSettings settings= JavaScriptPlugin.getDefault().getDialogSettings().getSection(sectionName);
- if (settings == null)
- settings= JavaScriptPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
-
- return settings;
- }
-
- /*
- * Overridden to insert the filter text into the title and menu area.
- *
- *
- */
- protected Control createTitleMenuArea(Composite parent) {
- fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);
-
- // If there is a header, then the filter text must be created
- // underneath the title and menu area.
-
- if (hasHeader()) {
- fFilterText= createFilterText(parent);
- }
-
- // Create show view menu action
- fShowViewMenuAction= new Action("showViewMenu") { //$NON-NLS-1$
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- showDialogMenu();
- }
- };
- fShowViewMenuAction.setEnabled(true);
- fShowViewMenuAction.setActionDefinitionId("org.eclipse.ui.window.showViewMenu"); //$NON-NLS-1$
-
- return fViewMenuButtonComposite;
- }
-
- /*
- * Overridden to insert the filter text into the title control
- * if there is no header specified.
- *
- */
- protected Control createTitleControl(Composite parent) {
- if (hasHeader()) {
- return super.createTitleControl(parent);
- }
- fFilterText= createFilterText(parent);
- return fFilterText;
- }
-
- /*
- * @see org.eclipse.jface.dialogs.PopupDialog#setTabOrder(org.eclipse.swt.widgets.Composite)
- */
- protected void setTabOrder(Composite composite) {
- if (hasHeader()) {
- composite.setTabList(new Control[] { fFilterText, fTreeViewer.getTree() });
- } else {
- fViewMenuButtonComposite.setTabList(new Control[] { fFilterText });
- composite.setTabList(new Control[] { fViewMenuButtonComposite, fTreeViewer.getTree() });
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractJavaScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractJavaScanner.java
deleted file mode 100644
index 70f53db1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/AbstractJavaScanner.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IColorManagerExtension;
-
-
-/**
- * Initialized with a color manager and a preference store, its subclasses are
- * only responsible for providing a list of preference keys for based on which tokens
- * are generated and to use this tokens to define the rules controlling this scanner.
- * <p>
- * This scanner stores the color defined by the color preference key into
- * the color manager under the same key.
- * </p>
- * <p>
- * Preference color key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} are used
- * to retrieve whether the token is rendered in bold.
- * </p>
- * <p>
- * Preference color key + {@link PreferenceConstants#EDITOR_ITALIC_SUFFIX} are used
- * to retrieve whether the token is rendered in italic.
- * </p>
- * <p>
- * Preference color key + {@link PreferenceConstants#EDITOR_STRIKETHROUGH_SUFFIX} are used
- * to retrieve whether the token is rendered in strikethrough.
- * </p>
- * <p>
- * Preference color key + {@link PreferenceConstants#EDITOR_UNDERLINE_SUFFIX} are used
- * to retrieve whether the token is rendered in underline.
- * </p>
- */
-public abstract class AbstractJavaScanner extends BufferedRuleBasedScanner {
-
-
- private IColorManager fColorManager;
- private IPreferenceStore fPreferenceStore;
-
- private Map fTokenMap= new HashMap();
- private String[] fPropertyNamesColor;
- /**
- * Preference keys for boolean preferences which are <code>true</code>,
- * iff the corresponding token should be rendered bold.
- */
- private String[] fPropertyNamesBold;
- /**
- * Preference keys for boolean preferences which are <code>true</code>,
- * iff the corresponding token should be rendered italic.
- *
- *
- */
- private String[] fPropertyNamesItalic;
- /**
- * Preference keys for boolean preferences which are <code>true</code>,
- * iff the corresponding token should be rendered strikethrough.
- *
- *
- */
- private String[] fPropertyNamesStrikethrough;
- /**
- * Preference keys for boolean preferences which are <code>true</code>,
- * iff the corresponding token should be rendered underline.
- *
- *
- */
- private String[] fPropertyNamesUnderline;
-
-
- private boolean fNeedsLazyColorLoading;
-
- /**
- * Returns an array of preference keys which define the tokens
- * used in the rules of this scanner.
- * <p>
- * The preference key is used access the color in the preference
- * store and in the color manager.
- * </p>
- * <p>
- * Preference key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} is used
- * to retrieve whether the token is rendered in bold.
- * </p>
- * <p>
- * Preference key + {@link PreferenceConstants#EDITOR_ITALIC_SUFFIX} is used
- * to retrieve whether the token is rendered in italic.
- * </p>
- * <p>
- * Preference key + {@link PreferenceConstants#EDITOR_UNDERLINE_SUFFIX} is used
- * to retrieve whether the token is rendered underlined.
- * </p>
- * <p>
- * Preference key + {@link PreferenceConstants#EDITOR_STRIKETHROUGH_SUFFIX} is used
- * to retrieve whether the token is rendered stricken out.
- * </p>
- */
- abstract protected String[] getTokenProperties();
-
- /**
- * Creates the list of rules controlling this scanner.
- */
- abstract protected List createRules();
-
-
- /**
- * Creates an abstract Java scanner.
- */
- public AbstractJavaScanner(IColorManager manager, IPreferenceStore store) {
- super();
- fColorManager= manager;
- fPreferenceStore= store;
- }
-
- /**
- * Must be called after the constructor has been called.
- */
- public final void initialize() {
-
- fPropertyNamesColor= getTokenProperties();
- int length= fPropertyNamesColor.length;
- fPropertyNamesBold= new String[length];
- fPropertyNamesItalic= new String[length];
- fPropertyNamesStrikethrough= new String[length];
- fPropertyNamesUnderline= new String[length];
-
- for (int i= 0; i < length; i++) {
- fPropertyNamesBold[i]= getBoldKey(fPropertyNamesColor[i]);
- fPropertyNamesItalic[i]= getItalicKey(fPropertyNamesColor[i]);
- fPropertyNamesStrikethrough[i]= getStrikethroughKey(fPropertyNamesColor[i]);
- fPropertyNamesUnderline[i]= getUnderlineKey(fPropertyNamesColor[i]);
- }
-
- fNeedsLazyColorLoading= Display.getCurrent() == null;
- for (int i= 0; i < length; i++) {
- if (fNeedsLazyColorLoading)
- addTokenWithProxyAttribute(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
- else
- addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
- }
-
- initializeRules();
- }
-
- protected String getBoldKey(String colorKey) {
- return colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX;
- }
-
- protected String getItalicKey(String colorKey) {
- return colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
- }
-
- protected String getStrikethroughKey(String colorKey) {
- return colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
- }
-
- protected String getUnderlineKey(String colorKey) {
- return colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
- }
-
- public IToken nextToken() {
- if (fNeedsLazyColorLoading)
- resolveProxyAttributes();
- return super.nextToken();
- }
-
- private void resolveProxyAttributes() {
- if (fNeedsLazyColorLoading && Display.getCurrent() != null) {
- for (int i= 0; i < fPropertyNamesColor.length; i++) {
- addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
- }
- fNeedsLazyColorLoading= false;
- }
- }
-
- private void addTokenWithProxyAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
- fTokenMap.put(colorKey, new Token(createTextAttribute(null, boldKey, italicKey, strikethroughKey, underlineKey)));
- }
-
- private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
- if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
- RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
- if (fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
- ext.unbindColor(colorKey);
- ext.bindColor(colorKey, rgb);
- }
- }
-
- if (!fNeedsLazyColorLoading)
- fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)));
- else {
- Token token= ((Token)fTokenMap.get(colorKey));
- if (token != null)
- token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey));
- }
- }
-
- /**
- * Create a text attribute based on the given color, bold, italic, strikethrough and underline preference keys.
- *
- * @param colorKey the color preference key
- * @param boldKey the bold preference key
- * @param italicKey the italic preference key
- * @param strikethroughKey the strikethrough preference key
- * @param underlineKey the italic preference key
- * @return the created text attribute
- *
- */
- private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
- Color color= null;
- if (colorKey != null)
- color= fColorManager.getColor(colorKey);
-
- int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
- if (fPreferenceStore.getBoolean(italicKey))
- style |= SWT.ITALIC;
-
- if (fPreferenceStore.getBoolean(strikethroughKey))
- style |= TextAttribute.STRIKETHROUGH;
-
- if (fPreferenceStore.getBoolean(underlineKey))
- style |= TextAttribute.UNDERLINE;
-
- return new TextAttribute(color, null, style);
- }
-
- protected Token getToken(String key) {
- if (fNeedsLazyColorLoading)
- resolveProxyAttributes();
- 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(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]) || property.equals(fPropertyNamesStrikethrough[i]) || property.equals(fPropertyNamesUnderline[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 if (fPropertyNamesBold[index].equals(p))
- adaptToStyleChange(token, event, SWT.BOLD);
- else if (fPropertyNamesItalic[index].equals(p))
- adaptToStyleChange(token, event, SWT.ITALIC);
- else if (fPropertyNamesStrikethrough[index].equals(p))
- adaptToStyleChange(token, event, TextAttribute.STRIKETHROUGH);
- else if (fPropertyNamesUnderline[index].equals(p))
- adaptToStyleChange(token, event, TextAttribute.UNDERLINE);
- }
-
- 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();
- Color color= fColorManager.getColor(property);
-
- if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) {
- IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
-
- ext.unbindColor(property);
- ext.bindColor(property, rgb);
-
- color= fColorManager.getColor(property);
- }
-
- Object data= token.getData();
- if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
- token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
- }
- }
- }
-
- private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
- boolean eventValue= false;
- Object value= event.getNewValue();
- if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
- else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
-
- Object data= token.getData();
- if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
- boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
- if (activeValue != eventValue)
- token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
- }
- }
- /**
- * Returns the preference store.
- *
- * @return the preference store.
- *
- *
- */
- protected IPreferenceStore getPreferenceStore() {
- return fPreferenceStore;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/BufferedDocumentScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/BufferedDocumentScanner.java
deleted file mode 100644
index 40e05f21..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/BufferedDocumentScanner.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-
-
-
-/**
- * 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) {
-
- fBufferOffset= offset;
-
- if (fBufferOffset + fBuffer.length > fRangeOffset + fRangeLength)
- fBufferLength= fRangeLength - (fBufferOffset - fRangeOffset);
- else
- fBufferLength= fBuffer.length;
-
- 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;
-
- 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) {
- int end= fBufferOffset + fBufferLength;
- if (end == fDocument.getLength() || end == fRangeOffset + fRangeLength)
- return EOF;
- else {
- updateBuffer(fBufferOffset + fBufferLength);
- fOffset= 0;
- }
- }
-
- try {
- return fBuffer[fOffset++];
- } catch (ArrayIndexOutOfBoundsException ex) {
- StringBuffer buf= new StringBuffer();
- buf.append("Detailed state of 'BufferedDocumentScanner:'"); //$NON-NLS-1$
- buf.append("\n\tfOffset= "); //$NON-NLS-1$
- buf.append(fOffset);
- buf.append("\n\tfBufferOffset= "); //$NON-NLS-1$
- buf.append(fBufferOffset);
- buf.append("\n\tfBufferLength= "); //$NON-NLS-1$
- buf.append(fBufferLength);
- buf.append("\n\tfRangeOffset= "); //$NON-NLS-1$
- buf.append(fRangeOffset);
- buf.append("\n\tfRangeLength= "); //$NON-NLS-1$
- buf.append(fRangeLength);
- JavaScriptPlugin.logErrorMessage(buf.toString());
- throw ex;
- }
- }
-
- /*
- * @see ICharacterScanner#unread
- */
- public final void unread() {
-
- if (fOffset == 0) {
- if (fBufferOffset == fRangeOffset) {
- // error: BOF
- } else {
- updateBuffer(fBufferOffset - fBuffer.length);
- fOffset= fBuffer.length - 1;
- }
- } 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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ChangeHoverInformationControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ChangeHoverInformationControl.java
deleted file mode 100644
index a33b1a34..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ChangeHoverInformationControl.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.jsdt.internal.ui.text.java.hover.SourceViewerInformationControl;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-/**
- * Specialized source viewer information control used to display quick diff hovers.
- *
- *
- */
-class ChangeHoverInformationControl extends SourceViewerInformationControl {
-
- /** The font name for the viewer font - the same as the java editor's. */
- private static final String SYMBOLIC_FONT_NAME= "org.eclipse.wst.jsdt.ui.editors.textfont"; //$NON-NLS-1$
-
- /** The maximum width of the control, set in <code>setSizeConstraints(int, int)</code>. */
- int fMaxWidth= Integer.MAX_VALUE;
- /** The maximum height of the control, set in <code>setSizeConstraints(int, int)</code>. */
- int fMaxHeight= Integer.MAX_VALUE;
-
- /** The partition type to be used as the starting partition type by the partition scanner. */
- private String fPartition;
- /** The horizontal scroll index. */
- private int fHorizontalScrollPixel;
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#setSizeConstraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- fMaxWidth= maxWidth;
- fMaxHeight= maxHeight;
- }
-
- /**
- * Creates a new information control.
- *
- * @param parent the shell that is the parent of this hover / control
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the styled text widget
- * @param partition the initial partition type to be used for the underlying viewer
- * @param statusFieldText the text to be used in the optional status field
- * or <code>null</code> if the status field should be hidden
- */
- public ChangeHoverInformationControl(Shell parent, int shellStyle, int style, String partition, String statusFieldText) {
- super(parent, shellStyle, style, statusFieldText);
- setViewerFont();
- setStartingPartitionType(partition);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- Point size= super.computeSizeHint();
- size.x= Math.min(size.x, fMaxWidth);
- size.y= Math.min(size.y, fMaxHeight);
- return size;
- }
-
- /**
- * Sets the font for this viewer sustaining selection and scroll position.
- */
- private void setViewerFont() {
- Font font= JFaceResources.getFont(SYMBOLIC_FONT_NAME);
-
- if (getViewer().getDocument() != null) {
-
- Point selection= getViewer().getSelectedRange();
- int topIndex= getViewer().getTopIndex();
-
- StyledText styledText= getViewer().getTextWidget();
- Control parent= styledText;
- if (getViewer() instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) getViewer();
- parent= extension.getControl();
- }
-
- parent.setRedraw(false);
-
- styledText.setFont(font);
-
- getViewer().setSelectedRange(selection.x , selection.y);
- getViewer().setTopIndex(topIndex);
-
- if (parent instanceof Composite) {
- Composite composite= (Composite) parent;
- composite.layout(true);
- }
-
- parent.setRedraw(true);
-
- } else {
- StyledText styledText= getViewer().getTextWidget();
- styledText.setFont(font);
- }
- }
-
- /**
- * Sets the initial partition for the underlying source viewer.
- *
- * @param partition the partition type
- */
- public void setStartingPartitionType(String partition) {
- if (partition == null)
- fPartition= IDocument.DEFAULT_CONTENT_TYPE;
- else
- fPartition= partition;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
- */
- public void setInformation(String content) {
- super.setInformation(content);
- IDocument doc= getViewer().getDocument();
- if (doc == null)
- return;
-
- // ensure that we can scroll enough
- ensureScrollable();
-
- String start= null;
- if (IJavaScriptPartitions.JAVA_DOC.equals(fPartition)) {
- start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
- } else if (IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT.equals(fPartition)) {
- start= "/*" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
- }
- if (start != null) {
- try {
- doc.replace(0, 0, start);
- int startLen= start.length();
- getViewer().setDocument(doc, startLen, doc.getLength() - startLen);
- } catch (BadLocationException e) {
- // impossible
- Assert.isTrue(false);
- }
- }
-
- getViewer().getTextWidget().setHorizontalPixel(fHorizontalScrollPixel);
- }
-
- /**
- * Ensures that the control can be scrolled at least to
- * <code>fHorizontalScrollPixel</code> and adjusts <code>fMaxWidth</code>
- * accordingly.
- */
- private void ensureScrollable() {
- IDocument doc= getViewer().getDocument();
- if (doc == null)
- return;
-
- StyledText widget= getViewer().getTextWidget();
- if (widget == null || widget.isDisposed())
- return;
-
- int last= doc.getNumberOfLines() - 1;
- GC gc= new GC(widget);
- gc.setFont(widget.getFont());
- int maxWidth= 0;
- String content= new String();
-
- try {
- for (int i= 0; i <= last; i++) {
- IRegion line;
- line= doc.getLineInformation(i);
- content= doc.get(line.getOffset(), line.getLength());
- int width= gc.textExtent(content).x;
- if (width > maxWidth) {
- maxWidth= width;
- }
- }
- } catch (BadLocationException e) {
- return;
- } finally {
- gc.dispose();
- }
-
- // limit the size of the window to the maximum width minus scrolling,
- // but never more than the configured max size (viewport size).
- fMaxWidth= Math.max(0, Math.min(fMaxWidth, maxWidth - fHorizontalScrollPixel + 8));
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.java.hover.SourceViewerInformationControl#hasContents()
- */
- public boolean hasContents() {
- return super.hasContents() && fMaxWidth > 0;
- }
-
- /**
- * Sets the horizontal scroll index in pixels.
- *
- * @param scrollIndex the new horizontal scroll index
- */
- public void setHorizontalScrollPixel(int scrollIndex) {
- scrollIndex= Math.max(0, scrollIndex);
- fHorizontalScrollPixel= scrollIndex;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CombinedWordRule.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CombinedWordRule.java
deleted file mode 100644
index 6c3bedf3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CombinedWordRule.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-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.IWordDetector;
-import org.eclipse.jface.text.rules.Token;
-
-
-/**
- * An implementation of <code>IRule</code> capable of detecting words.
- * <p>
- * Word rules also allow for the association of tokens with specific words.
- * That is, not only can the rule be used to provide tokens for exact matches,
- * but also for the generalized notion of a word in the context in which it is used.
- * A word rules uses a word detector to determine what a word is.</p>
- * <p>
- * This word rule allows a word detector to be shared among different word matchers.
- * Its up to the word matchers to decide if a word matches and, in this a case, which
- * token is associated with that word.
- * </p>
- *
- * @see IWordDetector
- *
- */
-public class CombinedWordRule implements IRule {
-
- /**
- * Word matcher, that associates matched words with tokens.
- */
- public static class WordMatcher {
-
- /** The table of predefined words and token for this matcher */
- private Map fWords= new HashMap();
-
- /**
- * 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) {
- Assert.isNotNull(word);
- Assert.isNotNull(token);
-
- fWords.put(new CharacterBuffer(word), token);
- }
-
- /**
- * Returns the token associated to the given word and the scanner state.
- *
- * @param scanner the scanner
- * @param word the word
- * @return the token or <code>null</code> if none is associated by this matcher
- */
- public IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
- IToken token= (IToken) fWords.get(word);
- if (token != null)
- return token;
- return Token.UNDEFINED;
- }
-
- /**
- * Removes all words.
- */
- public void clearWords() {
- fWords.clear();
- }
- }
-
- /**
- * Character buffer, mutable <b>or</b> suitable for use as key in hash maps.
- */
- public static class CharacterBuffer {
-
- /** Buffer content */
- private char[] fContent;
- /** Buffer content size */
- private int fLength= 0;
-
- /** Is hash code cached? */
- private boolean fIsHashCached= false;
- /** The hash code */
- private int fHashCode;
-
- /**
- * Initialize with the given capacity.
- *
- * @param capacity the initial capacity
- */
- public CharacterBuffer(int capacity) {
- fContent= new char[capacity];
- }
-
- /**
- * Initialize with the given content.
- *
- * @param content the initial content
- */
- public CharacterBuffer(String content) {
- fContent= content.toCharArray();
- fLength= content.length();
- }
-
- /**
- * Empties this buffer.
- */
- public void clear() {
- fIsHashCached= false;
- fLength= 0;
- }
-
- /**
- * Appends the given character to the buffer.
- *
- * @param c the character
- */
- public void append(char c) {
- fIsHashCached= false;
- if (fLength == fContent.length) {
- char[] old= fContent;
- fContent= new char[old.length << 1];
- System.arraycopy(old, 0, fContent, 0, old.length);
- }
- fContent[fLength++]= c;
- }
-
- /**
- * Returns the length of the content.
- *
- * @return the length
- */
- public int length() {
- return fLength;
- }
-
- /**
- * Returns the content as string.
- *
- * @return the content
- */
- public String toString() {
- return new String(fContent, 0, fLength);
- }
-
- /**
- * Returns the character at the given position.
- *
- * @param i the position
- * @return the character at position <code>i</code>
- */
- public char charAt(int i) {
- return fContent[i];
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- if (fIsHashCached)
- return fHashCode;
-
- int hash= 0;
- for (int i= 0, n= fLength; i < n; i++)
- hash= 29*hash + fContent[i];
- fHashCode= hash;
- fIsHashCached= true;
- return hash;
- }
-
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj == this)
- return true;
- if (!(obj instanceof CharacterBuffer))
- return false;
- CharacterBuffer buffer= (CharacterBuffer) obj;
- int length= buffer.length();
- if (length != fLength)
- return false;
- for (int i= 0; i < length; i++)
- if (buffer.charAt(i) != fContent[i])
- return false;
- return true;
- }
-
- /**
- * Is the content equal to the given string?
- *
- * @param string the string
- * @return <code>true</code> iff the content is the same character sequence as in the string
- */
- public boolean equals(String string) {
- int length= string.length();
- if (length != fLength)
- return false;
- for (int i= 0; i < length; i++)
- if (string.charAt(i) != fContent[i])
- return false;
- return true;
- }
- }
-
- /** Internal setting for the uninitialized column constraint */
- private static final int UNDEFINED= -1;
-
- /** The word detector used by this rule */
- private IWordDetector fDetector;
- /** The default token to be returned on success and if nothing else has been specified. */
- private IToken fDefaultToken;
- /** The column constraint */
- private int fColumn= UNDEFINED;
- /** Buffer used for pattern detection */
- private CharacterBuffer fBuffer= new CharacterBuffer(16);
-
- /** List of word matchers */
- private List fMatchers= new ArrayList();
-
- /**
- * 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 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 WordMatcher#addWord(String, IToken)
- */
- public CombinedWordRule(IWordDetector detector) {
- this(detector, null, 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 WordMatcher#addWord(String, IToken)
- */
- public CombinedWordRule(IWordDetector detector, IToken defaultToken) {
- this(detector, null, defaultToken);
- }
-
- /**
- * 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 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>
- * @param matcher the initial word matcher
- *
- * @see WordMatcher#addWord(String, IToken)
- */
- public CombinedWordRule(IWordDetector detector, WordMatcher matcher) {
- this(detector, matcher, 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 matcher the initial word matcher
- * @param defaultToken the default token to be returned on success
- * if nothing else is specified, may not be <code>null</code>
- *
- * @see WordMatcher#addWord(String, IToken)
- */
- public CombinedWordRule(IWordDetector detector, WordMatcher matcher, IToken defaultToken) {
-
- Assert.isNotNull(detector);
- Assert.isNotNull(defaultToken);
-
- fDetector= detector;
- fDefaultToken= defaultToken;
- if (matcher != null)
- addWordMatcher(matcher);
- }
-
-
- /**
- * Adds the given matcher.
- *
- * @param matcher the matcher
- */
- public void addWordMatcher(WordMatcher matcher) {
- fMatchers.add(matcher);
- }
-
- /**
- * Sets a column constraint for this rule. If set, the rule's token
- * will only be returned if the pattern is detected starting at the
- * specified column. If the column is smaller then 0, the column
- * constraint is considered removed.
- *
- * @param column the column in which the pattern starts
- */
- public void setColumnConstraint(int column) {
- if (column < 0)
- column= UNDEFINED;
- fColumn= column;
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (fDetector.isWordStart((char) c)) {
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
-
- fBuffer.clear();
- do {
- fBuffer.append((char) c);
- c= scanner.read();
- } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
- scanner.unread();
-
- for (int i= 0, n= fMatchers.size(); i < n; i++) {
- IToken token= ((WordMatcher) fMatchers.get(i)).evaluate(scanner, fBuffer);
- if (!token.isUndefined())
- return token;
- }
-
- if (fDefaultToken.isUndefined())
- unreadBuffer(scanner);
-
- return fDefaultToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- *
- * @param scanner the scanner to be used
- */
- private void unreadBuffer(ICharacterScanner scanner) {
- for (int i= fBuffer.length() - 1; i >= 0; i--)
- scanner.unread();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CompositeReconcilingStrategy.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CompositeReconcilingStrategy.java
deleted file mode 100644
index 6daf4b25..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/CompositeReconcilingStrategy.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-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.jface.text.reconciler.IReconcilingStrategyExtension;
-
-/**
- * A reconciling strategy consisting of a sequence of internal reconciling strategies.
- * By default, all requests are passed on to the contained strategies.
- *
- *
- */
-public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
-
- /** The list of internal reconciling strategies. */
- private IReconcilingStrategy[] fStrategies;
-
- /**
- * Creates a new, empty composite reconciling strategy.
- */
- public CompositeReconcilingStrategy() {
- }
-
- /**
- * Sets the reconciling strategies for this composite strategy.
- *
- * @param strategies the strategies to be set or <code>null</code>
- */
- public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
- fStrategies= strategies;
- }
-
- /**
- * Returns the previously set stratgies or <code>null</code>.
- *
- * @return the contained strategies or <code>null</code>
- */
- public IReconcilingStrategy[] getReconcilingStrategies() {
- return fStrategies;
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
- */
- public void setDocument(IDocument document) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].setDocument(document);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].reconcile(dirtyRegion, subRegion);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
- */
- public void reconcile(IRegion partition) {
- if (fStrategies == null)
- return;
-
- for (int i= 0; i < fStrategies.length; i++)
- fStrategies[i].reconcile(partition);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- if (fStrategies == null)
- return;
-
- for (int i=0; i < fStrategies.length; i++) {
- if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
- extension.setProgressMonitor(monitor);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
- */
- public void initialReconcile() {
- if (fStrategies == null)
- return;
-
- for (int i=0; i < fStrategies.length; i++) {
- if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
- extension.initialReconcile();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ContentAssistPreference.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ContentAssistPreference.java
deleted file mode 100644
index eec75732..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ContentAssistPreference.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-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;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProcessor;
-import org.eclipse.wst.jsdt.internal.ui.text.javadoc.JavadocCompletionProcessor;
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
-
-
-public class ContentAssistPreference {
-
- /** Preference key for content assist auto activation */
- private final static String AUTOACTIVATION= PreferenceConstants.CODEASSIST_AUTOACTIVATION;
- /** Preference key for content assist auto activation delay */
- private final static String AUTOACTIVATION_DELAY= PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY;
- /** Preference key for content assist proposal color */
- private final static String PROPOSALS_FOREGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
- /** Preference key for content assist proposal color */
- private final static String PROPOSALS_BACKGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
- /** Preference key for content assist parameters color */
- private final static String PARAMETERS_FOREGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
- /** Preference key for content assist parameters color */
- private final static String PARAMETERS_BACKGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
- /** Preference key for content assist auto insert */
- private final static String AUTOINSERT= PreferenceConstants.CODEASSIST_AUTOINSERT;
-
- /** Preference key for java content assist auto activation triggers */
- private final static String AUTOACTIVATION_TRIGGERS_JAVA= PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA;
- /** Preference key for javadoc content assist auto activation triggers */
- private final static String AUTOACTIVATION_TRIGGERS_JAVADOC= PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC;
-
- /** Preference key for visibility of proposals */
- private final static String SHOW_VISIBLE_PROPOSALS= PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS;
- /** Preference key for case sensitivity of proposals */
- private final static String CASE_SENSITIVITY= PreferenceConstants.CODEASSIST_CASE_SENSITIVITY;
- /** Preference key for adding imports on code assist */
- /** Preference key for filling argument names on method completion */
- private static final String FILL_METHOD_ARGUMENTS= PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES;
- /** Preference key for prefix completion. */
- private static final String PREFIX_COMPLETION= PreferenceConstants.CODEASSIST_PREFIX_COMPLETION;
-
-
- 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) {
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- return getColor(store, key, textTools.getColorManager());
- }
-
- private static JavaCompletionProcessor getJavaProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
- if (p instanceof JavaCompletionProcessor)
- return (JavaCompletionProcessor) p;
- return null;
- }
-
- private static JavadocCompletionProcessor getJavaDocProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p= assistant.getContentAssistProcessor(IJavaScriptPartitions.JAVA_DOC);
- if (p instanceof JavadocCompletionProcessor)
- return (JavadocCompletionProcessor) p;
- return null;
- }
-
- private static void configureJavaProcessor(ContentAssistant assistant, IPreferenceStore store) {
- JavaCompletionProcessor jcp= getJavaProcessor(assistant);
- if (jcp == null)
- return;
-
- String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVA);
- if (triggers != null)
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
-
- boolean enabled= store.getBoolean(SHOW_VISIBLE_PROPOSALS);
- jcp.restrictProposalsToVisibility(enabled);
-
- enabled= store.getBoolean(CASE_SENSITIVITY);
- jcp.restrictProposalsToMatchingCases(enabled);
- }
-
- private static void configureJavaDocProcessor(ContentAssistant assistant, IPreferenceStore store) {
- JavadocCompletionProcessor jdcp= getJavaDocProcessor(assistant);
- if (jdcp == null)
- return;
-
- String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVADOC);
- if (triggers != null)
- jdcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
-
- boolean enabled= store.getBoolean(CASE_SENSITIVITY);
- jdcp.restrictProposalsToMatchingCases(enabled);
- }
-
- /**
- * Configure the given content assistant from the given store.
- */
- public static void configure(ContentAssistant assistant, IPreferenceStore store) {
-
- JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
- IColorManager manager= textTools.getColorManager();
-
-
- boolean enabled= store.getBoolean(AUTOACTIVATION);
- assistant.enableAutoActivation(enabled);
-
- int delay= store.getInt(AUTOACTIVATION_DELAY);
- assistant.setAutoActivationDelay(delay);
-
- Color c= getColor(store, PROPOSALS_FOREGROUND, manager);
- assistant.setProposalSelectorForeground(c);
-
- c= getColor(store, PROPOSALS_BACKGROUND, manager);
- assistant.setProposalSelectorBackground(c);
-
- c= getColor(store, PARAMETERS_FOREGROUND, manager);
- assistant.setContextInformationPopupForeground(c);
- assistant.setContextSelectorForeground(c);
-
- c= getColor(store, PARAMETERS_BACKGROUND, manager);
- assistant.setContextInformationPopupBackground(c);
- assistant.setContextSelectorBackground(c);
-
- enabled= store.getBoolean(AUTOINSERT);
- assistant.enableAutoInsert(enabled);
-
- enabled= store.getBoolean(PREFIX_COMPLETION);
- assistant.enablePrefixCompletion(enabled);
-
- configureJavaProcessor(assistant, store);
- configureJavaDocProcessor(assistant, store);
- }
-
-
- private static void changeJavaProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
- JavaCompletionProcessor jcp= getJavaProcessor(assistant);
- if (jcp == null)
- return;
-
- if (AUTOACTIVATION_TRIGGERS_JAVA.equals(key)) {
- String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVA);
- if (triggers != null)
- jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- } else if (SHOW_VISIBLE_PROPOSALS.equals(key)) {
- boolean enabled= store.getBoolean(SHOW_VISIBLE_PROPOSALS);
- jcp.restrictProposalsToVisibility(enabled);
- } else if (CASE_SENSITIVITY.equals(key)) {
- boolean enabled= store.getBoolean(CASE_SENSITIVITY);
- jcp.restrictProposalsToMatchingCases(enabled);
- }
- }
-
- private static void changeJavaDocProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
- JavadocCompletionProcessor jdcp= getJavaDocProcessor(assistant);
- if (jdcp == null)
- return;
-
- if (AUTOACTIVATION_TRIGGERS_JAVADOC.equals(key)) {
- String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVADOC);
- if (triggers != null)
- jdcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- } else if (CASE_SENSITIVITY.equals(key)) {
- boolean enabled= store.getBoolean(CASE_SENSITIVITY);
- jdcp.restrictProposalsToMatchingCases(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.equals(p)) {
- boolean enabled= store.getBoolean(AUTOACTIVATION);
- 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);
- } else if (PREFIX_COMPLETION.equals(p)) {
- boolean enabled= store.getBoolean(PREFIX_COMPLETION);
- assistant.enablePrefixCompletion(enabled);
- }
-
- changeJavaProcessor(assistant, store, p);
- changeJavaDocProcessor(assistant, store, p);
- }
-
- public static boolean fillArgumentsOnMethodCompletion(IPreferenceStore store) {
- return store.getBoolean(FILL_METHOD_ARGUMENTS);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/DocumentCharacterIterator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/DocumentCharacterIterator.java
deleted file mode 100644
index 4362d93a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/DocumentCharacterIterator.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.text.CharacterIterator;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * An <code>IDocument</code> based implementation of
- * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that
- * the supplied document is not copied; if the document is modified during the
- * lifetime of a <code>DocumentCharacterIterator</code>, the methods
- * returning document content may not always return the same values. Also, if
- * accessing the document fails with a {@link BadLocationException}, any of
- * <code>CharacterIterator</code> methods as well as <code>charAt</code>may
- * return {@link CharacterIterator#DONE}.
- *
- *
- */
-public class DocumentCharacterIterator implements CharacterIterator, CharSequence {
-
- private int fIndex= -1;
- private final IDocument fDocument;
- private final int fFirst;
- private final int fLast;
-
- private void invariant() {
- Assert.isTrue(fIndex >= fFirst);
- Assert.isTrue(fIndex <= fLast);
- }
-
- /**
- * Creates an iterator for the entire document.
- *
- * @param document the document backing this iterator
- */
- public DocumentCharacterIterator(IDocument document) {
- this(document, 0);
- }
-
- /**
- * Creates an iterator, starting at offset <code>first</code>.
- *
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @throws IllegalArgumentException if the indices are out of bounds
- */
- public DocumentCharacterIterator(IDocument document, int first) throws IllegalArgumentException {
- this(document, first, document.getLength());
- }
-
- /**
- * Creates an iterator for the document contents from <code>first</code>
- * (inclusive) to <code>last</code> (exclusive).
- *
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @param last the last character index to consider
- * @throws IllegalArgumentException if the indices are out of bounds
- */
- public DocumentCharacterIterator(IDocument document, int first, int last) throws IllegalArgumentException {
- if (document == null)
- throw new NullPointerException();
- if (first < 0 || first > last)
- throw new IllegalArgumentException();
- if (last > document.getLength())
- throw new IllegalArgumentException();
- fDocument= document;
- fFirst= first;
- fLast= last;
- fIndex= first;
- invariant();
- }
-
- /*
- * @see java.text.CharacterIterator#first()
- */
- public char first() {
- return setIndex(getBeginIndex());
- }
-
- /*
- * @see java.text.CharacterIterator#last()
- */
- public char last() {
- if (fFirst == fLast)
- return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
- }
-
- /*
- * @see java.text.CharacterIterator#current()
- */
- public char current() {
- if (fIndex >= fFirst && fIndex < fLast)
- try {
- return fDocument.getChar(fIndex);
- } catch (BadLocationException e) {
- // ignore
- }
- return DONE;
- }
-
- /*
- * @see java.text.CharacterIterator#next()
- */
- public char next() {
- return setIndex(Math.min(fIndex + 1, getEndIndex()));
- }
-
- /*
- * @see java.text.CharacterIterator#previous()
- */
- public char previous() {
- if (fIndex > getBeginIndex()) {
- return setIndex(fIndex - 1);
- } else {
- return DONE;
- }
- }
-
- /*
- * @see java.text.CharacterIterator#setIndex(int)
- */
- public char setIndex(int position) {
- if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
- else
- throw new IllegalArgumentException();
-
- invariant();
- return current();
- }
-
- /*
- * @see java.text.CharacterIterator#getBeginIndex()
- */
- public int getBeginIndex() {
- return fFirst;
- }
-
- /*
- * @see java.text.CharacterIterator#getEndIndex()
- */
- public int getEndIndex() {
- return fLast;
- }
-
- /*
- * @see java.text.CharacterIterator#getIndex()
- */
- public int getIndex() {
- return fIndex;
- }
-
- /*
- * @see java.text.CharacterIterator#clone()
- */
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
- /*
- * @see java.lang.CharSequence#length()
- */
- public int length() {
- return getEndIndex() - getBeginIndex();
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Note that, if the document is modified concurrently, this method may
- * return {@link CharacterIterator#DONE} if a {@link BadLocationException}
- * was thrown when accessing the backing document.
- * </p>
- *
- * @param index {@inheritDoc}
- * @return {@inheritDoc}
- */
- public char charAt(int index) {
- if (index >= 0 && index < length())
- try {
- return fDocument.getChar(getBeginIndex() + index);
- } catch (BadLocationException e) {
- // ignore and return DONE
- return DONE;
- }
- else
- throw new IndexOutOfBoundsException();
- }
-
- /*
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int start, int end) {
- if (start < 0)
- throw new IndexOutOfBoundsException();
- if (end < start)
- throw new IndexOutOfBoundsException();
- if (end > length())
- throw new IndexOutOfBoundsException();
- return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java
deleted file mode 100644
index b8e6b1a3..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-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;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-
-/**
- * This scanner recognizes the JavaDoc comments, Java multi line comments, Java single line comments,
- * Java strings and Java characters.
- */
-public class FastJavaPartitionScanner implements IPartitionTokenScanner, IJavaScriptPartitions {
-
- // states
- private static final int JAVA= 0;
- private static final int SINGLE_LINE_COMMENT= 1;
- private static final int MULTI_LINE_COMMENT= 2;
- private static final int JAVADOC= 3;
- private static final int CHARACTER= 4;
- private static final int STRING= 5;
-
- // 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 JSDOC
- private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT or JSDOC
- private static final int SLASH_STAR_STAR= 4; // prefix for MULTI_LINE_COMMENT or JSDOC
- private static final int STAR= 5; // postfix for MULTI_LINE_COMMENT or JSDOC
- private static final int CARRIAGE_RETURN=6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
-
- /** The scanner. */
- 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 JavaPartitionScanner
- private boolean fEmulate= false;
- private int fJavaOffset;
- private int fJavaLength;
-
- private final IToken[] fTokens= new IToken[] {
- new Token(null),
- new Token(JAVA_SINGLE_LINE_COMMENT),
- new Token(JAVA_MULTI_LINE_COMMENT),
- new Token(JAVA_DOC),
- new Token(JAVA_CHARACTER),
- new Token(JAVA_STRING)
- };
-
- public FastJavaPartitionScanner(boolean emulate) {
- fEmulate= emulate;
- }
-
- public FastJavaPartitionScanner() {
- this(false);
- }
-
- /*
- * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
- */
- public IToken nextToken() {
-
- // emulate JavaPartitionScanner
- if (fEmulate) {
- if (fJavaOffset != -1 && fTokenOffset + fTokenLength != fJavaOffset + fJavaLength) {
- fTokenOffset += fTokenLength;
- return fTokens[JAVA];
- } else {
- fJavaOffset= -1;
- fJavaLength= 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, JAVA, NONE, 0);
-
- } else {
- fLast= NONE;
- fPrefixLength= 0;
- return Token.EOF;
- }
-
- case '\r':
- // emulate JavaPartitionScanner
- if (!fEmulate && 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 JavaPartitionScanner
- if (fEmulate) {
- fTokenLength++;
- fLast= NONE;
- fPrefixLength= 0;
- } else {
- fLast= CARRIAGE_RETURN;
- fPrefixLength= 1;
- }
-
- fState= JAVA;
- 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 (!fEmulate && fLast == CARRIAGE_RETURN) {
- switch (fState) {
- case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
-
- int last;
- int newState;
- switch (ch) {
- case '/':
- last= SLASH;
- newState= JAVA;
- break;
-
- case '*':
- last= STAR;
- newState= JAVA;
- break;
-
- case '\'':
- last= NONE;
- newState= CHARACTER;
- break;
-
- case '"':
- last= NONE;
- newState= STRING;
- break;
-
- case '\r':
- last= CARRIAGE_RETURN;
- newState= JAVA;
- break;
-
- case '\\':
- last= BACKSLASH;
- newState= JAVA;
- break;
-
- default:
- last= NONE;
- newState= JAVA;
- break;
- }
-
- fLast= NONE; // ignore fLast
- return preFix(fState, newState, last, 1);
-
- default:
- break;
- }
- }
- }
-
- // states
- switch (fState) {
- case JAVA:
- switch (ch) {
- case '/':
- if (fLast == SLASH) {
- if (fTokenLength - getLastLength(fLast) > 0) {
- return preFix(JAVA, SINGLE_LINE_COMMENT, NONE, 2);
- } else {
- preFix(JAVA, 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(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
- else {
- preFix(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- } else {
- consume();
- break;
- }
-
- case '\'':
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0)
- return preFix(JAVA, CHARACTER, NONE, 1);
- else {
- preFix(JAVA, CHARACTER, NONE, 1);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- case '"':
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0)
- return preFix(JAVA, STRING, NONE, 1);
- else {
- preFix(JAVA, STRING, NONE, 1);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- break;
- }
-
- default:
- consume();
- break;
- }
- break;
-
- case SINGLE_LINE_COMMENT:
- consume();
- break;
-
- case JAVADOC:
- switch (ch) {
- case '/':
- switch (fLast) {
- case SLASH_STAR_STAR:
- return postFix(MULTI_LINE_COMMENT);
-
- case STAR:
- return postFix(JAVADOC);
-
- default:
- consume();
- break;
- }
- break;
-
- case '*':
- fTokenLength++;
- fLast= STAR;
- break;
-
- default:
- consume();
- break;
- }
- break;
-
- case MULTI_LINE_COMMENT:
- switch (ch) {
- case '*':
- if (fLast == SLASH_STAR) {
- fLast= SLASH_STAR_STAR;
- fTokenLength++;
- fState= JAVADOC;
- } else {
- 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;
-
- case SLASH_STAR_STAR:
- return 3;
- }
- }
-
- private final void consume() {
- fTokenLength++;
- fLast= NONE;
- }
-
- private final IToken postFix(int state) {
- fTokenLength++;
- fLast= NONE;
- fState= JAVA;
- fPrefixLength= 0;
- return fTokens[state];
- }
-
- private final IToken preFix(int state, int newState, int last, int prefixLength) {
- // emulate JavaPartitionScanner
- if (fEmulate && state == JAVA && (fTokenLength - getLastLength(fLast) > 0)) {
- fTokenLength -= getLastLength(fLast);
- fJavaOffset= fTokenOffset;
- fJavaLength= 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 JAVA;
-
- else if (contentType.equals(JAVA_SINGLE_LINE_COMMENT))
- return SINGLE_LINE_COMMENT;
-
- else if (contentType.equals(JAVA_MULTI_LINE_COMMENT))
- return MULTI_LINE_COMMENT;
-
- else if (contentType.equals(JAVA_DOC))
- return JAVADOC;
-
- else if (contentType.equals(JAVA_STRING))
- return STRING;
-
- else if (contentType.equals(JAVA_CHARACTER))
- return CHARACTER;
-
- else
- return JAVA;
- }
-
- /*
- * @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= JAVA;
- } else {
- fState= getState(contentType);
- }
-
- // emulate JavaPartitionScanner
- if (fEmulate) {
- fJavaOffset= -1;
- fJavaLength= 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= JAVA;
-
- // emulate JavaPartitionScanner
- if (fEmulate) {
- fJavaOffset= -1;
- fJavaLength= 0;
- }
- }
-
- /*
- * @see ITokenScanner#getTokenLength()
- */
- public int getTokenLength() {
- return fTokenLength;
- }
-
- /*
- * @see ITokenScanner#getTokenOffset()
- */
- public int getTokenOffset() {
- return fTokenOffset;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/HTMLAnnotationHover.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/HTMLAnnotationHover.java
deleted file mode 100644
index 1c9dd9ac..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/HTMLAnnotationHover.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.jsdt.internal.ui.text.html.HTMLPrinter;
-import org.eclipse.jface.text.source.DefaultAnnotationHover;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-
-/**
- * Determines all markers for the given line and collects, concatenates, and formats
- * returns their messages in HTML.
- *
- *
- */
-public class HTMLAnnotationHover extends DefaultAnnotationHover {
-
- /*
- * Formats a message as HTML text.
- */
- protected 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.
- */
- protected String formatMultipleMessages(List messages) {
- StringBuffer buffer= new StringBuffer();
- HTMLPrinter.addPageProlog(buffer);
- HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(JavaUIMessages.JavaAnnotationHover_multipleMarkersAtThisLine));
-
- 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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ISourceVersionDependent.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ISourceVersionDependent.java
deleted file mode 100644
index 8139b38e..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ISourceVersionDependent.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-/**
- * Mix-in for any rule that changes its behavior based on the Java source
- * version.
- *
- *
- */
-public interface ISourceVersionDependent {
-
- /**
- * Sets the configured java source version to one of the
- * <code>JavaScriptCore.VERSION_X_Y</code> values.
- *
- * @param version the new java source version
- * @see org.eclipse.wst.jsdt.core.JavaScriptCore
- */
- void setSourceVersion(String version);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ITypingRunListener.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ITypingRunListener.java
deleted file mode 100644
index 3f162e17..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/ITypingRunListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import org.eclipse.wst.jsdt.internal.ui.text.TypingRun.ChangeType;
-
-
-/**
- * Listener for <code>TypingRun</code> events.
- *
- *
- */
-public interface ITypingRunListener {
- /**
- * Called when a new <code>TypingRun</code> is started.
- *
- * @param run the newly started run
- */
- void typingRunStarted(TypingRun run);
-
- /**
- * Called whenever a <code>TypingRun</code> is ended.
- *
- * @param run the ended run
- * @param reason the type of change that caused the end of the run
- */
- void typingRunEnded(TypingRun run, ChangeType reason);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaBreakIterator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaBreakIterator.java
deleted file mode 100644
index 6429c72d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaBreakIterator.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.text.CharacterIterator;
-
-import org.eclipse.core.runtime.Assert;
-
-import com.ibm.icu.text.BreakIterator;
-
-
-
-/**
- * A java break iterator. It returns all breaks, including before and after
- * whitespace, and it returns all camel case breaks.
- * <p>
- * A line break may be any of "\n", "\r", "\r\n", "\n\r".
- * </p>
- *
- *
- */
-public class JavaBreakIterator extends BreakIterator {
-
- /**
- * A run of common characters.
- */
- protected static abstract class Run {
- /** The length of this run. */
- protected int length;
-
- public Run() {
- init();
- }
-
- /**
- * Returns <code>true</code> if this run consumes <code>ch</code>,
- * <code>false</code> otherwise. If <code>true</code> is returned,
- * the length of the receiver is adjusted accordingly.
- *
- * @param ch the character to test
- * @return <code>true</code> if <code>ch</code> was consumed
- */
- protected boolean consume(char ch) {
- if (isValid(ch)) {
- length++;
- return true;
- }
- return false;
- }
-
- /**
- * Whether this run accepts that character; does not update state. Called
- * from the default implementation of <code>consume</code>.
- *
- * @param ch the character to test
- * @return <code>true</code> if <code>ch</code> is accepted
- */
- protected abstract boolean isValid(char ch);
-
- /**
- * Resets this run to the initial state.
- */
- protected void init() {
- length= 0;
- }
- }
-
- static final class Whitespace extends Run {
- protected boolean isValid(char ch) {
- return Character.isWhitespace(ch) && ch != '\n' && ch != '\r';
- }
- }
-
- static final class LineDelimiter extends Run {
- /** State: INIT -> delimiter -> EXIT. */
- private char fState;
- private static final char INIT= '\0';
- private static final char EXIT= '\1';
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#init()
- */
- protected void init() {
- super.init();
- fState= INIT;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#consume(char)
- */
- protected boolean consume(char ch) {
- if (!isValid(ch) || fState == EXIT)
- return false;
-
- if (fState == INIT) {
- fState= ch;
- length++;
- return true;
- } else if (fState != ch) {
- fState= EXIT;
- length++;
- return true;
- } else {
- return false;
- }
- }
-
- protected boolean isValid(char ch) {
- return ch == '\n' || ch == '\r';
- }
- }
-
- static final class Identifier extends Run {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#isValid(char)
- */
- protected boolean isValid(char ch) {
- return Character.isJavaIdentifierPart(ch);
- }
- }
-
- static final class CamelCaseIdentifier extends Run {
- /* states */
- private static final int S_INIT= 0;
- private static final int S_LOWER= 1;
- private static final int S_ONE_CAP= 2;
- private static final int S_ALL_CAPS= 3;
- private static final int S_EXIT= 4;
- private static final int S_EXIT_MINUS_ONE= 5;
-
- /* character types */
- private static final int K_INVALID= 0;
- private static final int K_LOWER= 1;
- private static final int K_UPPER= 2;
- private static final int K_OTHER= 3;
-
- private int fState;
-
- private final static int[][] MATRIX= new int[][] {
- // K_INVALID, K_LOWER, K_UPPER, K_OTHER
- { S_EXIT, S_LOWER, S_ONE_CAP, S_LOWER }, // S_INIT
- { S_EXIT, S_LOWER, S_EXIT, S_LOWER }, // S_LOWER
- { S_EXIT, S_LOWER, S_ALL_CAPS, S_LOWER }, // S_ONE_CAP
- { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_LOWER }, // S_ALL_CAPS
- };
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#init()
- */
- protected void init() {
- super.init();
- fState= S_INIT;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#consumes(char)
- */
- protected boolean consume(char ch) {
- int kind= getKind(ch);
- fState= MATRIX[fState][kind];
- switch (fState) {
- case S_LOWER:
- case S_ONE_CAP:
- case S_ALL_CAPS:
- length++;
- return true;
- case S_EXIT:
- return false;
- case S_EXIT_MINUS_ONE:
- length--;
- return false;
- default:
- Assert.isTrue(false);
- return false;
- }
- }
-
- /**
- * Determines the kind of a character.
- *
- * @param ch the character to test
- */
- private int getKind(char ch) {
- if (Character.isUpperCase(ch))
- return K_UPPER;
- if (Character.isLowerCase(ch))
- return K_LOWER;
- if (Character.isJavaIdentifierPart(ch)) // _, digits...
- return K_OTHER;
- return K_INVALID;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#isValid(char)
- */
- protected boolean isValid(char ch) {
- return Character.isJavaIdentifierPart(ch);
- }
- }
-
- static final class Other extends Run {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaBreakIterator.Run#isValid(char)
- */
- protected boolean isValid(char ch) {
- return !Character.isWhitespace(ch) && !Character.isJavaIdentifierPart(ch);
- }
- }
-
- private static final Run WHITESPACE= new Whitespace();
- private static final Run DELIMITER= new LineDelimiter();
- private static final Run CAMELCASE= new CamelCaseIdentifier(); // new Identifier();
- private static final Run OTHER= new Other();
-
- /** The platform break iterator (word instance) used as a base. */
- protected final BreakIterator fIterator;
- /** The text we operate on. */
- protected CharSequence fText;
- /** our current position for the stateful methods. */
- private int fIndex;
-
-
- /**
- * Creates a new break iterator.
- */
- public JavaBreakIterator() {
- fIterator= BreakIterator.getWordInstance();
- fIndex= fIterator.current();
- }
-
- /*
- * @see java.text.BreakIterator#current()
- */
- public int current() {
- return fIndex;
- }
-
- /*
- * @see java.text.BreakIterator#first()
- */
- public int first() {
- fIndex= fIterator.first();
- return fIndex;
- }
-
- /*
- * @see java.text.BreakIterator#following(int)
- */
- public int following(int offset) {
- // work around too eager IAEs in standard implementation
- if (offset == getText().getEndIndex())
- return DONE;
-
- int next= fIterator.following(offset);
- if (next == DONE)
- return DONE;
-
- // TODO deal with complex script word boundaries
- // Math.min(offset + run.length, next) does not work
- // since BreakIterator.getWordInstance considers _ as boundaries
- // seems to work fine, however
- Run run= consumeRun(offset);
- return offset + run.length;
-
- }
-
- /**
- * Consumes a run of characters at the limits of which we introduce a break.
- * @param offset the offset to start at
- * @return the run that was consumed
- */
- private Run consumeRun(int offset) {
- // assert offset < length
-
- char ch= fText.charAt(offset);
- int length= fText.length();
- Run run= getRun(ch);
- while (run.consume(ch) && offset < length - 1) {
- offset++;
- ch= fText.charAt(offset);
- }
-
- return run;
- }
-
- /**
- * Returns a run based on a character.
- *
- * @param ch the character to test
- * @return the correct character given <code>ch</code>
- */
- private Run getRun(char ch) {
- Run run;
- if (WHITESPACE.isValid(ch))
- run= WHITESPACE;
- else if (DELIMITER.isValid(ch))
- run= DELIMITER;
- else if (CAMELCASE.isValid(ch))
- run= CAMELCASE;
- else if (OTHER.isValid(ch))
- run= OTHER;
- else {
- Assert.isTrue(false);
- return null;
- }
-
- run.init();
- return run;
- }
-
- /*
- * @see java.text.BreakIterator#getText()
- */
- public CharacterIterator getText() {
- return fIterator.getText();
- }
-
- /*
- * @see java.text.BreakIterator#isBoundary(int)
- */
- public boolean isBoundary(int offset) {
- if (offset == getText().getBeginIndex())
- return true;
- else
- return following(offset - 1) == offset;
- }
-
- /*
- * @see java.text.BreakIterator#last()
- */
- public int last() {
- fIndex= fIterator.last();
- return fIndex;
- }
-
- /*
- * @see java.text.BreakIterator#next()
- */
- public int next() {
- fIndex= following(fIndex);
- return fIndex;
- }
-
- /*
- * @see java.text.BreakIterator#next(int)
- */
- public int next(int n) {
- return fIterator.next(n);
- }
-
- /*
- * @see java.text.BreakIterator#preceding(int)
- */
- public int preceding(int offset) {
- if (offset == getText().getBeginIndex())
- return DONE;
-
- if (isBoundary(offset - 1))
- return offset - 1;
-
- int previous= offset - 1;
- do {
- previous= fIterator.preceding(previous);
- } while (!isBoundary(previous));
-
- int last= DONE;
- while (previous < offset) {
- last= previous;
- previous= following(previous);
- }
-
- return last;
- }
-
- /*
- * @see java.text.BreakIterator#previous()
- */
- public int previous() {
- fIndex= preceding(fIndex);
- return fIndex;
- }
-
- /*
- * @see java.text.BreakIterator#setText(java.lang.String)
- */
- public void setText(String newText) {
- setText((CharSequence) newText);
- }
-
- /**
- * Creates a break iterator given a char sequence.
- * @param newText the new text
- */
- public void setText(CharSequence newText) {
- fText= newText;
- fIterator.setText(new SequenceCharacterIterator(newText));
- first();
- }
-
- /*
- * @see java.text.BreakIterator#setText(java.text.CharacterIterator)
- */
- public void setText(CharacterIterator newText) {
- if (newText instanceof CharSequence) {
- fText= (CharSequence) newText;
- fIterator.setText(newText);
- first();
- } else {
- throw new UnsupportedOperationException("CharacterIterator not supported"); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaChangeHover.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaChangeHover.java
deleted file mode 100644
index cb58a35d..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaChangeHover.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.LineChangeHover;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
-
-/**
- * A line change hover for Java source code. Adds a custom information control creator returning a
- * source viewer with syntax coloring.
- *
- *
- */
-public class JavaChangeHover extends LineChangeHover {
-
- /** The last computed partition type. */
- private String fPartition;
- /** The last created information control. */
- private ChangeHoverInformationControl fInformationControl;
- /** The document partitioning to be used by this hover. */
- private String fPartitioning;
- /** The last created information control. */
- private int fLastScrollIndex= 0;
-
- /**
- * The orientation to be used by this hover.
- * Allowed values are: SWT#RIGHT_TO_LEFT or SWT#LEFT_TO_RIGHT
- *
- */
- private int fOrientation;
-
- /**
- * Creates a new change hover for the given document partitioning.
- *
- * @param partitioning the document partitioning
- * @param orientation the orientation, allowed values are: SWT#RIGHT_TO_LEFT or SWT#LEFT_TO_RIGHT
- */
- public JavaChangeHover(String partitioning, int orientation) {
- Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT);
- fPartitioning= partitioning;
- fOrientation= orientation;
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.LineChangeHover#formatSource(java.lang.String)
- */
- protected String formatSource(String content) {
- return content;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator()
- */
- public IInformationControlCreator getHoverControlCreator() {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- int shellStyle= SWT.TOOL | SWT.NO_TRIM | fOrientation;
- fInformationControl= new ChangeHoverInformationControl(parent, shellStyle, SWT.NONE, fPartition, EditorsUI.getTooltipAffordanceString());
- fInformationControl.setHorizontalScrollPixel(fLastScrollIndex);
- return fInformationControl;
- }
- };
- }
-
- /*
- * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
- *
- */
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- int shellStyle= SWT.RESIZE | SWT.TOOL | fOrientation;
- int style= SWT.V_SCROLL | SWT.H_SCROLL;
- fInformationControl= new ChangeHoverInformationControl(parent, shellStyle, style, fPartition, null);
- fInformationControl.setHorizontalScrollPixel(fLastScrollIndex);
- return fInformationControl;
- }
- };
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineChangeHover#computeLineRange(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- */
- protected Point computeLineRange(ISourceViewer viewer, int line, int first, int number) {
- Point lineRange= super.computeLineRange(viewer, line, first, number);
- if (lineRange != null) {
- fPartition= getPartition(viewer, lineRange.x);
- } else {
- fPartition= IDocument.DEFAULT_CONTENT_TYPE;
- }
- fLastScrollIndex= viewer.getTextWidget().getHorizontalPixel();
- if (fInformationControl != null) {
- fInformationControl.setStartingPartitionType(fPartition);
- fInformationControl.setHorizontalScrollPixel(fLastScrollIndex);
- }
- return lineRange;
- }
-
- /**
- * Returns the partition type of the document displayed in <code>viewer</code> at <code>startLine</code>.
-
- * @param viewer the viewer
- * @param startLine the line in the viewer
- * @return the partition type at the start of <code>startLine</code>, or <code>IDocument.DEFAULT_CONTENT_TYPE</code> if none can be detected
- */
- private String getPartition(ISourceViewer viewer, int startLine) {
- if (viewer == null)
- return null;
- IDocument doc= viewer.getDocument();
- if (doc == null)
- return null;
- if (startLine <= 0)
- return IDocument.DEFAULT_CONTENT_TYPE;
- try {
- ITypedRegion region= TextUtilities.getPartition(doc, fPartitioning, doc.getLineOffset(startLine) - 1, true);
- return region.getType();
- } catch (BadLocationException e) {
- }
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
-
- /*
- * @see org.eclipse.jface.text.source.LineChangeHover#getTabReplacement()
- */
- protected String getTabReplacement() {
- return Character.toString('\t');
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCodeReader.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCodeReader.java
deleted file mode 100644
index c73d8a73..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCodeReader.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import java.io.IOException;
-
-import org.eclipse.wst.jsdt.internal.ui.text.html.SingleCharReader;
-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 JavaCodeReader 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 JavaCodeReader() {
- }
-
- /**
- * 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;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaColorManager.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaColorManager.java
deleted file mode 100644
index 5adc3e24..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaColorManager.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-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;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IColorManagerExtension;
-
-/**
- * Java color manager.
- */
-public class JavaColorManager implements IColorManager, IColorManagerExtension {
-
- protected Map fKeyTable= new HashMap(10);
- protected Map fDisplayTable= new HashMap(2);
-
- /**
- * Flag which tells if the colors are automatically disposed when
- * the current display gets disposed.
- */
- private boolean fAutoDisposeOnDisplayDispose;
-
-
- /**
- * Creates a new Java color manager which automatically
- * disposes the allocated colors when the current display
- * gets disposed.
- */
- public JavaColorManager() {
- this(true);
- }
-
- /**
- * Creates a new Java color manager.
- *
- * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager
- * automatically disposes all managed colors when the current display gets disposed
- * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored.
- *
- *
- */
- public JavaColorManager(boolean autoDisposeOnDisplayDispose) {
- fAutoDisposeOnDisplayDispose= autoDisposeOnDisplayDispose;
- }
-
- public void dispose(Display display) {
- Map colorTable= (Map) fDisplayTable.get(display);
- if (colorTable != null) {
- Iterator e= colorTable.values().iterator();
- while (e.hasNext()) {
- Color color= (Color)e.next();
- if (color != null && !color.isDisposed())
- color.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);
- if (fAutoDisposeOnDisplayDispose) {
- 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() {
- if (!fAutoDisposeOnDisplayDispose)
- dispose(Display.getCurrent());
- }
-
- /*
- * @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/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCommentScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCommentScanner.java
deleted file mode 100644
index e74b324a..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCommentScanner.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Michel Ishizuka <cqw10305@nifty.com> - Bug 113266 [syntax highlighting] javadoc tag names including period is not highlighting correctly
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-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.util.PropertyChangeEvent;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.internal.ui.text.CombinedWordRule.WordMatcher;
-import org.eclipse.wst.jsdt.ui.text.IColorManager;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptColorConstants;
-
-/**
- * AbstractJavaCommentScanner.java
- */
-public class JavaCommentScanner extends AbstractJavaScanner{
-
- private static class AtJavaIdentifierDetector implements IWordDetector {
-
- public boolean isWordStart(char c) {
- return c == '@' || Character.isJavaIdentifierStart(c);
- }
-
- public boolean isWordPart(char c) {
- return c == '.' || Character.isJavaIdentifierPart(c);
- }
- }
-
- private class TaskTagMatcher extends CombinedWordRule.WordMatcher {
-
- private IToken fToken;
- /**
- * Uppercase words
- *
- */
- private Map fUppercaseWords= new HashMap();
- /**
- * <code>true</code> if task tag detection is case-sensitive.
- *
- */
- private boolean fCaseSensitive= true;
- /**
- * Buffer for uppercase word
- *
- */
- private CombinedWordRule.CharacterBuffer fBuffer= new CombinedWordRule.CharacterBuffer(16);
-
- public TaskTagMatcher(IToken token) {
- fToken= token;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.CombinedWordRule.WordMatcher#clearWords()
- *
- */
- public synchronized void clearWords() {
- super.clearWords();
- fUppercaseWords.clear();
- }
-
- public synchronized 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;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.CombinedWordRule.WordMatcher#addWord(java.lang.String, org.eclipse.jface.text.rules.IToken)
- *
- */
- public synchronized void addWord(String word, IToken token) {
- Assert.isNotNull(word);
- Assert.isNotNull(token);
-
- super.addWord(word, token);
- fUppercaseWords.put(new CombinedWordRule.CharacterBuffer(word.toUpperCase()), token);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.CombinedWordRule.WordMatcher#evaluate(org.eclipse.jface.text.rules.ICharacterScanner, org.eclipse.wst.jsdt.internal.ui.text.CombinedWordRule.CharacterBuffer)
- *
- */
- public synchronized IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) {
- if (fCaseSensitive)
- return super.evaluate(scanner, word);
-
- fBuffer.clear();
- for (int i= 0, n= word.length(); i < n; i++)
- fBuffer.append(Character.toUpperCase(word.charAt(i)));
-
- IToken token= (IToken) fUppercaseWords.get(fBuffer);
- if (token != null)
- return token;
- return Token.UNDEFINED;
- }
-
- /**
- * Is task tag detection case-senstive?
- *
- * @return <code>true</code> iff task tag detection is case-sensitive
- *
- */
- public boolean isCaseSensitive() {
- return fCaseSensitive;
- }
-
- /**
- * Enables/disables the case-sensitivity of the task tag detection.
- *
- * @param caseSensitive <code>true</code> iff case-sensitivity should be enabled
- *
- */
- public void setCaseSensitive(boolean caseSensitive) {
- fCaseSensitive= caseSensitive;
- }
- }
-
- private static final String COMPILER_TASK_TAGS= JavaScriptCore.COMPILER_TASK_TAGS;
- protected static final String TASK_TAG= IJavaScriptColorConstants.TASK_TAG;
- /**
- * Preference key of a string preference, specifying if task tag detection is case-sensitive.
- *
- */
- private static final String COMPILER_TASK_CASE_SENSITIVE= JavaScriptCore.COMPILER_TASK_CASE_SENSITIVE;
- /**
- * Preference value of enabled preferences.
- *
- */
- private static final String ENABLED= JavaScriptCore.ENABLED;
-
- private TaskTagMatcher fTaskTagMatcher;
- private Preferences fCorePreferenceStore;
- private String fDefaultTokenProperty;
- private String[] fTokenProperties;
-
- public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
- this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
- }
-
- public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) {
- super(manager, store);
-
- fCorePreferenceStore= coreStore;
- fDefaultTokenProperty= defaultTokenProperty;
- fTokenProperties= tokenProperties;
-
- initialize();
- }
-
- /**
- * Initialize with the given arguments.
- *
- * @param manager Color manager
- * @param store Preference store
- * @param defaultTokenProperty Default token property
- *
- *
- */
- public JavaCommentScanner(IColorManager manager, IPreferenceStore store, String defaultTokenProperty) {
- this(manager, store, null, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
- }
-
- /**
- * Initialize with the given arguments.
- *
- * @param manager Color manager
- * @param store Preference store
- * @param defaultTokenProperty Default token property
- * @param tokenProperties Token properties
- *
- *
- */
- public JavaCommentScanner(IColorManager manager, IPreferenceStore store, String defaultTokenProperty, String[] tokenProperties) {
- this(manager, store, null, defaultTokenProperty, tokenProperties);
- }
-
- /*
- * @see AbstractJavaScanner#createRules()
- */
- protected List createRules() {
- List list= new ArrayList();
- Token defaultToken= getToken(fDefaultTokenProperty);
-
- List matchers= createMatchers();
- if (matchers.size() > 0) {
- CombinedWordRule combinedWordRule= new CombinedWordRule(new AtJavaIdentifierDetector(), defaultToken);
- for (int i= 0, n= matchers.size(); i < n; i++)
- combinedWordRule.addWordMatcher((WordMatcher) matchers.get(i));
- list.add(combinedWordRule);
- }
-
- setDefaultReturnToken(defaultToken);
-
- return list;
- }
-
- /**
- * Creates a list of word matchers.
- *
- * @return the list of word matchers
- */
- protected List createMatchers() {
- List list= new ArrayList();
-
- // Add rule for Task Tags.
- boolean isCaseSensitive= true;
- String tasks= null;
- if (getPreferenceStore().contains(COMPILER_TASK_TAGS)) {
- tasks= getPreferenceStore().getString(COMPILER_TASK_TAGS);
- isCaseSensitive= ENABLED.equals(getPreferenceStore().getString(COMPILER_TASK_CASE_SENSITIVE));
- } else if (fCorePreferenceStore != null) {
- tasks= fCorePreferenceStore.getString(COMPILER_TASK_TAGS);
- isCaseSensitive= ENABLED.equals(fCorePreferenceStore.getString(COMPILER_TASK_CASE_SENSITIVE));
- }
- if (tasks != null) {
- fTaskTagMatcher= new TaskTagMatcher(getToken(TASK_TAG));
- fTaskTagMatcher.addTaskTags(tasks);
- fTaskTagMatcher.setCaseSensitive(isCaseSensitive);
- list.add(fTaskTagMatcher);
- }
-
- return list;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public boolean affectsBehavior(PropertyChangeEvent event) {
- return event.getProperty().equals(COMPILER_TASK_TAGS) || event.getProperty().equals(COMPILER_TASK_CASE_SENSITIVE) || super.affectsBehavior(event);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void adaptToPreferenceChange(PropertyChangeEvent event) {
- if (fTaskTagMatcher != null && event.getProperty().equals(COMPILER_TASK_TAGS)) {
- Object value= event.getNewValue();
- if (value instanceof String) {
- synchronized (fTaskTagMatcher) {
- fTaskTagMatcher.clearWords();
- fTaskTagMatcher.addTaskTags((String) value);
- }
- }
- } else if (fTaskTagMatcher != null && event.getProperty().equals(COMPILER_TASK_CASE_SENSITIVE)) {
- Object value= event.getNewValue();
- if (value instanceof String)
- fTaskTagMatcher.setCaseSensitive(ENABLED.equals(value));
- } else if (super.affectsBehavior(event))
- super.adaptToPreferenceChange(event);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.AbstractJavaScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fTokenProperties;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCompositeReconcilingStrategy.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCompositeReconcilingStrategy.java
deleted file mode 100644
index 203ac7b1..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaCompositeReconcilingStrategy.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.text.java.IProblemRequestorExtension;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy;
-import org.eclipse.wst.jsdt.internal.ui.text.spelling.JavaSpellingReconcileStrategy;
-
-/**
- * Reconciling strategy for Java code. This is a composite strategy containing the
- * regular java model reconciler and the comment spelling strategy.
- *
- *
- */
-public class JavaCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
-
- private ITextEditor fEditor;
- private JavaReconcilingStrategy fJavaStrategy;
-
- /**
- * Creates a new Java reconciling strategy.
- *
- * @param viewer the source viewer
- * @param editor the editor of the strategy's reconciler
- * @param documentPartitioning the document partitioning this strategy uses for configuration
- */
- public JavaCompositeReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) {
- fEditor= editor;
- fJavaStrategy= new JavaReconcilingStrategy(editor);
- setReconcilingStrategies(new IReconcilingStrategy[] {
- fJavaStrategy,
- new JavaSpellingReconcileStrategy(viewer, editor)
- });
- }
-
- /**
- * Returns the problem requestor for the editor's input element.
- *
- * @return the problem requestor for the editor's input element
- */
- private IProblemRequestorExtension getProblemRequestorExtension() {
- IDocumentProvider p= fEditor.getDocumentProvider();
- if (p == null) {
- // work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=51522
- p= JavaScriptPlugin.getDefault().getCompilationUnitDocumentProvider();
- }
- IAnnotationModel m= p.getAnnotationModel(fEditor.getEditorInput());
- if (m instanceof IProblemRequestorExtension)
- return (IProblemRequestorExtension) m;
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- IProblemRequestorExtension e= getProblemRequestorExtension();
- if (e != null) {
- try {
- e.beginReportingSequence();
- super.reconcile(dirtyRegion, subRegion);
- } finally {
- e.endReportingSequence();
- }
- } else {
- super.reconcile(dirtyRegion, subRegion);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
- */
- public void reconcile(IRegion partition) {
- IProblemRequestorExtension e= getProblemRequestorExtension();
- if (e != null) {
- try {
- e.beginReportingSequence();
- super.reconcile(partition);
- } finally {
- e.endReportingSequence();
- }
- } else {
- super.reconcile(partition);
- }
- }
-
- /**
- * Tells this strategy whether to inform its listeners.
- *
- * @param notify <code>true</code> if listeners should be notified
- */
- public void notifyListeners(boolean notify) {
- fJavaStrategy.notifyListeners(notify);
- }
-
- /*
- * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
- */
- public void initialReconcile() {
- IProblemRequestorExtension e= getProblemRequestorExtension();
- if (e != null) {
- try {
- e.beginReportingSequence();
- super.initialReconcile();
- } finally {
- e.endReportingSequence();
- }
- } else {
- super.initialReconcile();
- }
- }
-
- /**
- * Called before reconciling is started.
- *
- *
- */
- public void aboutToBeReconciled() {
- fJavaStrategy.aboutToBeReconciled();
-
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaElementProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaElementProvider.java
deleted file mode 100644
index 0f4e1800..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaElementProvider.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
-
-/**
- * Provides a Java element to be displayed in by an information presenter.
- */
-public class JavaElementProvider implements IInformationProvider, IInformationProviderExtension {
-
- private JavaEditor fEditor;
- private boolean fUseCodeResolve;
-
- public JavaElementProvider(IEditorPart editor) {
- fUseCodeResolve= false;
- if (editor instanceof JavaEditor)
- fEditor= (JavaEditor)editor;
- }
-
- public JavaElementProvider(IEditorPart editor, boolean useCodeResolve) {
- this(editor);
- fUseCodeResolve= useCodeResolve;
- }
-
- /*
- * @see IInformationProvider#getSubject(ITextViewer, int)
- */
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- if (textViewer != null && fEditor != null) {
- IRegion region= JavaWordFinder.findWord(textViewer.getDocument(), offset);
- if (region != null)
- return region;
- else
- return new Region(offset, 0);
- }
- return null;
- }
-
- /*
- * @see IInformationProvider#getInformation(ITextViewer, IRegion)
- */
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return getInformation2(textViewer, subject).toString();
- }
-
- /*
- * @see IInformationProviderExtension#getElement(ITextViewer, IRegion)
- */
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- if (fEditor == null)
- return null;
-
- try {
- if (fUseCodeResolve) {
- IStructuredSelection sel= SelectionConverter.getStructuredSelection(fEditor);
- if (!sel.isEmpty())
- return sel.getFirstElement();
- }
- IJavaScriptElement element= SelectionConverter.getElementAtOffset(fEditor);
- if (element != null)
- return element;
-
- return EditorUtility.getEditorInputJavaElement(fEditor, false);
- } catch (JavaScriptModelException e) {
- return null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaHeuristicScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaHeuristicScanner.java
deleted file mode 100644
index 2ca59a9f..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaHeuristicScanner.java
+++ /dev/null
@@ -1,950 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedRegion;
-import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;
-
-/**
- * Utility methods for heuristic based Java manipulations in an incomplete Java source file.
- *
- * <p>An instance holds some internal position in the document and is therefore not threadsafe.</p>
- *
- *
- */
-public final class JavaHeuristicScanner implements Symbols {
- /**
- * Returned by all methods when the requested position could not be found, or if a
- * {@link BadLocationException} was thrown while scanning.
- */
- public static final int NOT_FOUND= -1;
-
- /**
- * Special bound parameter that means either -1 (backward scanning) or
- * <code>fDocument.getLength()</code> (forward scanning).
- */
- public static final int UNBOUND= -2;
-
-
- /* character constants */
- private static final char LBRACE= '{';
- private static final char RBRACE= '}';
- private static final char LPAREN= '(';
- private static final char RPAREN= ')';
- private static final char SEMICOLON= ';';
- private static final char COLON= ':';
- private static final char COMMA= ',';
- private static final char LBRACKET= '[';
- private static final char RBRACKET= ']';
- private static final char QUESTIONMARK= '?';
- private static final char EQUAL= '=';
- private static final char LANGLE= '<';
- private static final char RANGLE= '>';
-
- /**
- * Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether
- * to keep scanning or not. This interface may implemented by clients.
- */
- private static abstract class StopCondition {
- /**
- * Instructs the scanner to return the current position.
- *
- * @param ch the char at the current position
- * @param position the current position
- * @param forward the iteration direction
- * @return <code>true</code> if the stop condition is met.
- */
- public abstract boolean stop(char ch, int position, boolean forward);
-
- /**
- * Asks the condition to return the next position to query. The default
- * is to return the next/previous position.
- *
- * @return the next position to scan
- */
- public int nextPosition(int position, boolean forward) {
- return forward ? position + 1 : position - 1;
- }
- }
-
- /**
- * Stops upon a non-whitespace (as defined by {@link Character#isWhitespace(char)}) character.
- */
- private static class NonWhitespace extends StopCondition {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
- */
- public boolean stop(char ch, int position, boolean forward) {
- return !Character.isWhitespace(ch);
- }
- }
-
- /**
- * Stops upon a non-whitespace character in the default partition.
- *
- * @see JavaHeuristicScanner.NonWhitespace
- */
- private final class NonWhitespaceDefaultPartition extends NonWhitespace {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
- */
- public boolean stop(char ch, int position, boolean forward) {
- return super.stop(ch, position, true) && isDefaultPartition(position);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, boolean)
- */
- public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
- if (fPartition.equals(partition.getType()))
- return super.nextPosition(position, forward);
-
- if (forward) {
- int end= partition.getOffset() + partition.getLength();
- if (position < end)
- return end;
- } else {
- int offset= partition.getOffset();
- if (position > offset)
- return offset - 1;
- }
- return super.nextPosition(position, forward);
- }
- }
-
- /**
- * Stops upon a non-java identifier (as defined by {@link Character#isJavaIdentifierPart(char)}) character.
- */
- private static class NonJavaIdentifierPart extends StopCondition {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
- */
- public boolean stop(char ch, int position, boolean forward) {
- return !Character.isJavaIdentifierPart(ch);
- }
- }
-
- /**
- * Stops upon a non-java identifier character in the default partition.
- *
- * @see JavaHeuristicScanner.NonJavaIdentifierPart
- */
- private final class NonJavaIdentifierPartDefaultPartition extends NonJavaIdentifierPart {
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
- */
- public boolean stop(char ch, int position, boolean forward) {
- return super.stop(ch, position, true) || !isDefaultPartition(position);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, boolean)
- */
- public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
- if (fPartition.equals(partition.getType()))
- return super.nextPosition(position, forward);
-
- if (forward) {
- int end= partition.getOffset() + partition.getLength();
- if (position < end)
- return end;
- } else {
- int offset= partition.getOffset();
- if (position > offset)
- return offset - 1;
- }
- return super.nextPosition(position, forward);
- }
- }
-
- /**
- * Stops upon a character in the default partition that matches the given character list.
- */
- private final class CharacterMatch extends StopCondition {
- private final char[] fChars;
-
- /**
- * Creates a new instance.
- * @param ch the single character to match
- */
- public CharacterMatch(char ch) {
- this(new char[] {ch});
- }
-
- /**
- * Creates a new instance.
- * @param chars the chars to match.
- */
- public CharacterMatch(char[] chars) {
- Assert.isNotNull(chars);
- Assert.isTrue(chars.length > 0);
- fChars= chars;
- Arrays.sort(chars);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char, int)
- */
- public boolean stop(char ch, int position, boolean forward) {
- return Arrays.binarySearch(fChars, ch) >= 0 && isDefaultPartition(position);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, boolean)
- */
- public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
- if (fPartition.equals(partition.getType()))
- return super.nextPosition(position, forward);
-
- if (forward) {
- int end= partition.getOffset() + partition.getLength();
- if (position < end)
- return end;
- } else {
- int offset= partition.getOffset();
- if (position > offset)
- return offset - 1;
- }
- return super.nextPosition(position, forward);
- }
- }
-
- /** The document being scanned. */
- private final IDocument fDocument;
- /** The partitioning being used for scanning. */
- private final String fPartitioning;
- /** The partition to scan in. */
- private final String fPartition;
-
- /* internal scan state */
-
- /** the most recently read character. */
- private char fChar;
- /** the most recently read position. */
- private int fPos;
- /**
- * The most recently used partition.
- *
- */
- private ITypedRegion fCachedPartition= new TypedRegion(-1, 0, "__no_partition_at_all"); //$NON-NLS-1$
-
- /* preset stop conditions */
- private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
- private final static StopCondition fNonWS= new NonWhitespace();
- private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
-
- /**
- * Creates a new instance.
- *
- * @param document the document to scan
- * @param partitioning the partitioning to use for scanning
- * @param partition the partition to scan in
- */
- public JavaHeuristicScanner(IDocument document, String partitioning, String partition) {
- Assert.isLegal(document != null);
- Assert.isLegal(partitioning != null);
- Assert.isLegal(partition != null);
- fDocument= document;
- fPartitioning= partitioning;
- fPartition= partition;
- }
-
- /**
- * Calls <code>this(document, IJavaScriptPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>.
- *
- * @param document the document to scan.
- */
- public JavaHeuristicScanner(IDocument document) {
- this(document, IJavaScriptPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /**
- * Returns the most recent internal scan position.
- *
- * @return the most recent internal scan position.
- */
- public int getPosition() {
- return fPos;
- }
-
- /**
- * Returns the next token in forward direction, starting at <code>start</code>, and not extending
- * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
- * After a call, {@link #getPosition()} will return the position just after the scanned token
- * (i.e. the next position that will be scanned).
- *
- * @param start the first character position in the document to consider
- * @param bound the first position not to consider any more
- * @return a constant from {@link Symbols} describing the next token
- */
- public int nextToken(int start, int bound) {
- int pos= scanForward(start, bound, fNonWSDefaultPart);
- if (pos == NOT_FOUND)
- return TokenEOF;
-
- fPos++;
-
- switch (fChar) {
- case LBRACE:
- return TokenLBRACE;
- case RBRACE:
- return TokenRBRACE;
- case LBRACKET:
- return TokenLBRACKET;
- case RBRACKET:
- return TokenRBRACKET;
- case LPAREN:
- return TokenLPAREN;
- case RPAREN:
- return TokenRPAREN;
- case SEMICOLON:
- return TokenSEMICOLON;
- case COMMA:
- return TokenCOMMA;
- case QUESTIONMARK:
- return TokenQUESTIONMARK;
- case EQUAL:
- return TokenEQUAL;
- case LANGLE:
- return TokenLESSTHAN;
- case RANGLE:
- return TokenGREATERTHAN;
- }
-
- // else
- if (Character.isJavaIdentifierPart(fChar)) {
- // assume an identifier or keyword
- int from= pos, to;
- pos= scanForward(pos + 1, bound, fNonIdent);
- if (pos == NOT_FOUND)
- to= bound == UNBOUND ? fDocument.getLength() : bound;
- else
- to= pos;
-
- String identOrKeyword;
- try {
- identOrKeyword= fDocument.get(from, to - from);
- } catch (BadLocationException e) {
- return TokenEOF;
- }
-
- return getToken(identOrKeyword);
-
-
- } else {
- // operators, number literals etc
- return TokenOTHER;
- }
- }
-
- /**
- * Returns the next token in backward direction, starting at <code>start</code>, and not extending
- * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
- * After a call, {@link #getPosition()} will return the position just before the scanned token
- * starts (i.e. the next position that will be scanned).
- *
- * @param start the first character position in the document to consider
- * @param bound the first position not to consider any more
- * @return a constant from {@link Symbols} describing the previous token
- */
- public int previousToken(int start, int bound) {
- int pos= scanBackward(start, bound, fNonWSDefaultPart);
- if (pos == NOT_FOUND)
- return TokenEOF;
-
- fPos--;
-
- switch (fChar) {
- case LBRACE:
- return TokenLBRACE;
- case RBRACE:
- return TokenRBRACE;
- case LBRACKET:
- return TokenLBRACKET;
- case RBRACKET:
- return TokenRBRACKET;
- case LPAREN:
- return TokenLPAREN;
- case RPAREN:
- return TokenRPAREN;
- case SEMICOLON:
- return TokenSEMICOLON;
- case COLON:
- return TokenCOLON;
- case COMMA:
- return TokenCOMMA;
- case QUESTIONMARK:
- return TokenQUESTIONMARK;
- case EQUAL:
- return TokenEQUAL;
- case LANGLE:
- return TokenLESSTHAN;
- case RANGLE:
- return TokenGREATERTHAN;
- }
-
- // else
- if (Character.isJavaIdentifierPart(fChar)) {
- // assume an ident or keyword
- int from, to= pos + 1;
- pos= scanBackward(pos - 1, bound, fNonIdent);
- if (pos == NOT_FOUND)
- from= bound == UNBOUND ? 0 : bound + 1;
- else
- from= pos + 1;
-
- String identOrKeyword;
- try {
- identOrKeyword= fDocument.get(from, to - from);
- } catch (BadLocationException e) {
- return TokenEOF;
- }
-
- return getToken(identOrKeyword);
-
-
- } else {
- // operators, number literals etc
- return TokenOTHER;
- }
-
- }
-
- /**
- * Returns one of the keyword constants or <code>TokenIDENT</code> for a scanned identifier.
- *
- * @param s a scanned identifier
- * @return one of the constants defined in {@link Symbols}
- */
- private int getToken(String s) {
- Assert.isNotNull(s);
-
- switch (s.length()) {
- case 2:
- if ("if".equals(s)) //$NON-NLS-1$
- return TokenIF;
- if ("do".equals(s)) //$NON-NLS-1$
- return TokenDO;
- break;
- case 3:
- if ("for".equals(s)) //$NON-NLS-1$
- return TokenFOR;
- if ("try".equals(s)) //$NON-NLS-1$
- return TokenTRY;
- if ("new".equals(s)) //$NON-NLS-1$
- return TokenNEW;
- break;
- case 4:
- if ("case".equals(s)) //$NON-NLS-1$
- return TokenCASE;
- if ("else".equals(s)) //$NON-NLS-1$
- return TokenELSE;
- if ("enum".equals(s)) //$NON-NLS-1$
- return TokenENUM;
- if ("goto".equals(s)) //$NON-NLS-1$
- return TokenGOTO;
- break;
- case 5:
- if ("break".equals(s)) //$NON-NLS-1$
- return TokenBREAK;
- if ("catch".equals(s)) //$NON-NLS-1$
- return TokenCATCH;
- if ("class".equals(s)) //$NON-NLS-1$
- return TokenCLASS;
- if ("while".equals(s)) //$NON-NLS-1$
- return TokenWHILE;
- break;
- case 6:
- if ("return".equals(s)) //$NON-NLS-1$
- return TokenRETURN;
- if ("static".equals(s)) //$NON-NLS-1$
- return TokenSTATIC;
- if ("switch".equals(s)) //$NON-NLS-1$
- return TokenSWITCH;
- break;
- case 7:
- if ("default".equals(s)) //$NON-NLS-1$
- return TokenDEFAULT;
- if ("finally".equals(s)) //$NON-NLS-1$
- return TokenFINALLY;
- break;
- case 9:
- if ("interface".equals(s)) //$NON-NLS-1$
- return TokenINTERFACE;
- break;
- case 12:
- if ("synchronized".equals(s)) //$NON-NLS-1$
- return TokenSYNCHRONIZED;
- break;
- }
- return TokenIDENT;
- }
-
- /**
- * Returns the position of the closing peer character (forward search). Any scopes introduced by opening peers
- * are skipped. All peers accounted for must reside in the default partition.
- *
- * <p>Note that <code>start</code> must not point to the opening peer, but to the first
- * character being searched.</p>
- *
- * @param start the start position
- * @param openingPeer the opening peer character (e.g. '{')
- * @param closingPeer the closing peer character (e.g. '}')
- * @return the matching peer character position, or <code>NOT_FOUND</code>
- */
- public int findClosingPeer(int start, final char openingPeer, final char closingPeer) {
- return findClosingPeer(start, UNBOUND, openingPeer, closingPeer);
- }
-
- /**
- * Returns the position of the closing peer character (forward search). Any scopes introduced by opening peers
- * are skipped. All peers accounted for must reside in the default partition.
- *
- * <p>Note that <code>start</code> must not point to the opening peer, but to the first
- * character being searched.</p>
- *
- * @param start the start position
- * @param bound the bound
- * @param openingPeer the opening peer character (e.g. '{')
- * @param closingPeer the closing peer character (e.g. '}')
- * @return the matching peer character position, or <code>NOT_FOUND</code>
- */
- public int findClosingPeer(int start, int bound, final char openingPeer, final char closingPeer) {
- Assert.isLegal(start >= 0);
-
- try {
- CharacterMatch match= new CharacterMatch(new char[] {openingPeer, closingPeer});
- int depth= 1;
- start -= 1;
- while (true) {
- start= scanForward(start + 1, bound, match);
- if (start == NOT_FOUND)
- return NOT_FOUND;
-
- if (fDocument.getChar(start) == openingPeer)
- depth++;
- else
- depth--;
-
- if (depth == 0)
- return start;
- }
-
- } catch (BadLocationException e) {
- return NOT_FOUND;
- }
- }
-
- /**
- * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers
- * are skipped. All peers accounted for must reside in the default partition.
- *
- * <p>Note that <code>start</code> must not point to the closing peer, but to the first
- * character being searched.</p>
- *
- * @param start the start position
- * @param openingPeer the opening peer character (e.g. '{')
- * @param closingPeer the closing peer character (e.g. '}')
- * @return the matching peer character position, or <code>NOT_FOUND</code>
- */
- public int findOpeningPeer(int start, char openingPeer, char closingPeer) {
- return findOpeningPeer(start, UNBOUND, openingPeer, closingPeer);
- }
-
- /**
- * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers
- * are skipped. All peers accounted for must reside in the default partition.
- *
- * <p>Note that <code>start</code> must not point to the closing peer, but to the first
- * character being searched.</p>
- *
- * @param start the start position
- * @param bound the bound
- * @param openingPeer the opening peer character (e.g. '{')
- * @param closingPeer the closing peer character (e.g. '}')
- * @return the matching peer character position, or <code>NOT_FOUND</code>
- */
- public int findOpeningPeer(int start, int bound, char openingPeer, char closingPeer) {
- Assert.isLegal(start < fDocument.getLength());
-
- try {
- final CharacterMatch match= new CharacterMatch(new char[] {openingPeer, closingPeer});
- int depth= 1;
- start += 1;
- while (true) {
- start= scanBackward(start - 1, bound, match);
- if (start == NOT_FOUND)
- return NOT_FOUND;
-
- if (fDocument.getChar(start) == closingPeer)
- depth++;
- else
- depth--;
-
- if (depth == 0)
- return start;
- }
-
- } catch (BadLocationException e) {
- return NOT_FOUND;
- }
- }
-
- /**
- * Computes the surrounding block around <code>offset</code>. The search is started at the
- * beginning of <code>offset</code>, i.e. an opening brace at <code>offset</code> will not be
- * part of the surrounding block, but a closing brace will.
- *
- * @param offset the offset for which the surrounding block is computed
- * @return a region describing the surrounding block, or <code>null</code> if none can be found
- */
- public IRegion findSurroundingBlock(int offset) {
- if (offset < 1 || offset >= fDocument.getLength())
- return null;
-
- int begin= findOpeningPeer(offset - 1, LBRACE, RBRACE);
- int end= findClosingPeer(offset, LBRACE, RBRACE);
- if (begin == NOT_FOUND || end == NOT_FOUND)
- return null;
- return new Region(begin, end + 1 - begin);
- }
-
- /**
- * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
- * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
- * and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
- * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int findNonWhitespaceForward(int position, int bound) {
- return scanForward(position, bound, fNonWSDefaultPart);
- }
-
- /**
- * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
- * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
- * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>), or <code>NOT_FOUND</code> if none can be found
- */
- public int findNonWhitespaceForwardInAnyPartition(int position, int bound) {
- return scanForward(position, bound, fNonWS);
- }
-
- /**
- * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
- * and &gt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
- * and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
- * @return the highest position of a non-whitespace character in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int findNonWhitespaceBackward(int position, int bound) {
- return scanBackward(position, bound, fNonWSDefaultPart);
- }
-
- /**
- * Finds the lowest position <code>p</code> in <code>fDocument</code> such that <code>start</code> &lt;= p &lt;
- * <code>bound</code> and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
- *
- * @param start the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>start</code>, or <code>UNBOUND</code>
- * @param condition the <code>StopCondition</code> to check
- * @return the lowest position in [<code>start</code>, <code>bound</code>) for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanForward(int start, int bound, StopCondition condition) {
- Assert.isLegal(start >= 0);
-
- if (bound == UNBOUND)
- bound= fDocument.getLength();
-
- Assert.isLegal(bound <= fDocument.getLength());
-
- try {
- fPos= start;
- while (fPos < bound) {
-
- fChar= fDocument.getChar(fPos);
- if (condition.stop(fChar, fPos, true))
- return fPos;
-
- fPos= condition.nextPosition(fPos, true);
- }
- } catch (BadLocationException e) {
- }
- return NOT_FOUND;
- }
-
-
- /**
- * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
- * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code>
- * and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
- * @param ch the <code>char</code> to search for
- * @return the lowest position of <code>ch</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanForward(int position, int bound, char ch) {
- return scanForward(position, bound, new CharacterMatch(ch));
- }
-
- /**
- * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
- * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
- * ch in <code>chars</code> and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
- * @param chars an array of <code>char</code> to search for
- * @return the lowest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanForward(int position, int bound, char[] chars) {
- return scanForward(position, bound, new CharacterMatch(chars));
- }
-
- /**
- * Finds the highest position <code>p</code> in <code>fDocument</code> such that <code>bound</code> &lt; <code>p</code> &lt;= <code>start</code>
- * and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
- *
- * @param start the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
- * @param condition the <code>StopCondition</code> to check
- * @return the highest position in (<code>bound</code>, <code>start</code> for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanBackward(int start, int bound, StopCondition condition) {
- if (bound == UNBOUND)
- bound= -1;
-
- Assert.isLegal(bound >= -1);
- Assert.isLegal(start < fDocument.getLength() );
-
- try {
- fPos= start;
- while (fPos > bound) {
-
- fChar= fDocument.getChar(fPos);
- if (condition.stop(fChar, fPos, false))
- return fPos;
-
- fPos= condition.nextPosition(fPos, false);
- }
- } catch (BadLocationException e) {
- }
- return NOT_FOUND;
- }
-
- /**
- * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
- * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
- * ch in <code>chars</code> and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
- * @param ch the <code>char</code> to search for
- * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanBackward(int position, int bound, char ch) {
- return scanBackward(position, bound, new CharacterMatch(ch));
- }
-
- /**
- * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
- * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
- * ch in <code>chars</code> and the position is in the default partition.
- *
- * @param position the first character position in <code>fDocument</code> to be considered
- * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
- * @param chars an array of <code>char</code> to search for
- * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
- */
- public int scanBackward(int position, int bound, char[] chars) {
- return scanBackward(position, bound, new CharacterMatch(chars));
- }
-
- /**
- * Checks whether <code>position</code> resides in a default (Java) partition of <code>fDocument</code>.
- *
- * @param position the position to be checked
- * @return <code>true</code> if <code>position</code> is in the default partition of <code>fDocument</code>, <code>false</code> otherwise
- */
- public boolean isDefaultPartition(int position) {
- return fPartition.equals(getPartition(position).getType());
- }
-
- /**
- * Returns the partition at <code>position</code>.
- *
- * @param position the position to get the partition for
- * @return the partition at <code>position</code> or a dummy zero-length
- * partition if accessing the document fails
- */
- private ITypedRegion getPartition(int position) {
- if (!contains(fCachedPartition, position)) {
- Assert.isTrue(position >= 0);
- Assert.isTrue(position <= fDocument.getLength());
-
- try {
- fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false);
- } catch (BadLocationException e) {
- fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$
- }
- }
-
- return fCachedPartition;
- }
-
- /**
- * Returns <code>true</code> if <code>region</code> contains <code>position</code>.
- *
- * @param region a region
- * @param position an offset
- * @return <code>true</code> if <code>region</code> contains <code>position</code>
- *
- */
- private boolean contains(IRegion region, int position) {
- int offset= region.getOffset();
- return offset <= position && position < offset + region.getLength();
- }
-
- /**
- * Checks if the line seems to be an open condition not followed by a block (i.e. an if, while,
- * or for statement with just one following statement, see example below).
- *
- * <pre>
- * if (condition)
- * doStuff();
- * </pre>
- *
- * <p>Algorithm: if the last non-WS, non-Comment code on the line is an if (condition), while (condition),
- * for( expression), do, else, and there is no statement after that </p>
- *
- * @param position the insert position of the new character
- * @param bound the lowest position to consider
- * @return <code>true</code> if the code is a conditional statement or loop without a block, <code>false</code> otherwise
- */
- public boolean isBracelessBlockStart(int position, int bound) {
- if (position < 1)
- return false;
-
- switch (previousToken(position, bound)) {
- case TokenDO:
- case TokenELSE:
- return true;
- case TokenRPAREN:
- position= findOpeningPeer(fPos, LPAREN, RPAREN);
- if (position > 0) {
- switch (previousToken(position - 1, bound)) {
- case TokenIF:
- case TokenFOR:
- case TokenWHILE:
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
- * appears to contain a class instance creation, i.e. a possibly qualified name preceded by a
- * <code>new</code> keyword. The <code>start</code> must be at the end of the type name, and
- * before any generic signature or constructor parameter list. The heuristic will return
- * <code>true</code> if <code>start</code> is at the following positions (|):
- *
- * <pre>
- * new java.util. ArrayList|&lt;String&gt;(10)
- * new ArrayList |(10)
- * new / * comment * / ArrayList |(10)
- * </pre>
- *
- * but not the following:
- *
- * <pre>
- * new java.util. ArrayList&lt;String&gt;(10)|
- * new java.util. ArrayList&lt;String&gt;|(10)
- * new ArrayList (10)|
- * ArrayList |(10)
- * </pre>
- *
- * @param start the position where the type name of the class instance creation supposedly ends
- * @param bound the first position in <code>fDocument</code> to not consider any more, with
- * <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
- * @return <code>true</code> if the current position looks like after the type name of a class
- * instance creation
- *
- */
- public boolean looksLikeClassInstanceCreationBackward(int start, int bound) {
- int token= previousToken(start - 1, bound);
- if (token == Symbols.TokenIDENT) { // type name
- token= previousToken(getPosition(), bound);
- while (token == Symbols.TokenOTHER) { // dot of qualification
- token= previousToken(getPosition(), bound);
- if (token != Symbols.TokenIDENT) // qualification name
- return false;
- token= previousToken(getPosition(), bound);
- }
- return token == Symbols.TokenNEW;
- }
- return false;
- }
-
- /**
- * Returns <code>true</code> if <code>identifier</code> is probably a
- * type variable or type name, <code>false</code> if it is rather not.
- * This is a heuristic.
- *
- * @param identifier the identifier to check
- * @return <code>true</code> if <code>identifier</code> is probably a
- * type variable or type name, <code>false</code> if not
- *
- */
- public static boolean isGenericStarter(CharSequence identifier) {
- /* This heuristic allows any identifiers if they start with an upper
- * case. This will fail when a comparison is made with constants:
- *
- * if (MAX > foo)
- *
- * will try to find the matching '<' which will never come
- *
- * Also, it will fail on lower case types and type variables
- */
- int length= identifier.length();
- if (length > 0 && Character.isUpperCase(identifier.charAt(0))) {
- for (int i= 0; i < length; i++) {
- if (identifier.charAt(i) == '_')
- return false;
- }
- return true;
- }
- return false;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaIndenter.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaIndenter.java
deleted file mode 100644
index 93c5d1ab..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaIndenter.java
+++ /dev/null
@@ -1,1643 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
-
-
-/**
- * Uses the {@link org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner} to
- * get the indentation level for a certain position in a document.
- *
- * <p>
- * An instance holds some internal position in the document and is therefore
- * not threadsafe.
- * </p>
- *
- *
- */
-public final class JavaIndenter {
-
- /**
- * The JDT Core preferences.
- *
- */
- private final class CorePrefs {
- final boolean prefUseTabs;
- final int prefTabSize;
- final int prefIndentationSize;
- final boolean prefArrayDimensionsDeepIndent;
- final int prefArrayIndent;
- final boolean prefArrayDeepIndent;
- final boolean prefTernaryDeepAlign;
- final int prefTernaryIndent;
- final int prefCaseIndent;
- final int prefAssignmentIndent;
- final int prefCaseBlockIndent;
- final int prefSimpleIndent;
- final int prefBracketIndent;
- final boolean prefMethodDeclDeepIndent;
- final int prefMethodDeclIndent;
- final boolean prefMethodCallDeepIndent;
- final int prefMethodCallIndent;
- final boolean prefParenthesisDeepIndent;
- final int prefParenthesisIndent;
- final int prefBlockIndent;
- final int prefMethodBodyIndent;
- final int prefTypeIndent;
- final boolean prefIndentBracesForBlocks;
- final boolean prefIndentBracesForArrays;
- final boolean prefIndentBracesForMethods;
- final boolean prefIndentBracesForTypes;
- final int prefContinuationIndent;
- final boolean prefHasGenerics;
- final String prefTabChar;
-
- private final IJavaScriptProject fProject;
-
- /**
- * Returns <code>true</code> if the class is used outside the workbench,
- * <code>false</code> in normal mode
- *
- * @return <code>true</code> if the plug-ins are not available
- */
- private boolean isStandalone() {
- return JavaScriptCore.getPlugin() == null;
- }
-
- /**
- * Returns the possibly project-specific core preference defined under <code>key</code>.
- *
- * @param key the key of the preference
- * @return the value of the preference
- *
- */
- private String getCoreFormatterOption(String key) {
- if (fProject == null)
- return JavaScriptCore.getOption(key);
- return fProject.getOption(key, true);
- }
-
- CorePrefs(IJavaScriptProject project) {
- fProject= project;
- if (isStandalone()) {
- prefUseTabs= true;
- prefTabSize= 4;
- prefIndentationSize= 4;
- prefArrayDimensionsDeepIndent= true;
- prefContinuationIndent= 2;
- prefBlockIndent= 1;
- prefArrayIndent= prefContinuationIndent;
- prefArrayDeepIndent= true;
- prefTernaryDeepAlign= false;
- prefTernaryIndent= prefContinuationIndent;
- prefCaseIndent= 0;
- prefAssignmentIndent= prefBlockIndent;
- prefCaseBlockIndent= prefBlockIndent;
- prefIndentBracesForBlocks= false;
- prefSimpleIndent= (prefIndentBracesForBlocks && prefBlockIndent == 0) ? 1 : prefBlockIndent;
- prefBracketIndent= prefBlockIndent;
- prefMethodDeclDeepIndent= true;
- prefMethodDeclIndent= 1;
- prefMethodCallDeepIndent= false;
- prefMethodCallIndent= 1;
- prefParenthesisDeepIndent= false;
- prefParenthesisIndent= prefContinuationIndent;
- prefMethodBodyIndent= 1;
- prefTypeIndent= 1;
- prefIndentBracesForArrays= false;
- prefIndentBracesForMethods= false;
- prefIndentBracesForTypes= false;
- prefHasGenerics= false;
- prefTabChar= JavaScriptCore.TAB;
- } else {
- prefUseTabs= prefUseTabs();
- prefTabSize= prefTabSize();
- prefIndentationSize= prefIndentationSize();
- prefArrayDimensionsDeepIndent= prefArrayDimensionsDeepIndent();
- prefContinuationIndent= prefContinuationIndent();
- prefBlockIndent= prefBlockIndent();
- prefArrayIndent= prefArrayIndent();
- prefArrayDeepIndent= prefArrayDeepIndent();
- prefTernaryDeepAlign= prefTernaryDeepAlign();
- prefTernaryIndent= prefTernaryIndent();
- prefCaseIndent= prefCaseIndent();
- prefAssignmentIndent= prefAssignmentIndent();
- prefCaseBlockIndent= prefCaseBlockIndent();
- prefIndentBracesForBlocks= prefIndentBracesForBlocks();
- prefSimpleIndent= prefSimpleIndent();
- prefBracketIndent= prefBracketIndent();
- prefMethodDeclDeepIndent= prefMethodDeclDeepIndent();
- prefMethodDeclIndent= prefMethodDeclIndent();
- prefMethodCallDeepIndent= prefMethodCallDeepIndent();
- prefMethodCallIndent= prefMethodCallIndent();
- prefParenthesisDeepIndent= prefParenthesisDeepIndent();
- prefParenthesisIndent= prefParenthesisIndent();
- prefMethodBodyIndent= prefMethodBodyIndent();
- prefTypeIndent= prefTypeIndent();
- prefIndentBracesForArrays= prefIndentBracesForArrays();
- prefIndentBracesForMethods= prefIndentBracesForMethods();
- prefIndentBracesForTypes= prefIndentBracesForTypes();
- prefHasGenerics= hasGenerics();
- prefTabChar= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- }
- }
-
- private boolean prefUseTabs() {
- return !JavaScriptCore.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
- }
-
- private int prefTabSize() {
- return CodeFormatterUtil.getTabWidth(fProject);
- }
-
- private int prefIndentationSize() {
- return CodeFormatterUtil.getIndentWidth(fProject);
- }
-
- private boolean prefArrayDimensionsDeepIndent() {
- return true; // sensible default, no formatter setting
- }
-
- private int prefArrayIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
- try {
- if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
- return 1;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return prefContinuationIndent(); // default
- }
-
- private boolean prefArrayDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
- try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return true;
- }
-
- private boolean prefTernaryDeepAlign() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
- try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
- return false;
- }
-
- private int prefTernaryIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
- try {
- if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
- return 1;
- else
- return prefContinuationIndent();
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return prefContinuationIndent();
- }
-
- private int prefCaseIndent() {
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
- return prefBlockIndent();
- else
- return 0;
- }
-
- private int prefAssignmentIndent() {
- return prefBlockIndent();
- }
-
- private int prefCaseBlockIndent() {
- if (true)
- return prefBlockIndent();
-
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
- return prefBlockIndent();
- else
- return 0;
- }
-
- private int prefSimpleIndent() {
- if (prefIndentBracesForBlocks() && prefBlockIndent() == 0)
- return 1;
- else return prefBlockIndent();
- }
-
- private int prefBracketIndent() {
- return prefBlockIndent();
- }
-
- private boolean prefMethodDeclDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
- try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return true;
- }
-
- private int prefMethodDeclIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
- try {
- if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
- return 1;
- else
- return prefContinuationIndent();
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
- return 1;
- }
-
- private boolean prefMethodCallDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
- try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
- return false; // sensible default
- }
-
- private int prefMethodCallIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
- try {
- if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
- return 1;
- else
- return prefContinuationIndent();
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return 1; // sensible default
- }
-
- private boolean prefParenthesisDeepIndent() {
- if (true) // don't do parenthesis deep indentation
- return false;
-
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
- try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
- } catch (IllegalArgumentException e) {
- // ignore and return default
- }
-
- return false; // sensible default
- }
-
- private int prefParenthesisIndent() {
- return prefContinuationIndent();
- }
-
- private int prefBlockIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
- if (DefaultCodeFormatterConstants.FALSE.equals(option))
- return 0;
-
- return 1; // sensible default
- }
-
- private int prefMethodBodyIndent() {
- if (DefaultCodeFormatterConstants.FALSE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
- return 0;
-
- return 1; // sensible default
- }
-
- private int prefTypeIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER);
- if (DefaultCodeFormatterConstants.FALSE.equals(option))
- return 0;
-
- return 1; // sensible default
- }
-
- private boolean prefIndentBracesForBlocks() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
- }
-
- private boolean prefIndentBracesForArrays() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER));
- }
-
- private boolean prefIndentBracesForMethods() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
- }
-
- private boolean prefIndentBracesForTypes() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
- }
-
- private int prefContinuationIndent() {
- try {
- return Integer.parseInt(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
- } catch (NumberFormatException e) {
- // ignore and return default
- }
-
- return 2; // sensible default
- }
- private boolean hasGenerics() {
- return JavaScriptCore.VERSION_1_5.compareTo(getCoreFormatterOption(JavaScriptCore.COMPILER_SOURCE)) <= 0;
- }
- }
-
- /** The document being scanned. */
- private final IDocument fDocument;
- /** The indentation accumulated by <code>findReferencePosition</code>. */
- private int fIndent;
- /**
- * The absolute (character-counted) indentation offset for special cases
- * (method defs, array initializers)
- */
- private int fAlign;
- /** The stateful scanposition for the indentation methods. */
- private int fPosition;
- /** The previous position. */
- private int fPreviousPos;
- /** The most recent token. */
- private int fToken;
- /** The line of <code>fPosition</code>. */
- private int fLine;
- /**
- * The scanner we will use to scan the document. It has to be installed
- * on the same document as the one we get.
- */
- private final JavaHeuristicScanner fScanner;
- /**
- * The JDT Core preferences.
- *
- */
- private final CorePrefs fPrefs;
-
- /**
- * Creates a new instance.
- *
- * @param document the document to scan
- * @param scanner the {@link JavaHeuristicScanner} to be used for scanning
- * the document. It must be installed on the same <code>IDocument</code>.
- */
- public JavaIndenter(IDocument document, JavaHeuristicScanner scanner) {
- this(document, scanner, null);
- }
-
- /**
- * Creates a new instance.
- *
- * @param document the document to scan
- * @param scanner the {@link JavaHeuristicScanner}to be used for scanning
- * the document. It must be installed on the same
- * <code>IDocument</code>.
- * @param project the java project to get the formatter preferences from, or
- * <code>null</code> to use the workspace settings
- *
- */
- public JavaIndenter(IDocument document, JavaHeuristicScanner scanner, IJavaScriptProject project) {
- Assert.isNotNull(document);
- Assert.isNotNull(scanner);
- fDocument= document;
- fScanner= scanner;
- fPrefs= new CorePrefs(project);
- }
-
- /**
- * Computes the indentation at the reference point of <code>position</code>.
- *
- * @param offset the offset in the document
- * @return a String which reflects the indentation at the line in which the
- * reference position to <code>offset</code> resides, or <code>null</code>
- * if it cannot be determined
- */
- public StringBuffer getReferenceIndentation(int offset) {
- return getReferenceIndentation(offset, false);
- }
-
- /**
- * Computes the indentation at the reference point of <code>position</code>.
- *
- * @param offset the offset in the document
- * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
- * @return a String which reflects the indentation at the line in which the
- * reference position to <code>offset</code> resides, or <code>null</code>
- * if it cannot be determined
- */
- private StringBuffer getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
-
- int unit;
- if (assumeOpeningBrace)
- unit= findReferencePosition(offset, Symbols.TokenLBRACE);
- else
- unit= findReferencePosition(offset, peekChar(offset));
-
- // if we were unable to find anything, return null
- if (unit == JavaHeuristicScanner.NOT_FOUND)
- return null;
-
- return getLeadingWhitespace(unit);
-
- }
-
- /**
- * Computes the indentation at <code>offset</code>.
- *
- * @param offset the offset in the document
- * @return a String which reflects the correct indentation for the line in
- * which offset resides, or <code>null</code> if it cannot be
- * determined
- */
- public StringBuffer computeIndentation(int offset) {
- return computeIndentation(offset, false);
- }
-
- /**
- * Computes the indentation at <code>offset</code>.
- *
- * @param offset the offset in the document
- * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
- * @return a String which reflects the correct indentation for the line in
- * which offset resides, or <code>null</code> if it cannot be
- * determined
- */
- public StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace) {
-
- StringBuffer reference= getReferenceIndentation(offset, assumeOpeningBrace);
-
- // handle special alignment
- if (fAlign != JavaHeuristicScanner.NOT_FOUND) {
- try {
- // a special case has been detected.
- IRegion line= fDocument.getLineInformationOfOffset(fAlign);
- int lineOffset= line.getOffset();
- return createIndent(lineOffset, fAlign, false);
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- if (reference == null)
- return null;
-
- // add additional indent
- return createReusingIndent(reference, fIndent);
- }
-
- /**
- * Computes the length of a <code>CharacterSequence</code>, counting
- * a tab character as the size until the next tab stop and every other
- * character as one.
- *
- * @param indent the string to measure
- * @return the visual length in characters
- */
- private int computeVisualLength(CharSequence indent) {
- final int tabSize= fPrefs.prefTabSize;
- int length= 0;
- for (int i= 0; i < indent.length(); i++) {
- char ch= indent.charAt(i);
- switch (ch) {
- case '\t':
- if (tabSize > 0) {
- int reminder= length % tabSize;
- length += tabSize - reminder;
- }
- break;
- case ' ':
- length++;
- break;
- }
- }
- return length;
- }
-
- /**
- * Strips any characters off the end of <code>reference</code> that exceed
- * <code>indentLength</code>.
- *
- * @param reference the string to measure
- * @param indentLength the maximum visual indentation length
- * @return the stripped <code>reference</code>
- */
- private StringBuffer stripExceedingChars(StringBuffer reference, int indentLength) {
- final int tabSize= fPrefs.prefTabSize;
- int measured= 0;
- int chars= reference.length();
- int i= 0;
- for (; measured < indentLength && i < chars; i++) {
- char ch= reference.charAt(i);
- switch (ch) {
- case '\t':
- if (tabSize > 0) {
- int reminder= measured % tabSize;
- measured += tabSize - reminder;
- }
- break;
- case ' ':
- measured++;
- break;
- }
- }
- int deleteFrom= measured > indentLength ? i - 1 : i;
-
- return reference.delete(deleteFrom, chars);
- }
-
- /**
- * Returns the indentation of the line at <code>offset</code> as a
- * <code>StringBuffer</code>. If the offset is not valid, the empty string
- * is returned.
- *
- * @param offset the offset in the document
- * @return the indentation (leading whitespace) of the line in which
- * <code>offset</code> is located
- */
- private StringBuffer getLeadingWhitespace(int offset) {
- StringBuffer indent= new StringBuffer();
- try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineOffset= line.getOffset();
- int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
- indent.append(fDocument.get(lineOffset, nonWS - lineOffset));
- return indent;
- } catch (BadLocationException e) {
- return indent;
- }
- }
-
- /**
- * Creates an indentation string of the length indent - start, consisting of
- * the content in <code>fDocument</code> in the range [start, indent),
- * with every character replaced by a space except for tabs, which are kept
- * as such.
- * <p>
- * If <code>convertSpaceRunsToTabs</code> is <code>true</code>, every
- * run of the number of spaces that make up a tab are replaced by a tab
- * character. If it is not set, no conversion takes place, but tabs in the
- * original range are still copied verbatim.
- * </p>
- *
- * @param start the start of the document region to copy the indent from
- * @param indent the exclusive end of the document region to copy the indent
- * from
- * @param convertSpaceRunsToTabs whether to convert consecutive runs of
- * spaces to tabs
- * @return the indentation corresponding to the document content specified
- * by <code>start</code> and <code>indent</code>
- */
- private StringBuffer createIndent(int start, final int indent, final boolean convertSpaceRunsToTabs) {
- final boolean convertTabs= fPrefs.prefUseTabs && convertSpaceRunsToTabs;
- final int tabLen= fPrefs.prefTabSize;
- final StringBuffer ret= new StringBuffer();
- try {
- int spaces= 0;
- while (start < indent) {
-
- char ch= fDocument.getChar(start);
- if (ch == '\t') {
- ret.append('\t');
- spaces= 0;
- } else if (convertTabs) {
- spaces++;
- if (spaces == tabLen) {
- ret.append('\t');
- spaces= 0;
- }
- } else {
- ret.append(' ');
- }
-
- start++;
- }
- // remainder
- while (spaces-- > 0)
- ret.append(' ');
-
- } catch (BadLocationException e) {
- }
-
- return ret;
- }
-
- /**
- * Creates a string with a visual length of the given
- * <code>indentationSize</code>.
- *
- * @param buffer the original indent to reuse if possible
- * @param additional the additional indentation units to add or subtract to
- * reference
- * @return the modified <code>buffer</code> reflecting the indentation
- * adapted to <code>additional</code>
- */
- private StringBuffer createReusingIndent(StringBuffer buffer, int additional) {
- int refLength= computeVisualLength(buffer);
- int addLength= fPrefs.prefIndentationSize * additional; // may be < 0
- int totalLength= Math.max(0, refLength + addLength);
-
-
- // copy the reference indentation for the indent up to the last tab
- // stop within the maxCopy area
- int minLength= Math.min(totalLength, refLength);
- int tabSize= fPrefs.prefTabSize;
- int maxCopyLength= tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
- stripExceedingChars(buffer, maxCopyLength);
-
-
- // add additional indent
- int missing= totalLength - maxCopyLength;
- final int tabs, spaces;
- if (JavaScriptCore.SPACE.equals(fPrefs.prefTabChar)) {
- tabs= 0;
- spaces= missing;
- } else if (JavaScriptCore.TAB.equals(fPrefs.prefTabChar)) {
- tabs= tabSize > 0 ? missing / tabSize : 0;
- spaces= tabSize > 0 ? missing % tabSize : missing;
- } else if (DefaultCodeFormatterConstants.MIXED.equals(fPrefs.prefTabChar)) {
- tabs= tabSize > 0 ? missing / tabSize : 0;
- spaces= tabSize > 0 ? missing % tabSize : missing;
- } else {
- Assert.isTrue(false);
- return null;
- }
- for(int i= 0; i < tabs; i++)
- buffer.append('\t');
- for(int i= 0; i < spaces; i++)
- buffer.append(' ');
- return buffer;
- }
-
- /**
- * Returns the reference position regarding to indentation for <code>offset</code>,
- * or <code>NOT_FOUND</code>. This method calls
- * {@link #findReferencePosition(int, int) findReferencePosition(offset, nextChar)} where
- * <code>nextChar</code> is the next character after <code>offset</code>.
- *
- * @param offset the offset for which the reference is computed
- * @return the reference statement relative to which <code>offset</code>
- * should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
- */
- public int findReferencePosition(int offset) {
- return findReferencePosition(offset, peekChar(offset));
- }
-
- /**
- * Peeks the next char in the document that comes after <code>offset</code>
- * on the same line as <code>offset</code>.
- *
- * @param offset the offset into document
- * @return the token symbol of the next element, or TokenEOF if there is none
- */
- private int peekChar(int offset) {
- if (offset < fDocument.getLength()) {
- try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineOffset= line.getOffset();
- int next= fScanner.nextToken(offset, lineOffset + line.getLength());
- return next;
- } catch (BadLocationException e) {
- }
- }
- return Symbols.TokenEOF;
- }
-
- /**
- * Returns the reference position regarding to indentation for <code>position</code>,
- * or <code>NOT_FOUND</code>.
- *
- * <p>If <code>peekNextChar</code> is <code>true</code>, the next token after
- * <code>offset</code> is read and taken into account when computing the
- * indentation. Currently, if the next token is the first token on the line
- * (i.e. only preceded by whitespace), the following tokens are specially
- * handled:
- * <ul>
- * <li><code>switch</code> labels are indented relative to the switch block</li>
- * <li>opening curly braces are aligned correctly with the introducing code</li>
- * <li>closing curly braces are aligned properly with the introducing code of
- * the matching opening brace</li>
- * <li>closing parenthesis' are aligned with their opening peer</li>
- * <li>the <code>else</code> keyword is aligned with its <code>if</code>, anything
- * else is aligned normally (i.e. with the base of any introducing statements).</li>
- * <li>if there is no token on the same line after <code>offset</code>, the indentation
- * is the same as for an <code>else</code> keyword</li>
- * </ul>
- *
- * @param offset the offset for which the reference is computed
- * @param nextToken the next token to assume in the document
- * @return the reference statement relative to which <code>offset</code>
- * should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
- */
- public int findReferencePosition(int offset, int nextToken) {
- boolean danglingElse= false;
- boolean unindent= false;
- boolean indent= false;
- boolean matchBrace= false;
- boolean matchParen= false;
- boolean matchCase= false;
-
- // account for un-indentation characters already typed in, but after position
- // if they are on a line by themselves, the indentation gets adjusted
- // accordingly
- //
- // also account for a dangling else
- if (offset < fDocument.getLength()) {
- try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineOffset= line.getOffset();
- int prevPos= Math.max(offset - 1, 0);
- boolean isFirstTokenOnLine= fDocument.get(lineOffset, prevPos + 1 - lineOffset).trim().length() == 0;
- int prevToken= fScanner.previousToken(prevPos, JavaHeuristicScanner.UNBOUND);
- boolean bracelessBlockStart= fScanner.isBracelessBlockStart(prevPos, JavaHeuristicScanner.UNBOUND);
-
- switch (nextToken) {
- case Symbols.TokenELSE:
- danglingElse= true;
- break;
- case Symbols.TokenCASE:
- case Symbols.TokenDEFAULT:
- if (isFirstTokenOnLine)
- matchCase= true;
- break;
- case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
- if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
- unindent= true;
- else if ((prevToken == Symbols.TokenCOLON || prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) && !fPrefs.prefIndentBracesForArrays)
- unindent= true;
- else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
- indent= true;
- break;
- case Symbols.TokenRBRACE: // closing braces get unindented
- if (isFirstTokenOnLine)
- matchBrace= true;
- break;
- case Symbols.TokenRPAREN:
- if (isFirstTokenOnLine)
- matchParen= true;
- break;
- }
- } catch (BadLocationException e) {
- }
- } else {
- // don't assume an else could come if we are at the end of file
- danglingElse= false;
- }
-
- int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase);
- if (unindent)
- fIndent--;
- if (indent)
- fIndent++;
- return ref;
- }
-
- /**
- * Returns the reference position regarding to indentation for <code>position</code>,
- * or <code>NOT_FOUND</code>.<code>fIndent</code> will contain the
- * relative indentation (in indentation units, not characters) after the
- * call. If there is a special alignment (e.g. for a method declaration
- * where parameters should be aligned), <code>fAlign</code> will contain
- * the absolute position of the alignment reference in <code>fDocument</code>,
- * otherwise <code>fAlign</code> is set to <code>JavaHeuristicScanner.NOT_FOUND</code>.
- *
- * @param offset the offset for which the reference is computed
- * @param danglingElse whether a dangling else should be assumed at <code>position</code>
- * @param matchBrace whether the position of the matching brace should be
- * returned instead of doing code analysis
- * @param matchParen whether the position of the matching parenthesis
- * should be returned instead of doing code analysis
- * @param matchCase whether the position of a switch statement reference
- * should be returned (either an earlier case statement or the
- * switch block brace)
- * @return the reference statement relative to which <code>position</code>
- * should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
- */
- public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen, boolean matchCase) {
- fIndent= 0; // the indentation modification
- fAlign= JavaHeuristicScanner.NOT_FOUND;
- fPosition= offset;
-
- // forward cases
- // an unindentation happens sometimes if the next token is special, namely on braces, parens and case labels
- // align braces, but handle the case where we align with the method declaration start instead of
- // the opening brace.
- if (matchBrace) {
- if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) {
- try {
- // align with the opening brace that is on a line by its own
- int lineOffset= fDocument.getLineOffset(fLine);
- if (lineOffset <= fPosition && fDocument.get(lineOffset, fPosition - lineOffset).trim().length() == 0)
- return fPosition;
- } catch (BadLocationException e) {
- // concurrent modification - walk default path
- }
- // if the opening brace is not on the start of the line, skip to the start
- int pos= skipToStatementStart(true, true);
- fIndent= 0; // indent is aligned with reference position
- return pos;
- } else {
- // if we can't find the matching brace, the heuristic is to unindent
- // by one against the normal position
- int pos= findReferencePosition(offset, danglingElse, false, matchParen, matchCase);
- fIndent--;
- return pos;
- }
- }
-
- // align parenthesis'
- if (matchParen) {
- if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN))
- return fPosition;
- else {
- // if we can't find the matching paren, the heuristic is to unindent
- // by one against the normal position
- int pos= findReferencePosition(offset, danglingElse, matchBrace, false, matchCase);
- fIndent--;
- return pos;
- }
- }
-
- // the only reliable way to get case labels aligned (due to many different styles of using braces in a block)
- // is to go for another case statement, or the scope opening brace
- if (matchCase) {
- return matchCaseAlignment();
- }
-
- nextToken();
- switch (fToken) {
- case Symbols.TokenGREATERTHAN:
- case Symbols.TokenRBRACE:
- // skip the block and fall through
- // if we can't complete the scope, reset the scan position
- int pos= fPosition;
- if (!skipScope())
- fPosition= pos;
- case Symbols.TokenSEMICOLON:
- // this is the 90% case: after a statement block
- // the end of the previous statement / block previous.end
- // search to the end of the statement / block before the previous; the token just after that is previous.start
- return skipToStatementStart(danglingElse, false);
-
- // scope introduction: special treat who special is
- case Symbols.TokenLPAREN:
- case Symbols.TokenLBRACE:
- case Symbols.TokenLBRACKET:
- return handleScopeIntroduction(offset + 1);
-
- case Symbols.TokenEOF:
- // trap when hitting start of document
- return JavaHeuristicScanner.NOT_FOUND;
-
- case Symbols.TokenEQUAL:
- // indent assignments
- fIndent= fPrefs.prefAssignmentIndent;
- return fPosition;
-
- case Symbols.TokenCOLON:
- // TODO handle ternary deep indentation
- fIndent= fPrefs.prefCaseBlockIndent;
- return fPosition;
-
- case Symbols.TokenQUESTIONMARK:
- if (fPrefs.prefTernaryDeepAlign) {
- setFirstElementAlignment(fPosition, offset + 1);
- return fPosition;
- } else {
- fIndent= fPrefs.prefTernaryIndent;
- return fPosition;
- }
-
- // indentation for blockless introducers:
- case Symbols.TokenDO:
- case Symbols.TokenWHILE:
- case Symbols.TokenELSE:
- fIndent= fPrefs.prefSimpleIndent;
- return fPosition;
-
- case Symbols.TokenTRY:
- return skipToStatementStart(danglingElse, false);
- case Symbols.TokenRPAREN:
- int line= fLine;
- if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
- int scope= fPosition;
- nextToken();
- if (fToken == Symbols.TokenIF || fToken == Symbols.TokenWHILE || fToken == Symbols.TokenFOR) {
- fIndent= fPrefs.prefSimpleIndent;
- return fPosition;
- }
- fPosition= scope;
- if (looksLikeMethodDecl()) {
- return skipToStatementStart(danglingElse, false);
- }
- if (fToken == Symbols.TokenCATCH) {
- return skipToStatementStart(danglingElse, false);
- }
- fPosition= scope;
- if (looksLikeAnonymousTypeDecl()) {
- return skipToStatementStart(danglingElse, false);
- }
- }
- // restore
- fPosition= offset;
- fLine= line;
- // else: fall through to default
-
- case Symbols.TokenCOMMA:
- // inside a list of some type
- // easy if there is already a list item before with its own indentation - we just align
- // if not: take the start of the list ( LPAREN, LBRACE, LBRACKET ) and either align or
- // indent by list-indent
- default:
- // inside whatever we don't know about: similar to the list case:
- // if we are inside a continued expression, then either align with a previous line that has indentation
- // or indent from the expression start line (either a scope introducer or the start of the expr).
- return skipToPreviousListItemOrListStart();
-
- }
- }
-
- /**
- * Skips to the start of a statement that ends at the current position.
- *
- * @param danglingElse whether to indent aligned with the last <code>if</code>
- * @param isInBlock whether the current position is inside a block, which limits the search scope to the next scope introducer
- * @return the reference offset of the start of the statement
- */
- private int skipToStatementStart(boolean danglingElse, boolean isInBlock) {
- final int NOTHING= 0;
- final int READ_PARENS= 1;
- final int READ_IDENT= 2;
- int mayBeMethodBody= NOTHING;
- boolean isTypeBody= false;
- while (true) {
- nextToken();
-
- if (isInBlock) {
- switch (fToken) {
- // exit on all block introducers
- case Symbols.TokenIF:
- case Symbols.TokenELSE:
- case Symbols.TokenCATCH:
- case Symbols.TokenDO:
- case Symbols.TokenWHILE:
- case Symbols.TokenFINALLY:
- case Symbols.TokenFOR:
- case Symbols.TokenTRY:
- return fPosition;
-
- case Symbols.TokenSTATIC:
- mayBeMethodBody= READ_IDENT; // treat static blocks like methods
- break;
-
- case Symbols.TokenSYNCHRONIZED:
- // if inside a method declaration, use body indentation
- // else use block indentation.
- if (mayBeMethodBody != READ_IDENT)
- return fPosition;
- break;
-
- case Symbols.TokenCLASS:
- case Symbols.TokenINTERFACE:
- case Symbols.TokenENUM:
- isTypeBody= true;
- break;
-
- case Symbols.TokenSWITCH:
- fIndent= fPrefs.prefCaseIndent;
- return fPosition;
- }
- }
-
- switch (fToken) {
- // scope introduction through: LPAREN, LBRACE, LBRACKET
- // search stop on SEMICOLON, RBRACE, COLON, EOF
- // -> the next token is the start of the statement (i.e. previousPos when backward scanning)
- case Symbols.TokenLPAREN:
- case Symbols.TokenLBRACE:
- case Symbols.TokenLBRACKET:
- case Symbols.TokenSEMICOLON:
- case Symbols.TokenEOF:
- if (isInBlock)
- fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
- // else: fIndent set by previous calls
- return fPreviousPos;
-
- case Symbols.TokenCOLON:
- int pos= fPreviousPos;
- if (!isConditional())
- return pos;
- break;
-
- case Symbols.TokenRBRACE:
- // RBRACE is a little tricky: it can be the end of an array definition, but
- // usually it is the end of a previous block
- pos= fPreviousPos; // store state
- if (skipScope() && looksLikeArrayInitializerIntro()) {
- continue; // it's an array
- } else {
- if (isInBlock)
- fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
- return pos; // it's not - do as with all the above
- }
-
- // scopes: skip them
- case Symbols.TokenRPAREN:
- if (isInBlock)
- mayBeMethodBody= READ_PARENS;
- case Symbols.TokenRBRACKET:
- case Symbols.TokenGREATERTHAN:
- pos= fPreviousPos;
- if (skipScope())
- break;
- else
- return pos;
-
- // IF / ELSE: align the position after the conditional block with the if
- // so we are ready for an else, except if danglingElse is false
- // in order for this to work, we must skip an else to its if
- case Symbols.TokenIF:
- if (danglingElse)
- return fPosition;
- else
- break;
- case Symbols.TokenELSE:
- // skip behind the next if, as we have that one covered
- pos= fPosition;
- if (skipNextIF())
- break;
- else
- return pos;
-
- case Symbols.TokenDO:
- // align the WHILE position with its do
- return fPosition;
-
- case Symbols.TokenWHILE:
- // this one is tricky: while can be the start of a while loop
- // or the end of a do - while
- pos= fPosition;
- if (hasMatchingDo()) {
- // continue searching from the DO on
- break;
- } else {
- // continue searching from the WHILE on
- fPosition= pos;
- break;
- }
- case Symbols.TokenIDENT:
- if (mayBeMethodBody == READ_PARENS)
- mayBeMethodBody= READ_IDENT;
- break;
-
- default:
- // keep searching
-
- }
-
- }
- }
-
- private int getBlockIndent(boolean isMethodBody, boolean isTypeBody) {
- if (isTypeBody)
- return fPrefs.prefTypeIndent + (fPrefs.prefIndentBracesForTypes ? 1 : 0);
- else if (isMethodBody)
- return fPrefs.prefMethodBodyIndent + (fPrefs.prefIndentBracesForMethods ? 1 : 0);
- else
- return fIndent;
- }
-
- /**
- * Returns true if the colon at the current position is part of a conditional
- * (ternary) expression, false otherwise.
- *
- * @return true if the colon at the current position is part of a conditional
- */
- private boolean isConditional() {
- while (true) {
- nextToken();
- switch (fToken) {
-
- // search for case labels, which consist of (possibly qualified) identifiers or numbers
- case Symbols.TokenIDENT:
- case Symbols.TokenOTHER: // dots for qualified constants
- continue;
- case Symbols.TokenCASE:
- return false;
-
- default:
- return true;
- }
- }
- }
-
- /**
- * Returns as a reference any previous <code>switch</code> labels (<code>case</code>
- * or <code>default</code>) or the offset of the brace that scopes the switch
- * statement. Sets <code>fIndent</code> to <code>prefCaseIndent</code> upon
- * a match.
- *
- * @return the reference offset for a <code>switch</code> label
- */
- private int matchCaseAlignment() {
- while (true) {
- nextToken();
- switch (fToken) {
- // invalid cases: another case label or an LBRACE must come before a case
- // -> bail out with the current position
- case Symbols.TokenLPAREN:
- case Symbols.TokenLBRACKET:
- case Symbols.TokenEOF:
- return fPosition;
- case Symbols.TokenLBRACE:
- // opening brace of switch statement
- fIndent= fPrefs.prefCaseIndent;
- return fPosition;
- case Symbols.TokenCASE:
- case Symbols.TokenDEFAULT:
- // align with previous label
- fIndent= 0;
- return fPosition;
-
- // scopes: skip them
- case Symbols.TokenRPAREN:
- case Symbols.TokenRBRACKET:
- case Symbols.TokenRBRACE:
- case Symbols.TokenGREATERTHAN:
- skipScope();
- break;
-
- default:
- // keep searching
- continue;
-
- }
- }
- }
-
- /**
- * Returns the reference position for a list element. The algorithm
- * tries to match any previous indentation on the same list. If there is none,
- * the reference position returned is determined depending on the type of list:
- * The indentation will either match the list scope introducer (e.g. for
- * method declarations), so called deep indents, or simply increase the
- * indentation by a number of standard indents. See also {@link #handleScopeIntroduction(int)}.
- *
- * @return the reference position for a list item: either a previous list item
- * that has its own indentation, or the list introduction start.
- */
- private int skipToPreviousListItemOrListStart() {
- int startLine= fLine;
- int startPosition= fPosition;
- while (true) {
- nextToken();
-
- // if any line item comes with its own indentation, adapt to it
- if (fLine < startLine) {
- try {
- int lineOffset= fDocument.getLineOffset(startLine);
- int bound= Math.min(fDocument.getLength(), startPosition + 1);
- fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound);
- } catch (BadLocationException e) {
- // ignore and return just the position
- }
- return startPosition;
- }
-
- switch (fToken) {
- // scopes: skip them
- case Symbols.TokenRPAREN:
- case Symbols.TokenRBRACKET:
- case Symbols.TokenRBRACE:
- case Symbols.TokenGREATERTHAN:
- skipScope();
- break;
-
- // scope introduction: special treat who special is
- case Symbols.TokenLPAREN:
- case Symbols.TokenLBRACE:
- case Symbols.TokenLBRACKET:
- return handleScopeIntroduction(startPosition + 1);
-
- case Symbols.TokenSEMICOLON:
- return fPosition;
- case Symbols.TokenQUESTIONMARK:
- if (fPrefs.prefTernaryDeepAlign) {
- setFirstElementAlignment(fPosition - 1, fPosition + 1);
- return fPosition;
- } else {
- fIndent= fPrefs.prefTernaryIndent;
- return fPosition;
- }
- case Symbols.TokenEOF:
- return 0;
-
- }
- }
- }
-
- /**
- * Skips a scope and positions the cursor (<code>fPosition</code>) on the
- * token that opens the scope. Returns <code>true</code> if a matching peer
- * could be found, <code>false</code> otherwise. The current token when calling
- * must be one out of <code>Symbols.TokenRPAREN</code>, <code>Symbols.TokenRBRACE</code>,
- * and <code>Symbols.TokenRBRACKET</code>.
- *
- * @return <code>true</code> if a matching peer was found, <code>false</code> otherwise
- */
- private boolean skipScope() {
- switch (fToken) {
- case Symbols.TokenRPAREN:
- return skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN);
- case Symbols.TokenRBRACKET:
- return skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET);
- case Symbols.TokenRBRACE:
- return skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE);
- case Symbols.TokenGREATERTHAN:
- if (!fPrefs.prefHasGenerics)
- return false;
- int storedPosition= fPosition;
- int storedToken= fToken;
- nextToken();
- switch (fToken) {
- case Symbols.TokenIDENT:
- if (!JavaHeuristicScanner.isGenericStarter(getTokenContent()))
- break;
- case Symbols.TokenQUESTIONMARK:
- case Symbols.TokenGREATERTHAN:
- if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
- return true;
- }
- // <> are harder to detect - restore the position if we fail
- fPosition= storedPosition;
- fToken= storedToken;
- return false;
-
- default:
- Assert.isTrue(false);
- return false;
- }
- }
-
- /**
- * Returns the contents of the current token.
- *
- * @return the contents of the current token
- *
- */
- private CharSequence getTokenContent() {
- return new DocumentCharacterIterator(fDocument, fPosition, fPreviousPos);
- }
-
- /**
- * Handles the introduction of a new scope. The current token must be one out
- * of <code>Symbols.TokenLPAREN</code>, <code>Symbols.TokenLBRACE</code>,
- * and <code>Symbols.TokenLBRACKET</code>. Returns as the reference position
- * either the token introducing the scope or - if available - the first
- * java token after that.
- *
- * <p>Depending on the type of scope introduction, the indentation will align
- * (deep indenting) with the reference position (<code>fAlign</code> will be
- * set to the reference position) or <code>fIndent</code> will be set to
- * the number of indentation units.
- * </p>
- *
- * @param bound the bound for the search for the first token after the scope
- * introduction.
- * @return the indent
- */
- private int handleScopeIntroduction(int bound) {
- switch (fToken) {
- // scope introduction: special treat who special is
- case Symbols.TokenLPAREN:
- int pos= fPosition; // store
-
- // special: method declaration deep indentation
- if (looksLikeMethodDecl()) {
- if (fPrefs.prefMethodDeclDeepIndent)
- return setFirstElementAlignment(pos, bound);
- else {
- fIndent= fPrefs.prefMethodDeclIndent;
- return pos;
- }
- } else {
- fPosition= pos;
- if (looksLikeMethodCall()) {
- if (fPrefs.prefMethodCallDeepIndent)
- return setFirstElementAlignment(pos, bound);
- else {
- fIndent= fPrefs.prefMethodCallIndent;
- return pos;
- }
- } else if (fPrefs.prefParenthesisDeepIndent)
- return setFirstElementAlignment(pos, bound);
- }
-
- // normal: return the parenthesis as reference
- fIndent= fPrefs.prefParenthesisIndent;
- return pos;
-
- case Symbols.TokenLBRACE:
- pos= fPosition; // store
-
- // special: array initializer
- if (looksLikeArrayInitializerIntro())
- if (fPrefs.prefArrayDeepIndent)
- return setFirstElementAlignment(pos, bound);
- else
- fIndent= fPrefs.prefArrayIndent;
- else
- fIndent= fPrefs.prefBlockIndent;
-
- // normal: skip to the statement start before the scope introducer
- // opening braces are often on differently ending indents than e.g. a method definition
- if (looksLikeArrayInitializerIntro() && !fPrefs.prefIndentBracesForArrays
- || !fPrefs.prefIndentBracesForBlocks) {
- fPosition= pos; // restore
- return skipToStatementStart(true, true); // set to true to match the first if
- } else {
- return pos;
- }
-
- case Symbols.TokenLBRACKET:
- pos= fPosition; // store
-
- // special: method declaration deep indentation
- if (fPrefs.prefArrayDimensionsDeepIndent) {
- return setFirstElementAlignment(pos, bound);
- }
-
- // normal: return the bracket as reference
- fIndent= fPrefs.prefBracketIndent;
- return pos; // restore
-
- default:
- Assert.isTrue(false);
- return -1; // dummy
- }
- }
-
- /**
- * Sets the deep indent offset (<code>fAlign</code>) to either the offset
- * right after <code>scopeIntroducerOffset</code> or - if available - the
- * first Java token after <code>scopeIntroducerOffset</code>, but before
- * <code>bound</code>.
- *
- * @param scopeIntroducerOffset the offset of the scope introducer
- * @param bound the bound for the search for another element
- * @return the reference position
- */
- private int setFirstElementAlignment(int scopeIntroducerOffset, int bound) {
- int firstPossible= scopeIntroducerOffset + 1; // align with the first position after the scope intro
- fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(firstPossible, bound);
- if (fAlign == JavaHeuristicScanner.NOT_FOUND)
- fAlign= firstPossible;
- return fAlign;
- }
-
-
- /**
- * Returns <code>true</code> if the next token received after calling
- * <code>nextToken</code> is either an equal sign or an array designator ('[]').
- *
- * @return <code>true</code> if the next elements look like the start of an array definition
- */
- private boolean looksLikeArrayInitializerIntro() {
- nextToken();
- if (fToken == Symbols.TokenEQUAL || skipBrackets()) {
- return true;
- }
- return false;
- }
-
- /**
- * Skips over the next <code>if</code> keyword. The current token when calling
- * this method must be an <code>else</code> keyword. Returns <code>true</code>
- * if a matching <code>if</code> could be found, <code>false</code> otherwise.
- * The cursor (<code>fPosition</code>) is set to the offset of the <code>if</code>
- * token.
- *
- * @return <code>true</code> if a matching <code>if</code> token was found, <code>false</code> otherwise
- */
- private boolean skipNextIF() {
- Assert.isTrue(fToken == Symbols.TokenELSE);
-
- while (true) {
- nextToken();
- switch (fToken) {
- // scopes: skip them
- case Symbols.TokenRPAREN:
- case Symbols.TokenRBRACKET:
- case Symbols.TokenRBRACE:
- case Symbols.TokenGREATERTHAN:
- skipScope();
- break;
-
- case Symbols.TokenIF:
- // found it, return
- return true;
- case Symbols.TokenELSE:
- // recursively skip else-if blocks
- skipNextIF();
- break;
-
- // shortcut scope starts
- case Symbols.TokenLPAREN:
- case Symbols.TokenLBRACE:
- case Symbols.TokenLBRACKET:
- case Symbols.TokenEOF:
- return false;
- }
- }
- }
-
-
- /**
- * while(condition); is ambiguous when parsed backwardly, as it is a valid
- * statement by its own, so we have to check whether there is a matching
- * do. A <code>do</code> can either be separated from the while by a
- * block, or by a single statement, which limits our search distance.
- *
- * @return <code>true</code> if the <code>while</code> currently in
- * <code>fToken</code> has a matching <code>do</code>.
- */
- private boolean hasMatchingDo() {
- Assert.isTrue(fToken == Symbols.TokenWHILE);
- nextToken();
- switch (fToken) {
- case Symbols.TokenRBRACE:
- skipScope(); // and fall thru
- case Symbols.TokenSEMICOLON:
- skipToStatementStart(false, false);
- return fToken == Symbols.TokenDO;
- }
- return false;
- }
-
- /**
- * Skips brackets if the current token is a RBRACKET. There can be nothing
- * but whitespace in between, this is only to be used for <code>[]</code> elements.
- *
- * @return <code>true</code> if a <code>[]</code> could be scanned, the
- * current token is left at the LBRACKET.
- */
- private boolean skipBrackets() {
- if (fToken == Symbols.TokenRBRACKET) {
- nextToken();
- if (fToken == Symbols.TokenLBRACKET) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Reads the next token in backward direction from the heuristic scanner
- * and sets the fields <code>fToken, fPreviousPosition</code> and <code>fPosition</code>
- * accordingly.
- */
- private void nextToken() {
- nextToken(fPosition);
- }
-
- /**
- * Reads the next token in backward direction of <code>start</code> from
- * the heuristic scanner and sets the fields <code>fToken, fPreviousPosition</code>
- * and <code>fPosition</code> accordingly.
- *
- * @param start the start offset from which to scan backwards
- */
- private void nextToken(int start) {
- fToken= fScanner.previousToken(start - 1, JavaHeuristicScanner.UNBOUND);
- fPreviousPos= start;
- fPosition= fScanner.getPosition() + 1;
- try {
- fLine= fDocument.getLineOfOffset(fPosition);
- } catch (BadLocationException e) {
- fLine= -1;
- }
- }
-
- /**
- * Returns <code>true</code> if the current tokens look like a method
- * declaration header (i.e. only the return type and method name). The
- * heuristic calls <code>nextToken</code> and expects an identifier
- * (method name) and a type declaration (an identifier with optional
- * brackets) which also covers the visibility modifier of constructors; it
- * does not recognize package visible constructors.
- *
- * @return <code>true</code> if the current position looks like a method
- * declaration header.
- */
- private boolean looksLikeMethodDecl() {
- /*
- * TODO This heuristic does not recognize package private constructors
- * since those do have neither type nor visibility keywords.
- * One option would be to go over the parameter list, but that might
- * be empty as well, or not typed in yet - hard to do without an AST...
- */
-
- nextToken();
- if (fToken == Symbols.TokenIDENT) { // method name
- do nextToken();
- while (skipBrackets()); // optional brackets for array valued return types
-
- return fToken == Symbols.TokenIDENT; // return type name
-
- }
- return false;
- }
-
- /**
- * Returns <code>true</code> if the current tokens look like an anonymous type declaration
- * header (i.e. a type name (potentially qualified) and a new keyword). The heuristic calls
- * <code>nextToken</code> and expects a possibly qualified identifier (type name) and a new
- * keyword
- *
- * @return <code>true</code> if the current position looks like a anonymous type declaration
- * header.
- */
- private boolean looksLikeAnonymousTypeDecl() {
-
- nextToken();
- if (fToken == Symbols.TokenIDENT) { // type name
- nextToken();
- while (fToken == Symbols.TokenOTHER) { // dot of qualification
- nextToken();
- if (fToken != Symbols.TokenIDENT) // qualificating name
- return false;
- nextToken();
- }
- return fToken == Symbols.TokenNEW;
- }
- return false;
- }
-
- /**
- * Returns <code>true</code> if the current tokens look like a method
- * call header (i.e. an identifier as opposed to a keyword taking parenthesized
- * parameters such as <code>if</code>).
- * <p>The heuristic calls <code>nextToken</code> and expects an identifier
- * (method name).
- *
- * @return <code>true</code> if the current position looks like a method call
- * header.
- */
- private boolean looksLikeMethodCall() {
- // TODO [5.0] add awareness for constructor calls with generic types: new ArrayList<String>()
- nextToken();
- return fToken == Symbols.TokenIDENT; // method name
- }
-
- /**
- * Scans tokens for the matching opening peer. The internal cursor
- * (<code>fPosition</code>) is set to the offset of the opening peer if found.
- *
- * @param openToken the opening peer token
- * @param closeToken the closing peer token
- * @return <code>true</code> if a matching token was found, <code>false</code>
- * otherwise
- */
- private boolean skipScope(int openToken, int closeToken) {
-
- int depth= 1;
-
- while (true) {
- nextToken();
-
- if (fToken == closeToken) {
- depth++;
- } else if (fToken == openToken) {
- depth--;
- if (depth == 0)
- return true;
- } else if (fToken == Symbols.TokenEOF) {
- return false;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java
deleted file mode 100644
index b9d99235..00000000
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java
+++ /dev/null
@@ -1,752 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.ui.text;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IDecoratorManager;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.keys.KeySequence;
-import org.eclipse.ui.keys.SWTKeySupport;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeHierarchy;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.corext.util.Messages;
-import org.eclipse.wst.jsdt.internal.corext.util.MethodOverrideTester;
-import org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache;
-import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
-import org.eclipse.wst.jsdt.internal.ui.JavaPluginImages;
-import org.eclipse.wst.jsdt.internal.ui.JavaUIMessages;
-import org.eclipse.wst.jsdt.internal.ui.actions.CategoryFilterActionGroup;
-import org.eclipse.wst.jsdt.internal.ui.typehierarchy.AbstractHierarchyViewerSorter;
-import org.eclipse.wst.jsdt.internal.ui.util.StringMatcher;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.ColoredViewersManager;
-import org.eclipse.wst.jsdt.internal.ui.viewsupport.MemberFilter;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-import org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator;
-import org.eclipse.wst.jsdt.ui.ProblemsLabelDecorator;
-import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
-
-/**
- * Show outline in light-weight control.
- *
- *
- */
-public class JavaOutlineInformationControl extends AbstractInformationControl {
-
- private KeyAdapter fKeyAdapter;
- private OutlineContentProvider fOutlineContentProvider;
- private IJavaScriptElement fInput= null;
-
- private OutlineSorter fOutlineSorter;
-
- private OutlineLabelProvider fInnerLabelProvider;
-
- private boolean fShowOnlyMainType;
- private LexicalSortingAction fLexicalSortingAction;
- private SortByDefiningTypeAction fSortByDefiningTypeAction;
- private ShowOnlyMainTypeAction fShowOnlyMainTypeAction;
- private Map fTypeHierarchies= new HashMap();
-
- /**
- * Category filter action group.
- *
- */
- private CategoryFilterActionGroup fCategoryFilterActionGroup;
- private String fPattern;
-
- private class OutlineLabelProvider extends AppearanceAwareLabelProvider {
-
- private boolean fShowDefiningType;
-
- private OutlineLabelProvider() {
- super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.ALL_CATEGORY, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
- }
-
- /*
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- String text= super.getText(element);
- if (fShowDefiningType) {
- try {
- IType type= getDefiningType(element);
- if (type != null) {
- StringBuffer buf= new StringBuffer(super.getText(type));
- buf.append(JavaScriptElementLabels.CONCAT_STRING);
- buf.append(text);
- return buf.toString();
- }
- } catch (JavaScriptModelException e) {
- }
- }
- return text;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.viewsupport.JavaUILabelProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (fOutlineContentProvider.isShowingInheritedMembers()) {
- if (element instanceof IJavaScriptElement) {
- IJavaScriptElement je= (IJavaScriptElement)element;
- if (fInput.getElementType() == IJavaScriptElement.CLASS_FILE)
- je= je.getAncestor(IJavaScriptElement.CLASS_FILE);
- else
- je= je.getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
- if (fInput.equals(je)) {
- return null;
- }
- }
- return JFaceResources.getColorRegistry().get(ColoredViewersManager.INHERITED_COLOR_NAME);
- }
- return null;
- }
-
- public void setShowDefiningType(boolean showDefiningType) {
- fShowDefiningType= showDefiningType;
- }
-
- public boolean isShowDefiningType() {
- return fShowDefiningType;
- }
-
- private IType getDefiningType(Object element) throws JavaScriptModelException {
- int kind= ((IJavaScriptElement) element).getElementType();
-
- if (kind != IJavaScriptElement.METHOD && kind != IJavaScriptElement.FIELD && kind != IJavaScriptElement.INITIALIZER) {
- return null;
- }
- IType declaringType= ((IMember) element).getDeclaringType();
- if (kind != IJavaScriptElement.METHOD) {
- return declaringType;
- }
- ITypeHierarchy hierarchy= getSuperTypeHierarchy(declaringType);
- if (hierarchy == null) {
- return declaringType;
- }
- IFunction method= (IFunction) element;
- MethodOverrideTester tester= new MethodOverrideTester(declaringType, hierarchy);
- IFunction res= tester.findDeclaringMethod(method, true);
- if (res == null || method.equals(res)) {
- return declaringType;
- }
- return res.getDeclaringType();
- }
- }
-
-
- private class OutlineTreeViewer extends TreeViewer {
-
- private boolean fIsFiltering= false;
-
- private OutlineTreeViewer(Tree tree) {
- super(tree);
-
- }
-
- /**
- * {@inheritDoc}
- */
- protected Object[] getFilteredChildren(Object parent) {
- Object[] result = getRawChildren(parent);
- int unfilteredChildren= result.length;
- ViewerFilter[] filters = getFilters();
- if (filters != null) {
- for (int i= 0; i < filters.length; i++)
- result = filters[i].filter(this, parent, result);
- }
- fIsFiltering= unfilteredChildren != result.length;
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void internalExpandToLevel(Widget node, int level) {
- if (!fIsFiltering && node instanceof TreeItem && getMatcher() == null) {
- TreeItem treeItem= (TreeItem)node;
- if (treeItem.getParentItem() != null && treeItem.getData() instanceof IJavaScriptElement) {
- IJavaScriptElement je= (IJavaScriptElement) treeItem.getData();
- if (je.getElementType() == IJavaScriptElement.IMPORT_CONTAINER || isInnerType(je)) {
- setExpanded(treeItem, false);
- return;
- }
- }
- }
- super.internalExpandToLevel(node, level);
- }
-
- private boolean isInnerType(IJavaScriptElement element) {
- if (element != null && element.getElementType() == IJavaScriptElement.TYPE) {
- IType type= (IType)element;